diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index ccf6481bd..ee3dc6c12 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -2021,6 +2021,28 @@ impl BaseBtcCentsSatsUsdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CoinblocksCoindaysSentPattern { + pub coinblocks_destroyed: CumulativeHeightPattern, + pub coindays_destroyed: CumulativeHeightSumPattern, + pub sent: MetricPattern1, + pub sent_sum: _24hPattern, + pub sent_sum_extended: _1m1w1yPattern, +} + +impl CoinblocksCoindaysSentPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + coinblocks_destroyed: CumulativeHeightPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")), + coindays_destroyed: CumulativeHeightSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + sent: MetricPattern1::new(client.clone(), _m(&acc, "sent")), + sent_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_24h")), + sent_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sent")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct EmaHistogramLineSignalPattern { pub ema_fast: MetricPattern1, @@ -2043,28 +2065,6 @@ impl EmaHistogramLineSignalPattern { } } -/// Pattern struct for repeated tree structure. -pub struct SupplyPattern2 { - pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern, - pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern, - pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern, - pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern, - pub supply_rel_to_circulating_supply: BpsPercentRatioPattern, -} - -impl SupplyPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_circulating_supply")), - supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_own_supply")), - supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_circulating_supply")), - supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_own_supply")), - supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hHeightPattern { pub _1m: MetricPattern1, @@ -2187,26 +2187,6 @@ impl BtcCentsSatsUsdPattern { } } -/// Pattern struct for repeated tree structure. -pub struct CoinblocksCoindaysSentPattern { - pub coinblocks_destroyed: CumulativeHeightPattern, - pub coindays_destroyed: CumulativeHeightSumPattern, - pub sent: BaseCumulativePattern, - pub sent_ema: _2wPattern, -} - -impl CoinblocksCoindaysSentPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - coinblocks_destroyed: CumulativeHeightPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")), - coindays_destroyed: CumulativeHeightSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - sent: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent")), - sent_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_ema_2w")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct InvestedMaxMinPercentilesPattern { pub invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, @@ -2375,6 +2355,24 @@ impl ChangeHalvedTotalPattern { } } +/// Pattern struct for repeated tree structure. +pub struct SupplyPattern2 { + pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern, + pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern, + pub supply_rel_to_circulating_supply: BpsPercentRatioPattern, +} + +impl SupplyPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_circulating_supply")), + supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_circulating_supply")), + supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _1m1w1yPattern { pub _1m: MetricPattern1, @@ -2575,16 +2573,16 @@ impl SdSmaPattern { /// Pattern struct for repeated tree structure. pub struct SentPattern { - pub sent: BaseCumulativePattern, - pub sent_ema: _2wPattern, + pub sent: MetricPattern1, + pub sent_sum: _24hPattern, } impl SentPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - sent: BaseCumulativePattern::new(client.clone(), acc.clone()), - sent_ema: _2wPattern::new(client.clone(), _m(&acc, "ema_2w")), + sent: MetricPattern1::new(client.clone(), acc.clone()), + sent_sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), } } } @@ -2637,20 +2635,6 @@ impl CumulativeHeightPattern { } } -/// Pattern struct for repeated tree structure. -pub struct _2wPattern { - pub _2w: BtcCentsSatsUsdPattern, -} - -impl _2wPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _2w: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _24hPattern { pub _24h: MetricPattern1, @@ -5575,12 +5559,12 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Adjusted { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative { + pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern, + pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern, pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern, pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern, pub nupl: MetricPattern1, - pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern, - pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern, pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern, pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern, pub net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern, @@ -5589,12 +5573,12 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative { impl MetricsTree_Distribution_UtxoCohorts_All_Relative { pub fn new(client: Arc, base_path: String) -> Self { Self { + supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_profit_rel_to_own_supply".to_string()), + supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_loss_rel_to_own_supply".to_string()), unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_market_cap".to_string()), unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_market_cap".to_string()), net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_market_cap".to_string()), nupl: MetricPattern1::new(client.clone(), "nupl".to_string()), - supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_profit_rel_to_own_supply".to_string()), - supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_loss_rel_to_own_supply".to_string()), unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_own_gross_pnl".to_string()), unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()), net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_own_gross_pnl".to_string()), diff --git a/crates/brk_computer/src/distribution/metrics/activity/base.rs b/crates/brk_computer/src/distribution/metrics/activity/base.rs index 6a1ea67d3..73a49817f 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/base.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/base.rs @@ -3,35 +3,36 @@ use brk_traversable::Traversable; use brk_types::{Height, Indexes, Sats, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; -use crate::internal::{RollingEmas2w, ValueFromHeightCumulative}; +use crate::internal::{ComputedFromHeight, RollingWindow24h}; -use crate::{blocks, distribution::metrics::ImportConfig, prices}; +use crate::{blocks, distribution::metrics::ImportConfig}; #[derive(Traversable)] pub struct ActivityBase { - pub sent: ValueFromHeightCumulative, - pub sent_ema: RollingEmas2w, + pub sent: ComputedFromHeight, + pub sent_sum: RollingWindow24h, } impl ActivityBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let v1 = Version::ONE; Ok(Self { - sent: cfg.import("sent", Version::ZERO)?, - sent_ema: cfg.import("sent", Version::ZERO)?, + sent: cfg.import("sent", v1)?, + sent_sum: cfg.import("sent", v1)?, }) } pub(crate) fn min_len(&self) -> usize { - self.sent.base.sats.height.len() + self.sent.height.len() } pub(crate) fn truncate_push(&mut self, height: Height, sent: Sats) -> Result<()> { - self.sent.base.sats.height.truncate_push(height, sent)?; + self.sent.height.truncate_push(height, sent)?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![&mut self.sent.base.sats.height as &mut dyn AnyStoredVec] + vec![&mut self.sent.height as &mut dyn AnyStoredVec] } pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { @@ -44,11 +45,11 @@ impl ActivityBase { others: &[&Self], exit: &Exit, ) -> Result<()> { - self.sent.base.sats.height.compute_sum_of_others( + self.sent.height.compute_sum_of_others( starting_indexes.height, &others .iter() - .map(|v| &v.sent.base.sats.height) + .map(|v| &v.sent.height) .collect::>(), exit, )?; @@ -58,21 +59,15 @@ impl ActivityBase { pub(crate) fn compute_rest_part1( &mut self, blocks: &blocks::Vecs, - prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.sent - .compute(prices, starting_indexes.height, exit)?; - - self.sent_ema.compute( + self.sent_sum.compute_rolling_sum( starting_indexes.height, - &blocks.count.height_2w_ago, - &self.sent.base.sats.height, - &self.sent.base.cents.height, + &blocks.count.height_24h_ago, + &self.sent.height, exit, )?; - Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index e4ee15f53..32b22c32b 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -4,9 +4,11 @@ use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF64, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; -use crate::internal::{ComputedFromHeightCumulative, ComputedFromHeightCumulativeSum}; +use crate::internal::{ + ComputedFromHeightCumulative, ComputedFromHeightCumulativeSum, RollingWindowsFrom1w, +}; -use crate::{blocks, distribution::metrics::ImportConfig, prices}; +use crate::{blocks, distribution::metrics::ImportConfig}; use super::ActivityBase; @@ -19,15 +21,19 @@ pub struct ActivityFull { pub coinblocks_destroyed: ComputedFromHeightCumulative, pub coindays_destroyed: ComputedFromHeightCumulativeSum, + + pub sent_sum_extended: RollingWindowsFrom1w, } impl ActivityFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let v1 = Version::ONE; Ok(Self { base: ActivityBase::forced_import(cfg)?, coinblocks_destroyed: cfg - .import("coinblocks_destroyed", Version::ONE)?, - coindays_destroyed: cfg.import("coindays_destroyed", Version::ONE)?, + .import("coinblocks_destroyed", v1)?, + coindays_destroyed: cfg.import("coindays_destroyed", v1)?, + sent_sum_extended: cfg.import("sent", v1)?, }) } @@ -59,7 +65,7 @@ impl ActivityFull { pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { vec![ - &mut self.base.sent.base.sats.height as &mut dyn AnyStoredVec, + &mut self.base.sent.height as &mut dyn AnyStoredVec, &mut self.coinblocks_destroyed.height as &mut dyn AnyStoredVec, &mut self.coindays_destroyed.height as &mut dyn AnyStoredVec, ] @@ -87,12 +93,11 @@ impl ActivityFull { pub(crate) fn compute_rest_part1( &mut self, blocks: &blocks::Vecs, - prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.base - .compute_rest_part1(blocks, prices, starting_indexes, exit)?; + .compute_rest_part1(blocks, starting_indexes, exit)?; self.coinblocks_destroyed .compute_rest(starting_indexes.height, exit)?; @@ -101,6 +106,13 @@ impl ActivityFull { self.coindays_destroyed .compute_rest(starting_indexes.height, &window_starts, exit)?; + self.sent_sum_extended.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.base.sent.height, + exit, + )?; + Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index e67365d96..9acb0d434 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -125,7 +125,7 @@ impl AllCohortMetrics { self.dormancy.height.compute_transform2( starting_indexes.height, &self.activity.coindays_destroyed.height, - &self.activity.sent.base.sats.height, + &self.activity.sent.height, |(i, cdd, sent_sats, ..)| { let sent_btc = f64::from(Bitcoin::from(sent_sats)); if sent_btc == 0.0 { @@ -139,7 +139,7 @@ impl AllCohortMetrics { self.velocity.height.compute_transform2( starting_indexes.height, - &self.activity.sent.base.sats.height, + &self.activity.sent.height, &self.supply.total.sats.height, |(i, sent_sats, supply_sats, ..)| { let supply = supply_sats.as_u128() as f64; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs index d9afd8b8c..8cbec8ca8 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs @@ -8,7 +8,7 @@ use crate::{blocks, prices}; use crate::distribution::metrics::{ ActivityFull, CohortMetricsBase, CostBasisBase, ImportConfig, OutputsMetrics, RealizedBase, - RelativeBaseWithRelToAll, SupplyMetrics, UnrealizedBase, + RelativeToAll, SupplyMetrics, UnrealizedBase, }; /// Basic cohort metrics: no extensions, with relative (rel_to_all). @@ -23,7 +23,7 @@ pub struct BasicCohortMetrics { pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, - pub relative: Box>, + pub relative: Box>, } impl CohortMetricsBase for BasicCohortMetrics { @@ -51,7 +51,7 @@ impl BasicCohortMetrics { let unrealized = UnrealizedBase::forced_import(cfg)?; let realized = RealizedBase::forced_import(cfg)?; - let relative = RelativeBaseWithRelToAll::forced_import(cfg)?; + let relative = RelativeToAll::forced_import(cfg)?; Ok(Self { filter: cfg.filter.clone(), @@ -83,7 +83,8 @@ impl BasicCohortMetrics { self.relative.compute( starting_indexes.height, - &self.unrealized.core, + &self.unrealized.supply_in_profit.sats.height, + &self.unrealized.supply_in_loss.sats.height, &self.supply.total.sats.height, all_supply_sats, exit, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index 47d815af3..9f27fb3ca 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -8,7 +8,7 @@ use crate::{blocks, prices}; use crate::distribution::metrics::{ ActivityBase, CohortMetricsBase, RealizedCore, ImportConfig, OutputsMetrics, - RelativeBaseWithRelToAll, SupplyMetrics, UnrealizedCore, + RelativeToAll, SupplyMetrics, UnrealizedCore, }; #[derive(Traversable)] @@ -20,7 +20,7 @@ pub struct CoreCohortMetrics { pub activity: Box>, pub realized: Box>, pub unrealized: Box>, - pub relative: Box>, + pub relative: Box>, } impl CoreCohortMetrics { @@ -32,7 +32,7 @@ impl CoreCohortMetrics { activity: Box::new(ActivityBase::forced_import(cfg)?), realized: Box::new(RealizedCore::forced_import(cfg)?), unrealized: Box::new(UnrealizedCore::forced_import(cfg)?), - relative: Box::new(RelativeBaseWithRelToAll::forced_import(cfg)?), + relative: Box::new(RelativeToAll::forced_import(cfg)?), }) } @@ -112,7 +112,7 @@ impl CoreCohortMetrics { .compute_rest(blocks, starting_indexes, exit)?; self.activity - .compute_rest_part1(blocks, prices, starting_indexes, exit)?; + .compute_rest_part1(blocks, starting_indexes, exit)?; self.realized .compute_rest_part1(starting_indexes, exit)?; @@ -140,7 +140,8 @@ impl CoreCohortMetrics { self.relative.compute( starting_indexes.height, - &self.unrealized, + &self.unrealized.supply_in_profit.sats.height, + &self.unrealized.supply_in_loss.sats.height, &self.supply.total.sats.height, all_supply_sats, exit, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index 07a672bc9..e9620a62d 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -105,7 +105,7 @@ impl ExtendedCohortMetrics { self.dormancy.height.compute_transform2( starting_indexes.height, &self.activity.coindays_destroyed.height, - &self.activity.sent.base.sats.height, + &self.activity.sent.height, |(i, cdd, sent_sats, ..)| { let sent_btc = f64::from(Bitcoin::from(sent_sats)); if sent_btc == 0.0 { @@ -119,7 +119,7 @@ impl ExtendedCohortMetrics { self.velocity.height.compute_transform2( starting_indexes.height, - &self.activity.sent.base.sats.height, + &self.activity.sent.height, &self.supply.total.sats.height, |(i, sent_sats, supply_sats, ..)| { let supply = supply_sats.as_u128() as f64; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs index 38632f29d..143f51c9e 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs @@ -191,7 +191,7 @@ impl MinimalCohortMetrics { self.outputs .compute_rest(blocks, starting_indexes, exit)?; self.activity - .compute_rest_part1(blocks, prices, starting_indexes, exit)?; + .compute_rest_part1(blocks, starting_indexes, exit)?; self.realized .compute_rest_part1(starting_indexes, exit)?; self.unrealized diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index 2c0830e47..4a32a7d8b 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -55,7 +55,7 @@ pub use realized::{ RealizedAdjusted, RealizedBase, RealizedCore, RealizedFull, RealizedLike, RealizedMinimal, }; pub use relative::{ - RelativeBaseWithRelToAll, RelativeForAll, RelativeWithExtended, + RelativeForAll, RelativeToAll, RelativeWithExtended, }; pub use supply::SupplyMetrics; pub use unrealized::{UnrealizedBase, UnrealizedCore, UnrealizedFull, UnrealizedLike}; @@ -200,10 +200,7 @@ pub trait CohortMetricsBase: CohortMetricsState + Send self.outputs_mut() .compute_rest(blocks, starting_indexes, exit)?; self.activity_mut() - .sent - .compute(prices, starting_indexes.height, exit)?; - self.activity_mut() - .compute_rest_part1(blocks, prices, starting_indexes, exit)?; + .compute_rest_part1(blocks, starting_indexes, exit)?; self.realized_mut() .compute_rest_part1(starting_indexes, exit)?; diff --git a/crates/brk_computer/src/distribution/metrics/relative/base.rs b/crates/brk_computer/src/distribution/metrics/relative/base.rs deleted file mode 100644 index 198d3083b..000000000 --- a/crates/brk_computer/src/distribution/metrics/relative/base.rs +++ /dev/null @@ -1,52 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, Sats, Version}; -use vecdb::{Exit, ReadableVec, Rw, StorageMode}; - -use crate::internal::{PercentFromHeight, RatioSatsBp16}; - -use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; - -/// Relative metrics for the Complete tier. -#[derive(Traversable)] -pub struct RelativeBase { - pub supply_in_profit_rel_to_own_supply: PercentFromHeight, - pub supply_in_loss_rel_to_own_supply: PercentFromHeight, -} - -impl RelativeBase { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v1 = Version::ONE; - - Ok(Self { - supply_in_profit_rel_to_own_supply: cfg - .import("supply_in_profit_rel_to_own_supply", v1)?, - supply_in_loss_rel_to_own_supply: cfg - .import("supply_in_loss_rel_to_own_supply", v1)?, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - unrealized: &UnrealizedCore, - supply_total_sats: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self.supply_in_profit_rel_to_own_supply - .compute_binary::( - max_from, - &unrealized.supply_in_profit.sats.height, - supply_total_sats, - exit, - )?; - self.supply_in_loss_rel_to_own_supply - .compute_binary::( - max_from, - &unrealized.supply_in_loss.sats.height, - supply_total_sats, - exit, - )?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/relative/full.rs b/crates/brk_computer/src/distribution/metrics/relative/full.rs index 2ddb4de90..e499e1695 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/full.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/full.rs @@ -3,24 +3,20 @@ use brk_traversable::Traversable; use brk_types::{ BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, StoredF32, Version, }; -use derive_more::{Deref, DerefMut}; use vecdb::{Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; use crate::internal::{ Bps32ToFloat, LazyFromHeight, PercentFromHeight, RatioDollarsBp16, RatioDollarsBps32, + RatioSatsBp16, }; use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; -use super::RelativeBase; - -/// Full relative metrics (Source/Extended tier). -#[derive(Deref, DerefMut, Traversable)] +/// Full relative metrics (sth/lth/all tier). +#[derive(Traversable)] pub struct RelativeFull { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub base: RelativeBase, + pub supply_in_profit_rel_to_own_supply: PercentFromHeight, + pub supply_in_loss_rel_to_own_supply: PercentFromHeight, pub unrealized_profit_rel_to_market_cap: PercentFromHeight, pub unrealized_loss_rel_to_market_cap: PercentFromHeight, @@ -30,8 +26,7 @@ pub struct RelativeFull { impl RelativeFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let base = RelativeBase::forced_import(cfg)?; - + let v1 = Version::ONE; let v2 = Version::new(2); let v3 = Version::new(3); @@ -49,7 +44,10 @@ impl RelativeFull { ); Ok(Self { - base, + supply_in_profit_rel_to_own_supply: cfg + .import("supply_in_profit_rel_to_own_supply", v1)?, + supply_in_loss_rel_to_own_supply: cfg + .import("supply_in_loss_rel_to_own_supply", v1)?, unrealized_profit_rel_to_market_cap: cfg .import("unrealized_profit_rel_to_market_cap", v2)?, unrealized_loss_rel_to_market_cap: cfg @@ -67,12 +65,20 @@ impl RelativeFull { market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.base.compute( - max_from, - unrealized, - supply_total_sats, - exit, - )?; + self.supply_in_profit_rel_to_own_supply + .compute_binary::( + max_from, + &unrealized.supply_in_profit.sats.height, + supply_total_sats, + exit, + )?; + self.supply_in_loss_rel_to_own_supply + .compute_binary::( + max_from, + &unrealized.supply_in_loss.sats.height, + supply_total_sats, + exit, + )?; self.unrealized_profit_rel_to_market_cap .compute_binary::( diff --git a/crates/brk_computer/src/distribution/metrics/relative/mod.rs b/crates/brk_computer/src/distribution/metrics/relative/mod.rs index 84d9a45c7..70e4ad837 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/mod.rs @@ -1,17 +1,13 @@ -mod base; mod extended_own_market_cap; mod extended_own_pnl; mod for_all; mod full; mod to_all; mod with_extended; -mod with_rel_to_all; -pub use base::RelativeBase; pub use extended_own_market_cap::RelativeExtendedOwnMarketCap; pub use extended_own_pnl::RelativeExtendedOwnPnl; pub use for_all::RelativeForAll; pub use full::RelativeFull; pub use to_all::RelativeToAll; pub use with_extended::RelativeWithExtended; -pub use with_rel_to_all::RelativeBaseWithRelToAll; diff --git a/crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all.rs b/crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all.rs deleted file mode 100644 index dd89cf0d2..000000000 --- a/crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all.rs +++ /dev/null @@ -1,55 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Sats}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Exit, ReadableVec, Rw, StorageMode}; - -use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; - -use super::{RelativeBase, RelativeToAll}; - -/// Base relative metrics with rel_to_all. -/// Used by: age_range, epoch, class, min_age, max_age cohorts. -#[derive(Deref, DerefMut, Traversable)] -pub struct RelativeBaseWithRelToAll { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub base: RelativeBase, - #[traversable(flatten)] - pub rel_to_all: RelativeToAll, -} - -impl RelativeBaseWithRelToAll { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - Ok(Self { - base: RelativeBase::forced_import(cfg)?, - rel_to_all: RelativeToAll::forced_import(cfg)?, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - unrealized: &UnrealizedCore, - supply_total_sats: &impl ReadableVec, - all_supply_sats: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self.base.compute( - max_from, - unrealized, - supply_total_sats, - exit, - )?; - self.rel_to_all.compute( - max_from, - &unrealized.supply_in_profit.sats.height, - &unrealized.supply_in_loss.sats.height, - supply_total_sats, - all_supply_sats, - exit, - )?; - Ok(()) - } -} diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 7bf79ce83..7205df6d6 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -2745,6 +2745,31 @@ function createBaseBtcCentsSatsUsdPattern(client, acc) { }; } +/** + * @typedef {Object} CoinblocksCoindaysSentPattern + * @property {CumulativeHeightPattern} coinblocksDestroyed + * @property {CumulativeHeightSumPattern} coindaysDestroyed + * @property {MetricPattern1} sent + * @property {_24hPattern} sentSum + * @property {_1m1w1yPattern} sentSumExtended + */ + +/** + * Create a CoinblocksCoindaysSentPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoinblocksCoindaysSentPattern} + */ +function createCoinblocksCoindaysSentPattern(client, acc) { + return { + coinblocksDestroyed: createCumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')), + coindaysDestroyed: createCumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')), + sent: createMetricPattern1(client, _m(acc, 'sent')), + sentSum: create_24hPattern(client, _m(acc, 'sent_24h')), + sentSumExtended: create_1m1w1yPattern(client, _m(acc, 'sent')), + }; +} + /** * @typedef {Object} EmaHistogramLineSignalPattern * @property {MetricPattern1} emaFast @@ -2770,31 +2795,6 @@ function createEmaHistogramLineSignalPattern(client, acc) { }; } -/** - * @typedef {Object} SupplyPattern2 - * @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply - */ - -/** - * Create a SupplyPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {SupplyPattern2} - */ -function createSupplyPattern2(client, acc) { - return { - supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')), - supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_own_supply')), - supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')), - supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_own_supply')), - supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), - }; -} - /** * @template T * @typedef {Object} _1m1w1y24hHeightPattern @@ -2937,29 +2937,6 @@ function createBtcCentsSatsUsdPattern(client, acc) { }; } -/** - * @typedef {Object} CoinblocksCoindaysSentPattern - * @property {CumulativeHeightPattern} coinblocksDestroyed - * @property {CumulativeHeightSumPattern} coindaysDestroyed - * @property {BaseCumulativePattern} sent - * @property {_2wPattern} sentEma - */ - -/** - * Create a CoinblocksCoindaysSentPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CoinblocksCoindaysSentPattern} - */ -function createCoinblocksCoindaysSentPattern(client, acc) { - return { - coinblocksDestroyed: createCumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')), - coindaysDestroyed: createCumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')), - sent: createBaseCumulativePattern(client, _m(acc, 'sent')), - sentEma: create_2wPattern(client, _m(acc, 'sent_ema_2w')), - }; -} - /** * @typedef {Object} InvestedMaxMinPercentilesPattern * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} investedCapital @@ -3157,6 +3134,27 @@ function createChangeHalvedTotalPattern(client, acc) { }; } +/** + * @typedef {Object} SupplyPattern2 + * @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply + * @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply + * @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply + */ + +/** + * Create a SupplyPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {SupplyPattern2} + */ +function createSupplyPattern2(client, acc) { + return { + supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')), + supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')), + supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), + }; +} + /** * @template T * @typedef {Object} _1m1w1yPattern @@ -3399,8 +3397,8 @@ function createSdSmaPattern(client, acc) { /** * @typedef {Object} SentPattern - * @property {BaseCumulativePattern} sent - * @property {_2wPattern} sentEma + * @property {MetricPattern1} sent + * @property {_24hPattern} sentSum */ /** @@ -3411,8 +3409,8 @@ function createSdSmaPattern(client, acc) { */ function createSentPattern(client, acc) { return { - sent: createBaseCumulativePattern(client, acc), - sentEma: create_2wPattern(client, _m(acc, 'ema_2w')), + sent: createMetricPattern1(client, acc), + sentSum: create_24hPattern(client, _m(acc, '24h')), }; } @@ -3475,23 +3473,6 @@ function createCumulativeHeightPattern(client, acc) { }; } -/** - * @typedef {Object} _2wPattern - * @property {BtcCentsSatsUsdPattern} _2w - */ - -/** - * Create a _2wPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_2wPattern} - */ -function create_2wPattern(client, acc) { - return { - _2w: createBtcCentsSatsUsdPattern(client, acc), - }; -} - /** * @template T * @typedef {Object} _24hPattern @@ -4803,12 +4784,12 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Relative + * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply + * @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply * @property {BpsPercentRatioPattern} unrealizedProfitRelToMarketCap * @property {BpsPercentRatioPattern} unrealizedLossRelToMarketCap * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToMarketCap * @property {MetricPattern1} nupl - * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply * @property {BpsPercentRatioPattern} unrealizedProfitRelToOwnGrossPnl * @property {BpsPercentRatioPattern} unrealizedLossRelToOwnGrossPnl * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToOwnGrossPnl @@ -7014,12 +6995,12 @@ class BrkClient extends BrkClientBase { adjustedSoprEma: create_1m1wPattern(this, 'adjusted_sopr_24h_ema'), }, relative: { + supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_profit_rel_to_own_supply'), + supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_loss_rel_to_own_supply'), unrealizedProfitRelToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_market_cap'), unrealizedLossRelToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_market_cap'), netUnrealizedPnlRelToMarketCap: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_market_cap'), nupl: createMetricPattern1(this, 'nupl'), - supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_profit_rel_to_own_supply'), - supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_loss_rel_to_own_supply'), unrealizedProfitRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_own_gross_pnl'), unrealizedLossRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_own_gross_pnl'), netUnrealizedPnlRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'), diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 0311dead5..236f7cf97 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2607,6 +2607,17 @@ class BaseBtcCentsSatsUsdPattern: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'rewards_cumulative')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'rewards_cumulative_usd')) +class CoinblocksCoindaysSentPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.coinblocks_destroyed: CumulativeHeightPattern[StoredF64] = CumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')) + self.coindays_destroyed: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')) + self.sent: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent')) + self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_24h')) + self.sent_sum_extended: _1m1w1yPattern[Sats] = _1m1w1yPattern(client, _m(acc, 'sent')) + class EmaHistogramLineSignalPattern: """Pattern struct for repeated tree structure.""" @@ -2618,17 +2629,6 @@ class EmaHistogramLineSignalPattern: self.line: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'line_24h')) self.signal: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'signal_24h')) -class SupplyPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')) - self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_own_supply')) - self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')) - self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_own_supply')) - self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) - class _1m1w1y24hHeightPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2690,16 +2690,6 @@ class BtcCentsSatsUsdPattern: self.sats: MetricPattern1[Sats] = MetricPattern1(client, acc) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) -class CoinblocksCoindaysSentPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.coinblocks_destroyed: CumulativeHeightPattern[StoredF64] = CumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')) - self.coindays_destroyed: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')) - self.sent: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent')) - self.sent_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_ema_2w')) - class InvestedMaxMinPercentilesPattern: """Pattern struct for repeated tree structure.""" @@ -2784,6 +2774,15 @@ class ChangeHalvedTotalPattern: self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) +class SupplyPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')) + self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')) + self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) + class _1m1w1yPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2888,8 +2887,8 @@ class SentPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.sent: BaseCumulativePattern = BaseCumulativePattern(client, acc) - self.sent_ema: _2wPattern = _2wPattern(client, _m(acc, 'ema_2w')) + self.sent: MetricPattern1[Sats] = MetricPattern1(client, acc) + self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, '24h')) class SupplyPattern: """Pattern struct for repeated tree structure.""" @@ -2915,13 +2914,6 @@ class CumulativeHeightPattern(Generic[T]): self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) self.height: MetricPattern18[T] = MetricPattern18(client, acc) -class _2wPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._2w: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) - class _24hPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -4262,12 +4254,12 @@ class MetricsTree_Distribution_UtxoCohorts_All_Relative: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): + self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_profit_rel_to_own_supply') + self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_loss_rel_to_own_supply') self.unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_market_cap') self.unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_market_cap') self.net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_market_cap') self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, 'nupl') - self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_profit_rel_to_own_supply') - self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_loss_rel_to_own_supply') self.unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_own_gross_pnl') self.unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_own_gross_pnl') self.net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_own_gross_pnl')