From 9507eb3de53f64bc32bdfec04bc9489cc66afad9 Mon Sep 17 00:00:00 2001 From: nym21 Date: Fri, 6 Mar 2026 23:46:10 +0100 Subject: [PATCH] global: snapshot --- crates/brk_client/src/lib.rs | 1084 ++++++---------- .../src/distribution/metrics/activity/base.rs | 89 +- .../src/distribution/metrics/activity/core.rs | 78 -- .../src/distribution/metrics/activity/full.rs | 107 ++ .../src/distribution/metrics/activity/mod.rs | 4 +- .../src/distribution/metrics/cohort/all.rs | 14 +- .../src/distribution/metrics/cohort/basic.rs | 13 +- .../src/distribution/metrics/cohort/core.rs | 32 +- .../distribution/metrics/cohort/extended.rs | 14 +- .../distribution/metrics/cohort/minimal.rs | 157 +-- .../src/distribution/metrics/mod.rs | 167 ++- .../src/distribution/metrics/realized/base.rs | 449 +++---- .../distribution/metrics/realized/complete.rs | 245 ---- .../src/distribution/metrics/realized/core.rs | 347 ------ .../distribution/metrics/realized/extended.rs | 160 --- .../metrics/realized/{basic.rs => full.rs} | 290 ++--- .../distribution/metrics/realized/minimal.rs | 151 +++ .../src/distribution/metrics/realized/mod.rs | 14 +- .../metrics/realized/with_extended.rs | 60 - .../src/distribution/metrics/relative/base.rs | 132 +- .../distribution/metrics/relative/complete.rs | 105 -- .../distribution/metrics/relative/for_all.rs | 10 +- .../src/distribution/metrics/relative/full.rs | 81 ++ .../src/distribution/metrics/relative/mod.rs | 8 +- .../metrics/relative/with_extended.rs | 10 +- .../metrics/relative/with_rel_to_all.rs | 10 +- ...ll_complete.rs => with_rel_to_all_base.rs} | 14 +- .../distribution/metrics/unrealized/base.rs | 290 ++--- .../metrics/unrealized/complete.rs | 141 --- .../distribution/metrics/unrealized/full.rs | 278 +++++ .../distribution/metrics/unrealized/mod.rs | 4 +- .../distribution/state/cost_basis/realized.rs | 69 +- .../src/internal/from_height/ratio/full.rs | 51 - .../src/internal/from_height/ratio/mod.rs | 2 - modules/brk-client/index.js | 1089 ++++++----------- packages/brk_client/brk_client/__init__.py | 539 +++----- 36 files changed, 2447 insertions(+), 3861 deletions(-) delete mode 100644 crates/brk_computer/src/distribution/metrics/activity/core.rs create mode 100644 crates/brk_computer/src/distribution/metrics/activity/full.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/realized/complete.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/realized/core.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/realized/extended.rs rename crates/brk_computer/src/distribution/metrics/realized/{basic.rs => full.rs} (66%) create mode 100644 crates/brk_computer/src/distribution/metrics/realized/minimal.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/realized/with_extended.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/relative/complete.rs create mode 100644 crates/brk_computer/src/distribution/metrics/relative/full.rs rename crates/brk_computer/src/distribution/metrics/relative/{with_rel_to_all_complete.rs => with_rel_to_all_base.rs} (79%) delete mode 100644 crates/brk_computer/src/distribution/metrics/unrealized/complete.rs create mode 100644 crates/brk_computer/src/distribution/metrics/unrealized/full.rs delete mode 100644 crates/brk_computer/src/internal/from_height/ratio/full.rs diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index c3f5bf2f1..0af979ac5 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -940,13 +940,7 @@ impl MetricPattern for MetricPattern35 { fn get(&self // Reusable pattern structs /// Pattern struct for repeated tree structure. -pub struct AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { - pub adjusted_sopr: _1m1w1y24hPattern, - pub adjusted_sopr_ema: _1m1wPattern, - pub adjusted_value_created: MetricPattern1, - pub adjusted_value_created_sum: _1m1w1y24hPattern, - pub adjusted_value_destroyed: MetricPattern1, - pub adjusted_value_destroyed_sum: _1m1w1y24hPattern, +pub struct CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { pub cap_raw: MetricPattern18, pub capitulation_flow: MetricPattern1, pub gross_pnl: CentsUsdPattern, @@ -1004,16 +998,10 @@ pub struct AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitReal pub value_destroyed_sum: _1m1w1y24hPattern, } -impl AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { +impl CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - adjusted_sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "adjusted_sopr")), - adjusted_sopr_ema: _1m1wPattern::new(client.clone(), _m(&acc, "adjusted_sopr_24h_ema")), - adjusted_value_created: MetricPattern1::new(client.clone(), _m(&acc, "adjusted_value_created")), - adjusted_value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "adjusted_value_created")), - adjusted_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "adjusted_value_destroyed")), - adjusted_value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "adjusted_value_destroyed")), cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "cap_raw")), capitulation_flow: MetricPattern1::new(client.clone(), _m(&acc, "capitulation_flow")), gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")), @@ -1073,198 +1061,6 @@ impl AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSe } } -/// Pattern struct for repeated tree structure. -pub struct CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { - pub cap_raw: MetricPattern18, - pub capitulation_flow: MetricPattern1, - pub gross_pnl: CentsUsdPattern, - pub gross_pnl_sum: _1m1w1y24hPattern, - pub investor_cap_raw: MetricPattern18, - pub investor_price: CentsSatsUsdPattern, - pub investor_price_ratio: BpsRatioPattern, - pub loss_value_created: MetricPattern1, - pub loss_value_destroyed: MetricPattern1, - pub lower_price_band: CentsSatsUsdPattern, - pub mvrv: MetricPattern1, - pub neg_realized_loss: MetricPattern1, - pub net_pnl_change_1m: MetricPattern1, - pub net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern, - pub net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern, - pub net_realized_pnl: CumulativeHeightPattern, - pub net_realized_pnl_ema_1w: MetricPattern1, - pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern, - pub peak_regret: CumulativeHeightPattern, - pub peak_regret_rel_to_realized_cap: BpsPercentRatioPattern, - pub profit_flow: MetricPattern1, - pub profit_value_created: MetricPattern1, - pub profit_value_destroyed: MetricPattern1, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_cap_change_1m: MetricPattern1, - pub realized_loss: CumulativeHeightPattern, - pub realized_loss_ema_1w: MetricPattern1, - pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_profit: CumulativeHeightPattern, - pub realized_profit_ema_1w: MetricPattern1, - pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern, - pub sell_side_risk_ratio: _1m1w1y24hPattern2, - pub sell_side_risk_ratio_24h_ema: _1m1wPattern2, - pub sent_in_loss: BaseCumulativePattern, - pub sent_in_loss_ema: _2wPattern, - pub sent_in_profit: BaseCumulativePattern, - pub sent_in_profit_ema: _2wPattern, - pub sopr: _1m1w1y24hPattern, - pub sopr_24h_ema: _1m1wPattern, - pub upper_price_band: CentsSatsUsdPattern, - pub value_created: MetricPattern1, - pub value_created_sum: _1m1w1y24hPattern, - pub value_destroyed: MetricPattern1, - pub value_destroyed_sum: _1m1w1y24hPattern, -} - -impl CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "cap_raw")), - capitulation_flow: MetricPattern1::new(client.clone(), _m(&acc, "capitulation_flow")), - gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")), - gross_pnl_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "gross_pnl_sum")), - investor_cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_raw")), - investor_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")), - investor_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")), - loss_value_created: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_created")), - loss_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_destroyed")), - lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")), - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), - net_pnl_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "net_pnl_change_1m")), - net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_market_cap")), - net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_realized_cap")), - net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), - net_realized_pnl_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl_ema_1w")), - net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_realized_pnl_rel_to_realized_cap")), - peak_regret: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_peak_regret")), - peak_regret_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_peak_regret_rel_to_realized_cap")), - profit_flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")), - profit_value_created: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_created")), - profit_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_destroyed")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_cap_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_change_1m")), - realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_loss_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_ema_1w")), - realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_ema_1w")), - realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")), - sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio")), - sell_side_risk_ratio_24h_ema: _1m1wPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio_24h_ema")), - sent_in_loss: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_loss")), - sent_in_loss_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_loss_ema_2w")), - sent_in_profit: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_profit")), - sent_in_profit_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_profit_ema_2w")), - sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), - sopr_24h_ema: _1m1wPattern::new(client.clone(), _m(&acc, "sopr_24h_ema")), - upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")), - value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")), - value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_created")), - value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")), - value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_destroyed")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern { - pub capitulation_flow: MetricPattern1, - pub gross_pnl: CentsUsdPattern, - pub gross_pnl_sum: _1m1w1y24hPattern, - pub loss_value_created: MetricPattern1, - pub loss_value_destroyed: MetricPattern1, - pub mvrv: MetricPattern1, - pub neg_realized_loss: MetricPattern1, - pub net_pnl_change_1m: MetricPattern1, - pub net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern, - pub net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern, - pub net_realized_pnl: CumulativeHeightPattern, - pub net_realized_pnl_ema_1w: MetricPattern1, - pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern, - pub profit_flow: MetricPattern1, - pub profit_value_created: MetricPattern1, - pub profit_value_destroyed: MetricPattern1, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_cap_change_1m: MetricPattern1, - pub realized_loss: CumulativeHeightPattern, - pub realized_loss_ema_1w: MetricPattern1, - pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_profit: CumulativeHeightPattern, - pub realized_profit_ema_1w: MetricPattern1, - pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern, - pub sent_in_loss: BaseCumulativePattern, - pub sent_in_loss_ema: _2wPattern, - pub sent_in_profit: BaseCumulativePattern, - pub sent_in_profit_ema: _2wPattern, - pub sopr: _1m1w1y24hPattern, - pub sopr_24h_ema: _1m1wPattern, - pub value_created: MetricPattern1, - pub value_created_sum: _1m1w1y24hPattern, - pub value_destroyed: MetricPattern1, - pub value_destroyed_sum: _1m1w1y24hPattern, -} - -impl CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - capitulation_flow: MetricPattern1::new(client.clone(), _m(&acc, "capitulation_flow")), - gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")), - gross_pnl_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "gross_pnl_sum")), - loss_value_created: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_created")), - loss_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_destroyed")), - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), - net_pnl_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "net_pnl_change_1m")), - net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_market_cap")), - net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_realized_cap")), - net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), - net_realized_pnl_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl_ema_1w")), - net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_realized_pnl_rel_to_realized_cap")), - profit_flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")), - profit_value_created: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_created")), - profit_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_destroyed")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_cap_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_change_1m")), - realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_loss_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_ema_1w")), - realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_ema_1w")), - realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")), - sent_in_loss: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_loss")), - sent_in_loss_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_loss_ema_2w")), - sent_in_profit: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_profit")), - sent_in_profit_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_profit_ema_2w")), - sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), - sopr_24h_ema: _1m1wPattern::new(client.clone(), _m(&acc, "sopr_24h_ema")), - value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")), - value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_created")), - value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")), - value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_destroyed")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { pub _0sd_price: CentsSatsUsdPattern, @@ -1333,6 +1129,74 @@ impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { } } +/// Pattern struct for repeated tree structure. +pub struct GrossMvrvNegNetRealizedSentSoprValuePattern { + pub gross_pnl: CentsUsdPattern, + pub mvrv: MetricPattern1, + pub neg_realized_loss: MetricPattern1, + pub net_realized_pnl: CumulativeHeightPattern, + pub net_realized_pnl_ema_1w: MetricPattern1, + pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern, + pub realized_cap: MetricPattern1, + pub realized_cap_cents: MetricPattern1, + pub realized_cap_change_1m: MetricPattern1, + pub realized_loss: CumulativeHeightPattern, + pub realized_loss_ema_1w: MetricPattern1, + pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern, + pub realized_price: CentsSatsUsdPattern, + pub realized_price_ratio: BpsRatioPattern, + pub realized_price_ratio_percentiles: RatioPattern, + pub realized_profit: CumulativeHeightPattern, + pub realized_profit_ema_1w: MetricPattern1, + pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern, + pub sent_in_loss: BaseCumulativePattern, + pub sent_in_loss_ema: _2wPattern, + pub sent_in_profit: BaseCumulativePattern, + pub sent_in_profit_ema: _2wPattern, + pub sopr: _1m1w1y24hPattern, + pub sopr_24h_ema: _1m1wPattern, + pub value_created: MetricPattern1, + pub value_created_sum: _1m1w1y24hPattern, + pub value_destroyed: MetricPattern1, + pub value_destroyed_sum: _1m1w1y24hPattern, +} + +impl GrossMvrvNegNetRealizedSentSoprValuePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")), + mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), + neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), + net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), + net_realized_pnl_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl_ema_1w")), + net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_realized_pnl_rel_to_realized_cap")), + realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), + realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), + realized_cap_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_change_1m")), + realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), + realized_loss_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_ema_1w")), + realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")), + realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), + realized_price_ratio_percentiles: RatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), + realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), + realized_profit_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_ema_1w")), + realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")), + sent_in_loss: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_loss")), + sent_in_loss_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_loss_ema_2w")), + sent_in_profit: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_profit")), + sent_in_profit_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_profit_ema_2w")), + sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), + sopr_24h_ema: _1m1wPattern::new(client.clone(), _m(&acc, "sopr_24h_ema")), + value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")), + value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_created")), + value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")), + value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_destroyed")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct InvestedNegNetNuplSupplyUnrealizedPattern3 { pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern, @@ -1385,56 +1249,6 @@ impl InvestedNegNetNuplSupplyUnrealizedPattern3 { } } -/// Pattern struct for repeated tree structure. -pub struct GrossMvrvNegNetRealizedSoprPattern { - pub gross_pnl: CentsUsdPattern, - pub mvrv: MetricPattern1, - pub neg_realized_loss: MetricPattern1, - pub net_realized_pnl: CumulativeHeightPattern, - pub net_realized_pnl_ema_1w: MetricPattern1, - pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_cap_change_1m: MetricPattern1, - pub realized_loss: CumulativeHeightPattern, - pub realized_loss_ema_1w: MetricPattern1, - pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_profit: CumulativeHeightPattern, - pub realized_profit_ema_1w: MetricPattern1, - pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern, - pub sopr: _1m1w1y24hPattern, - pub sopr_24h_ema: _1m1wPattern, -} - -impl GrossMvrvNegNetRealizedSoprPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")), - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), - net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), - net_realized_pnl_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl_ema_1w")), - net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_realized_pnl_rel_to_realized_cap")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_cap_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_change_1m")), - realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_loss_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_ema_1w")), - realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_ema_1w")), - realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")), - sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), - sopr_24h_ema: _1m1wPattern::new(client.clone(), _m(&acc, "sopr_24h_ema")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern { pub pct05: CentsSatsUsdPattern, @@ -1821,6 +1635,38 @@ impl AverageGainsLossesRsiStochPattern { } } +/// Pattern struct for repeated tree structure. +pub struct NegNetNuplSupplyUnrealizedPattern { + pub neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, + pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern, + pub nupl: MetricPattern1, + 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, + pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, + pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern, +} + +impl NegNetNuplSupplyUnrealizedPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_market_cap")), + net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_market_cap")), + nupl: MetricPattern1::new(client.clone(), _m(&acc, "nupl")), + supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_circulating_supply")), + supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")), + supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_circulating_supply")), + supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")), + supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_rel_to_circulating_supply")), + unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")), + unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern { pub all: ChangeCountPattern, @@ -1911,36 +1757,6 @@ impl AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern { } } -/// Pattern struct for repeated tree structure. -pub struct NetNuplSupplyUnrealizedPattern { - pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern, - pub nupl: MetricPattern1, - 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, - pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, - pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern, -} - -impl NetNuplSupplyUnrealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_market_cap")), - nupl: MetricPattern1::new(client.clone(), _m(&acc, "nupl")), - supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_circulating_supply")), - supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")), - supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_circulating_supply")), - supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")), - supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_rel_to_circulating_supply")), - unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")), - unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern { pub average: _1m1w1y24hPattern, @@ -2005,10 +1821,10 @@ pub struct ActivityAddrOutputsRealizedRelativeSupplyUnrealizedPattern { pub addr_count: MetricPattern1, pub addr_count_change_1m: MetricPattern1, pub outputs: UtxoPattern, - pub realized: GrossMvrvNegNetRealizedSoprPattern, - pub relative: NetNuplSupplyUnrealizedPattern, + pub realized: MvrvRealizedPattern, + pub relative: SupplyPattern, pub supply: ChangeHalvedTotalPattern, - pub unrealized: NegNetSupplyUnrealizedPattern, + pub unrealized: SupplyPattern2, } impl ActivityAddrOutputsRealizedRelativeSupplyUnrealizedPattern { @@ -2019,10 +1835,10 @@ impl ActivityAddrOutputsRealizedRelativeSupplyUnrealizedPattern { addr_count: MetricPattern1::new(client.clone(), _m(&acc, "addr_count")), addr_count_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "addr_count_change_1m")), outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: GrossMvrvNegNetRealizedSoprPattern::new(client.clone(), acc.clone()), - relative: NetNuplSupplyUnrealizedPattern::new(client.clone(), acc.clone()), + realized: MvrvRealizedPattern::new(client.clone(), acc.clone()), + relative: SupplyPattern::new(client.clone(), _m(&acc, "supply_in")), supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: NegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()), + unrealized: SupplyPattern2::new(client.clone(), _m(&acc, "supply_in")), } } } @@ -2086,7 +1902,7 @@ pub struct ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern { pub activity: CoinblocksCoindaysSentPattern, pub cost_basis: MaxMinPattern, pub outputs: UtxoPattern, - pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, + pub realized: GrossMvrvNegNetRealizedSentSoprValuePattern, pub relative: InvestedNegNetNuplSupplyUnrealizedPattern, pub supply: ChangeHalvedTotalPattern, pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, @@ -2099,7 +1915,7 @@ impl ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern { activity: CoinblocksCoindaysSentPattern::new(client.clone(), acc.clone()), cost_basis: MaxMinPattern::new(client.clone(), _m(&acc, "cost_basis")), outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), acc.clone()), + realized: GrossMvrvNegNetRealizedSentSoprValuePattern::new(client.clone(), acc.clone()), relative: InvestedNegNetNuplSupplyUnrealizedPattern::new(client.clone(), acc.clone()), supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), acc.clone()), @@ -2108,27 +1924,53 @@ impl ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern { } /// Pattern struct for repeated tree structure. -pub struct ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 { - pub activity: CoinblocksCoindaysSentPattern, - pub cost_basis: MaxMinPattern, - pub outputs: UtxoPattern, - pub realized: CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern, - pub relative: NetNuplSupplyUnrealizedPattern, - pub supply: ChangeHalvedTotalPattern, - pub unrealized: NegNetSupplyUnrealizedPattern, +pub struct GrossNegNetSupplyUnrealizedPattern { + pub gross_pnl: CentsUsdPattern, + pub neg_unrealized_loss: MetricPattern1, + pub net_unrealized_pnl: CentsUsdPattern, + pub supply_in_loss: BtcCentsSatsUsdPattern, + pub supply_in_profit: BtcCentsSatsUsdPattern, + pub unrealized_loss: CentsUsdPattern, + pub unrealized_profit: CentsUsdPattern, } -impl ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 { +impl GrossNegNetSupplyUnrealizedPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - activity: CoinblocksCoindaysSentPattern::new(client.clone(), acc.clone()), - cost_basis: MaxMinPattern::new(client.clone(), _m(&acc, "cost_basis")), - outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern::new(client.clone(), acc.clone()), - relative: NetNuplSupplyUnrealizedPattern::new(client.clone(), acc.clone()), - supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: NegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()), + gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_gross_pnl")), + neg_unrealized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), + net_unrealized_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), + supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")), + supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), + unrealized_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), + unrealized_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct MvrvRealizedPattern { + pub mvrv: MetricPattern1, + pub realized_cap: MetricPattern1, + pub realized_cap_cents: MetricPattern1, + pub realized_loss: CumulativeHeightPattern, + pub realized_price: CentsSatsUsdPattern, + pub realized_price_ratio: BpsRatioPattern, + pub realized_profit: CumulativeHeightPattern, +} + +impl MvrvRealizedPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), + realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), + realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), + realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), + realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), + realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), } } } @@ -2157,14 +1999,38 @@ impl _1m1w1y24hBaseCumulativePattern { } } +/// Pattern struct for repeated tree structure. +pub struct ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 { + pub activity: SentPattern, + pub outputs: UtxoPattern, + pub realized: GrossMvrvNegNetRealizedSentSoprValuePattern, + pub relative: NegNetNuplSupplyUnrealizedPattern, + pub supply: ChangeHalvedTotalPattern, + pub unrealized: GrossNegNetSupplyUnrealizedPattern, +} + +impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + activity: SentPattern::new(client.clone(), _m(&acc, "sent")), + outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: GrossMvrvNegNetRealizedSentSoprValuePattern::new(client.clone(), acc.clone()), + relative: NegNetNuplSupplyUnrealizedPattern::new(client.clone(), acc.clone()), + supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), + unrealized: GrossNegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct ActivityOutputsRealizedRelativeSupplyUnrealizedPattern { pub activity: SentPattern, pub outputs: UtxoPattern, - pub realized: GrossMvrvNegNetRealizedSoprPattern, - pub relative: NetNuplSupplyUnrealizedPattern, + pub realized: MvrvRealizedPattern, + pub relative: SupplyPattern, pub supply: ChangeHalvedTotalPattern, - pub unrealized: NegNetSupplyUnrealizedPattern, + pub unrealized: SupplyPattern2, } impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern { @@ -2173,10 +2039,10 @@ impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern { Self { activity: SentPattern::new(client.clone(), _m(&acc, "sent")), outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: GrossMvrvNegNetRealizedSoprPattern::new(client.clone(), acc.clone()), - relative: NetNuplSupplyUnrealizedPattern::new(client.clone(), acc.clone()), + realized: MvrvRealizedPattern::new(client.clone(), acc.clone()), + relative: SupplyPattern::new(client.clone(), _m(&acc, "supply_in")), supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: NegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()), + unrealized: SupplyPattern2::new(client.clone(), _m(&acc, "supply_in")), } } } @@ -2205,30 +2071,6 @@ impl BalanceBothReactivatedReceivingSendingPattern { } } -/// Pattern struct for repeated tree structure. -pub struct NegNetSupplyUnrealizedPattern { - pub neg_unrealized_loss: MetricPattern1, - pub net_unrealized_pnl: CentsUsdPattern, - pub supply_in_loss: BtcCentsSatsUsdPattern, - pub supply_in_profit: BtcCentsSatsUsdPattern, - pub unrealized_loss: CentsUsdPattern, - pub unrealized_profit: CentsUsdPattern, -} - -impl NegNetSupplyUnrealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - neg_unrealized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - net_unrealized_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")), - supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), - unrealized_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - unrealized_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct EmaHistogramLineSignalPattern { pub ema_fast: MetricPattern1, @@ -2251,50 +2093,6 @@ impl EmaHistogramLineSignalPattern { } } -/// Pattern struct for repeated tree structure. -pub struct MvrvRealizedPattern { - pub mvrv: MetricPattern1, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, -} - -impl MvrvRealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct OutputsRealizedRelativeSupplyUnrealizedPattern { - pub outputs: UtxoPattern, - pub realized: MvrvRealizedPattern, - pub relative: SupplyPattern, - pub supply: ChangeHalvedTotalPattern, - pub unrealized: SupplyPattern2, -} - -impl OutputsRealizedRelativeSupplyUnrealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: MvrvRealizedPattern::new(client.clone(), acc.clone()), - relative: SupplyPattern::new(client.clone(), _m(&acc, "supply_in")), - supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: SupplyPattern2::new(client.clone(), _m(&acc, "supply_in")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hPattern2 { pub _1m: BpsPercentRatioPattern, @@ -5613,11 +5411,11 @@ pub struct MetricsTree_Distribution_UtxoCohorts { pub age_range: MetricsTree_Distribution_UtxoCohorts_AgeRange, pub max_age: MetricsTree_Distribution_UtxoCohorts_MaxAge, pub min_age: MetricsTree_Distribution_UtxoCohorts_MinAge, + pub epoch: MetricsTree_Distribution_UtxoCohorts_Epoch, + pub class: MetricsTree_Distribution_UtxoCohorts_Class, pub ge_amount: MetricsTree_Distribution_UtxoCohorts_GeAmount, pub amount_range: MetricsTree_Distribution_UtxoCohorts_AmountRange, pub lt_amount: MetricsTree_Distribution_UtxoCohorts_LtAmount, - pub epoch: MetricsTree_Distribution_UtxoCohorts_Epoch, - pub class: MetricsTree_Distribution_UtxoCohorts_Class, pub type_: MetricsTree_Distribution_UtxoCohorts_Type, } @@ -5630,11 +5428,11 @@ impl MetricsTree_Distribution_UtxoCohorts { age_range: MetricsTree_Distribution_UtxoCohorts_AgeRange::new(client.clone(), format!("{base_path}_age_range")), max_age: MetricsTree_Distribution_UtxoCohorts_MaxAge::new(client.clone(), format!("{base_path}_max_age")), min_age: MetricsTree_Distribution_UtxoCohorts_MinAge::new(client.clone(), format!("{base_path}_min_age")), + epoch: MetricsTree_Distribution_UtxoCohorts_Epoch::new(client.clone(), format!("{base_path}_epoch")), + class: MetricsTree_Distribution_UtxoCohorts_Class::new(client.clone(), format!("{base_path}_class")), ge_amount: MetricsTree_Distribution_UtxoCohorts_GeAmount::new(client.clone(), format!("{base_path}_ge_amount")), amount_range: MetricsTree_Distribution_UtxoCohorts_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), lt_amount: MetricsTree_Distribution_UtxoCohorts_LtAmount::new(client.clone(), format!("{base_path}_lt_amount")), - epoch: MetricsTree_Distribution_UtxoCohorts_Epoch::new(client.clone(), format!("{base_path}_epoch")), - class: MetricsTree_Distribution_UtxoCohorts_Class::new(client.clone(), format!("{base_path}_class")), type_: MetricsTree_Distribution_UtxoCohorts_Type::new(client.clone(), format!("{base_path}_type_")), } } @@ -5645,10 +5443,13 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All { pub supply: ChangeHalvedTotalPattern, pub outputs: UtxoPattern, pub activity: CoinblocksCoindaysSentPattern, - pub realized: AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, + pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, pub cost_basis: InvestedMaxMinPercentilesPattern, pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, + pub adjusted: MetricsTree_Distribution_UtxoCohorts_All_Adjusted, pub relative: MetricsTree_Distribution_UtxoCohorts_All_Relative, + pub dormancy: MetricPattern1, + pub velocity: MetricPattern1, } impl MetricsTree_Distribution_UtxoCohorts_All { @@ -5657,17 +5458,42 @@ impl MetricsTree_Distribution_UtxoCohorts_All { supply: ChangeHalvedTotalPattern::new(client.clone(), "supply".to_string()), outputs: UtxoPattern::new(client.clone(), "utxo_count".to_string()), activity: CoinblocksCoindaysSentPattern::new(client.clone(), "".to_string()), - realized: AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "".to_string()), + realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "".to_string()), cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "".to_string()), unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "".to_string()), + adjusted: MetricsTree_Distribution_UtxoCohorts_All_Adjusted::new(client.clone(), format!("{base_path}_adjusted")), relative: MetricsTree_Distribution_UtxoCohorts_All_Relative::new(client.clone(), format!("{base_path}_relative")), + dormancy: MetricPattern1::new(client.clone(), "dormancy".to_string()), + velocity: MetricPattern1::new(client.clone(), "velocity".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_All_Adjusted { + pub adjusted_value_created: MetricPattern1, + pub adjusted_value_destroyed: MetricPattern1, + pub adjusted_value_created_sum: _1m1w1y24hPattern, + pub adjusted_value_destroyed_sum: _1m1w1y24hPattern, + pub adjusted_sopr: _1m1w1y24hPattern, + pub adjusted_sopr_ema: _1m1wPattern, +} + +impl MetricsTree_Distribution_UtxoCohorts_All_Adjusted { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + adjusted_value_created: MetricPattern1::new(client.clone(), "adjusted_value_created".to_string()), + adjusted_value_destroyed: MetricPattern1::new(client.clone(), "adjusted_value_destroyed".to_string()), + adjusted_value_created_sum: _1m1w1y24hPattern::new(client.clone(), "adjusted_value_created".to_string()), + adjusted_value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), "adjusted_value_destroyed".to_string()), + adjusted_sopr: _1m1w1y24hPattern::new(client.clone(), "adjusted_sopr".to_string()), + adjusted_sopr_ema: _1m1wPattern::new(client.clone(), "adjusted_sopr_24h_ema".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative { - pub neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, pub invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern, pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern, pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern, @@ -5675,6 +5501,7 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative { 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 neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, pub nupl: MetricPattern1, pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern, pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern, @@ -5685,7 +5512,6 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative { impl MetricsTree_Distribution_UtxoCohorts_All_Relative { pub fn new(client: Arc, base_path: String) -> Self { Self { - neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "neg_unrealized_loss_rel_to_market_cap".to_string()), invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "invested_capital_in_profit_rel_to_realized_cap".to_string()), invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "invested_capital_in_loss_rel_to_realized_cap".to_string()), supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_profit_rel_to_own_supply".to_string()), @@ -5693,6 +5519,7 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Relative { 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()), + neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "neg_unrealized_loss_rel_to_market_cap".to_string()), nupl: MetricPattern1::new(client.clone(), "nupl".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()), @@ -5707,10 +5534,18 @@ pub struct MetricsTree_Distribution_UtxoCohorts_Sth { pub supply: ChangeHalvedTotalPattern, pub outputs: UtxoPattern, pub activity: CoinblocksCoindaysSentPattern, - pub realized: AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, + pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, pub cost_basis: InvestedMaxMinPercentilesPattern, pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, pub relative: InvestedNegNetNuplSupplyUnrealizedPattern3, + pub dormancy: MetricPattern1, + pub velocity: MetricPattern1, + pub adjusted_value_created: MetricPattern1, + pub adjusted_value_destroyed: MetricPattern1, + pub adjusted_value_created_sum: _1m1w1y24hPattern, + pub adjusted_value_destroyed_sum: _1m1w1y24hPattern, + pub adjusted_sopr: _1m1w1y24hPattern, + pub adjusted_sopr_ema: _1m1wPattern, } impl MetricsTree_Distribution_UtxoCohorts_Sth { @@ -5719,10 +5554,18 @@ impl MetricsTree_Distribution_UtxoCohorts_Sth { supply: ChangeHalvedTotalPattern::new(client.clone(), "sth_supply".to_string()), outputs: UtxoPattern::new(client.clone(), "sth_utxo_count".to_string()), activity: CoinblocksCoindaysSentPattern::new(client.clone(), "sth".to_string()), - realized: AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "sth".to_string()), + realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "sth".to_string()), cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "sth".to_string()), unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "sth".to_string()), relative: InvestedNegNetNuplSupplyUnrealizedPattern3::new(client.clone(), "sth".to_string()), + dormancy: MetricPattern1::new(client.clone(), "sth_dormancy".to_string()), + velocity: MetricPattern1::new(client.clone(), "sth_velocity".to_string()), + adjusted_value_created: MetricPattern1::new(client.clone(), "sth_adjusted_value_created".to_string()), + adjusted_value_destroyed: MetricPattern1::new(client.clone(), "sth_adjusted_value_destroyed".to_string()), + adjusted_value_created_sum: _1m1w1y24hPattern::new(client.clone(), "sth_adjusted_value_created".to_string()), + adjusted_value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), "sth_adjusted_value_destroyed".to_string()), + adjusted_sopr: _1m1w1y24hPattern::new(client.clone(), "sth_adjusted_sopr".to_string()), + adjusted_sopr_ema: _1m1wPattern::new(client.clone(), "sth_adjusted_sopr_24h_ema".to_string()), } } } @@ -5732,10 +5575,12 @@ pub struct MetricsTree_Distribution_UtxoCohorts_Lth { pub supply: ChangeHalvedTotalPattern, pub outputs: UtxoPattern, pub activity: CoinblocksCoindaysSentPattern, - pub realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized, + pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, pub cost_basis: InvestedMaxMinPercentilesPattern, pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, pub relative: InvestedNegNetNuplSupplyUnrealizedPattern3, + pub dormancy: MetricPattern1, + pub velocity: MetricPattern1, } impl MetricsTree_Distribution_UtxoCohorts_Lth { @@ -5744,131 +5589,12 @@ impl MetricsTree_Distribution_UtxoCohorts_Lth { supply: ChangeHalvedTotalPattern::new(client.clone(), "lth_supply".to_string()), outputs: UtxoPattern::new(client.clone(), "lth_utxo_count".to_string()), activity: CoinblocksCoindaysSentPattern::new(client.clone(), "lth".to_string()), - realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), + realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "lth".to_string()), cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "lth".to_string()), unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "lth".to_string()), relative: InvestedNegNetNuplSupplyUnrealizedPattern3::new(client.clone(), "lth".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_UtxoCohorts_Lth_Realized { - pub investor_price: CentsSatsUsdPattern, - pub investor_price_ratio: BpsRatioPattern, - pub lower_price_band: CentsSatsUsdPattern, - pub upper_price_band: CentsSatsUsdPattern, - pub cap_raw: MetricPattern18, - pub investor_cap_raw: MetricPattern18, - pub sell_side_risk_ratio: _1m1w1y24hPattern2, - pub sell_side_risk_ratio_24h_ema: _1m1wPattern2, - pub peak_regret: CumulativeHeightPattern, - pub peak_regret_rel_to_realized_cap: BpsPercentRatioPattern, - pub profit_value_created: MetricPattern1, - pub profit_value_destroyed: MetricPattern1, - pub loss_value_created: MetricPattern1, - pub loss_value_destroyed: MetricPattern1, - pub value_created: MetricPattern1, - pub value_destroyed: MetricPattern1, - pub capitulation_flow: MetricPattern1, - pub profit_flow: MetricPattern1, - pub value_created_sum: _1m1w1y24hPattern, - pub value_destroyed_sum: _1m1w1y24hPattern, - pub gross_pnl_sum: _1m1w1y24hPattern, - pub net_pnl_change_1m: MetricPattern1, - pub net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern, - pub net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern, - pub sent_in_profit: BaseCumulativePattern, - pub sent_in_profit_ema: _2wPattern, - pub sent_in_loss: BaseCumulativePattern, - pub sent_in_loss_ema: _2wPattern, - pub realized_cap_cents: MetricPattern1, - pub realized_profit: CumulativeHeightPattern, - pub realized_loss: CumulativeHeightPattern, - pub realized_cap: MetricPattern1, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_cap_change_1m: MetricPattern1, - pub mvrv: MetricPattern1, - pub neg_realized_loss: MetricPattern1, - pub net_realized_pnl: CumulativeHeightPattern, - pub net_realized_pnl_ema_1w: MetricPattern1, - pub gross_pnl: CentsUsdPattern, - pub realized_profit_ema_1w: MetricPattern1, - pub realized_loss_ema_1w: MetricPattern1, - pub sopr: _1m1w1y24hPattern, - pub sopr_24h_ema: _1m1wPattern, - pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern, - pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern, - pub realized_profit_sum: _1m1w1y24hPattern, - pub realized_loss_sum: _1m1w1y24hPattern, - pub realized_profit_to_loss_ratio: _1m1w1y24hPattern, - pub realized_price_ratio_percentiles: RatioPattern, - pub realized_price_ratio_std_dev: RatioPattern2, - pub investor_price_ratio_percentiles: RatioPattern, - pub investor_price_ratio_std_dev: RatioPattern2, -} - -impl MetricsTree_Distribution_UtxoCohorts_Lth_Realized { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - investor_price: CentsSatsUsdPattern::new(client.clone(), "lth_investor_price".to_string()), - investor_price_ratio: BpsRatioPattern::new(client.clone(), "lth_investor_price_ratio".to_string()), - lower_price_band: CentsSatsUsdPattern::new(client.clone(), "lth_lower_price_band".to_string()), - upper_price_band: CentsSatsUsdPattern::new(client.clone(), "lth_upper_price_band".to_string()), - cap_raw: MetricPattern18::new(client.clone(), "lth_cap_raw".to_string()), - investor_cap_raw: MetricPattern18::new(client.clone(), "lth_investor_cap_raw".to_string()), - sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), "lth_sell_side_risk_ratio".to_string()), - sell_side_risk_ratio_24h_ema: _1m1wPattern2::new(client.clone(), "lth_sell_side_risk_ratio_24h_ema".to_string()), - peak_regret: CumulativeHeightPattern::new(client.clone(), "lth_realized_peak_regret".to_string()), - peak_regret_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "lth_realized_peak_regret_rel_to_realized_cap".to_string()), - profit_value_created: MetricPattern1::new(client.clone(), "lth_profit_value_created".to_string()), - profit_value_destroyed: MetricPattern1::new(client.clone(), "lth_profit_value_destroyed".to_string()), - loss_value_created: MetricPattern1::new(client.clone(), "lth_loss_value_created".to_string()), - loss_value_destroyed: MetricPattern1::new(client.clone(), "lth_loss_value_destroyed".to_string()), - value_created: MetricPattern1::new(client.clone(), "lth_value_created".to_string()), - value_destroyed: MetricPattern1::new(client.clone(), "lth_value_destroyed".to_string()), - capitulation_flow: MetricPattern1::new(client.clone(), "lth_capitulation_flow".to_string()), - profit_flow: MetricPattern1::new(client.clone(), "lth_profit_flow".to_string()), - value_created_sum: _1m1w1y24hPattern::new(client.clone(), "lth_value_created".to_string()), - value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), "lth_value_destroyed".to_string()), - gross_pnl_sum: _1m1w1y24hPattern::new(client.clone(), "lth_gross_pnl_sum".to_string()), - net_pnl_change_1m: MetricPattern1::new(client.clone(), "lth_net_pnl_change_1m".to_string()), - net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "lth_net_pnl_change_1m_rel_to_realized_cap".to_string()), - net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "lth_net_pnl_change_1m_rel_to_market_cap".to_string()), - sent_in_profit: BaseCumulativePattern::new(client.clone(), "lth_sent_in_profit".to_string()), - sent_in_profit_ema: _2wPattern::new(client.clone(), "lth_sent_in_profit_ema_2w".to_string()), - sent_in_loss: BaseCumulativePattern::new(client.clone(), "lth_sent_in_loss".to_string()), - sent_in_loss_ema: _2wPattern::new(client.clone(), "lth_sent_in_loss_ema_2w".to_string()), - realized_cap_cents: MetricPattern1::new(client.clone(), "lth_realized_cap_cents".to_string()), - realized_profit: CumulativeHeightPattern::new(client.clone(), "lth_realized_profit".to_string()), - realized_loss: CumulativeHeightPattern::new(client.clone(), "lth_realized_loss".to_string()), - realized_cap: MetricPattern1::new(client.clone(), "lth_realized_cap".to_string()), - realized_price: CentsSatsUsdPattern::new(client.clone(), "lth_realized_price".to_string()), - realized_price_ratio: BpsRatioPattern::new(client.clone(), "lth_realized_price_ratio".to_string()), - realized_cap_change_1m: MetricPattern1::new(client.clone(), "lth_realized_cap_change_1m".to_string()), - mvrv: MetricPattern1::new(client.clone(), "lth_mvrv".to_string()), - neg_realized_loss: MetricPattern1::new(client.clone(), "lth_neg_realized_loss".to_string()), - net_realized_pnl: CumulativeHeightPattern::new(client.clone(), "lth_net_realized_pnl".to_string()), - net_realized_pnl_ema_1w: MetricPattern1::new(client.clone(), "lth_net_realized_pnl_ema_1w".to_string()), - gross_pnl: CentsUsdPattern::new(client.clone(), "lth_realized_gross_pnl".to_string()), - realized_profit_ema_1w: MetricPattern1::new(client.clone(), "lth_realized_profit_ema_1w".to_string()), - realized_loss_ema_1w: MetricPattern1::new(client.clone(), "lth_realized_loss_ema_1w".to_string()), - sopr: _1m1w1y24hPattern::new(client.clone(), "lth_sopr".to_string()), - sopr_24h_ema: _1m1wPattern::new(client.clone(), "lth_sopr_24h_ema".to_string()), - realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "lth_realized_profit_rel_to_realized_cap".to_string()), - realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "lth_realized_loss_rel_to_realized_cap".to_string()), - net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "lth_net_realized_pnl_rel_to_realized_cap".to_string()), - realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), "lth_realized_cap_rel_to_own_market_cap".to_string()), - realized_profit_sum: _1m1w1y24hPattern::new(client.clone(), "lth_realized_profit".to_string()), - realized_loss_sum: _1m1w1y24hPattern::new(client.clone(), "lth_realized_loss".to_string()), - realized_profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "lth_realized_profit_to_loss_ratio".to_string()), - realized_price_ratio_percentiles: RatioPattern::new(client.clone(), "lth_realized_price_ratio".to_string()), - realized_price_ratio_std_dev: RatioPattern2::new(client.clone(), "lth_realized_price_ratio".to_string()), - investor_price_ratio_percentiles: RatioPattern::new(client.clone(), "lth_investor_price_ratio".to_string()), - investor_price_ratio_std_dev: RatioPattern2::new(client.clone(), "lth_investor_price_ratio".to_string()), + dormancy: MetricPattern1::new(client.clone(), "lth_dormancy".to_string()), + velocity: MetricPattern1::new(client.clone(), "lth_velocity".to_string()), } } } @@ -5928,94 +5654,162 @@ impl MetricsTree_Distribution_UtxoCohorts_AgeRange { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_MaxAge { - pub _1w: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _1m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _2m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _3m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _4m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _5m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _6m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _1y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _2y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _3y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _4y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _5y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _6y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _7y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _8y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _10y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _12y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _15y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, + pub _1w: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _1m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _3m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _4m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _5m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _6m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _1y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _3y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _4y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _5y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _6y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _7y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _8y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _10y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _12y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _15y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, } impl MetricsTree_Distribution_UtxoCohorts_MaxAge { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1w: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_1w_old".to_string()), - _1m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_1m_old".to_string()), - _2m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_2m_old".to_string()), - _3m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_3m_old".to_string()), - _4m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_4m_old".to_string()), - _5m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_5m_old".to_string()), - _6m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_6m_old".to_string()), - _1y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_1y_old".to_string()), - _2y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_2y_old".to_string()), - _3y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_3y_old".to_string()), - _4y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_4y_old".to_string()), - _5y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_5y_old".to_string()), - _6y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_6y_old".to_string()), - _7y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_7y_old".to_string()), - _8y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_8y_old".to_string()), - _10y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_10y_old".to_string()), - _12y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_12y_old".to_string()), - _15y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_under_15y_old".to_string()), + _1w: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1w_old".to_string()), + _1m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1m_old".to_string()), + _2m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_2m_old".to_string()), + _3m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_3m_old".to_string()), + _4m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_4m_old".to_string()), + _5m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_5m_old".to_string()), + _6m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_6m_old".to_string()), + _1y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_1y_old".to_string()), + _2y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_2y_old".to_string()), + _3y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_3y_old".to_string()), + _4y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_4y_old".to_string()), + _5y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_5y_old".to_string()), + _6y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_6y_old".to_string()), + _7y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_7y_old".to_string()), + _8y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_8y_old".to_string()), + _10y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_10y_old".to_string()), + _12y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_12y_old".to_string()), + _15y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_under_15y_old".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_MinAge { - pub _1d: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _1w: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _1m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _2m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _3m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _4m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _5m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _6m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _1y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _2y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _3y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _4y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _5y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _6y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _7y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _8y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _10y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, - pub _12y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4, + pub _1d: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _1w: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _1m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _3m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _4m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _5m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _6m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _1y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _3y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _4y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _5y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _6y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _7y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _8y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _10y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _12y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, } impl MetricsTree_Distribution_UtxoCohorts_MinAge { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1d: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_1d_old".to_string()), - _1w: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_1w_old".to_string()), - _1m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_1m_old".to_string()), - _2m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_2m_old".to_string()), - _3m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_3m_old".to_string()), - _4m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_4m_old".to_string()), - _5m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_5m_old".to_string()), - _6m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_6m_old".to_string()), - _1y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_1y_old".to_string()), - _2y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_2y_old".to_string()), - _3y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_3y_old".to_string()), - _4y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_4y_old".to_string()), - _5y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_5y_old".to_string()), - _6y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_6y_old".to_string()), - _7y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_7y_old".to_string()), - _8y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_8y_old".to_string()), - _10y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_10y_old".to_string()), - _12y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4::new(client.clone(), "utxos_over_12y_old".to_string()), + _1d: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1d_old".to_string()), + _1w: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1w_old".to_string()), + _1m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1m_old".to_string()), + _2m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_2m_old".to_string()), + _3m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_3m_old".to_string()), + _4m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_4m_old".to_string()), + _5m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_5m_old".to_string()), + _6m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_6m_old".to_string()), + _1y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_1y_old".to_string()), + _2y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_2y_old".to_string()), + _3y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_3y_old".to_string()), + _4y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_4y_old".to_string()), + _5y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_5y_old".to_string()), + _6y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_6y_old".to_string()), + _7y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_7y_old".to_string()), + _8y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_8y_old".to_string()), + _10y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_10y_old".to_string()), + _12y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "utxos_over_12y_old".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_Epoch { + pub _0: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _1: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _3: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _4: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, +} + +impl MetricsTree_Distribution_UtxoCohorts_Epoch { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + _0: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "epoch_0".to_string()), + _1: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "epoch_1".to_string()), + _2: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "epoch_2".to_string()), + _3: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "epoch_3".to_string()), + _4: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "epoch_4".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_Class { + pub _2009: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2010: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2011: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2012: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2013: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2014: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2015: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2016: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2017: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2018: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2019: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2020: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2021: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2022: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2023: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2024: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2025: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, + pub _2026: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2, +} + +impl MetricsTree_Distribution_UtxoCohorts_Class { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + _2009: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2009".to_string()), + _2010: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2010".to_string()), + _2011: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2011".to_string()), + _2012: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2012".to_string()), + _2013: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2013".to_string()), + _2014: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2014".to_string()), + _2015: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2015".to_string()), + _2016: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2016".to_string()), + _2017: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2017".to_string()), + _2018: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2018".to_string()), + _2019: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2019".to_string()), + _2020: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2020".to_string()), + _2021: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2021".to_string()), + _2022: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2022".to_string()), + _2023: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2023".to_string()), + _2024: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2024".to_string()), + _2025: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2025".to_string()), + _2026: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2::new(client.clone(), "class_2026".to_string()), } } } @@ -6135,103 +5929,35 @@ impl MetricsTree_Distribution_UtxoCohorts_LtAmount { } } -/// Metrics tree node. -pub struct MetricsTree_Distribution_UtxoCohorts_Epoch { - pub _0: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _1: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _3: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _4: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, -} - -impl MetricsTree_Distribution_UtxoCohorts_Epoch { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - _0: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "epoch_0".to_string()), - _1: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "epoch_1".to_string()), - _2: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "epoch_2".to_string()), - _3: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "epoch_3".to_string()), - _4: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "epoch_4".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_UtxoCohorts_Class { - pub _2009: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2010: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2011: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2012: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2013: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2014: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2015: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2016: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2017: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2018: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2019: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2020: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2021: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2022: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2023: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2024: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2025: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, - pub _2026: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, -} - -impl MetricsTree_Distribution_UtxoCohorts_Class { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - _2009: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2009".to_string()), - _2010: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2010".to_string()), - _2011: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2011".to_string()), - _2012: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2012".to_string()), - _2013: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2013".to_string()), - _2014: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2014".to_string()), - _2015: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2015".to_string()), - _2016: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2016".to_string()), - _2017: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2017".to_string()), - _2018: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2018".to_string()), - _2019: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2019".to_string()), - _2020: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2020".to_string()), - _2021: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2021".to_string()), - _2022: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2022".to_string()), - _2023: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2023".to_string()), - _2024: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2024".to_string()), - _2025: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2025".to_string()), - _2026: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "class_2026".to_string()), - } - } -} - /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_Type { - pub p2pk65: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2pk33: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2pkh: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2ms: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2sh: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2wpkh: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2wsh: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2tr: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub p2a: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub unknown: OutputsRealizedRelativeSupplyUnrealizedPattern, - pub empty: OutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2pk65: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2pk33: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2pkh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2ms: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2sh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2wpkh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2wsh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2tr: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub p2a: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub unknown: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, + pub empty: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern, } impl MetricsTree_Distribution_UtxoCohorts_Type { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk65: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2pk65".to_string()), - p2pk33: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2pk33".to_string()), - p2pkh: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2pkh".to_string()), - p2ms: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2ms".to_string()), - p2sh: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2sh".to_string()), - p2wpkh: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2wpkh".to_string()), - p2wsh: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2wsh".to_string()), - p2tr: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2tr".to_string()), - p2a: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2a".to_string()), - unknown: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "unknown_outputs".to_string()), - empty: OutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "empty_outputs".to_string()), + p2pk65: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2pk65".to_string()), + p2pk33: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2pk33".to_string()), + p2pkh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2pkh".to_string()), + p2ms: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2ms".to_string()), + p2sh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2sh".to_string()), + p2wpkh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2wpkh".to_string()), + p2wsh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2wsh".to_string()), + p2tr: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2tr".to_string()), + p2a: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "p2a".to_string()), + unknown: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "unknown_outputs".to_string()), + empty: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern::new(client.clone(), "empty_outputs".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 c098c8fd1..07a60d29b 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/base.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/base.rs @@ -1,68 +1,37 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF64, Version}; -use derive_more::{Deref, DerefMut}; +use brk_types::{Height, Indexes, Sats, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; -use crate::internal::ComputedFromHeightCumulativeSum; +use crate::internal::{RollingEmas2w, ValueFromHeightCumulative}; use crate::{blocks, distribution::metrics::ImportConfig, prices}; -use super::ActivityCore; - -#[derive(Deref, DerefMut, Traversable)] -pub struct ActivityMetrics { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub core: ActivityCore, - - pub coinblocks_destroyed: ComputedFromHeightCumulativeSum, - pub coindays_destroyed: ComputedFromHeightCumulativeSum, +#[derive(Traversable)] +pub struct ActivityBase { + pub sent: ValueFromHeightCumulative, + pub sent_ema: RollingEmas2w, } -impl ActivityMetrics { +impl ActivityBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - core: ActivityCore::forced_import(cfg)?, - coinblocks_destroyed: cfg - .import_cumulative_sum("coinblocks_destroyed", Version::ONE)?, - coindays_destroyed: cfg.import_cumulative_sum("coindays_destroyed", Version::ONE)?, + sent: cfg.import_value_cumulative("sent", Version::ZERO)?, + sent_ema: cfg.import_emas_2w("sent", Version::ZERO)?, }) } pub(crate) fn min_len(&self) -> usize { - self.core - .min_len() - .min(self.coinblocks_destroyed.height.len()) - .min(self.coindays_destroyed.height.len()) + self.sent.base.sats.height.len() } - pub(crate) fn truncate_push( - &mut self, - height: Height, - sent: Sats, - satblocks_destroyed: Sats, - satdays_destroyed: Sats, - ) -> Result<()> { - self.core.truncate_push(height, sent)?; - self.coinblocks_destroyed.height.truncate_push( - height, - StoredF64::from(Bitcoin::from(satblocks_destroyed)), - )?; - self.coindays_destroyed.height.truncate_push( - height, - StoredF64::from(Bitcoin::from(satdays_destroyed)), - )?; + pub(crate) fn truncate_push(&mut self, height: Height, sent: Sats) -> Result<()> { + self.sent.base.sats.height.truncate_push(height, sent)?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![ - &mut self.core.sent.base.sats.height as &mut dyn AnyStoredVec, - &mut self.coinblocks_destroyed.height as &mut dyn AnyStoredVec, - &mut self.coindays_destroyed.height as &mut dyn AnyStoredVec, - ] + vec![&mut self.sent.base.sats.height as &mut dyn AnyStoredVec] } pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { @@ -75,12 +44,14 @@ impl ActivityMetrics { others: &[&Self], exit: &Exit, ) -> Result<()> { - let core_refs: Vec<&ActivityCore> = others.iter().map(|o| &o.core).collect(); - self.core - .compute_from_stateful(starting_indexes, &core_refs, exit)?; - - sum_others!(self, starting_indexes, others, exit; coinblocks_destroyed.height); - sum_others!(self, starting_indexes, others, exit; coindays_destroyed.height); + self.sent.base.sats.height.compute_sum_of_others( + starting_indexes.height, + &others + .iter() + .map(|v| &v.sent.base.sats.height) + .collect::>(), + exit, + )?; Ok(()) } @@ -91,16 +62,16 @@ impl ActivityMetrics { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.core - .compute_rest_part1(blocks, prices, starting_indexes, exit)?; + self.sent + .compute(prices, starting_indexes.height, exit)?; - let window_starts = blocks.count.window_starts(); - - self.coinblocks_destroyed - .compute_rest(starting_indexes.height, &window_starts, exit)?; - - self.coindays_destroyed - .compute_rest(starting_indexes.height, &window_starts, exit)?; + self.sent_ema.compute( + starting_indexes.height, + &blocks.count.height_2w_ago, + &self.sent.base.sats.height, + &self.sent.base.cents.height, + exit, + )?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/activity/core.rs b/crates/brk_computer/src/distribution/metrics/activity/core.rs deleted file mode 100644 index 27e57406f..000000000 --- a/crates/brk_computer/src/distribution/metrics/activity/core.rs +++ /dev/null @@ -1,78 +0,0 @@ -use brk_error::Result; -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::{blocks, distribution::metrics::ImportConfig, prices}; - -#[derive(Traversable)] -pub struct ActivityCore { - pub sent: ValueFromHeightCumulative, - pub sent_ema: RollingEmas2w, -} - -impl ActivityCore { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - Ok(Self { - sent: cfg.import_value_cumulative("sent", Version::ZERO)?, - sent_ema: cfg.import_emas_2w("sent", Version::ZERO)?, - }) - } - - pub(crate) fn min_len(&self) -> usize { - self.sent.base.sats.height.len() - } - - pub(crate) fn truncate_push(&mut self, height: Height, sent: Sats) -> Result<()> { - self.sent.base.sats.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] - } - - pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { - Ok(()) - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - self.sent.base.sats.height.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.sent.base.sats.height) - .collect::>(), - exit, - )?; - Ok(()) - } - - 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( - starting_indexes.height, - &blocks.count.height_2w_ago, - &self.sent.base.sats.height, - &self.sent.base.cents.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 new file mode 100644 index 000000000..519c6c953 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -0,0 +1,107 @@ +use brk_error::Result; +use brk_traversable::Traversable; +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::ComputedFromHeightCumulativeSum; + +use crate::{blocks, distribution::metrics::ImportConfig, prices}; + +use super::ActivityBase; + +#[derive(Deref, DerefMut, Traversable)] +pub struct ActivityFull { + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub base: ActivityBase, + + pub coinblocks_destroyed: ComputedFromHeightCumulativeSum, + pub coindays_destroyed: ComputedFromHeightCumulativeSum, +} + +impl ActivityFull { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + Ok(Self { + base: ActivityBase::forced_import(cfg)?, + coinblocks_destroyed: cfg + .import_cumulative_sum("coinblocks_destroyed", Version::ONE)?, + coindays_destroyed: cfg.import_cumulative_sum("coindays_destroyed", Version::ONE)?, + }) + } + + pub(crate) fn min_len(&self) -> usize { + self.base + .min_len() + .min(self.coinblocks_destroyed.height.len()) + .min(self.coindays_destroyed.height.len()) + } + + pub(crate) fn truncate_push( + &mut self, + height: Height, + sent: Sats, + satblocks_destroyed: Sats, + satdays_destroyed: Sats, + ) -> Result<()> { + self.base.truncate_push(height, sent)?; + self.coinblocks_destroyed.height.truncate_push( + height, + StoredF64::from(Bitcoin::from(satblocks_destroyed)), + )?; + self.coindays_destroyed.height.truncate_push( + height, + StoredF64::from(Bitcoin::from(satdays_destroyed)), + )?; + Ok(()) + } + + 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.coinblocks_destroyed.height as &mut dyn AnyStoredVec, + &mut self.coindays_destroyed.height as &mut dyn AnyStoredVec, + ] + } + + pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { + Ok(()) + } + + pub(crate) fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&Self], + exit: &Exit, + ) -> Result<()> { + let core_refs: Vec<&ActivityBase> = others.iter().map(|o| &o.base).collect(); + self.base + .compute_from_stateful(starting_indexes, &core_refs, exit)?; + + sum_others!(self, starting_indexes, others, exit; coinblocks_destroyed.height); + sum_others!(self, starting_indexes, others, exit; coindays_destroyed.height); + Ok(()) + } + + 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)?; + + let window_starts = blocks.count.window_starts(); + + self.coinblocks_destroyed + .compute_rest(starting_indexes.height, &window_starts, exit)?; + + self.coindays_destroyed + .compute_rest(starting_indexes.height, &window_starts, exit)?; + + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/activity/mod.rs b/crates/brk_computer/src/distribution/metrics/activity/mod.rs index 5074723b6..17a3cd90b 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/mod.rs @@ -1,5 +1,5 @@ mod base; -mod core; +mod full; pub use base::*; -pub use core::*; +pub use full::*; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index 29fc115d3..2b6aa5d67 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -9,8 +9,8 @@ use crate::{blocks, prices}; use crate::internal::ComputedFromHeight; use crate::distribution::metrics::{ - ActivityMetrics, CostBasisWithExtended, ImportConfig, OutputsMetrics, RealizedAdjusted, - RealizedWithExtended, RelativeForAll, SupplyMetrics, UnrealizedFull, + ActivityFull, CostBasisWithExtended, ImportConfig, OutputsMetrics, RealizedAdjusted, + RealizedFull, RelativeForAll, SupplyMetrics, UnrealizedFull, }; /// All-cohort metrics: extended realized + adjusted (as composable add-on), @@ -22,8 +22,8 @@ pub struct AllCohortMetrics { pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, - pub realized: Box>, + pub activity: Box>, + pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, pub adjusted: Box>, @@ -44,7 +44,7 @@ impl AllCohortMetrics { supply: SupplyMetrics, ) -> Result { let unrealized = UnrealizedFull::forced_import(cfg)?; - let realized = RealizedWithExtended::forced_import(cfg)?; + let realized = RealizedFull::forced_import(cfg)?; let adjusted = RealizedAdjusted::forced_import(cfg)?; let relative = RelativeForAll::forced_import(cfg)?; @@ -53,7 +53,7 @@ impl AllCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(supply), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityMetrics::forced_import(cfg)?), + activity: Box::new(ActivityFull::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasisWithExtended::forced_import(cfg)?), unrealized: Box::new(unrealized), @@ -97,7 +97,7 @@ impl AllCohortMetrics { self.relative.compute( starting_indexes.height, &self.unrealized, - &self.realized.base, + &self.realized, &self.supply.total.sats.height, height_to_market_cap, exit, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs index c7c7739d8..86ac19b67 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs @@ -7,20 +7,20 @@ use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityMetrics, CostBasisBase, ImportConfig, OutputsMetrics, RealizedFull, + ActivityFull, CostBasisBase, ImportConfig, OutputsMetrics, RealizedBase, RelativeWithRelToAll, SupplyMetrics, UnrealizedFull, }; /// Basic cohort metrics: no extensions, with relative (rel_to_all). -/// Used by: epoch, year, type (spendable), amount, address cohorts. +/// Used by: age_range cohorts. #[derive(Traversable)] pub struct BasicCohortMetrics { #[traversable(skip)] pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, - pub realized: Box>, + pub activity: Box>, + pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, pub relative: Box>, @@ -32,7 +32,7 @@ impl BasicCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let supply = SupplyMetrics::forced_import(cfg)?; let unrealized = UnrealizedFull::forced_import(cfg)?; - let realized = RealizedFull::forced_import(cfg)?; + let realized = RealizedBase::forced_import(cfg)?; let relative = RelativeWithRelToAll::forced_import(cfg)?; @@ -40,7 +40,7 @@ impl BasicCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(supply), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityMetrics::forced_import(cfg)?), + activity: Box::new(ActivityFull::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasisBase::forced_import(cfg)?), unrealized: Box::new(unrealized), @@ -62,7 +62,6 @@ impl BasicCohortMetrics { prices, starting_indexes, &self.supply.total.btc.height, - height_to_market_cap, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index fd4bb395b..02eb7de3d 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -7,8 +7,8 @@ use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityCore, CohortMetricsBase, RealizedCore, ImportConfig, OutputsMetrics, - RelativeCompleteWithRelToAll, SupplyMetrics, UnrealizedComplete, + ActivityBase, CohortMetricsBase, RealizedBase, ImportConfig, OutputsMetrics, + RelativeBaseWithRelToAll, SupplyMetrics, UnrealizedBase, }; #[derive(Traversable)] @@ -17,10 +17,10 @@ pub struct CoreCohortMetrics { pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, - pub realized: Box>, - pub unrealized: Box>, - pub relative: Box>, + pub activity: Box>, + pub realized: Box>, + pub unrealized: Box>, + pub relative: Box>, } impl CoreCohortMetrics { @@ -29,10 +29,10 @@ impl CoreCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(SupplyMetrics::forced_import(cfg)?), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityCore::forced_import(cfg)?), - realized: Box::new(RealizedCore::forced_import(cfg)?), - unrealized: Box::new(UnrealizedComplete::forced_import(cfg)?), - relative: Box::new(RelativeCompleteWithRelToAll::forced_import(cfg)?), + activity: Box::new(ActivityBase::forced_import(cfg)?), + realized: Box::new(RealizedBase::forced_import(cfg)?), + unrealized: Box::new(UnrealizedBase::forced_import(cfg)?), + relative: Box::new(RelativeBaseWithRelToAll::forced_import(cfg)?), }) } @@ -80,17 +80,17 @@ impl CoreCohortMetrics { )?; self.activity.compute_from_stateful( starting_indexes, - &others.iter().map(|v| &v.activity().core).collect::>(), + &others.iter().map(|v| &v.activity().base).collect::>(), exit, )?; self.realized.compute_from_stateful( starting_indexes, - &others.iter().map(|v| &v.realized_full().core).collect::>(), + &others.iter().map(|v| v.realized_base()).collect::>(), exit, )?; self.unrealized.compute_from_stateful( starting_indexes, - &others.iter().map(|v| &v.unrealized_full().complete).collect::>(), + &others.iter().map(|v| &v.unrealized_full().base).collect::>(), exit, )?; @@ -114,6 +114,12 @@ impl CoreCohortMetrics { self.activity .compute_rest_part1(blocks, prices, starting_indexes, exit)?; + self.realized + .sent_in_profit + .compute(prices, starting_indexes.height, exit)?; + self.realized + .sent_in_loss + .compute(prices, starting_indexes.height, exit)?; self.realized .compute_rest_part1(starting_indexes, exit)?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index f9b95544c..a7833dd3b 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -9,8 +9,8 @@ use crate::{blocks, prices}; use crate::internal::ComputedFromHeight; use crate::distribution::metrics::{ - ActivityMetrics, CostBasisWithExtended, ImportConfig, OutputsMetrics, - RealizedWithExtended, RelativeWithExtended, SupplyMetrics, UnrealizedFull, + ActivityFull, CostBasisWithExtended, ImportConfig, OutputsMetrics, + RealizedFull, RelativeWithExtended, SupplyMetrics, UnrealizedFull, }; /// Cohort metrics with extended realized + extended cost basis (no adjusted). @@ -21,8 +21,8 @@ pub struct ExtendedCohortMetrics { pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, - pub realized: Box>, + pub activity: Box>, + pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, pub relative: Box>, @@ -36,7 +36,7 @@ impl ExtendedCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let supply = SupplyMetrics::forced_import(cfg)?; let unrealized = UnrealizedFull::forced_import(cfg)?; - let realized = RealizedWithExtended::forced_import(cfg)?; + let realized = RealizedFull::forced_import(cfg)?; let relative = RelativeWithExtended::forced_import(cfg)?; @@ -44,7 +44,7 @@ impl ExtendedCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(supply), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityMetrics::forced_import(cfg)?), + activity: Box::new(ActivityFull::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasisWithExtended::forced_import(cfg)?), unrealized: Box::new(unrealized), @@ -75,7 +75,7 @@ impl ExtendedCohortMetrics { self.relative.compute( starting_indexes.height, &self.unrealized, - &self.realized.base, + &self.realized, &self.supply.total.sats.height, height_to_market_cap, all_supply_sats, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs index 75c1d224f..a00abff5c 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs @@ -2,36 +2,22 @@ use brk_cohort::Filter; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - BasisPoints16, BasisPoints32, Bitcoin, Cents, Dollars, Height, Indexes, Sats, StoredF32, - Version, + BasisPoints16, Height, Indexes, Sats, Version, }; -use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec}; +use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; use crate::{blocks, prices}; use crate::internal::{ - CentsUnsignedToDollars, ComputedFromHeight, ComputedFromHeightCumulative, - ComputedFromHeightRatio, Identity, LazyFromHeight, PercentFromHeight, Price, RatioSatsBp16, + PercentFromHeight, RatioSatsBp16, ValueFromHeight, }; use crate::distribution::{ - metrics::{ActivityCore, ImportConfig, OutputsMetrics, SupplyMetrics}, - state::{RealizedOps, UnrealizedState}, + metrics::{ActivityBase, ImportConfig, OutputsMetrics, RealizedMinimal, SupplyMetrics}, + state::UnrealizedState, }; -/// Minimal realized metrics: realized cap, realized price, MVRV, and realized P/L. -#[derive(Traversable)] -pub struct MinimalRealized { - pub realized_cap_cents: ComputedFromHeight, - pub realized_profit: ComputedFromHeightCumulative, - pub realized_loss: ComputedFromHeightCumulative, - pub realized_cap: LazyFromHeight, - pub realized_price: Price>, - pub realized_price_ratio: ComputedFromHeightRatio, - pub mvrv: LazyFromHeight, -} - /// Minimal unrealized metrics: supply in profit/loss only. #[derive(Traversable)] pub struct MinimalUnrealized { @@ -57,135 +43,12 @@ pub struct MinimalCohortMetrics { pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, - pub realized: Box>, + pub activity: Box>, + pub realized: Box>, pub unrealized: Box>, pub relative: Box>, } -impl MinimalRealized { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let realized_cap_cents = cfg.import_computed("realized_cap_cents", Version::ZERO)?; - let realized_cap = LazyFromHeight::from_computed::( - &cfg.name("realized_cap"), - cfg.version, - realized_cap_cents.height.read_only_boxed_clone(), - &realized_cap_cents, - ); - - let realized_profit = cfg.import_cumulative("realized_profit", Version::ZERO)?; - let realized_loss = cfg.import_cumulative("realized_loss", Version::ZERO)?; - - let realized_price = cfg.import_price("realized_price", Version::ONE)?; - let realized_price_ratio = cfg.import_ratio("realized_price", Version::ONE)?; - let mvrv = LazyFromHeight::from_lazy::, BasisPoints32>( - &cfg.name("mvrv"), - cfg.version, - &realized_price_ratio.ratio, - ); - - Ok(Self { - realized_cap_cents, - realized_profit, - realized_loss, - realized_cap, - realized_price, - realized_price_ratio, - mvrv, - }) - } - - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.realized_cap_cents - .height - .len() - .min(self.realized_profit.height.len()) - .min(self.realized_loss.height.len()) - } - - pub(crate) fn truncate_push( - &mut self, - height: Height, - state: &impl RealizedOps, - ) -> Result<()> { - self.realized_cap_cents - .height - .truncate_push(height, state.cap())?; - self.realized_profit - .height - .truncate_push(height, state.profit())?; - self.realized_loss - .height - .truncate_push(height, state.loss())?; - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![ - &mut self.realized_cap_cents.height as &mut dyn AnyStoredVec, - &mut self.realized_profit.height, - &mut self.realized_loss.height, - ] - } - - pub(crate) fn compute_from_sources( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - sum_others!(self, starting_indexes, others, exit; realized_cap_cents.height); - sum_others!(self, starting_indexes, others, exit; realized_profit.height); - sum_others!(self, starting_indexes, others, exit; realized_loss.height); - Ok(()) - } - - pub(crate) fn compute_rest_part1( - &mut self, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.realized_profit - .compute_rest(starting_indexes.height, exit)?; - self.realized_loss - .compute_rest(starting_indexes.height, exit)?; - Ok(()) - } - - pub(crate) fn compute_rest_part2( - &mut self, - prices: &prices::Vecs, - starting_indexes: &Indexes, - height_to_supply: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self.realized_price.cents.height.compute_transform2( - starting_indexes.height, - &self.realized_cap_cents.height, - height_to_supply, - |(i, cap_cents, supply, ..)| { - let cap = cap_cents.as_u128(); - let supply_sats = Sats::from(supply).as_u128(); - if supply_sats == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(cap * Sats::ONE_BTC_U128 / supply_sats)) - } - }, - exit, - )?; - - self.realized_price_ratio.compute_ratio( - starting_indexes, - &prices.price.cents.height, - &self.realized_price.cents.height, - exit, - )?; - - Ok(()) - } -} - impl MinimalUnrealized { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { @@ -292,8 +155,8 @@ impl MinimalCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(SupplyMetrics::forced_import(cfg)?), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityCore::forced_import(cfg)?), - realized: Box::new(MinimalRealized::forced_import(cfg)?), + activity: Box::new(ActivityBase::forced_import(cfg)?), + realized: Box::new(RealizedMinimal::forced_import(cfg)?), unrealized: Box::new(MinimalUnrealized::forced_import(cfg)?), relative: Box::new(MinimalRelative::forced_import(cfg)?), }) @@ -345,7 +208,7 @@ impl MinimalCohortMetrics { &others.iter().map(|v| v.activity.as_ref()).collect::>(), exit, )?; - self.realized.compute_from_sources( + self.realized.compute_from_stateful( starting_indexes, &others .iter() diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index 627a31b09..bb5c770c0 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -68,6 +68,104 @@ macro_rules! impl_cohort_metrics_base { Ok(()) } + fn min_stateful_height_len(&self) -> usize { + self.supply.min_len() + .min(self.outputs.min_len()) + .min(self.activity.min_len()) + .min(self.realized.min_stateful_height_len()) + .min(self.unrealized_full().min_stateful_height_len()) + .min(self.cost_basis_base().min_stateful_height_len()) + } + + fn truncate_push( + &mut self, + height: brk_types::Height, + state: &$crate::distribution::state::CohortState<$crate::distribution::state::RealizedState>, + ) -> brk_error::Result<()> { + self.supply_mut() + .truncate_push(height, state.supply.value)?; + self.outputs_mut() + .truncate_push(height, state.supply.utxo_count)?; + self.activity_mut().truncate_push( + height, + state.sent, + state.satblocks_destroyed, + state.satdays_destroyed, + )?; + self.realized.truncate_push(height, &state.realized)?; + Ok(()) + } + + fn compute_base_from_others( + &mut self, + starting_indexes: &brk_types::Indexes, + others: &[&T], + exit: &vecdb::Exit, + ) -> brk_error::Result<()> { + self.supply_mut().compute_from_stateful( + starting_indexes, + &others.iter().map(|v| v.supply()).collect::>(), + exit, + )?; + self.outputs_mut().compute_from_stateful( + starting_indexes, + &others.iter().map(|v| v.outputs()).collect::>(), + exit, + )?; + self.activity_mut().compute_from_stateful( + starting_indexes, + &others.iter().map(|v| v.activity()).collect::>(), + exit, + )?; + self.realized.compute_from_stateful( + starting_indexes, + &others.iter().map(|v| v.realized_base()).collect::>(), + exit, + )?; + self.unrealized_full_mut().compute_from_stateful( + starting_indexes, + &others.iter().map(|v| v.unrealized_full()).collect::>(), + exit, + )?; + self.cost_basis_base_mut().compute_from_stateful( + starting_indexes, + &others.iter().map(|v| v.cost_basis_base()).collect::>(), + exit, + )?; + Ok(()) + } + + fn compute_rest_part1( + &mut self, + blocks: &$crate::blocks::Vecs, + prices: &$crate::prices::Vecs, + starting_indexes: &brk_types::Indexes, + exit: &vecdb::Exit, + ) -> brk_error::Result<()> { + self.supply_mut() + .compute(prices, starting_indexes.height, exit)?; + self.supply_mut() + .compute_rest_part1(blocks, starting_indexes, exit)?; + 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)?; + + self.realized.sent_in_profit + .compute(prices, starting_indexes.height, exit)?; + self.realized.sent_in_loss + .compute(prices, starting_indexes.height, exit)?; + self.realized.compute_rest_part1(starting_indexes, exit)?; + + self.unrealized_full_mut() + .compute_rest(prices, starting_indexes, exit)?; + + Ok(()) + } + fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn vecdb::AnyStoredVec> { let mut vecs: Vec<&mut dyn vecdb::AnyStoredVec> = Vec::new(); vecs.extend(self.supply.collect_vecs_mut()); @@ -103,6 +201,37 @@ macro_rules! impl_cohort_metrics_base { ) } + fn min_stateful_height_len(&self) -> usize { + self.inner.min_stateful_height_len() + } + + fn truncate_push( + &mut self, + height: brk_types::Height, + state: &$crate::distribution::state::CohortState<$crate::distribution::state::RealizedState>, + ) -> brk_error::Result<()> { + self.inner.truncate_push(height, state) + } + + fn compute_rest_part1( + &mut self, + blocks: &$crate::blocks::Vecs, + prices: &$crate::prices::Vecs, + starting_indexes: &brk_types::Indexes, + exit: &vecdb::Exit, + ) -> brk_error::Result<()> { + self.inner.compute_rest_part1(blocks, prices, starting_indexes, exit) + } + + fn compute_base_from_others( + &mut self, + starting_indexes: &brk_types::Indexes, + others: &[&T], + exit: &vecdb::Exit, + ) -> brk_error::Result<()> { + self.inner.compute_base_from_others(starting_indexes, others, exit) + } + fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn vecdb::AnyStoredVec> { self.inner.collect_all_vecs_mut() } @@ -115,10 +244,10 @@ macro_rules! impl_cohort_metrics_base { fn supply_mut(&mut self) -> &mut $crate::distribution::metrics::SupplyMetrics { &mut self.supply } fn outputs(&self) -> &$crate::distribution::metrics::OutputsMetrics { &self.outputs } fn outputs_mut(&mut self) -> &mut $crate::distribution::metrics::OutputsMetrics { &mut self.outputs } - fn activity(&self) -> &$crate::distribution::metrics::ActivityMetrics { &self.activity } - fn activity_mut(&mut self) -> &mut $crate::distribution::metrics::ActivityMetrics { &mut self.activity } - fn realized_full(&self) -> &$crate::distribution::metrics::RealizedFull { &self.realized } - fn realized_full_mut(&mut self) -> &mut $crate::distribution::metrics::RealizedFull { &mut self.realized } + fn activity(&self) -> &$crate::distribution::metrics::ActivityFull { &self.activity } + fn activity_mut(&mut self) -> &mut $crate::distribution::metrics::ActivityFull { &mut self.activity } + fn realized_base(&self) -> &$crate::distribution::metrics::RealizedBase { &self.realized } + fn realized_base_mut(&mut self) -> &mut $crate::distribution::metrics::RealizedBase { &mut self.realized } fn unrealized_full(&self) -> &$crate::distribution::metrics::UnrealizedFull { &self.unrealized } fn unrealized_full_mut(&mut self) -> &mut $crate::distribution::metrics::UnrealizedFull { &mut self.unrealized } fn cost_basis_base(&self) -> &$crate::distribution::metrics::CostBasisBase { &self.cost_basis } @@ -131,10 +260,10 @@ macro_rules! impl_cohort_metrics_base { fn supply_mut(&mut self) -> &mut $crate::distribution::metrics::SupplyMetrics { self.inner.supply_mut() } fn outputs(&self) -> &$crate::distribution::metrics::OutputsMetrics { self.inner.outputs() } fn outputs_mut(&mut self) -> &mut $crate::distribution::metrics::OutputsMetrics { self.inner.outputs_mut() } - fn activity(&self) -> &$crate::distribution::metrics::ActivityMetrics { self.inner.activity() } - fn activity_mut(&mut self) -> &mut $crate::distribution::metrics::ActivityMetrics { self.inner.activity_mut() } - fn realized_full(&self) -> &$crate::distribution::metrics::RealizedFull { self.inner.realized_full() } - fn realized_full_mut(&mut self) -> &mut $crate::distribution::metrics::RealizedFull { self.inner.realized_full_mut() } + fn activity(&self) -> &$crate::distribution::metrics::ActivityFull { self.inner.activity() } + fn activity_mut(&mut self) -> &mut $crate::distribution::metrics::ActivityFull { self.inner.activity_mut() } + fn realized_base(&self) -> &$crate::distribution::metrics::RealizedBase { self.inner.realized_base() } + fn realized_base_mut(&mut self) -> &mut $crate::distribution::metrics::RealizedBase { self.inner.realized_base_mut() } fn unrealized_full(&self) -> &$crate::distribution::metrics::UnrealizedFull { self.inner.unrealized_full() } fn unrealized_full_mut(&mut self) -> &mut $crate::distribution::metrics::UnrealizedFull { self.inner.unrealized_full_mut() } fn cost_basis_base(&self) -> &$crate::distribution::metrics::CostBasisBase { self.inner.cost_basis_base() } @@ -197,10 +326,10 @@ pub trait CohortMetricsBase: CohortMetricsState + Send fn supply_mut(&mut self) -> &mut SupplyMetrics; fn outputs(&self) -> &OutputsMetrics; fn outputs_mut(&mut self) -> &mut OutputsMetrics; - fn activity(&self) -> &ActivityMetrics; - fn activity_mut(&mut self) -> &mut ActivityMetrics; - fn realized_full(&self) -> &RealizedFull; - fn realized_full_mut(&mut self) -> &mut RealizedFull; + fn activity(&self) -> &ActivityFull; + fn activity_mut(&mut self) -> &mut ActivityFull; + fn realized_base(&self) -> &RealizedBase; + fn realized_base_mut(&mut self) -> &mut RealizedBase; fn unrealized_full(&self) -> &UnrealizedFull; fn unrealized_full_mut(&mut self) -> &mut UnrealizedFull; fn cost_basis_base(&self) -> &CostBasisBase; @@ -242,7 +371,7 @@ pub trait CohortMetricsBase: CohortMetricsState + Send .min_len() .min(self.outputs().min_len()) .min(self.activity().min_len()) - .min(self.realized_full().min_stateful_height_len()) + .min(self.realized_base().min_stateful_height_len()) .min(self.unrealized_full().min_stateful_height_len()) .min(self.cost_basis_base().min_stateful_height_len()) } @@ -258,7 +387,7 @@ pub trait CohortMetricsBase: CohortMetricsState + Send state.satblocks_destroyed, state.satdays_destroyed, )?; - self.realized_full_mut() + self.realized_base_mut() .truncate_push(height, &state.realized)?; Ok(()) } @@ -272,7 +401,7 @@ pub trait CohortMetricsBase: CohortMetricsState + Send ) -> Result<()> { let weights: Vec<_> = others .iter() - .map(|o| &o.realized_full().realized_cap.height) + .map(|o| &o.realized_base().realized_cap.height) .collect(); let values: Vec<_> = others .iter() @@ -308,13 +437,13 @@ pub trait CohortMetricsBase: CohortMetricsState + Send self.activity_mut() .compute_rest_part1(blocks, prices, starting_indexes, exit)?; - self.realized_full_mut() + self.realized_base_mut() .sent_in_profit .compute(prices, starting_indexes.height, exit)?; - self.realized_full_mut() + self.realized_base_mut() .sent_in_loss .compute(prices, starting_indexes.height, exit)?; - self.realized_full_mut() + self.realized_base_mut() .compute_rest_part1(starting_indexes, exit)?; self.unrealized_full_mut() @@ -354,7 +483,7 @@ pub trait CohortMetricsBase: CohortMetricsState + Send aggregate!(supply_mut, supply); aggregate!(outputs_mut, outputs); aggregate!(activity_mut, activity); - aggregate!(realized_full_mut, realized_full); + aggregate!(realized_base_mut, realized_base); aggregate!(unrealized_full_mut, unrealized_full); aggregate!(cost_basis_base_mut, cost_basis_base); Ok(()) diff --git a/crates/brk_computer/src/distribution/metrics/realized/base.rs b/crates/brk_computer/src/distribution/metrics/realized/base.rs index 488e71529..937b76ec0 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/base.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/base.rs @@ -1,124 +1,172 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - BasisPoints32, Bitcoin, Cents, CentsSats, CentsSquaredSats, Dollars, Height, Indexes, Version, + BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Dollars, Height, Indexes, + StoredF64, Version, }; use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, AnyVec, BytesVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; +use vecdb::{ + AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec, +}; use crate::{ blocks, - distribution::state::RealizedState, + distribution::state::RealizedOps, internal::{ - ComputedFromHeight, ComputedFromHeightCumulative, ComputedFromHeightRatio, - PercentFromHeight, PercentRollingEmas1w1m, PercentRollingWindows, Price, RatioCentsBp32, + ComputedFromHeight, ComputedFromHeightCumulative, + ComputedFromHeightRatioPercentiles, FiatFromHeight, + LazyFromHeight, NegCentsUnsignedToDollars, PercentFromHeight, RatioCents64, + RatioCentsBp32, RatioCentsSignedCentsBps32, RollingEmas1w1m, RollingEmas2w, + RollingWindows, ValueFromHeightCumulative, }, prices, }; use crate::distribution::metrics::ImportConfig; -use super::RealizedComplete; +use super::RealizedMinimal; -/// Full realized metrics (Source/Extended tier). -/// -/// Contains all Complete-tier fields (via Deref to RealizedComplete) plus: -/// - Source-only: peak_regret, peak_regret_rel_to_realized_cap -/// - Extended-only: investor_price, price bands, cap_raw, sell_side_risk_ratio #[derive(Deref, DerefMut, Traversable)] -pub struct RealizedFull { +pub struct RealizedBase { #[deref] #[deref_mut] #[traversable(flatten)] - pub complete: RealizedComplete, + pub minimal: RealizedMinimal, - // --- Extended-only fields --- - pub investor_price: Price>, - pub investor_price_ratio: ComputedFromHeightRatio, + pub realized_cap_change_1m: ComputedFromHeight, - pub lower_price_band: Price>, - pub upper_price_band: Price>, + pub neg_realized_loss: LazyFromHeight, + pub net_realized_pnl: ComputedFromHeightCumulative, + pub net_realized_pnl_ema_1w: ComputedFromHeight, + pub gross_pnl: FiatFromHeight, - pub cap_raw: M::Stored>, - pub investor_cap_raw: M::Stored>, + pub realized_profit_ema_1w: ComputedFromHeight, + pub realized_loss_ema_1w: ComputedFromHeight, - pub sell_side_risk_ratio: PercentRollingWindows, - pub sell_side_risk_ratio_24h_ema: PercentRollingEmas1w1m, + pub realized_profit_rel_to_realized_cap: PercentFromHeight, + pub realized_loss_rel_to_realized_cap: PercentFromHeight, + pub net_realized_pnl_rel_to_realized_cap: PercentFromHeight, - // --- Source-only fields --- - pub peak_regret: ComputedFromHeightCumulative, - pub peak_regret_rel_to_realized_cap: PercentFromHeight, + pub value_created: ComputedFromHeight, + pub value_destroyed: ComputedFromHeight, + pub value_created_sum: RollingWindows, + pub value_destroyed_sum: RollingWindows, + pub sopr: RollingWindows, + pub sopr_24h_ema: RollingEmas1w1m, + + pub realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles, + + pub sent_in_profit: ValueFromHeightCumulative, + pub sent_in_loss: ValueFromHeightCumulative, + pub sent_in_profit_ema: RollingEmas2w, + pub sent_in_loss_ema: RollingEmas2w, } -impl RealizedFull { +impl RealizedBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v0 = Version::ZERO; + let v1 = Version::ONE; - let complete = RealizedComplete::forced_import(cfg)?; + let minimal = RealizedMinimal::forced_import(cfg)?; - let investor_price = cfg.import_price("investor_price", v0)?; - let investor_price_ratio = cfg.import_ratio("investor_price", v0)?; - let lower_price_band = cfg.import_price("lower_price_band", v0)?; - let upper_price_band = cfg.import_price("upper_price_band", v0)?; + let neg_realized_loss = LazyFromHeight::from_height_source::( + &cfg.name("neg_realized_loss"), + cfg.version + Version::ONE, + minimal.realized_loss.height.read_only_boxed_clone(), + cfg.indexes, + ); - let cap_raw = cfg.import_bytes("cap_raw", v0)?; - let investor_cap_raw = cfg.import_bytes("investor_cap_raw", v0)?; + let realized_profit_ema_1w = cfg.import_computed("realized_profit_ema_1w", v0)?; + let realized_loss_ema_1w = cfg.import_computed("realized_loss_ema_1w", v0)?; - let sell_side_risk_ratio = - cfg.import_percent_rolling_bp32("sell_side_risk_ratio", Version::new(2))?; - let sell_side_risk_ratio_24h_ema = - cfg.import_percent_emas_1w_1m_bp32("sell_side_risk_ratio_24h", Version::new(2))?; + let net_realized_pnl = cfg.import_cumulative("net_realized_pnl", v0)?; + let net_realized_pnl_ema_1w = cfg.import_computed("net_realized_pnl_ema_1w", v0)?; + let gross_pnl = cfg.import_fiat("realized_gross_pnl", v0)?; - let peak_regret = cfg.import_cumulative("realized_peak_regret", Version::new(2))?; - let peak_regret_rel_to_realized_cap = - cfg.import_percent_bp32("realized_peak_regret_rel_to_realized_cap", Version::new(2))?; + let realized_profit_rel_to_realized_cap = + cfg.import_percent_bp32("realized_profit_rel_to_realized_cap", Version::new(2))?; + let realized_loss_rel_to_realized_cap = + cfg.import_percent_bp32("realized_loss_rel_to_realized_cap", Version::new(2))?; + let net_realized_pnl_rel_to_realized_cap = + cfg.import_percent_bps32("net_realized_pnl_rel_to_realized_cap", Version::new(2))?; + + let value_created = cfg.import_computed("value_created", v0)?; + let value_destroyed = cfg.import_computed("value_destroyed", v0)?; + let value_created_sum = cfg.import_rolling("value_created", v1)?; + let value_destroyed_sum = cfg.import_rolling("value_destroyed", v1)?; + let sopr = cfg.import_rolling("sopr", v1)?; + let sopr_24h_ema = cfg.import_emas_1w_1m("sopr_24h", v1)?; + + let realized_price_ratio_percentiles = + ComputedFromHeightRatioPercentiles::forced_import( + cfg.db, + &cfg.name("realized_price"), + cfg.version + v1, + cfg.indexes, + )?; Ok(Self { - complete, - investor_price, - investor_price_ratio, - lower_price_band, - upper_price_band, - cap_raw, - investor_cap_raw, - sell_side_risk_ratio, - sell_side_risk_ratio_24h_ema, - peak_regret, - peak_regret_rel_to_realized_cap, + minimal, + realized_cap_change_1m: cfg.import_computed("realized_cap_change_1m", v0)?, + neg_realized_loss, + net_realized_pnl, + net_realized_pnl_ema_1w, + gross_pnl, + realized_profit_ema_1w, + realized_loss_ema_1w, + realized_profit_rel_to_realized_cap, + realized_loss_rel_to_realized_cap, + net_realized_pnl_rel_to_realized_cap, + value_created, + value_destroyed, + value_created_sum, + value_destroyed_sum, + sopr, + sopr_24h_ema, + realized_price_ratio_percentiles, + sent_in_profit: cfg.import_value_cumulative("sent_in_profit", v0)?, + sent_in_loss: cfg.import_value_cumulative("sent_in_loss", v0)?, + sent_in_profit_ema: cfg.import_emas_2w("sent_in_profit", v0)?, + sent_in_loss_ema: cfg.import_emas_2w("sent_in_loss", v0)?, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { - self.complete + self.minimal .min_stateful_height_len() - .min(self.investor_price.cents.height.len()) - .min(self.cap_raw.len()) - .min(self.investor_cap_raw.len()) - .min(self.peak_regret.height.len()) + .min(self.value_created.height.len()) + .min(self.value_destroyed.height.len()) + .min(self.sent_in_profit.base.sats.height.len()) + .min(self.sent_in_loss.base.sats.height.len()) } - pub(crate) fn truncate_push(&mut self, height: Height, state: &RealizedState) -> Result<()> { - self.complete.truncate_push(height, state)?; - self.investor_price - .cents + pub(crate) fn truncate_push(&mut self, height: Height, state: &impl RealizedOps) -> Result<()> { + self.minimal.truncate_push(height, state)?; + self.value_created .height - .truncate_push(height, state.investor_price())?; - self.cap_raw.truncate_push(height, state.cap_raw())?; - self.investor_cap_raw - .truncate_push(height, state.investor_cap_raw())?; - self.peak_regret + .truncate_push(height, state.value_created())?; + self.value_destroyed .height - .truncate_push(height, state.peak_regret())?; - + .truncate_push(height, state.value_destroyed())?; + self.sent_in_profit + .base + .sats + .height + .truncate_push(height, state.sent_in_profit())?; + self.sent_in_loss + .base + .sats + .height + .truncate_push(height, state.sent_in_loss())?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - let mut vecs = self.complete.collect_vecs_mut(); - vecs.push(&mut self.investor_price.cents.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.cap_raw as &mut dyn AnyStoredVec); - vecs.push(&mut self.investor_cap_raw as &mut dyn AnyStoredVec); - vecs.push(&mut self.peak_regret.height as &mut dyn AnyStoredVec); + let mut vecs = self.minimal.collect_vecs_mut(); + vecs.push(&mut self.value_created.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.value_destroyed.height); + vecs.push(&mut self.sent_in_profit.base.sats.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.sent_in_loss.base.sats.height); vecs } @@ -128,80 +176,14 @@ impl RealizedFull { others: &[&Self], exit: &Exit, ) -> Result<()> { - // Delegate Complete-tier aggregation - let complete_refs: Vec<&RealizedComplete> = - others.iter().map(|o| &o.complete).collect(); - self.complete - .compute_from_stateful(starting_indexes, &complete_refs, exit)?; + let minimal_refs: Vec<&RealizedMinimal> = others.iter().map(|o| &o.minimal).collect(); + self.minimal + .compute_from_stateful(starting_indexes, &minimal_refs, exit)?; - // Aggregate raw values for investor_price computation - let investor_price_dep_version = others - .iter() - .map(|o| o.investor_price.cents.height.version()) - .fold(vecdb::Version::ZERO, |acc, v| acc + v); - self.investor_price - .cents - .height - .validate_computed_version_or_reset(investor_price_dep_version)?; - - let start = self - .cap_raw - .len() - .min(self.investor_cap_raw.len()) - .min(self.investor_price.cents.height.len()); - let end = others.iter().map(|o| o.cap_raw.len()).min().unwrap_or(0); - - // Pre-collect all cohort data to avoid per-element BytesVec reads in nested loop - let cap_ranges: Vec> = others - .iter() - .map(|o| o.cap_raw.collect_range_at(start, end)) - .collect(); - let investor_cap_ranges: Vec> = others - .iter() - .map(|o| o.investor_cap_raw.collect_range_at(start, end)) - .collect(); - - for i in start..end { - let height = Height::from(i); - let local_i = i - start; - - let mut sum_cap = CentsSats::ZERO; - let mut sum_investor_cap = CentsSquaredSats::ZERO; - - for idx in 0..others.len() { - sum_cap += cap_ranges[idx][local_i]; - sum_investor_cap += investor_cap_ranges[idx][local_i]; - } - - self.cap_raw.truncate_push(height, sum_cap)?; - self.investor_cap_raw - .truncate_push(height, sum_investor_cap)?; - - let investor_price = if sum_cap.inner() == 0 { - Cents::ZERO - } else { - Cents::new((sum_investor_cap / sum_cap.inner()) as u64) - }; - self.investor_price - .cents - .height - .truncate_push(height, investor_price)?; - } - - { - let _lock = exit.lock(); - self.investor_price.cents.height.write()?; - } - - // Source-only: peak_regret - self.peak_regret.height.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.peak_regret.height) - .collect::>(), - exit, - )?; + sum_others!(self, starting_indexes, others, exit; value_created.height); + sum_others!(self, starting_indexes, others, exit; value_destroyed.height); + sum_others!(self, starting_indexes, others, exit; sent_in_profit.base.sats.height); + sum_others!(self, starting_indexes, others, exit; sent_in_loss.base.sats.height); Ok(()) } @@ -211,10 +193,31 @@ impl RealizedFull { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.complete.compute_rest_part1(starting_indexes, exit)?; + self.minimal.compute_rest_part1(starting_indexes, exit)?; - self.peak_regret - .compute_rest(starting_indexes.height, exit)?; + self.net_realized_pnl + .compute(starting_indexes.height, exit, |vec| { + vec.compute_transform2( + starting_indexes.height, + &self.minimal.realized_profit.height, + &self.minimal.realized_loss.height, + |(i, profit, loss, ..)| { + ( + i, + CentsSigned::new(profit.inner() as i64 - loss.inner() as i64), + ) + }, + exit, + )?; + Ok(()) + })?; + + self.gross_pnl.cents.height.compute_add( + starting_indexes.height, + &self.minimal.realized_profit.height, + &self.minimal.realized_loss.height, + exit, + )?; Ok(()) } @@ -225,91 +228,121 @@ impl RealizedFull { prices: &prices::Vecs, starting_indexes: &Indexes, height_to_supply: &impl ReadableVec, - height_to_market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - // Compute all Complete-tier fields - self.complete.compute_rest_part2( - blocks, - prices, - starting_indexes, - height_to_supply, - height_to_market_cap, - exit, - )?; + self.minimal + .compute_rest_part2(prices, starting_indexes, height_to_supply, exit)?; - // Extended-only: investor_price ratio and price bands - self.investor_price_ratio.compute_ratio( - starting_indexes, - &prices.price.cents.height, - &self.investor_price.cents.height, - exit, - )?; - - self.lower_price_band.cents.height.compute_transform2( + self.realized_cap_change_1m.height.compute_rolling_change( starting_indexes.height, - &self.complete.realized_price.cents.height, - &self.investor_price.cents.height, - |(i, rp, ip, ..)| { - let rp = rp.as_u128(); - let ip = ip.as_u128(); - if ip == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(rp * rp / ip)) - } - }, + &blocks.count.height_1m_ago, + &self.minimal.realized_cap_cents.height, exit, )?; - self.upper_price_band.cents.height.compute_transform2( + self.realized_profit_ema_1w.height.compute_rolling_ema( starting_indexes.height, - &self.investor_price.cents.height, - &self.complete.realized_price.cents.height, - |(i, ip, rp, ..)| { - let ip = ip.as_u128(); - let rp = rp.as_u128(); - if rp == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(ip * ip / rp)) - } - }, + &blocks.count.height_1w_ago, + &self.minimal.realized_profit.height, + exit, + )?; + self.realized_loss_ema_1w.height.compute_rolling_ema( + starting_indexes.height, + &blocks.count.height_1w_ago, + &self.minimal.realized_loss.height, + exit, + )?; + self.net_realized_pnl_ema_1w.height.compute_rolling_ema( + starting_indexes.height, + &blocks.count.height_1w_ago, + &self.net_realized_pnl.height, exit, )?; - // Extended-only: sell-side risk ratios - for (ssrr, rv) in self - .sell_side_risk_ratio + self.realized_profit_rel_to_realized_cap + .compute_binary::( + starting_indexes.height, + &self.minimal.realized_profit.height, + &self.minimal.realized_cap_cents.height, + exit, + )?; + self.realized_loss_rel_to_realized_cap + .compute_binary::( + starting_indexes.height, + &self.minimal.realized_loss.height, + &self.minimal.realized_cap_cents.height, + exit, + )?; + self.net_realized_pnl_rel_to_realized_cap + .compute_binary::( + starting_indexes.height, + &self.net_realized_pnl.height, + &self.minimal.realized_cap_cents.height, + exit, + )?; + + // SOPR: rolling sums of stateful value_created/destroyed, then ratio, then EMAs + let window_starts = blocks.count.window_starts(); + self.value_created_sum.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.value_created.height, + exit, + )?; + self.value_destroyed_sum.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.value_destroyed.height, + exit, + )?; + + for ((sopr, vc), vd) in self + .sopr .as_mut_array() .into_iter() - .zip(self.complete.gross_pnl_sum.as_array()) + .zip(self.value_created_sum.as_array()) + .zip(self.value_destroyed_sum.as_array()) { - ssrr.compute_binary::( + sopr.compute_binary::( starting_indexes.height, - &rv.height, - &self.complete.realized_cap_cents.height, + &vc.height, + &vd.height, exit, )?; } - // Extended-only: sell side risk EMAs - self.sell_side_risk_ratio_24h_ema.compute_from_24h( + self.sopr_24h_ema.compute_from_24h( starting_indexes.height, &blocks.count.height_1w_ago, &blocks.count.height_1m_ago, - &self.sell_side_risk_ratio._24h.bps.height, + &self.sopr._24h.height, exit, )?; - // Source-only: peak_regret relative to realized cap - self.peak_regret_rel_to_realized_cap - .compute_binary::( - starting_indexes.height, - &self.peak_regret.height, - &self.complete.realized_cap_cents.height, - exit, - )?; + // Realized price ratio percentiles + self.realized_price_ratio_percentiles.compute( + blocks, + starting_indexes, + exit, + &self.minimal.realized_price_ratio.ratio.height, + &self.minimal.realized_price.cents.height, + )?; + + // Sent in profit/loss EMAs + self.sent_in_profit_ema.compute( + starting_indexes.height, + &blocks.count.height_2w_ago, + &self.sent_in_profit.base.sats.height, + &self.sent_in_profit.base.cents.height, + exit, + )?; + self.sent_in_loss_ema.compute( + starting_indexes.height, + &blocks.count.height_2w_ago, + &self.sent_in_loss.base.sats.height, + &self.sent_in_loss.base.cents.height, + exit, + )?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/realized/complete.rs b/crates/brk_computer/src/distribution/metrics/realized/complete.rs deleted file mode 100644 index c4b8eceeb..000000000 --- a/crates/brk_computer/src/distribution/metrics/realized/complete.rs +++ /dev/null @@ -1,245 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{ - BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Dollars, Height, Indexes, Version, -}; -use derive_more::{Deref, DerefMut}; -use vecdb::{ - AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec, -}; - -use crate::{ - blocks, - distribution::state::RealizedState, - internal::{ - CentsUnsignedToDollars, ComputedFromHeight, LazyFromHeight, PercentFromHeight, - RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RollingEmas2w, RollingWindows, - ValueFromHeightCumulative, - }, - prices, -}; - -use crate::distribution::metrics::ImportConfig; - -use super::RealizedCore; - -#[derive(Deref, DerefMut, Traversable)] -pub struct RealizedComplete { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub core: RealizedCore, - - pub profit_value_created: ComputedFromHeight, - pub profit_value_destroyed: ComputedFromHeight, - pub loss_value_created: ComputedFromHeight, - pub loss_value_destroyed: ComputedFromHeight, - - pub capitulation_flow: LazyFromHeight, - pub profit_flow: LazyFromHeight, - - pub gross_pnl_sum: RollingWindows, - - pub net_pnl_change_1m: ComputedFromHeight, - pub net_pnl_change_1m_rel_to_realized_cap: PercentFromHeight, - pub net_pnl_change_1m_rel_to_market_cap: PercentFromHeight, - - pub sent_in_profit: ValueFromHeightCumulative, - pub sent_in_profit_ema: RollingEmas2w, - pub sent_in_loss: ValueFromHeightCumulative, - pub sent_in_loss_ema: RollingEmas2w, -} - -impl RealizedComplete { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v0 = Version::ZERO; - - let core = RealizedCore::forced_import(cfg)?; - - let profit_value_created = cfg.import_computed("profit_value_created", v0)?; - let profit_value_destroyed = cfg.import_computed("profit_value_destroyed", v0)?; - let loss_value_created = cfg.import_computed("loss_value_created", v0)?; - let loss_value_destroyed = cfg.import_computed("loss_value_destroyed", v0)?; - - let capitulation_flow = LazyFromHeight::from_computed::( - &cfg.name("capitulation_flow"), - cfg.version, - loss_value_destroyed.height.read_only_boxed_clone(), - &loss_value_destroyed, - ); - let profit_flow = LazyFromHeight::from_computed::( - &cfg.name("profit_flow"), - cfg.version, - profit_value_destroyed.height.read_only_boxed_clone(), - &profit_value_destroyed, - ); - - let gross_pnl_sum = cfg.import_rolling("gross_pnl_sum", Version::ONE)?; - - Ok(Self { - core, - profit_value_created, - profit_value_destroyed, - loss_value_created, - loss_value_destroyed, - capitulation_flow, - profit_flow, - gross_pnl_sum, - net_pnl_change_1m: cfg.import_computed("net_pnl_change_1m", Version::new(3))?, - net_pnl_change_1m_rel_to_realized_cap: cfg - .import_percent_bps32("net_pnl_change_1m_rel_to_realized_cap", Version::new(4))?, - net_pnl_change_1m_rel_to_market_cap: cfg - .import_percent_bps32("net_pnl_change_1m_rel_to_market_cap", Version::new(4))?, - sent_in_profit: cfg.import_value_cumulative("sent_in_profit", v0)?, - sent_in_profit_ema: cfg.import_emas_2w("sent_in_profit", v0)?, - sent_in_loss: cfg.import_value_cumulative("sent_in_loss", v0)?, - sent_in_loss_ema: cfg.import_emas_2w("sent_in_loss", v0)?, - }) - } - - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.core - .min_stateful_height_len() - .min(self.profit_value_created.height.len()) - .min(self.profit_value_destroyed.height.len()) - .min(self.loss_value_created.height.len()) - .min(self.loss_value_destroyed.height.len()) - .min(self.sent_in_profit.base.sats.height.len()) - .min(self.sent_in_loss.base.sats.height.len()) - } - - pub(crate) fn truncate_push(&mut self, height: Height, state: &RealizedState) -> Result<()> { - self.core.truncate_push(height, state)?; - self.profit_value_created - .height - .truncate_push(height, state.profit_value_created())?; - self.profit_value_destroyed - .height - .truncate_push(height, state.profit_value_destroyed())?; - self.loss_value_created - .height - .truncate_push(height, state.loss_value_created())?; - self.loss_value_destroyed - .height - .truncate_push(height, state.loss_value_destroyed())?; - self.sent_in_profit - .base - .sats - .height - .truncate_push(height, state.sent_in_profit())?; - self.sent_in_loss - .base - .sats - .height - .truncate_push(height, state.sent_in_loss())?; - - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - let mut vecs = self.core.collect_vecs_mut(); - vecs.push(&mut self.profit_value_created.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.profit_value_destroyed.height); - vecs.push(&mut self.loss_value_created.height); - vecs.push(&mut self.loss_value_destroyed.height); - vecs.push(&mut self.sent_in_profit.base.sats.height); - vecs.push(&mut self.sent_in_loss.base.sats.height); - vecs - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - let core_refs: Vec<&RealizedCore> = others.iter().map(|o| &o.core).collect(); - self.core - .compute_from_stateful(starting_indexes, &core_refs, exit)?; - - sum_others!(self, starting_indexes, others, exit; profit_value_created.height); - sum_others!(self, starting_indexes, others, exit; profit_value_destroyed.height); - sum_others!(self, starting_indexes, others, exit; loss_value_created.height); - sum_others!(self, starting_indexes, others, exit; loss_value_destroyed.height); - sum_others!(self, starting_indexes, others, exit; sent_in_profit.base.sats.height); - sum_others!(self, starting_indexes, others, exit; sent_in_loss.base.sats.height); - - Ok(()) - } - - pub(crate) fn compute_rest_part1( - &mut self, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.core.compute_rest_part1(starting_indexes, exit)?; - - Ok(()) - } - - pub(crate) fn compute_rest_part2( - &mut self, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - height_to_supply: &impl ReadableVec, - height_to_market_cap: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self.core.compute_rest_part2( - blocks, - prices, - starting_indexes, - height_to_supply, - exit, - )?; - - let window_starts = blocks.count.window_starts(); - self.gross_pnl_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.gross_pnl.cents.height, - exit, - )?; - - self.sent_in_profit_ema.compute( - starting_indexes.height, - &blocks.count.height_2w_ago, - &self.sent_in_profit.base.sats.height, - &self.sent_in_profit.base.cents.height, - exit, - )?; - self.sent_in_loss_ema.compute( - starting_indexes.height, - &blocks.count.height_2w_ago, - &self.sent_in_loss.base.sats.height, - &self.sent_in_loss.base.cents.height, - exit, - )?; - - self.net_pnl_change_1m.height.compute_rolling_change( - starting_indexes.height, - &blocks.count.height_1m_ago, - &self.core.net_realized_pnl.cumulative.height, - exit, - )?; - - self.net_pnl_change_1m_rel_to_realized_cap - .compute_binary::( - starting_indexes.height, - &self.net_pnl_change_1m.height, - &self.core.realized_cap_cents.height, - exit, - )?; - - self.net_pnl_change_1m_rel_to_market_cap - .compute_binary::( - starting_indexes.height, - &self.net_pnl_change_1m.height, - height_to_market_cap, - exit, - )?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/realized/core.rs b/crates/brk_computer/src/distribution/metrics/realized/core.rs deleted file mode 100644 index 2ee00f809..000000000 --- a/crates/brk_computer/src/distribution/metrics/realized/core.rs +++ /dev/null @@ -1,347 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{ - BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Dollars, Height, Indexes, - Sats, StoredF32, StoredF64, Version, -}; -use vecdb::{ - AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec, -}; - -use crate::{ - blocks, - distribution::state::RealizedOps, - internal::{ - CentsUnsignedToDollars, ComputedFromHeight, ComputedFromHeightCumulative, - ComputedFromHeightRatio, FiatFromHeight, Identity, LazyFromHeight, - NegCentsUnsignedToDollars, PercentFromHeight, Price, RatioCents64, RatioCentsBp32, - RatioCentsSignedCentsBps32, RollingEmas1w1m, RollingWindows, - }, - prices, -}; - -use crate::distribution::metrics::ImportConfig; - -#[derive(Traversable)] -pub struct RealizedCore { - pub realized_cap_cents: ComputedFromHeight, - pub realized_profit: ComputedFromHeightCumulative, - pub realized_loss: ComputedFromHeightCumulative, - - pub realized_cap: LazyFromHeight, - pub realized_price: Price>, - pub realized_price_ratio: ComputedFromHeightRatio, - pub realized_cap_change_1m: ComputedFromHeight, - - pub mvrv: LazyFromHeight, - - pub neg_realized_loss: LazyFromHeight, - pub net_realized_pnl: ComputedFromHeightCumulative, - pub net_realized_pnl_ema_1w: ComputedFromHeight, - pub gross_pnl: FiatFromHeight, - - pub realized_profit_ema_1w: ComputedFromHeight, - pub realized_loss_ema_1w: ComputedFromHeight, - - pub realized_profit_rel_to_realized_cap: PercentFromHeight, - pub realized_loss_rel_to_realized_cap: PercentFromHeight, - pub net_realized_pnl_rel_to_realized_cap: PercentFromHeight, - - pub value_created: ComputedFromHeight, - pub value_destroyed: ComputedFromHeight, - pub value_created_sum: RollingWindows, - pub value_destroyed_sum: RollingWindows, - pub sopr: RollingWindows, - pub sopr_24h_ema: RollingEmas1w1m, -} - -impl RealizedCore { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v0 = Version::ZERO; - let v1 = Version::ONE; - - let realized_cap_cents = cfg.import_computed("realized_cap_cents", v0)?; - let realized_cap = LazyFromHeight::from_computed::( - &cfg.name("realized_cap"), - cfg.version, - realized_cap_cents.height.read_only_boxed_clone(), - &realized_cap_cents, - ); - - let realized_profit = cfg.import_cumulative("realized_profit", v0)?; - let realized_profit_ema_1w = cfg.import_computed("realized_profit_ema_1w", v0)?; - let realized_loss = cfg.import_cumulative("realized_loss", v0)?; - let realized_loss_ema_1w = cfg.import_computed("realized_loss_ema_1w", v0)?; - - let neg_realized_loss = LazyFromHeight::from_height_source::( - &cfg.name("neg_realized_loss"), - cfg.version + Version::ONE, - realized_loss.height.read_only_boxed_clone(), - cfg.indexes, - ); - - let net_realized_pnl = cfg.import_cumulative("net_realized_pnl", v0)?; - let net_realized_pnl_ema_1w = cfg.import_computed("net_realized_pnl_ema_1w", v0)?; - let gross_pnl = cfg.import_fiat("realized_gross_pnl", v0)?; - - let realized_profit_rel_to_realized_cap = - cfg.import_percent_bp32("realized_profit_rel_to_realized_cap", Version::new(2))?; - let realized_loss_rel_to_realized_cap = - cfg.import_percent_bp32("realized_loss_rel_to_realized_cap", Version::new(2))?; - let net_realized_pnl_rel_to_realized_cap = - cfg.import_percent_bps32("net_realized_pnl_rel_to_realized_cap", Version::new(2))?; - - let realized_price = cfg.import_price("realized_price", v1)?; - - let realized_price_ratio = cfg.import_ratio("realized_price", v1)?; - let mvrv = LazyFromHeight::from_lazy::, BasisPoints32>( - &cfg.name("mvrv"), - cfg.version, - &realized_price_ratio.ratio, - ); - - let value_created = cfg.import_computed("value_created", v0)?; - let value_destroyed = cfg.import_computed("value_destroyed", v0)?; - let value_created_sum = cfg.import_rolling("value_created", v1)?; - let value_destroyed_sum = cfg.import_rolling("value_destroyed", v1)?; - let sopr = cfg.import_rolling("sopr", v1)?; - let sopr_24h_ema = cfg.import_emas_1w_1m("sopr_24h", v1)?; - - Ok(Self { - realized_cap_cents, - realized_cap, - realized_price, - realized_price_ratio, - realized_cap_change_1m: cfg.import_computed("realized_cap_change_1m", v0)?, - mvrv, - realized_profit, - realized_profit_ema_1w, - realized_loss, - realized_loss_ema_1w, - neg_realized_loss, - net_realized_pnl, - net_realized_pnl_ema_1w, - gross_pnl, - realized_profit_rel_to_realized_cap, - realized_loss_rel_to_realized_cap, - net_realized_pnl_rel_to_realized_cap, - value_created, - value_destroyed, - value_created_sum, - value_destroyed_sum, - sopr, - sopr_24h_ema, - }) - } - - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.realized_cap_cents - .height - .len() - .min(self.realized_profit.height.len()) - .min(self.realized_loss.height.len()) - .min(self.value_created.height.len()) - .min(self.value_destroyed.height.len()) - } - - pub(crate) fn truncate_push(&mut self, height: Height, state: &impl RealizedOps) -> Result<()> { - self.realized_cap_cents - .height - .truncate_push(height, state.cap())?; - self.realized_profit - .height - .truncate_push(height, state.profit())?; - self.realized_loss - .height - .truncate_push(height, state.loss())?; - self.value_created - .height - .truncate_push(height, state.value_created())?; - self.value_destroyed - .height - .truncate_push(height, state.value_destroyed())?; - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![ - &mut self.realized_cap_cents.height as &mut dyn AnyStoredVec, - &mut self.realized_profit.height, - &mut self.realized_loss.height, - &mut self.value_created.height, - &mut self.value_destroyed.height, - ] - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - sum_others!(self, starting_indexes, others, exit; realized_cap_cents.height); - sum_others!(self, starting_indexes, others, exit; realized_profit.height); - sum_others!(self, starting_indexes, others, exit; realized_loss.height); - sum_others!(self, starting_indexes, others, exit; value_created.height); - sum_others!(self, starting_indexes, others, exit; value_destroyed.height); - - Ok(()) - } - - pub(crate) fn compute_rest_part1( - &mut self, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.realized_profit - .compute_rest(starting_indexes.height, exit)?; - self.realized_loss - .compute_rest(starting_indexes.height, exit)?; - - self.net_realized_pnl - .compute(starting_indexes.height, exit, |vec| { - vec.compute_transform2( - starting_indexes.height, - &self.realized_profit.height, - &self.realized_loss.height, - |(i, profit, loss, ..)| { - ( - i, - CentsSigned::new(profit.inner() as i64 - loss.inner() as i64), - ) - }, - exit, - )?; - Ok(()) - })?; - - self.gross_pnl.cents.height.compute_add( - starting_indexes.height, - &self.realized_profit.height, - &self.realized_loss.height, - exit, - )?; - - Ok(()) - } - - pub(crate) fn compute_rest_part2( - &mut self, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - height_to_supply: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self.realized_price.cents.height.compute_transform2( - starting_indexes.height, - &self.realized_cap_cents.height, - height_to_supply, - |(i, cap_cents, supply, ..)| { - let cap = cap_cents.as_u128(); - let supply_sats = Sats::from(supply).as_u128(); - if supply_sats == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(cap * Sats::ONE_BTC_U128 / supply_sats)) - } - }, - exit, - )?; - - self.realized_price_ratio.compute_ratio( - starting_indexes, - &prices.price.cents.height, - &self.realized_price.cents.height, - exit, - )?; - - self.realized_cap_change_1m.height.compute_rolling_change( - starting_indexes.height, - &blocks.count.height_1m_ago, - &self.realized_cap_cents.height, - exit, - )?; - - self.realized_profit_ema_1w.height.compute_rolling_ema( - starting_indexes.height, - &blocks.count.height_1w_ago, - &self.realized_profit.height, - exit, - )?; - self.realized_loss_ema_1w.height.compute_rolling_ema( - starting_indexes.height, - &blocks.count.height_1w_ago, - &self.realized_loss.height, - exit, - )?; - self.net_realized_pnl_ema_1w.height.compute_rolling_ema( - starting_indexes.height, - &blocks.count.height_1w_ago, - &self.net_realized_pnl.height, - exit, - )?; - - self.realized_profit_rel_to_realized_cap - .compute_binary::( - starting_indexes.height, - &self.realized_profit.height, - &self.realized_cap_cents.height, - exit, - )?; - self.realized_loss_rel_to_realized_cap - .compute_binary::( - starting_indexes.height, - &self.realized_loss.height, - &self.realized_cap_cents.height, - exit, - )?; - self.net_realized_pnl_rel_to_realized_cap - .compute_binary::( - starting_indexes.height, - &self.net_realized_pnl.height, - &self.realized_cap_cents.height, - exit, - )?; - - // SOPR: rolling sums of stateful value_created/destroyed, then ratio, then EMAs - let window_starts = blocks.count.window_starts(); - self.value_created_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.value_created.height, - exit, - )?; - self.value_destroyed_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.value_destroyed.height, - exit, - )?; - - for ((sopr, vc), vd) in self - .sopr - .as_mut_array() - .into_iter() - .zip(self.value_created_sum.as_array()) - .zip(self.value_destroyed_sum.as_array()) - { - sopr.compute_binary::( - starting_indexes.height, - &vc.height, - &vd.height, - exit, - )?; - } - - self.sopr_24h_ema.compute_from_24h( - starting_indexes.height, - &blocks.count.height_1w_ago, - &blocks.count.height_1m_ago, - &self.sopr._24h.height, - exit, - )?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/realized/extended.rs b/crates/brk_computer/src/distribution/metrics/realized/extended.rs deleted file mode 100644 index 6ba658eec..000000000 --- a/crates/brk_computer/src/distribution/metrics/realized/extended.rs +++ /dev/null @@ -1,160 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Cents, Dollars, Height, Indexes, StoredF64, Version}; -use vecdb::{Exit, ReadableVec, Rw, StorageMode}; - -use crate::{ - blocks, - internal::{ - ComputedFromHeightRatioPercentiles, ComputedFromHeightRatioStdDevBands, - PercentFromHeight, RatioCents64, RatioDollarsBp32, RollingWindows, - }, - prices, -}; - -use crate::distribution::metrics::ImportConfig; - -use super::RealizedFull; - -#[derive(Traversable)] -pub struct RealizedExtended { - pub realized_cap_rel_to_own_market_cap: PercentFromHeight, - - pub realized_profit_sum: RollingWindows, - pub realized_loss_sum: RollingWindows, - - pub realized_profit_to_loss_ratio: RollingWindows, - - pub realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles, - pub realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands, - pub investor_price_ratio_percentiles: ComputedFromHeightRatioPercentiles, - pub investor_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands, -} - -impl RealizedExtended { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let realized_price_name = cfg.name("realized_price"); - let realized_price_version = cfg.version + Version::ONE; - let investor_price_name = cfg.name("investor_price"); - let investor_price_version = cfg.version; - - Ok(RealizedExtended { - realized_cap_rel_to_own_market_cap: cfg - .import_percent_bp32("realized_cap_rel_to_own_market_cap", Version::ONE)?, - realized_profit_sum: cfg.import_rolling("realized_profit", Version::ONE)?, - realized_loss_sum: cfg.import_rolling("realized_loss", Version::ONE)?, - realized_profit_to_loss_ratio: cfg - .import_rolling("realized_profit_to_loss_ratio", Version::ONE)?, - realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles::forced_import( - cfg.db, - &realized_price_name, - realized_price_version, - cfg.indexes, - )?, - realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands::forced_import( - cfg.db, - &realized_price_name, - realized_price_version, - cfg.indexes, - )?, - investor_price_ratio_percentiles: ComputedFromHeightRatioPercentiles::forced_import( - cfg.db, - &investor_price_name, - investor_price_version, - cfg.indexes, - )?, - investor_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands::forced_import( - cfg.db, - &investor_price_name, - investor_price_version, - cfg.indexes, - )?, - }) - } - - pub(crate) fn compute_rest_part2( - &mut self, - base: &RealizedFull, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - height_to_market_cap: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - // Realized profit/loss rolling sums - let window_starts = blocks.count.window_starts(); - self.realized_profit_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &base.realized_profit.height, - exit, - )?; - self.realized_loss_sum.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &base.realized_loss.height, - exit, - )?; - - // Realized cap relative to own market cap - self.realized_cap_rel_to_own_market_cap - .compute_binary::( - starting_indexes.height, - &base.realized_cap.height, - height_to_market_cap, - exit, - )?; - - // Realized profit to loss ratios - for ((ratio, profit), loss) in self - .realized_profit_to_loss_ratio - .as_mut_array() - .into_iter() - .zip(self.realized_profit_sum.as_array()) - .zip(self.realized_loss_sum.as_array()) - { - ratio.compute_binary::( - starting_indexes.height, - &profit.height, - &loss.height, - exit, - )?; - } - - // Realized price: percentiles + stddev bands - let realized_price = &base.realized_price.cents.height; - self.realized_price_ratio_percentiles.compute( - blocks, - starting_indexes, - exit, - &base.realized_price_ratio.ratio.height, - realized_price, - )?; - self.realized_price_ratio_std_dev.compute( - blocks, - starting_indexes, - exit, - &base.realized_price_ratio.ratio.height, - realized_price, - )?; - - // Investor price: percentiles + stddev bands - let investor_price = &base.investor_price.cents.height; - self.investor_price_ratio_percentiles.compute( - blocks, - starting_indexes, - exit, - &base.investor_price_ratio.ratio.height, - investor_price, - )?; - self.investor_price_ratio_std_dev.compute( - blocks, - starting_indexes, - exit, - &base.investor_price_ratio.ratio.height, - investor_price, - )?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/realized/basic.rs b/crates/brk_computer/src/distribution/metrics/realized/full.rs similarity index 66% rename from crates/brk_computer/src/distribution/metrics/realized/basic.rs rename to crates/brk_computer/src/distribution/metrics/realized/full.rs index f21040910..5cfe679a8 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSats, CentsSigned, CentsSquaredSats, - Dollars, Height, Indexes, Version, + Dollars, Height, Indexes, StoredF64, Version, }; use derive_more::{Deref, DerefMut}; use vecdb::{ @@ -15,26 +15,26 @@ use crate::{ distribution::state::RealizedState, internal::{ CentsUnsignedToDollars, ComputedFromHeight, ComputedFromHeightCumulative, - ComputedFromHeightRatio, ComputedFromHeightRatioPercentiles, LazyFromHeight, - PercentFromHeight, PercentRollingEmas1w1m, PercentRollingWindows, Price, RatioCentsBp32, - RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RollingEmas2w, RollingWindows, - ValueFromHeightCumulative, + ComputedFromHeightRatio, ComputedFromHeightRatioPercentiles, + ComputedFromHeightRatioStdDevBands, LazyFromHeight, PercentFromHeight, + PercentRollingEmas1w1m, PercentRollingWindows, Price, RatioCents64, RatioCentsBp32, + RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RatioDollarsBp32, + RollingWindows, }, prices, }; use crate::distribution::metrics::ImportConfig; -use super::RealizedCore; +use super::RealizedBase; #[derive(Deref, DerefMut, Traversable)] -pub struct RealizedBasic { +pub struct RealizedFull { #[deref] #[deref_mut] #[traversable(flatten)] - pub core: RealizedCore, + pub core: RealizedBase, - // --- Stateful fields --- pub profit_value_created: ComputedFromHeight, pub profit_value_destroyed: ComputedFromHeight, pub loss_value_created: ComputedFromHeight, @@ -49,12 +49,6 @@ pub struct RealizedBasic { pub net_pnl_change_1m_rel_to_realized_cap: PercentFromHeight, pub net_pnl_change_1m_rel_to_market_cap: PercentFromHeight, - pub sent_in_profit: ValueFromHeightCumulative, - pub sent_in_profit_ema: RollingEmas2w, - pub sent_in_loss: ValueFromHeightCumulative, - pub sent_in_loss_ema: RollingEmas2w, - - // --- Investor price & price bands --- pub investor_price: Price>, pub investor_price_ratio: ComputedFromHeightRatio, @@ -67,22 +61,27 @@ pub struct RealizedBasic { pub sell_side_risk_ratio: PercentRollingWindows, pub sell_side_risk_ratio_24h_ema: PercentRollingEmas1w1m, - // --- Peak regret --- pub peak_regret: ComputedFromHeightCumulative, pub peak_regret_rel_to_realized_cap: PercentFromHeight, - // --- Realized price ratio percentiles --- - pub realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles, + pub realized_cap_rel_to_own_market_cap: PercentFromHeight, + + pub realized_profit_sum: RollingWindows, + pub realized_loss_sum: RollingWindows, + pub realized_profit_to_loss_ratio: RollingWindows, + + pub realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands, + pub investor_price_ratio_percentiles: ComputedFromHeightRatioPercentiles, + pub investor_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands, } -impl RealizedBasic { +impl RealizedFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v0 = Version::ZERO; let v1 = Version::ONE; - let core = RealizedCore::forced_import(cfg)?; + let core = RealizedBase::forced_import(cfg)?; - // Stateful fields let profit_value_created = cfg.import_computed("profit_value_created", v0)?; let profit_value_destroyed = cfg.import_computed("profit_value_destroyed", v0)?; let loss_value_created = cfg.import_computed("loss_value_created", v0)?; @@ -101,9 +100,8 @@ impl RealizedBasic { &profit_value_destroyed, ); - let gross_pnl_sum = cfg.import_rolling("gross_pnl_sum", v1)?; + let gross_pnl_sum = cfg.import_rolling("gross_pnl_sum", Version::ONE)?; - // Investor price & price bands let investor_price = cfg.import_price("investor_price", v0)?; let investor_price_ratio = cfg.import_ratio("investor_price", v0)?; let lower_price_band = cfg.import_price("lower_price_band", v0)?; @@ -117,19 +115,14 @@ impl RealizedBasic { let sell_side_risk_ratio_24h_ema = cfg.import_percent_emas_1w_1m_bp32("sell_side_risk_ratio_24h", Version::new(2))?; - // Peak regret let peak_regret = cfg.import_cumulative("realized_peak_regret", Version::new(2))?; let peak_regret_rel_to_realized_cap = cfg.import_percent_bp32("realized_peak_regret_rel_to_realized_cap", Version::new(2))?; - // Realized price ratio percentiles - let realized_price_ratio_percentiles = - ComputedFromHeightRatioPercentiles::forced_import( - cfg.db, - &cfg.name("realized_price"), - cfg.version + v1, - cfg.indexes, - )?; + let realized_price_name = cfg.name("realized_price"); + let realized_price_version = cfg.version + v1; + let investor_price_name = cfg.name("investor_price"); + let investor_price_version = cfg.version; Ok(Self { core, @@ -145,10 +138,6 @@ impl RealizedBasic { .import_percent_bps32("net_pnl_change_1m_rel_to_realized_cap", Version::new(4))?, net_pnl_change_1m_rel_to_market_cap: cfg .import_percent_bps32("net_pnl_change_1m_rel_to_market_cap", Version::new(4))?, - sent_in_profit: cfg.import_value_cumulative("sent_in_profit", v0)?, - sent_in_profit_ema: cfg.import_emas_2w("sent_in_profit", v0)?, - sent_in_loss: cfg.import_value_cumulative("sent_in_loss", v0)?, - sent_in_loss_ema: cfg.import_emas_2w("sent_in_loss", v0)?, investor_price, investor_price_ratio, lower_price_band, @@ -159,7 +148,30 @@ impl RealizedBasic { sell_side_risk_ratio_24h_ema, peak_regret, peak_regret_rel_to_realized_cap, - realized_price_ratio_percentiles, + realized_cap_rel_to_own_market_cap: cfg + .import_percent_bp32("realized_cap_rel_to_own_market_cap", v1)?, + realized_profit_sum: cfg.import_rolling("realized_profit", v1)?, + realized_loss_sum: cfg.import_rolling("realized_loss", v1)?, + realized_profit_to_loss_ratio: cfg + .import_rolling("realized_profit_to_loss_ratio", v1)?, + realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands::forced_import( + cfg.db, + &realized_price_name, + realized_price_version, + cfg.indexes, + )?, + investor_price_ratio_percentiles: ComputedFromHeightRatioPercentiles::forced_import( + cfg.db, + &investor_price_name, + investor_price_version, + cfg.indexes, + )?, + investor_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands::forced_import( + cfg.db, + &investor_price_name, + investor_price_version, + cfg.indexes, + )?, }) } @@ -170,8 +182,6 @@ impl RealizedBasic { .min(self.profit_value_destroyed.height.len()) .min(self.loss_value_created.height.len()) .min(self.loss_value_destroyed.height.len()) - .min(self.sent_in_profit.base.sats.height.len()) - .min(self.sent_in_loss.base.sats.height.len()) .min(self.investor_price.cents.height.len()) .min(self.cap_raw.len()) .min(self.investor_cap_raw.len()) @@ -192,16 +202,6 @@ impl RealizedBasic { self.loss_value_destroyed .height .truncate_push(height, state.loss_value_destroyed())?; - self.sent_in_profit - .base - .sats - .height - .truncate_push(height, state.sent_in_profit())?; - self.sent_in_loss - .base - .sats - .height - .truncate_push(height, state.sent_in_loss())?; self.investor_price .cents .height @@ -222,8 +222,6 @@ impl RealizedBasic { vecs.push(&mut self.profit_value_destroyed.height); vecs.push(&mut self.loss_value_created.height); vecs.push(&mut self.loss_value_destroyed.height); - vecs.push(&mut self.sent_in_profit.base.sats.height); - vecs.push(&mut self.sent_in_loss.base.sats.height); vecs.push(&mut self.investor_price.cents.height); vecs.push(&mut self.cap_raw as &mut dyn AnyStoredVec); vecs.push(&mut self.investor_cap_raw as &mut dyn AnyStoredVec); @@ -231,92 +229,16 @@ impl RealizedBasic { vecs } + /// Aggregate Core-level fields from source cohorts. + /// investor_price, cap_raw, investor_cap_raw come from the stateful scan, not aggregated. pub(crate) fn compute_from_stateful( &mut self, starting_indexes: &Indexes, - others: &[&Self], + others: &[&RealizedBase], exit: &Exit, ) -> Result<()> { - // Core aggregation - let core_refs: Vec<&RealizedCore> = others.iter().map(|o| &o.core).collect(); self.core - .compute_from_stateful(starting_indexes, &core_refs, exit)?; - - // Stateful field aggregation - sum_others!(self, starting_indexes, others, exit; profit_value_created.height); - sum_others!(self, starting_indexes, others, exit; profit_value_destroyed.height); - sum_others!(self, starting_indexes, others, exit; loss_value_created.height); - sum_others!(self, starting_indexes, others, exit; loss_value_destroyed.height); - sum_others!(self, starting_indexes, others, exit; sent_in_profit.base.sats.height); - sum_others!(self, starting_indexes, others, exit; sent_in_loss.base.sats.height); - - // Investor price aggregation from raw values - let investor_price_dep_version = others - .iter() - .map(|o| o.investor_price.cents.height.version()) - .fold(vecdb::Version::ZERO, |acc, v| acc + v); - self.investor_price - .cents - .height - .validate_computed_version_or_reset(investor_price_dep_version)?; - - let start = self - .cap_raw - .len() - .min(self.investor_cap_raw.len()) - .min(self.investor_price.cents.height.len()); - let end = others.iter().map(|o| o.cap_raw.len()).min().unwrap_or(0); - - let cap_ranges: Vec> = others - .iter() - .map(|o| o.cap_raw.collect_range_at(start, end)) - .collect(); - let investor_cap_ranges: Vec> = others - .iter() - .map(|o| o.investor_cap_raw.collect_range_at(start, end)) - .collect(); - - for i in start..end { - let height = Height::from(i); - let local_i = i - start; - - let mut sum_cap = CentsSats::ZERO; - let mut sum_investor_cap = CentsSquaredSats::ZERO; - - for idx in 0..others.len() { - sum_cap += cap_ranges[idx][local_i]; - sum_investor_cap += investor_cap_ranges[idx][local_i]; - } - - self.cap_raw.truncate_push(height, sum_cap)?; - self.investor_cap_raw - .truncate_push(height, sum_investor_cap)?; - - let investor_price = if sum_cap.inner() == 0 { - Cents::ZERO - } else { - Cents::new((sum_investor_cap / sum_cap.inner()) as u64) - }; - self.investor_price - .cents - .height - .truncate_push(height, investor_price)?; - } - - { - let _lock = exit.lock(); - self.investor_price.cents.height.write()?; - } - - // Peak regret aggregation - self.peak_regret.height.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.peak_regret.height) - .collect::>(), - exit, - )?; + .compute_from_stateful(starting_indexes, others, exit)?; Ok(()) } @@ -329,7 +251,6 @@ impl RealizedBasic { self.core.compute_rest_part1(starting_indexes, exit)?; self.peak_regret .compute_rest(starting_indexes.height, exit)?; - Ok(()) } @@ -342,7 +263,6 @@ impl RealizedBasic { height_to_market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - // Core computation self.core.compute_rest_part2( blocks, prices, @@ -351,7 +271,7 @@ impl RealizedBasic { exit, )?; - // Gross PnL rolling sums + // Gross PnL rolling sum let window_starts = blocks.count.window_starts(); self.gross_pnl_sum.compute_rolling_sum( starting_indexes.height, @@ -360,22 +280,6 @@ impl RealizedBasic { exit, )?; - // Sent in profit/loss EMAs - self.sent_in_profit_ema.compute( - starting_indexes.height, - &blocks.count.height_2w_ago, - &self.sent_in_profit.base.sats.height, - &self.sent_in_profit.base.cents.height, - exit, - )?; - self.sent_in_loss_ema.compute( - starting_indexes.height, - &blocks.count.height_2w_ago, - &self.sent_in_loss.base.sats.height, - &self.sent_in_loss.base.cents.height, - exit, - )?; - // Net PnL change 1m self.net_pnl_change_1m.height.compute_rolling_change( starting_indexes.height, @@ -383,15 +287,13 @@ impl RealizedBasic { &self.core.net_realized_pnl.cumulative.height, exit, )?; - self.net_pnl_change_1m_rel_to_realized_cap .compute_binary::( starting_indexes.height, &self.net_pnl_change_1m.height, - &self.core.realized_cap_cents.height, + &self.core.minimal.realized_cap_cents.height, exit, )?; - self.net_pnl_change_1m_rel_to_market_cap .compute_binary::( starting_indexes.height, @@ -400,6 +302,15 @@ impl RealizedBasic { exit, )?; + // Peak regret + self.peak_regret_rel_to_realized_cap + .compute_binary::( + starting_indexes.height, + &self.peak_regret.height, + &self.core.minimal.realized_cap_cents.height, + exit, + )?; + // Investor price ratio and price bands self.investor_price_ratio.compute_ratio( starting_indexes, @@ -408,9 +319,10 @@ impl RealizedBasic { exit, )?; + // Use explicit field paths for split borrows self.lower_price_band.cents.height.compute_transform2( starting_indexes.height, - &self.core.realized_price.cents.height, + &self.core.minimal.realized_price.cents.height, &self.investor_price.cents.height, |(i, rp, ip, ..)| { let rp = rp.as_u128(); @@ -427,7 +339,7 @@ impl RealizedBasic { self.upper_price_band.cents.height.compute_transform2( starting_indexes.height, &self.investor_price.cents.height, - &self.core.realized_price.cents.height, + &self.core.minimal.realized_price.cents.height, |(i, ip, rp, ..)| { let ip = ip.as_u128(); let rp = rp.as_u128(); @@ -450,7 +362,7 @@ impl RealizedBasic { ssrr.compute_binary::( starting_indexes.height, &rv.height, - &self.core.realized_cap_cents.height, + &self.core.minimal.realized_cap_cents.height, exit, )?; } @@ -463,22 +375,70 @@ impl RealizedBasic { exit, )?; - // Peak regret relative to realized cap - self.peak_regret_rel_to_realized_cap - .compute_binary::( + // Extended: realized profit/loss rolling sums + let window_starts = blocks.count.window_starts(); + self.realized_profit_sum.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.core.minimal.realized_profit.height, + exit, + )?; + self.realized_loss_sum.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.core.minimal.realized_loss.height, + exit, + )?; + + // Realized cap relative to own market cap + self.realized_cap_rel_to_own_market_cap + .compute_binary::( starting_indexes.height, - &self.peak_regret.height, - &self.core.realized_cap_cents.height, + &self.core.minimal.realized_cap.height, + height_to_market_cap, exit, )?; - // Realized price ratio percentiles - self.realized_price_ratio_percentiles.compute( + // Realized profit to loss ratios + for ((ratio, profit), loss) in self + .realized_profit_to_loss_ratio + .as_mut_array() + .into_iter() + .zip(self.realized_profit_sum.as_array()) + .zip(self.realized_loss_sum.as_array()) + { + ratio.compute_binary::( + starting_indexes.height, + &profit.height, + &loss.height, + exit, + )?; + } + + // Realized price stddev bands + self.realized_price_ratio_std_dev.compute( blocks, starting_indexes, exit, - &self.core.realized_price_ratio.ratio.height, - &self.core.realized_price.cents.height, + &self.core.minimal.realized_price_ratio.ratio.height, + &self.core.minimal.realized_price.cents.height, + )?; + + // Investor price: percentiles + stddev bands + let investor_price = &self.investor_price.cents.height; + self.investor_price_ratio_percentiles.compute( + blocks, + starting_indexes, + exit, + &self.investor_price_ratio.ratio.height, + investor_price, + )?; + self.investor_price_ratio_std_dev.compute( + blocks, + starting_indexes, + exit, + &self.investor_price_ratio.ratio.height, + investor_price, )?; Ok(()) diff --git a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs new file mode 100644 index 000000000..2f2fb8418 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs @@ -0,0 +1,151 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{ + BasisPoints32, Bitcoin, Cents, Dollars, Height, Indexes, Sats, StoredF32, Version, +}; +use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec}; + +use crate::{ + distribution::state::RealizedOps, + internal::{ + CentsUnsignedToDollars, ComputedFromHeight, ComputedFromHeightCumulative, + ComputedFromHeightRatio, Identity, LazyFromHeight, Price, + }, + prices, +}; + +use crate::distribution::metrics::ImportConfig; + +#[derive(Traversable)] +pub struct RealizedMinimal { + pub realized_cap_cents: ComputedFromHeight, + pub realized_profit: ComputedFromHeightCumulative, + pub realized_loss: ComputedFromHeightCumulative, + pub realized_cap: LazyFromHeight, + pub realized_price: Price>, + pub realized_price_ratio: ComputedFromHeightRatio, + pub mvrv: LazyFromHeight, +} + +impl RealizedMinimal { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let realized_cap_cents = cfg.import_computed("realized_cap_cents", Version::ZERO)?; + let realized_cap = LazyFromHeight::from_computed::( + &cfg.name("realized_cap"), + cfg.version, + realized_cap_cents.height.read_only_boxed_clone(), + &realized_cap_cents, + ); + + let realized_profit = cfg.import_cumulative("realized_profit", Version::ZERO)?; + let realized_loss = cfg.import_cumulative("realized_loss", Version::ZERO)?; + + let realized_price = cfg.import_price("realized_price", Version::ONE)?; + let realized_price_ratio = cfg.import_ratio("realized_price", Version::ONE)?; + let mvrv = LazyFromHeight::from_lazy::, BasisPoints32>( + &cfg.name("mvrv"), + cfg.version, + &realized_price_ratio.ratio, + ); + + Ok(Self { + realized_cap_cents, + realized_profit, + realized_loss, + realized_cap, + realized_price, + realized_price_ratio, + mvrv, + }) + } + + pub(crate) fn min_stateful_height_len(&self) -> usize { + self.realized_cap_cents + .height + .len() + .min(self.realized_profit.height.len()) + .min(self.realized_loss.height.len()) + } + + pub(crate) fn truncate_push( + &mut self, + height: Height, + state: &impl RealizedOps, + ) -> Result<()> { + self.realized_cap_cents + .height + .truncate_push(height, state.cap())?; + self.realized_profit + .height + .truncate_push(height, state.profit())?; + self.realized_loss + .height + .truncate_push(height, state.loss())?; + Ok(()) + } + + pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + vec![ + &mut self.realized_cap_cents.height as &mut dyn AnyStoredVec, + &mut self.realized_profit.height, + &mut self.realized_loss.height, + ] + } + + pub(crate) fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&Self], + exit: &Exit, + ) -> Result<()> { + sum_others!(self, starting_indexes, others, exit; realized_cap_cents.height); + sum_others!(self, starting_indexes, others, exit; realized_profit.height); + sum_others!(self, starting_indexes, others, exit; realized_loss.height); + Ok(()) + } + + pub(crate) fn compute_rest_part1( + &mut self, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.realized_profit + .compute_rest(starting_indexes.height, exit)?; + self.realized_loss + .compute_rest(starting_indexes.height, exit)?; + Ok(()) + } + + pub(crate) fn compute_rest_part2( + &mut self, + prices: &prices::Vecs, + starting_indexes: &Indexes, + height_to_supply: &impl ReadableVec, + exit: &Exit, + ) -> Result<()> { + self.realized_price.cents.height.compute_transform2( + starting_indexes.height, + &self.realized_cap_cents.height, + height_to_supply, + |(i, cap_cents, supply, ..)| { + let cap = cap_cents.as_u128(); + let supply_sats = Sats::from(supply).as_u128(); + if supply_sats == 0 { + (i, Cents::ZERO) + } else { + (i, Cents::from(cap * Sats::ONE_BTC_U128 / supply_sats)) + } + }, + exit, + )?; + + self.realized_price_ratio.compute_ratio( + starting_indexes, + &prices.price.cents.height, + &self.realized_price.cents.height, + exit, + )?; + + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/realized/mod.rs b/crates/brk_computer/src/distribution/metrics/realized/mod.rs index 2c32e35ab..cfb332d9d 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/mod.rs @@ -1,15 +1,9 @@ mod adjusted; mod base; -mod complete; -mod core; -mod extended; - -mod with_extended; +mod full; +mod minimal; pub use adjusted::*; pub use base::*; -pub use complete::*; -pub use core::*; -pub use extended::*; - -pub use with_extended::*; +pub use full::*; +pub use minimal::*; diff --git a/crates/brk_computer/src/distribution/metrics/realized/with_extended.rs b/crates/brk_computer/src/distribution/metrics/realized/with_extended.rs deleted file mode 100644 index a776b7e84..000000000 --- a/crates/brk_computer/src/distribution/metrics/realized/with_extended.rs +++ /dev/null @@ -1,60 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Bitcoin, Dollars, Height, Indexes}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Exit, ReadableVec, Rw, StorageMode}; - -use crate::{blocks, prices}; - -use crate::distribution::metrics::ImportConfig; - -use super::{RealizedFull, RealizedExtended}; - -/// Realized metrics with guaranteed extended (no Option). -#[derive(Deref, DerefMut, Traversable)] -pub struct RealizedWithExtended { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub base: RealizedFull, - #[traversable(flatten)] - pub extended: RealizedExtended, -} - -impl RealizedWithExtended { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let base = RealizedFull::forced_import(cfg)?; - let extended = RealizedExtended::forced_import(cfg)?; - Ok(Self { base, extended }) - } - - pub(crate) fn compute_rest_part2( - &mut self, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - height_to_supply: &impl ReadableVec, - height_to_market_cap: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> { - self.base.compute_rest_part2( - blocks, - prices, - starting_indexes, - height_to_supply, - height_to_market_cap, - exit, - )?; - - self.extended.compute_rest_part2( - &self.base, - blocks, - prices, - starting_indexes, - height_to_market_cap, - exit, - )?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/relative/base.rs b/crates/brk_computer/src/distribution/metrics/relative/base.rs index bb8e3ccfe..200a27235 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/base.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/base.rs @@ -1,71 +1,107 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Exit, ReadableVec, Rw, StorageMode}; +use brk_types::{BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, StoredF32, Version}; +use vecdb::{Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; -use crate::internal::{NegRatioDollarsBps32, PercentFromHeight, RatioDollarsBp16}; +use crate::internal::{ + Bps32ToFloat, LazyFromHeight, NegRatioDollarsBps32, PercentFromHeight, RatioDollarsBp16, + RatioDollarsBps32, RatioSatsBp16, +}; -use crate::distribution::metrics::{ImportConfig, RealizedFull, UnrealizedFull}; +use crate::distribution::metrics::{ImportConfig, UnrealizedBase}; -use super::RelativeComplete; - -/// Full relative metrics (Source/Extended tier). +/// Relative metrics for the Complete tier (~6 fields). /// -/// Contains all Complete-tier fields (via Deref to RelativeComplete) plus: -/// - Source-only: neg_unrealized_loss_rel_to_market_cap, invested_capital_in_profit/loss_rel_to_realized_cap -#[derive(Deref, DerefMut, Traversable)] +/// Excludes source-only fields (invested_capital_in_profit/loss_rel_to_realized_cap). +#[derive(Traversable)] pub struct RelativeBase { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub complete: RelativeComplete, + pub supply_in_profit_rel_to_own_supply: PercentFromHeight, + pub supply_in_loss_rel_to_own_supply: PercentFromHeight, - // --- Source-only fields --- + pub unrealized_profit_rel_to_market_cap: PercentFromHeight, + pub unrealized_loss_rel_to_market_cap: PercentFromHeight, + pub net_unrealized_pnl_rel_to_market_cap: PercentFromHeight, pub neg_unrealized_loss_rel_to_market_cap: PercentFromHeight, - - pub invested_capital_in_profit_rel_to_realized_cap: PercentFromHeight, - pub invested_capital_in_loss_rel_to_realized_cap: PercentFromHeight, + pub nupl: LazyFromHeight, } impl RelativeBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let complete = RelativeComplete::forced_import(cfg)?; + let v1 = Version::ONE; + let v2 = Version::new(2); + + let net_unrealized_pnl_rel_to_market_cap = + cfg.import_percent_bps32("net_unrealized_pnl_rel_to_market_cap", Version::new(3))?; + + let nupl = LazyFromHeight::from_computed::( + &cfg.name("nupl"), + cfg.version + Version::new(3), + net_unrealized_pnl_rel_to_market_cap + .bps + .height + .read_only_boxed_clone(), + &net_unrealized_pnl_rel_to_market_cap.bps, + ); Ok(Self { - complete, + supply_in_profit_rel_to_own_supply: cfg + .import_percent_bp16("supply_in_profit_rel_to_own_supply", v1)?, + supply_in_loss_rel_to_own_supply: cfg + .import_percent_bp16("supply_in_loss_rel_to_own_supply", v1)?, + unrealized_profit_rel_to_market_cap: cfg + .import_percent_bp16("unrealized_profit_rel_to_market_cap", v2)?, + unrealized_loss_rel_to_market_cap: cfg + .import_percent_bp16("unrealized_loss_rel_to_market_cap", v2)?, + net_unrealized_pnl_rel_to_market_cap, neg_unrealized_loss_rel_to_market_cap: cfg .import_percent_bps32("neg_unrealized_loss_rel_to_market_cap", Version::new(3))?, - invested_capital_in_profit_rel_to_realized_cap: cfg.import_percent_bp16( - "invested_capital_in_profit_rel_to_realized_cap", - Version::ZERO, - )?, - invested_capital_in_loss_rel_to_realized_cap: cfg.import_percent_bp16( - "invested_capital_in_loss_rel_to_realized_cap", - Version::ZERO, - )?, + nupl, }) } pub(crate) fn compute( &mut self, max_from: Height, - unrealized: &UnrealizedFull, - realized: &RealizedFull, + unrealized: &UnrealizedBase, supply_total_sats: &impl ReadableVec, market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - // Compute Complete-tier fields - self.complete.compute( - max_from, - &unrealized.complete, - supply_total_sats, - market_cap, - exit, - )?; - - // Source-only + 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::( + max_from, + &unrealized.unrealized_profit.usd.height, + market_cap, + exit, + )?; + self.unrealized_loss_rel_to_market_cap + .compute_binary::( + max_from, + &unrealized.unrealized_loss.usd.height, + market_cap, + exit, + )?; + self.net_unrealized_pnl_rel_to_market_cap + .compute_binary::( + max_from, + &unrealized.net_unrealized_pnl.usd.height, + market_cap, + exit, + )?; self.neg_unrealized_loss_rel_to_market_cap .compute_binary::( max_from, @@ -73,20 +109,6 @@ impl RelativeBase { market_cap, exit, )?; - self.invested_capital_in_profit_rel_to_realized_cap - .compute_binary::( - max_from, - &unrealized.invested_capital_in_profit.usd.height, - &realized.realized_cap.height, - exit, - )?; - self.invested_capital_in_loss_rel_to_realized_cap - .compute_binary::( - max_from, - &unrealized.invested_capital_in_loss.usd.height, - &realized.realized_cap.height, - exit, - )?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/relative/complete.rs b/crates/brk_computer/src/distribution/metrics/relative/complete.rs deleted file mode 100644 index b6f5083a0..000000000 --- a/crates/brk_computer/src/distribution/metrics/relative/complete.rs +++ /dev/null @@ -1,105 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, StoredF32, Version}; -use vecdb::{Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; - -use crate::internal::{ - Bps32ToFloat, LazyFromHeight, PercentFromHeight, RatioDollarsBp16, RatioDollarsBps32, - RatioSatsBp16, -}; - -use crate::distribution::metrics::{ImportConfig, UnrealizedComplete}; - -/// Relative metrics for the Complete tier (~6 fields). -/// -/// Excludes source-only fields (invested_capital_in_profit/loss_rel_to_realized_cap, -/// neg_unrealized_loss_rel_to_market_cap). -#[derive(Traversable)] -pub struct RelativeComplete { - 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, - pub net_unrealized_pnl_rel_to_market_cap: PercentFromHeight, - pub nupl: LazyFromHeight, -} - -impl RelativeComplete { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v1 = Version::ONE; - let v2 = Version::new(2); - - let net_unrealized_pnl_rel_to_market_cap = - cfg.import_percent_bps32("net_unrealized_pnl_rel_to_market_cap", Version::new(3))?; - - let nupl = LazyFromHeight::from_computed::( - &cfg.name("nupl"), - cfg.version + Version::new(3), - net_unrealized_pnl_rel_to_market_cap - .bps - .height - .read_only_boxed_clone(), - &net_unrealized_pnl_rel_to_market_cap.bps, - ); - - Ok(Self { - supply_in_profit_rel_to_own_supply: cfg - .import_percent_bp16("supply_in_profit_rel_to_own_supply", v1)?, - supply_in_loss_rel_to_own_supply: cfg - .import_percent_bp16("supply_in_loss_rel_to_own_supply", v1)?, - unrealized_profit_rel_to_market_cap: cfg - .import_percent_bp16("unrealized_profit_rel_to_market_cap", v2)?, - unrealized_loss_rel_to_market_cap: cfg - .import_percent_bp16("unrealized_loss_rel_to_market_cap", v2)?, - net_unrealized_pnl_rel_to_market_cap, - nupl, - }) - } - - pub(crate) fn compute( - &mut self, - max_from: Height, - unrealized: &UnrealizedComplete, - supply_total_sats: &impl ReadableVec, - market_cap: &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, - )?; - self.unrealized_profit_rel_to_market_cap - .compute_binary::( - max_from, - &unrealized.unrealized_profit.usd.height, - market_cap, - exit, - )?; - self.unrealized_loss_rel_to_market_cap - .compute_binary::( - max_from, - &unrealized.unrealized_loss.usd.height, - market_cap, - exit, - )?; - self.net_unrealized_pnl_rel_to_market_cap - .compute_binary::( - max_from, - &unrealized.net_unrealized_pnl.usd.height, - market_cap, - exit, - )?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/relative/for_all.rs b/crates/brk_computer/src/distribution/metrics/relative/for_all.rs index a89d9146c..b7f7426df 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/for_all.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/for_all.rs @@ -4,9 +4,9 @@ use brk_types::{Dollars, Height, Sats}; use derive_more::{Deref, DerefMut}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::distribution::metrics::{ImportConfig, RealizedFull, UnrealizedFull}; +use crate::distribution::metrics::{ImportConfig, RealizedBase, UnrealizedFull}; -use super::{RelativeBase, RelativeExtendedOwnPnl}; +use super::{RelativeFull, RelativeExtendedOwnPnl}; /// Relative metrics for the "all" cohort (base + own_pnl, NO rel_to_all). #[derive(Deref, DerefMut, Traversable)] @@ -14,7 +14,7 @@ pub struct RelativeForAll { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: RelativeBase, + pub base: RelativeFull, #[traversable(flatten)] pub extended_own_pnl: RelativeExtendedOwnPnl, } @@ -22,7 +22,7 @@ pub struct RelativeForAll { impl RelativeForAll { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - base: RelativeBase::forced_import(cfg)?, + base: RelativeFull::forced_import(cfg)?, extended_own_pnl: RelativeExtendedOwnPnl::forced_import(cfg)?, }) } @@ -31,7 +31,7 @@ impl RelativeForAll { &mut self, max_from: Height, unrealized: &UnrealizedFull, - realized: &RealizedFull, + realized: &RealizedBase, supply_total_sats: &impl ReadableVec, market_cap: &impl ReadableVec, exit: &Exit, diff --git a/crates/brk_computer/src/distribution/metrics/relative/full.rs b/crates/brk_computer/src/distribution/metrics/relative/full.rs new file mode 100644 index 000000000..76262d8ae --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/relative/full.rs @@ -0,0 +1,81 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{BasisPoints16, Dollars, Height, Sats, Version}; +use derive_more::{Deref, DerefMut}; +use vecdb::{Exit, ReadableVec, Rw, StorageMode}; + +use crate::internal::{PercentFromHeight, RatioDollarsBp16}; + +use crate::distribution::metrics::{ImportConfig, RealizedBase, UnrealizedFull}; + +use super::RelativeBase; + +/// Full relative metrics (Source/Extended tier). +/// +/// Contains all Complete-tier fields (via Deref to RelativeBase) plus: +/// - Source-only: invested_capital_in_profit/loss_rel_to_realized_cap +#[derive(Deref, DerefMut, Traversable)] +pub struct RelativeFull { + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub base: RelativeBase, + + // --- Source-only fields --- + pub invested_capital_in_profit_rel_to_realized_cap: PercentFromHeight, + pub invested_capital_in_loss_rel_to_realized_cap: PercentFromHeight, +} + +impl RelativeFull { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let base = RelativeBase::forced_import(cfg)?; + + Ok(Self { + base, + invested_capital_in_profit_rel_to_realized_cap: cfg.import_percent_bp16( + "invested_capital_in_profit_rel_to_realized_cap", + Version::ZERO, + )?, + invested_capital_in_loss_rel_to_realized_cap: cfg.import_percent_bp16( + "invested_capital_in_loss_rel_to_realized_cap", + Version::ZERO, + )?, + }) + } + + pub(crate) fn compute( + &mut self, + max_from: Height, + unrealized: &UnrealizedFull, + realized: &RealizedBase, + supply_total_sats: &impl ReadableVec, + market_cap: &impl ReadableVec, + exit: &Exit, + ) -> Result<()> { + // Compute Complete-tier fields + self.base.compute( + max_from, + &unrealized.base, + supply_total_sats, + market_cap, + exit, + )?; + + // Source-only + self.invested_capital_in_profit_rel_to_realized_cap + .compute_binary::( + max_from, + &unrealized.invested_capital_in_profit.usd.height, + &realized.realized_cap.height, + exit, + )?; + self.invested_capital_in_loss_rel_to_realized_cap + .compute_binary::( + max_from, + &unrealized.invested_capital_in_loss.usd.height, + &realized.realized_cap.height, + exit, + )?; + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/relative/mod.rs b/crates/brk_computer/src/distribution/metrics/relative/mod.rs index 302238142..ab1c022ea 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/mod.rs @@ -1,21 +1,21 @@ mod base; -mod complete; 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; -mod with_rel_to_all_complete; +mod with_rel_to_all_base; pub use base::*; -pub use complete::*; pub use extended_own_market_cap::*; pub use extended_own_pnl::*; pub use for_all::*; +pub use full::*; pub use to_all::*; pub use with_extended::*; pub use with_rel_to_all::*; -pub use with_rel_to_all_complete::*; +pub use with_rel_to_all_base::*; diff --git a/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs b/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs index 20ed5a215..7f629b88b 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs @@ -4,9 +4,9 @@ use brk_types::{Dollars, Height, Sats}; use derive_more::{Deref, DerefMut}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::distribution::metrics::{ImportConfig, RealizedFull, UnrealizedFull}; +use crate::distribution::metrics::{ImportConfig, RealizedBase, UnrealizedFull}; -use super::{RelativeBase, RelativeExtendedOwnMarketCap, RelativeExtendedOwnPnl, RelativeToAll}; +use super::{RelativeFull, RelativeExtendedOwnMarketCap, RelativeExtendedOwnPnl, RelativeToAll}; /// Full extended relative metrics (base + rel_to_all + own_market_cap + own_pnl). /// Used by: sth, lth, age_range cohorts. @@ -15,7 +15,7 @@ pub struct RelativeWithExtended { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: RelativeBase, + pub base: RelativeFull, #[traversable(flatten)] pub rel_to_all: RelativeToAll, #[traversable(flatten)] @@ -27,7 +27,7 @@ pub struct RelativeWithExtended { impl RelativeWithExtended { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - base: RelativeBase::forced_import(cfg)?, + base: RelativeFull::forced_import(cfg)?, rel_to_all: RelativeToAll::forced_import(cfg)?, extended_own_market_cap: RelativeExtendedOwnMarketCap::forced_import(cfg)?, extended_own_pnl: RelativeExtendedOwnPnl::forced_import(cfg)?, @@ -39,7 +39,7 @@ impl RelativeWithExtended { &mut self, max_from: Height, unrealized: &UnrealizedFull, - realized: &RealizedFull, + realized: &RealizedBase, supply_total_sats: &impl ReadableVec, market_cap: &impl ReadableVec, all_supply_sats: &impl ReadableVec, 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 index 831a0b12d..7e0fbd07f 100644 --- 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 @@ -4,9 +4,9 @@ use brk_types::{Dollars, Height, Sats}; use derive_more::{Deref, DerefMut}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::distribution::metrics::{ImportConfig, RealizedFull, UnrealizedFull}; +use crate::distribution::metrics::{ImportConfig, RealizedBase, UnrealizedFull}; -use super::{RelativeBase, RelativeToAll}; +use super::{RelativeFull, RelativeToAll}; /// Relative metrics with rel_to_all (no extended, no peak_regret). /// Used by: epoch, year, type, amount, address cohorts. @@ -15,7 +15,7 @@ pub struct RelativeWithRelToAll { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: RelativeBase, + pub base: RelativeFull, #[traversable(flatten)] pub rel_to_all: RelativeToAll, } @@ -23,7 +23,7 @@ pub struct RelativeWithRelToAll { impl RelativeWithRelToAll { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - base: RelativeBase::forced_import(cfg)?, + base: RelativeFull::forced_import(cfg)?, rel_to_all: RelativeToAll::forced_import(cfg)?, }) } @@ -33,7 +33,7 @@ impl RelativeWithRelToAll { &mut self, max_from: Height, unrealized: &UnrealizedFull, - realized: &RealizedFull, + realized: &RealizedBase, supply_total_sats: &impl ReadableVec, market_cap: &impl ReadableVec, all_supply_sats: &impl ReadableVec, diff --git a/crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all_complete.rs b/crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all_base.rs similarity index 79% rename from crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all_complete.rs rename to crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all_base.rs index 649d1113e..f6edd68d1 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all_complete.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/with_rel_to_all_base.rs @@ -4,26 +4,26 @@ use brk_types::{Dollars, Height, Sats}; use derive_more::{Deref, DerefMut}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::distribution::metrics::{ImportConfig, UnrealizedComplete}; +use crate::distribution::metrics::{ImportConfig, UnrealizedBase}; -use super::{RelativeComplete, RelativeToAll}; +use super::{RelativeBase, RelativeToAll}; /// Complete relative metrics with rel_to_all. /// Used by CompleteCohortMetrics (epoch, class, min_age, max_age). #[derive(Deref, DerefMut, Traversable)] -pub struct RelativeCompleteWithRelToAll { +pub struct RelativeBaseWithRelToAll { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: RelativeComplete, + pub base: RelativeBase, #[traversable(flatten)] pub rel_to_all: RelativeToAll, } -impl RelativeCompleteWithRelToAll { +impl RelativeBaseWithRelToAll { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { - base: RelativeComplete::forced_import(cfg)?, + base: RelativeBase::forced_import(cfg)?, rel_to_all: RelativeToAll::forced_import(cfg)?, }) } @@ -31,7 +31,7 @@ impl RelativeCompleteWithRelToAll { pub(crate) fn compute( &mut self, max_from: Height, - unrealized: &UnrealizedComplete, + unrealized: &UnrealizedBase, supply_total_sats: &impl ReadableVec, market_cap: &impl ReadableVec, all_supply_sats: &impl ReadableVec, diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs index 26f5e90d6..caad9be02 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs @@ -1,93 +1,78 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Cents, CentsSats, CentsSigned, CentsSquaredSats, Height, Indexes, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, AnyVec, BytesVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; +use brk_types::{Cents, CentsSigned, Height, Indexes, Version}; +use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, Rw, StorageMode, WritableVec}; use crate::{ distribution::state::UnrealizedState, - internal::{CentsSubtractToCentsSigned, FiatFromHeight}, - prices, + internal::{ + CentsSubtractToCentsSigned, FiatFromHeight, LazyFromHeight, NegCentsUnsignedToDollars, + ValueFromHeight, + }, }; +use brk_types::Dollars; + use crate::distribution::metrics::ImportConfig; -use super::UnrealizedComplete; - -/// Full unrealized metrics (Source/Extended tier). +/// Unrealized metrics for the Complete tier (~6 fields). /// -/// Contains all Complete-tier fields (via Deref to UnrealizedComplete) plus: -/// - Source-only: invested_capital, raw BytesVecs, unrealized_gross_pnl -/// - Extended-only: pain_index, greed_index, net_sentiment -#[derive(Deref, DerefMut, Traversable)] -pub struct UnrealizedFull { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub complete: UnrealizedComplete, +/// Excludes source-only fields (invested_capital, raw BytesVecs) +/// and extended-only fields (pain_index, greed_index, net_sentiment). +#[derive(Traversable)] +pub struct UnrealizedBase { + pub supply_in_profit: ValueFromHeight, + pub supply_in_loss: ValueFromHeight, - // --- Source-only fields --- - pub invested_capital_in_profit: FiatFromHeight, - pub invested_capital_in_loss: FiatFromHeight, + pub unrealized_profit: FiatFromHeight, + pub unrealized_loss: FiatFromHeight, - pub invested_capital_in_profit_raw: M::Stored>, - pub invested_capital_in_loss_raw: M::Stored>, - pub investor_cap_in_profit_raw: M::Stored>, - pub investor_cap_in_loss_raw: M::Stored>, + pub neg_unrealized_loss: LazyFromHeight, pub gross_pnl: FiatFromHeight, - // --- Extended-only fields --- - pub pain_index: FiatFromHeight, - pub greed_index: FiatFromHeight, - pub net_sentiment: FiatFromHeight, + pub net_unrealized_pnl: FiatFromHeight, } -impl UnrealizedFull { +impl UnrealizedBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v0 = Version::ZERO; + let supply_in_profit = cfg.import_value("supply_in_profit", v0)?; + let supply_in_loss = cfg.import_value("supply_in_loss", v0)?; - let complete = UnrealizedComplete::forced_import(cfg)?; + let unrealized_profit = cfg.import_fiat("unrealized_profit", v0)?; + let unrealized_loss = cfg.import_fiat("unrealized_loss", v0)?; - let invested_capital_in_profit = cfg.import_fiat("invested_capital_in_profit", v0)?; - let invested_capital_in_loss = cfg.import_fiat("invested_capital_in_loss", v0)?; - - let invested_capital_in_profit_raw = - cfg.import_bytes("invested_capital_in_profit_raw", v0)?; - let invested_capital_in_loss_raw = cfg.import_bytes("invested_capital_in_loss_raw", v0)?; - let investor_cap_in_profit_raw = cfg.import_bytes("investor_cap_in_profit_raw", v0)?; - let investor_cap_in_loss_raw = cfg.import_bytes("investor_cap_in_loss_raw", v0)?; - - let pain_index = cfg.import_fiat("pain_index", v0)?; - let greed_index = cfg.import_fiat("greed_index", v0)?; - let net_sentiment = cfg.import_fiat("net_sentiment", Version::ONE)?; + let neg_unrealized_loss = LazyFromHeight::from_computed::( + &cfg.name("neg_unrealized_loss"), + cfg.version, + unrealized_loss.cents.height.read_only_boxed_clone(), + &unrealized_loss.cents, + ); let gross_pnl = cfg.import_fiat("unrealized_gross_pnl", v0)?; + let net_unrealized_pnl = cfg.import_fiat("net_unrealized_pnl", v0)?; + Ok(Self { - complete, - invested_capital_in_profit, - invested_capital_in_loss, - invested_capital_in_profit_raw, - invested_capital_in_loss_raw, - investor_cap_in_profit_raw, - investor_cap_in_loss_raw, - pain_index, - greed_index, - net_sentiment, + supply_in_profit, + supply_in_loss, + unrealized_profit, + unrealized_loss, + neg_unrealized_loss, gross_pnl, + net_unrealized_pnl, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { - self.complete - .min_stateful_height_len() - .min(self.invested_capital_in_profit.cents.height.len()) - .min(self.invested_capital_in_loss.cents.height.len()) - .min(self.invested_capital_in_profit_raw.len()) - .min(self.invested_capital_in_loss_raw.len()) - .min(self.investor_cap_in_profit_raw.len()) - .min(self.investor_cap_in_loss_raw.len()) + self.supply_in_profit + .sats + .height + .len() + .min(self.supply_in_loss.sats.height.len()) + .min(self.unrealized_profit.cents.height.len()) + .min(self.unrealized_loss.cents.height.len()) } pub(crate) fn truncate_push( @@ -95,46 +80,35 @@ impl UnrealizedFull { height: Height, height_state: &UnrealizedState, ) -> Result<()> { - self.complete.truncate_push(height, height_state)?; - - self.invested_capital_in_profit + self.supply_in_profit + .sats + .height + .truncate_push(height, height_state.supply_in_profit)?; + self.supply_in_loss + .sats + .height + .truncate_push(height, height_state.supply_in_loss)?; + self.unrealized_profit .cents .height - .truncate_push(height, height_state.invested_capital_in_profit)?; - self.invested_capital_in_loss + .truncate_push(height, height_state.unrealized_profit)?; + self.unrealized_loss .cents .height - .truncate_push(height, height_state.invested_capital_in_loss)?; - - self.invested_capital_in_profit_raw.truncate_push( - height, - CentsSats::new(height_state.invested_capital_in_profit_raw), - )?; - self.invested_capital_in_loss_raw.truncate_push( - height, - CentsSats::new(height_state.invested_capital_in_loss_raw), - )?; - self.investor_cap_in_profit_raw.truncate_push( - height, - CentsSquaredSats::new(height_state.investor_cap_in_profit_raw), - )?; - self.investor_cap_in_loss_raw.truncate_push( - height, - CentsSquaredSats::new(height_state.investor_cap_in_loss_raw), - )?; + .truncate_push(height, height_state.unrealized_loss)?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - let mut vecs = self.complete.collect_vecs_mut(); - vecs.push(&mut self.invested_capital_in_profit.cents.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.invested_capital_in_loss.cents.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.invested_capital_in_profit_raw as &mut dyn AnyStoredVec); - vecs.push(&mut self.invested_capital_in_loss_raw as &mut dyn AnyStoredVec); - vecs.push(&mut self.investor_cap_in_profit_raw as &mut dyn AnyStoredVec); - vecs.push(&mut self.investor_cap_in_loss_raw as &mut dyn AnyStoredVec); - vecs + vec![ + &mut self.supply_in_profit.base.sats.height as &mut dyn AnyStoredVec, + &mut self.supply_in_profit.base.cents.height as &mut dyn AnyStoredVec, + &mut self.supply_in_loss.base.sats.height as &mut dyn AnyStoredVec, + &mut self.supply_in_loss.base.cents.height as &mut dyn AnyStoredVec, + &mut self.unrealized_profit.cents.height, + &mut self.unrealized_loss.cents.height, + ] } pub(crate) fn compute_from_stateful( @@ -143,149 +117,37 @@ impl UnrealizedFull { others: &[&Self], exit: &Exit, ) -> Result<()> { - // Delegate Complete-tier aggregation - let complete_refs: Vec<&UnrealizedComplete> = - others.iter().map(|o| &o.complete).collect(); - self.complete - .compute_from_stateful(starting_indexes, &complete_refs, exit)?; - - // Source-only: invested_capital - sum_others!(self, starting_indexes, others, exit; invested_capital_in_profit.cents.height); - sum_others!(self, starting_indexes, others, exit; invested_capital_in_loss.cents.height); - - // Source-only: raw BytesVec aggregation - let start = self - .invested_capital_in_profit_raw - .len() - .min(self.invested_capital_in_loss_raw.len()) - .min(self.investor_cap_in_profit_raw.len()) - .min(self.investor_cap_in_loss_raw.len()); - let end = others - .iter() - .map(|o| o.invested_capital_in_profit_raw.len()) - .min() - .unwrap_or(0); - - // Pre-collect all cohort data to avoid per-element BytesVec reads in nested loop - let invested_profit_ranges: Vec> = others - .iter() - .map(|o| { - o.invested_capital_in_profit_raw - .collect_range_at(start, end) - }) - .collect(); - let invested_loss_ranges: Vec> = others - .iter() - .map(|o| o.invested_capital_in_loss_raw.collect_range_at(start, end)) - .collect(); - let investor_profit_ranges: Vec> = others - .iter() - .map(|o| o.investor_cap_in_profit_raw.collect_range_at(start, end)) - .collect(); - let investor_loss_ranges: Vec> = others - .iter() - .map(|o| o.investor_cap_in_loss_raw.collect_range_at(start, end)) - .collect(); - - for i in start..end { - let height = Height::from(i); - let local_i = i - start; - - let mut sum_invested_profit = CentsSats::ZERO; - let mut sum_invested_loss = CentsSats::ZERO; - let mut sum_investor_profit = CentsSquaredSats::ZERO; - let mut sum_investor_loss = CentsSquaredSats::ZERO; - - for idx in 0..others.len() { - sum_invested_profit += invested_profit_ranges[idx][local_i]; - sum_invested_loss += invested_loss_ranges[idx][local_i]; - sum_investor_profit += investor_profit_ranges[idx][local_i]; - sum_investor_loss += investor_loss_ranges[idx][local_i]; - } - - self.invested_capital_in_profit_raw - .truncate_push(height, sum_invested_profit)?; - self.invested_capital_in_loss_raw - .truncate_push(height, sum_invested_loss)?; - self.investor_cap_in_profit_raw - .truncate_push(height, sum_investor_profit)?; - self.investor_cap_in_loss_raw - .truncate_push(height, sum_investor_loss)?; - } + sum_others!(self, starting_indexes, others, exit; supply_in_profit.sats.height); + sum_others!(self, starting_indexes, others, exit; supply_in_loss.sats.height); + sum_others!(self, starting_indexes, others, exit; unrealized_profit.cents.height); + sum_others!(self, starting_indexes, others, exit; unrealized_loss.cents.height); Ok(()) } - /// Compute derived metrics from stored values + price. + /// Compute derived metrics from stored values. pub(crate) fn compute_rest( &mut self, - prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - // Complete-tier: net_unrealized_pnl - self.complete.compute_rest(starting_indexes, exit)?; - - // Extended-only: Pain index (investor_price_of_losers - spot) - self.pain_index.cents.height.compute_transform3( - starting_indexes.height, - &self.investor_cap_in_loss_raw, - &self.invested_capital_in_loss_raw, - &prices.price.cents.height, - |(h, investor_cap, invested_cap, spot, ..)| { - if invested_cap.inner() == 0 { - return (h, Cents::ZERO); - } - let investor_price_losers = investor_cap.inner() / invested_cap.inner(); - let spot_u128 = spot.as_u128(); - (h, Cents::new((investor_price_losers - spot_u128) as u64)) - }, - exit, - )?; - - // Extended-only: Greed index (spot - investor_price_of_winners) - self.greed_index.cents.height.compute_transform3( - starting_indexes.height, - &self.investor_cap_in_profit_raw, - &self.invested_capital_in_profit_raw, - &prices.price.cents.height, - |(h, investor_cap, invested_cap, spot, ..)| { - if invested_cap.inner() == 0 { - return (h, Cents::ZERO); - } - let investor_price_winners = investor_cap.inner() / invested_cap.inner(); - let spot_u128 = spot.as_u128(); - (h, Cents::new((spot_u128 - investor_price_winners) as u64)) - }, - exit, - )?; - - // Source-only: unrealized gross pnl self.gross_pnl.cents.height.compute_add( starting_indexes.height, - &self.complete.unrealized_profit.cents.height, - &self.complete.unrealized_loss.cents.height, + &self.unrealized_profit.cents.height, + &self.unrealized_loss.cents.height, exit, )?; - Ok(()) - } - - /// Compute net_sentiment.height for separate cohorts (greed - pain). - pub(crate) fn compute_net_sentiment_height( - &mut self, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.net_sentiment + self.net_unrealized_pnl .cents .height .compute_binary::( starting_indexes.height, - &self.greed_index.cents.height, - &self.pain_index.cents.height, + &self.unrealized_profit.cents.height, + &self.unrealized_loss.cents.height, exit, )?; + Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/complete.rs b/crates/brk_computer/src/distribution/metrics/unrealized/complete.rs deleted file mode 100644 index e357a4901..000000000 --- a/crates/brk_computer/src/distribution/metrics/unrealized/complete.rs +++ /dev/null @@ -1,141 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Cents, CentsSigned, Height, Indexes, Version}; -use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, Rw, StorageMode, WritableVec}; - -use crate::{ - distribution::state::UnrealizedState, - internal::{ - CentsSubtractToCentsSigned, FiatFromHeight, LazyFromHeight, NegCentsUnsignedToDollars, - ValueFromHeight, - }, -}; - -use brk_types::Dollars; - -use crate::distribution::metrics::ImportConfig; - -/// Unrealized metrics for the Complete tier (~6 fields). -/// -/// Excludes source-only fields (invested_capital, raw BytesVecs, unrealized_gross_pnl) -/// and extended-only fields (pain_index, greed_index, net_sentiment). -#[derive(Traversable)] -pub struct UnrealizedComplete { - pub supply_in_profit: ValueFromHeight, - pub supply_in_loss: ValueFromHeight, - - pub unrealized_profit: FiatFromHeight, - pub unrealized_loss: FiatFromHeight, - - pub neg_unrealized_loss: LazyFromHeight, - - pub net_unrealized_pnl: FiatFromHeight, -} - -impl UnrealizedComplete { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v0 = Version::ZERO; - let supply_in_profit = cfg.import_value("supply_in_profit", v0)?; - let supply_in_loss = cfg.import_value("supply_in_loss", v0)?; - - let unrealized_profit = cfg.import_fiat("unrealized_profit", v0)?; - let unrealized_loss = cfg.import_fiat("unrealized_loss", v0)?; - - let neg_unrealized_loss = LazyFromHeight::from_computed::( - &cfg.name("neg_unrealized_loss"), - cfg.version, - unrealized_loss.cents.height.read_only_boxed_clone(), - &unrealized_loss.cents, - ); - - let net_unrealized_pnl = cfg.import_fiat("net_unrealized_pnl", v0)?; - - Ok(Self { - supply_in_profit, - supply_in_loss, - unrealized_profit, - unrealized_loss, - neg_unrealized_loss, - net_unrealized_pnl, - }) - } - - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.supply_in_profit - .sats - .height - .len() - .min(self.supply_in_loss.sats.height.len()) - .min(self.unrealized_profit.cents.height.len()) - .min(self.unrealized_loss.cents.height.len()) - } - - pub(crate) fn truncate_push( - &mut self, - height: Height, - height_state: &UnrealizedState, - ) -> Result<()> { - self.supply_in_profit - .sats - .height - .truncate_push(height, height_state.supply_in_profit)?; - self.supply_in_loss - .sats - .height - .truncate_push(height, height_state.supply_in_loss)?; - self.unrealized_profit - .cents - .height - .truncate_push(height, height_state.unrealized_profit)?; - self.unrealized_loss - .cents - .height - .truncate_push(height, height_state.unrealized_loss)?; - - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![ - &mut self.supply_in_profit.base.sats.height as &mut dyn AnyStoredVec, - &mut self.supply_in_profit.base.cents.height as &mut dyn AnyStoredVec, - &mut self.supply_in_loss.base.sats.height as &mut dyn AnyStoredVec, - &mut self.supply_in_loss.base.cents.height as &mut dyn AnyStoredVec, - &mut self.unrealized_profit.cents.height, - &mut self.unrealized_loss.cents.height, - ] - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - sum_others!(self, starting_indexes, others, exit; supply_in_profit.sats.height); - sum_others!(self, starting_indexes, others, exit; supply_in_loss.sats.height); - sum_others!(self, starting_indexes, others, exit; unrealized_profit.cents.height); - sum_others!(self, starting_indexes, others, exit; unrealized_loss.cents.height); - - Ok(()) - } - - /// Compute derived metrics from stored values. - pub(crate) fn compute_rest( - &mut self, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.net_unrealized_pnl - .cents - .height - .compute_binary::( - starting_indexes.height, - &self.unrealized_profit.cents.height, - &self.unrealized_loss.cents.height, - exit, - )?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/full.rs b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs new file mode 100644 index 000000000..3732a861f --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs @@ -0,0 +1,278 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{Cents, CentsSats, CentsSigned, CentsSquaredSats, Height, Indexes, Version}; +use derive_more::{Deref, DerefMut}; +use vecdb::{AnyStoredVec, AnyVec, BytesVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; + +use crate::{ + distribution::state::UnrealizedState, + internal::{CentsSubtractToCentsSigned, FiatFromHeight}, + prices, +}; + +use crate::distribution::metrics::ImportConfig; + +use super::UnrealizedBase; + +/// Full unrealized metrics (Source/Extended tier). +/// +/// Contains all Complete-tier fields (via Deref to UnrealizedBase) plus: +/// - Source-only: invested_capital, raw BytesVecs +/// - Extended-only: pain_index, greed_index, net_sentiment +#[derive(Deref, DerefMut, Traversable)] +pub struct UnrealizedFull { + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub base: UnrealizedBase, + + // --- Source-only fields --- + pub invested_capital_in_profit: FiatFromHeight, + pub invested_capital_in_loss: FiatFromHeight, + + pub invested_capital_in_profit_raw: M::Stored>, + pub invested_capital_in_loss_raw: M::Stored>, + pub investor_cap_in_profit_raw: M::Stored>, + pub investor_cap_in_loss_raw: M::Stored>, + + // --- Extended-only fields --- + pub pain_index: FiatFromHeight, + pub greed_index: FiatFromHeight, + pub net_sentiment: FiatFromHeight, +} + +impl UnrealizedFull { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let v0 = Version::ZERO; + + let base = UnrealizedBase::forced_import(cfg)?; + + let invested_capital_in_profit = cfg.import_fiat("invested_capital_in_profit", v0)?; + let invested_capital_in_loss = cfg.import_fiat("invested_capital_in_loss", v0)?; + + let invested_capital_in_profit_raw = + cfg.import_bytes("invested_capital_in_profit_raw", v0)?; + let invested_capital_in_loss_raw = cfg.import_bytes("invested_capital_in_loss_raw", v0)?; + let investor_cap_in_profit_raw = cfg.import_bytes("investor_cap_in_profit_raw", v0)?; + let investor_cap_in_loss_raw = cfg.import_bytes("investor_cap_in_loss_raw", v0)?; + + let pain_index = cfg.import_fiat("pain_index", v0)?; + let greed_index = cfg.import_fiat("greed_index", v0)?; + let net_sentiment = cfg.import_fiat("net_sentiment", Version::ONE)?; + + Ok(Self { + base, + invested_capital_in_profit, + invested_capital_in_loss, + invested_capital_in_profit_raw, + invested_capital_in_loss_raw, + investor_cap_in_profit_raw, + investor_cap_in_loss_raw, + pain_index, + greed_index, + net_sentiment, + }) + } + + pub(crate) fn min_stateful_height_len(&self) -> usize { + self.base + .min_stateful_height_len() + .min(self.invested_capital_in_profit.cents.height.len()) + .min(self.invested_capital_in_loss.cents.height.len()) + .min(self.invested_capital_in_profit_raw.len()) + .min(self.invested_capital_in_loss_raw.len()) + .min(self.investor_cap_in_profit_raw.len()) + .min(self.investor_cap_in_loss_raw.len()) + } + + pub(crate) fn truncate_push( + &mut self, + height: Height, + height_state: &UnrealizedState, + ) -> Result<()> { + self.base.truncate_push(height, height_state)?; + + self.invested_capital_in_profit + .cents + .height + .truncate_push(height, height_state.invested_capital_in_profit)?; + self.invested_capital_in_loss + .cents + .height + .truncate_push(height, height_state.invested_capital_in_loss)?; + + self.invested_capital_in_profit_raw.truncate_push( + height, + CentsSats::new(height_state.invested_capital_in_profit_raw), + )?; + self.invested_capital_in_loss_raw.truncate_push( + height, + CentsSats::new(height_state.invested_capital_in_loss_raw), + )?; + self.investor_cap_in_profit_raw.truncate_push( + height, + CentsSquaredSats::new(height_state.investor_cap_in_profit_raw), + )?; + self.investor_cap_in_loss_raw.truncate_push( + height, + CentsSquaredSats::new(height_state.investor_cap_in_loss_raw), + )?; + + Ok(()) + } + + pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + let mut vecs = self.base.collect_vecs_mut(); + vecs.push(&mut self.invested_capital_in_profit.cents.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.invested_capital_in_loss.cents.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.invested_capital_in_profit_raw as &mut dyn AnyStoredVec); + vecs.push(&mut self.invested_capital_in_loss_raw as &mut dyn AnyStoredVec); + vecs.push(&mut self.investor_cap_in_profit_raw as &mut dyn AnyStoredVec); + vecs.push(&mut self.investor_cap_in_loss_raw as &mut dyn AnyStoredVec); + vecs + } + + pub(crate) fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&Self], + exit: &Exit, + ) -> Result<()> { + // Delegate Complete-tier aggregation + let base_refs: Vec<&UnrealizedBase> = + others.iter().map(|o| &o.base).collect(); + self.base + .compute_from_stateful(starting_indexes, &base_refs, exit)?; + + // Source-only: invested_capital + sum_others!(self, starting_indexes, others, exit; invested_capital_in_profit.cents.height); + sum_others!(self, starting_indexes, others, exit; invested_capital_in_loss.cents.height); + + // Source-only: raw BytesVec aggregation + let start = self + .invested_capital_in_profit_raw + .len() + .min(self.invested_capital_in_loss_raw.len()) + .min(self.investor_cap_in_profit_raw.len()) + .min(self.investor_cap_in_loss_raw.len()); + let end = others + .iter() + .map(|o| o.invested_capital_in_profit_raw.len()) + .min() + .unwrap_or(0); + + // Pre-collect all cohort data to avoid per-element BytesVec reads in nested loop + let invested_profit_ranges: Vec> = others + .iter() + .map(|o| { + o.invested_capital_in_profit_raw + .collect_range_at(start, end) + }) + .collect(); + let invested_loss_ranges: Vec> = others + .iter() + .map(|o| o.invested_capital_in_loss_raw.collect_range_at(start, end)) + .collect(); + let investor_profit_ranges: Vec> = others + .iter() + .map(|o| o.investor_cap_in_profit_raw.collect_range_at(start, end)) + .collect(); + let investor_loss_ranges: Vec> = others + .iter() + .map(|o| o.investor_cap_in_loss_raw.collect_range_at(start, end)) + .collect(); + + for i in start..end { + let height = Height::from(i); + let local_i = i - start; + + let mut sum_invested_profit = CentsSats::ZERO; + let mut sum_invested_loss = CentsSats::ZERO; + let mut sum_investor_profit = CentsSquaredSats::ZERO; + let mut sum_investor_loss = CentsSquaredSats::ZERO; + + for idx in 0..others.len() { + sum_invested_profit += invested_profit_ranges[idx][local_i]; + sum_invested_loss += invested_loss_ranges[idx][local_i]; + sum_investor_profit += investor_profit_ranges[idx][local_i]; + sum_investor_loss += investor_loss_ranges[idx][local_i]; + } + + self.invested_capital_in_profit_raw + .truncate_push(height, sum_invested_profit)?; + self.invested_capital_in_loss_raw + .truncate_push(height, sum_invested_loss)?; + self.investor_cap_in_profit_raw + .truncate_push(height, sum_investor_profit)?; + self.investor_cap_in_loss_raw + .truncate_push(height, sum_investor_loss)?; + } + + Ok(()) + } + + /// Compute derived metrics from stored values + price. + pub(crate) fn compute_rest( + &mut self, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + // Complete-tier: net_unrealized_pnl + self.base.compute_rest(starting_indexes, exit)?; + + // Extended-only: Pain index (investor_price_of_losers - spot) + self.pain_index.cents.height.compute_transform3( + starting_indexes.height, + &self.investor_cap_in_loss_raw, + &self.invested_capital_in_loss_raw, + &prices.price.cents.height, + |(h, investor_cap, invested_cap, spot, ..)| { + if invested_cap.inner() == 0 { + return (h, Cents::ZERO); + } + let investor_price_losers = investor_cap.inner() / invested_cap.inner(); + let spot_u128 = spot.as_u128(); + (h, Cents::new((investor_price_losers - spot_u128) as u64)) + }, + exit, + )?; + + // Extended-only: Greed index (spot - investor_price_of_winners) + self.greed_index.cents.height.compute_transform3( + starting_indexes.height, + &self.investor_cap_in_profit_raw, + &self.invested_capital_in_profit_raw, + &prices.price.cents.height, + |(h, investor_cap, invested_cap, spot, ..)| { + if invested_cap.inner() == 0 { + return (h, Cents::ZERO); + } + let investor_price_winners = investor_cap.inner() / invested_cap.inner(); + let spot_u128 = spot.as_u128(); + (h, Cents::new((spot_u128 - investor_price_winners) as u64)) + }, + exit, + )?; + + Ok(()) + } + + /// Compute net_sentiment.height for separate cohorts (greed - pain). + pub(crate) fn compute_net_sentiment_height( + &mut self, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.net_sentiment + .cents + .height + .compute_binary::( + starting_indexes.height, + &self.greed_index.cents.height, + &self.pain_index.cents.height, + exit, + )?; + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs index 4fc634b09..17a3cd90b 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs @@ -1,5 +1,5 @@ mod base; -mod complete; +mod full; pub use base::*; -pub use complete::*; +pub use full::*; diff --git a/crates/brk_computer/src/distribution/state/cost_basis/realized.rs b/crates/brk_computer/src/distribution/state/cost_basis/realized.rs index 5452c9211..c0ae49a42 100644 --- a/crates/brk_computer/src/distribution/state/cost_basis/realized.rs +++ b/crates/brk_computer/src/distribution/state/cost_basis/realized.rs @@ -13,6 +13,12 @@ pub trait RealizedOps: Default + Clone + Send + Sync + 'static { fn value_destroyed(&self) -> Cents { Cents::ZERO } + fn sent_in_profit(&self) -> Sats { + Sats::ZERO + } + fn sent_in_loss(&self) -> Sats { + Sats::ZERO + } fn set_cap_raw(&mut self, cap_raw: CentsSats); fn set_investor_cap_raw(&mut self, investor_cap_raw: CentsSquaredSats); fn reset_single_iteration_values(&mut self); @@ -121,13 +127,15 @@ impl RealizedOps for MinimalRealizedState { } } -/// Core realized state: cap, profit, loss + value_created/destroyed for SOPR. +/// Core realized state: cap, profit, loss + value_created/destroyed for SOPR + sent tracking. /// Used by CoreCohortMetrics cohorts (epoch, class, max_age, min_age — ~59 separate cohorts). #[derive(Debug, Default, Clone)] pub struct CoreRealizedState { minimal: MinimalRealizedState, value_created_raw: u128, value_destroyed_raw: u128, + sent_in_profit: Sats, + sent_in_loss: Sats, } impl RealizedOps for CoreRealizedState { @@ -162,6 +170,16 @@ impl RealizedOps for CoreRealizedState { Cents::new((self.value_destroyed_raw / Sats::ONE_BTC_U128) as u64) } + #[inline] + fn sent_in_profit(&self) -> Sats { + self.sent_in_profit + } + + #[inline] + fn sent_in_loss(&self) -> Sats { + self.sent_in_loss + } + #[inline] fn set_cap_raw(&mut self, cap_raw: CentsSats) { self.minimal.set_cap_raw(cap_raw); @@ -175,6 +193,8 @@ impl RealizedOps for CoreRealizedState { self.minimal.reset_single_iteration_values(); self.value_created_raw = 0; self.value_destroyed_raw = 0; + self.sent_in_profit = Sats::ZERO; + self.sent_in_loss = Sats::ZERO; } #[inline] @@ -205,6 +225,14 @@ impl RealizedOps for CoreRealizedState { .send(sats, current_ps, prev_ps, ath_ps, prev_investor_cap); self.value_created_raw += current_ps.as_u128(); self.value_destroyed_raw += prev_ps.as_u128(); + match current_ps.cmp(&prev_ps) { + Ordering::Greater | Ordering::Equal => { + self.sent_in_profit += sats; + } + Ordering::Less => { + self.sent_in_loss += sats; + } + } } } @@ -232,10 +260,6 @@ pub struct RealizedState { loss_value_destroyed_raw: u128, /// Raw realized peak regret: Σ((peak - sell_price) × sats) peak_regret_raw: u128, - /// Sats sent in profit - sent_in_profit: Sats, - /// Sats sent in loss - sent_in_loss: Sats, } impl RealizedOps for RealizedState { @@ -272,6 +296,16 @@ impl RealizedOps for RealizedState { Cents::new((raw / Sats::ONE_BTC_U128) as u64) } + #[inline] + fn sent_in_profit(&self) -> Sats { + self.core.sent_in_profit() + } + + #[inline] + fn sent_in_loss(&self) -> Sats { + self.core.sent_in_loss() + } + #[inline] fn set_cap_raw(&mut self, cap_raw: CentsSats) { self.core.set_cap_raw(cap_raw); @@ -290,8 +324,6 @@ impl RealizedOps for RealizedState { self.loss_value_created_raw = 0; self.loss_value_destroyed_raw = 0; self.peak_regret_raw = 0; - self.sent_in_profit = Sats::ZERO; - self.sent_in_loss = Sats::ZERO; } #[inline] @@ -323,7 +355,7 @@ impl RealizedOps for RealizedState { ath_ps: CentsSats, prev_investor_cap: CentsSquaredSats, ) { - // Delegate cap/profit/loss + value_created/destroyed to core + // Delegate cap/profit/loss + value_created/destroyed + sent tracking to core self.core .send(sats, current_ps, prev_ps, ath_ps, prev_investor_cap); @@ -331,20 +363,13 @@ impl RealizedOps for RealizedState { let current = current_ps.as_u128(); let prev = prev_ps.as_u128(); match current_ps.cmp(&prev_ps) { - Ordering::Greater => { + Ordering::Greater | Ordering::Equal => { self.profit_value_created_raw += current; self.profit_value_destroyed_raw += prev; - self.sent_in_profit += sats; } Ordering::Less => { self.loss_value_created_raw += current; self.loss_value_destroyed_raw += prev; - self.sent_in_loss += sats; - } - Ordering::Equal => { - self.profit_value_created_raw += current; - self.profit_value_destroyed_raw += prev; - self.sent_in_profit += sats; } } @@ -421,16 +446,4 @@ impl RealizedState { } Cents::new((self.peak_regret_raw / Sats::ONE_BTC_U128) as u64) } - - /// Get sats sent in profit. - #[inline] - pub(crate) fn sent_in_profit(&self) -> Sats { - self.sent_in_profit - } - - /// Get sats sent in loss. - #[inline] - pub(crate) fn sent_in_loss(&self) -> Sats { - self.sent_in_loss - } } diff --git a/crates/brk_computer/src/internal/from_height/ratio/full.rs b/crates/brk_computer/src/internal/from_height/ratio/full.rs deleted file mode 100644 index c4a2c0450..000000000 --- a/crates/brk_computer/src/internal/from_height/ratio/full.rs +++ /dev/null @@ -1,51 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Cents, Height, Indexes, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; - -use crate::{blocks, indexes, prices}; - -use super::{ComputedFromHeightRatioExtended, ComputedFromHeightRatioStdDevBands}; - -#[derive(Deref, DerefMut, Traversable)] -pub struct ComputedFromHeightRatioFull { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub base: ComputedFromHeightRatioExtended, - #[traversable(flatten)] - pub std_dev: ComputedFromHeightRatioStdDevBands, -} - -impl ComputedFromHeightRatioFull { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - base: ComputedFromHeightRatioExtended::forced_import(db, name, version, indexes)?, - std_dev: ComputedFromHeightRatioStdDevBands::forced_import( - db, name, version, indexes, - )?, - }) - } - - /// Compute ratio, percentiles, and all stddev bands from an externally-provided metric price (in cents). - pub(crate) fn compute_rest( - &mut self, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - metric_price: &impl ReadableVec, - ) -> Result<()> { - self.base - .compute_rest(blocks, prices, starting_indexes, exit, metric_price)?; - self.std_dev - .compute(blocks, starting_indexes, exit, &self.base.base.ratio.height, metric_price)?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/from_height/ratio/mod.rs b/crates/brk_computer/src/internal/from_height/ratio/mod.rs index b30c7b32d..51ea8db22 100644 --- a/crates/brk_computer/src/internal/from_height/ratio/mod.rs +++ b/crates/brk_computer/src/internal/from_height/ratio/mod.rs @@ -1,11 +1,9 @@ mod extended; -mod full; mod percentiles; mod price_extended; mod std_dev_bands; pub use extended::*; -pub use full::*; pub use percentiles::*; pub use price_extended::*; pub use std_dev_bands::*; diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 90da302ba..7f7b4dded 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -1570,13 +1570,7 @@ function createMetricPattern35(client, name) { return /** @type {MetricPattern35 // Reusable structural pattern factories /** - * @typedef {Object} AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern - * @property {_1m1w1y24hPattern} adjustedSopr - * @property {_1m1wPattern} adjustedSoprEma - * @property {MetricPattern1} adjustedValueCreated - * @property {_1m1w1y24hPattern} adjustedValueCreatedSum - * @property {MetricPattern1} adjustedValueDestroyed - * @property {_1m1w1y24hPattern} adjustedValueDestroyedSum + * @typedef {Object} CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern * @property {MetricPattern18} capRaw * @property {MetricPattern1} capitulationFlow * @property {CentsUsdPattern} grossPnl @@ -1635,19 +1629,13 @@ function createMetricPattern35(client, name) { return /** @type {MetricPattern35 */ /** - * Create a AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern pattern node + * Create a CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} + * @returns {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} */ -function createAdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, acc) { +function createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, acc) { return { - adjustedSopr: create_1m1w1y24hPattern(client, _m(acc, 'adjusted_sopr')), - adjustedSoprEma: create_1m1wPattern(client, _m(acc, 'adjusted_sopr_24h_ema')), - adjustedValueCreated: createMetricPattern1(client, _m(acc, 'adjusted_value_created')), - adjustedValueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'adjusted_value_created')), - adjustedValueDestroyed: createMetricPattern1(client, _m(acc, 'adjusted_value_destroyed')), - adjustedValueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'adjusted_value_destroyed')), capRaw: createMetricPattern18(client, _m(acc, 'cap_raw')), capitulationFlow: createMetricPattern1(client, _m(acc, 'capitulation_flow')), grossPnl: createCentsUsdPattern(client, _m(acc, 'realized_gross_pnl')), @@ -1706,204 +1694,6 @@ function createAdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfit }; } -/** - * @typedef {Object} CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern - * @property {MetricPattern18} capRaw - * @property {MetricPattern1} capitulationFlow - * @property {CentsUsdPattern} grossPnl - * @property {_1m1w1y24hPattern} grossPnlSum - * @property {MetricPattern18} investorCapRaw - * @property {CentsSatsUsdPattern} investorPrice - * @property {BpsRatioPattern} investorPriceRatio - * @property {MetricPattern1} lossValueCreated - * @property {MetricPattern1} lossValueDestroyed - * @property {CentsSatsUsdPattern} lowerPriceBand - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} negRealizedLoss - * @property {MetricPattern1} netPnlChange1m - * @property {BpsPercentRatioPattern} netPnlChange1mRelToMarketCap - * @property {BpsPercentRatioPattern} netPnlChange1mRelToRealizedCap - * @property {CumulativeHeightPattern} netRealizedPnl - * @property {MetricPattern1} netRealizedPnlEma1w - * @property {BpsPercentRatioPattern} netRealizedPnlRelToRealizedCap - * @property {CumulativeHeightPattern} peakRegret - * @property {BpsPercentRatioPattern} peakRegretRelToRealizedCap - * @property {MetricPattern1} profitFlow - * @property {MetricPattern1} profitValueCreated - * @property {MetricPattern1} profitValueDestroyed - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {MetricPattern1} realizedCapChange1m - * @property {CumulativeHeightPattern} realizedLoss - * @property {MetricPattern1} realizedLossEma1w - * @property {BpsPercentRatioPattern} realizedLossRelToRealizedCap - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {CumulativeHeightPattern} realizedProfit - * @property {MetricPattern1} realizedProfitEma1w - * @property {BpsPercentRatioPattern} realizedProfitRelToRealizedCap - * @property {_1m1w1y24hPattern2} sellSideRiskRatio - * @property {_1m1wPattern2} sellSideRiskRatio24hEma - * @property {BaseCumulativePattern} sentInLoss - * @property {_2wPattern} sentInLossEma - * @property {BaseCumulativePattern} sentInProfit - * @property {_2wPattern} sentInProfitEma - * @property {_1m1w1y24hPattern} sopr - * @property {_1m1wPattern} sopr24hEma - * @property {CentsSatsUsdPattern} upperPriceBand - * @property {MetricPattern1} valueCreated - * @property {_1m1w1y24hPattern} valueCreatedSum - * @property {MetricPattern1} valueDestroyed - * @property {_1m1w1y24hPattern} valueDestroyedSum - */ - -/** - * Create a CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} - */ -function createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, acc) { - return { - capRaw: createMetricPattern18(client, _m(acc, 'cap_raw')), - capitulationFlow: createMetricPattern1(client, _m(acc, 'capitulation_flow')), - grossPnl: createCentsUsdPattern(client, _m(acc, 'realized_gross_pnl')), - grossPnlSum: create_1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')), - investorCapRaw: createMetricPattern18(client, _m(acc, 'investor_cap_raw')), - investorPrice: createCentsSatsUsdPattern(client, _m(acc, 'investor_price')), - investorPriceRatio: createBpsRatioPattern(client, _m(acc, 'investor_price_ratio')), - lossValueCreated: createMetricPattern1(client, _m(acc, 'loss_value_created')), - lossValueDestroyed: createMetricPattern1(client, _m(acc, 'loss_value_destroyed')), - lowerPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'lower_price_band')), - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - negRealizedLoss: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), - netPnlChange1m: createMetricPattern1(client, _m(acc, 'net_pnl_change_1m')), - netPnlChange1mRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_market_cap')), - netPnlChange1mRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_realized_cap')), - netRealizedPnl: createCumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')), - netRealizedPnlEma1w: createMetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')), - netRealizedPnlRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')), - peakRegret: createCumulativeHeightPattern(client, _m(acc, 'realized_peak_regret')), - peakRegretRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_peak_regret_rel_to_realized_cap')), - profitFlow: createMetricPattern1(client, _m(acc, 'profit_flow')), - profitValueCreated: createMetricPattern1(client, _m(acc, 'profit_value_created')), - profitValueDestroyed: createMetricPattern1(client, _m(acc, 'profit_value_destroyed')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedCapChange1m: createMetricPattern1(client, _m(acc, 'realized_cap_change_1m')), - realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), - realizedLossEma1w: createMetricPattern1(client, _m(acc, 'realized_loss_ema_1w')), - realizedLossRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), - realizedProfitEma1w: createMetricPattern1(client, _m(acc, 'realized_profit_ema_1w')), - realizedProfitRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')), - sellSideRiskRatio: create_1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')), - sellSideRiskRatio24hEma: create_1m1wPattern2(client, _m(acc, 'sell_side_risk_ratio_24h_ema')), - sentInLoss: createBaseCumulativePattern(client, _m(acc, 'sent_in_loss')), - sentInLossEma: create_2wPattern(client, _m(acc, 'sent_in_loss_ema_2w')), - sentInProfit: createBaseCumulativePattern(client, _m(acc, 'sent_in_profit')), - sentInProfitEma: create_2wPattern(client, _m(acc, 'sent_in_profit_ema_2w')), - sopr: create_1m1w1y24hPattern(client, _m(acc, 'sopr')), - sopr24hEma: create_1m1wPattern(client, _m(acc, 'sopr_24h_ema')), - upperPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'upper_price_band')), - valueCreated: createMetricPattern1(client, _m(acc, 'value_created')), - valueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_created')), - valueDestroyed: createMetricPattern1(client, _m(acc, 'value_destroyed')), - valueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_destroyed')), - }; -} - -/** - * @typedef {Object} CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern - * @property {MetricPattern1} capitulationFlow - * @property {CentsUsdPattern} grossPnl - * @property {_1m1w1y24hPattern} grossPnlSum - * @property {MetricPattern1} lossValueCreated - * @property {MetricPattern1} lossValueDestroyed - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} negRealizedLoss - * @property {MetricPattern1} netPnlChange1m - * @property {BpsPercentRatioPattern} netPnlChange1mRelToMarketCap - * @property {BpsPercentRatioPattern} netPnlChange1mRelToRealizedCap - * @property {CumulativeHeightPattern} netRealizedPnl - * @property {MetricPattern1} netRealizedPnlEma1w - * @property {BpsPercentRatioPattern} netRealizedPnlRelToRealizedCap - * @property {MetricPattern1} profitFlow - * @property {MetricPattern1} profitValueCreated - * @property {MetricPattern1} profitValueDestroyed - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {MetricPattern1} realizedCapChange1m - * @property {CumulativeHeightPattern} realizedLoss - * @property {MetricPattern1} realizedLossEma1w - * @property {BpsPercentRatioPattern} realizedLossRelToRealizedCap - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {CumulativeHeightPattern} realizedProfit - * @property {MetricPattern1} realizedProfitEma1w - * @property {BpsPercentRatioPattern} realizedProfitRelToRealizedCap - * @property {BaseCumulativePattern} sentInLoss - * @property {_2wPattern} sentInLossEma - * @property {BaseCumulativePattern} sentInProfit - * @property {_2wPattern} sentInProfitEma - * @property {_1m1w1y24hPattern} sopr - * @property {_1m1wPattern} sopr24hEma - * @property {MetricPattern1} valueCreated - * @property {_1m1w1y24hPattern} valueCreatedSum - * @property {MetricPattern1} valueDestroyed - * @property {_1m1w1y24hPattern} valueDestroyedSum - */ - -/** - * Create a CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern} - */ -function createCapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern(client, acc) { - return { - capitulationFlow: createMetricPattern1(client, _m(acc, 'capitulation_flow')), - grossPnl: createCentsUsdPattern(client, _m(acc, 'realized_gross_pnl')), - grossPnlSum: create_1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')), - lossValueCreated: createMetricPattern1(client, _m(acc, 'loss_value_created')), - lossValueDestroyed: createMetricPattern1(client, _m(acc, 'loss_value_destroyed')), - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - negRealizedLoss: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), - netPnlChange1m: createMetricPattern1(client, _m(acc, 'net_pnl_change_1m')), - netPnlChange1mRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_market_cap')), - netPnlChange1mRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_realized_cap')), - netRealizedPnl: createCumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')), - netRealizedPnlEma1w: createMetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')), - netRealizedPnlRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')), - profitFlow: createMetricPattern1(client, _m(acc, 'profit_flow')), - profitValueCreated: createMetricPattern1(client, _m(acc, 'profit_value_created')), - profitValueDestroyed: createMetricPattern1(client, _m(acc, 'profit_value_destroyed')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedCapChange1m: createMetricPattern1(client, _m(acc, 'realized_cap_change_1m')), - realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), - realizedLossEma1w: createMetricPattern1(client, _m(acc, 'realized_loss_ema_1w')), - realizedLossRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), - realizedProfitEma1w: createMetricPattern1(client, _m(acc, 'realized_profit_ema_1w')), - realizedProfitRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')), - sentInLoss: createBaseCumulativePattern(client, _m(acc, 'sent_in_loss')), - sentInLossEma: create_2wPattern(client, _m(acc, 'sent_in_loss_ema_2w')), - sentInProfit: createBaseCumulativePattern(client, _m(acc, 'sent_in_profit')), - sentInProfitEma: create_2wPattern(client, _m(acc, 'sent_in_profit_ema_2w')), - sopr: create_1m1w1y24hPattern(client, _m(acc, 'sopr')), - sopr24hEma: create_1m1wPattern(client, _m(acc, 'sopr_24h_ema')), - valueCreated: createMetricPattern1(client, _m(acc, 'value_created')), - valueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_created')), - valueDestroyed: createMetricPattern1(client, _m(acc, 'value_destroyed')), - valueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_destroyed')), - }; -} - /** * @typedef {Object} _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern * @property {CentsSatsUsdPattern} _0sdPrice @@ -1975,6 +1765,77 @@ function create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client }; } +/** + * @typedef {Object} GrossMvrvNegNetRealizedSentSoprValuePattern + * @property {CentsUsdPattern} grossPnl + * @property {MetricPattern1} mvrv + * @property {MetricPattern1} negRealizedLoss + * @property {CumulativeHeightPattern} netRealizedPnl + * @property {MetricPattern1} netRealizedPnlEma1w + * @property {BpsPercentRatioPattern} netRealizedPnlRelToRealizedCap + * @property {MetricPattern1} realizedCap + * @property {MetricPattern1} realizedCapCents + * @property {MetricPattern1} realizedCapChange1m + * @property {CumulativeHeightPattern} realizedLoss + * @property {MetricPattern1} realizedLossEma1w + * @property {BpsPercentRatioPattern} realizedLossRelToRealizedCap + * @property {CentsSatsUsdPattern} realizedPrice + * @property {BpsRatioPattern} realizedPriceRatio + * @property {RatioPattern} realizedPriceRatioPercentiles + * @property {CumulativeHeightPattern} realizedProfit + * @property {MetricPattern1} realizedProfitEma1w + * @property {BpsPercentRatioPattern} realizedProfitRelToRealizedCap + * @property {BaseCumulativePattern} sentInLoss + * @property {_2wPattern} sentInLossEma + * @property {BaseCumulativePattern} sentInProfit + * @property {_2wPattern} sentInProfitEma + * @property {_1m1w1y24hPattern} sopr + * @property {_1m1wPattern} sopr24hEma + * @property {MetricPattern1} valueCreated + * @property {_1m1w1y24hPattern} valueCreatedSum + * @property {MetricPattern1} valueDestroyed + * @property {_1m1w1y24hPattern} valueDestroyedSum + */ + +/** + * Create a GrossMvrvNegNetRealizedSentSoprValuePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {GrossMvrvNegNetRealizedSentSoprValuePattern} + */ +function createGrossMvrvNegNetRealizedSentSoprValuePattern(client, acc) { + return { + grossPnl: createCentsUsdPattern(client, _m(acc, 'realized_gross_pnl')), + mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + negRealizedLoss: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), + netRealizedPnl: createCumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')), + netRealizedPnlEma1w: createMetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')), + netRealizedPnlRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')), + realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), + realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), + realizedCapChange1m: createMetricPattern1(client, _m(acc, 'realized_cap_change_1m')), + realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), + realizedLossEma1w: createMetricPattern1(client, _m(acc, 'realized_loss_ema_1w')), + realizedLossRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')), + realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), + realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), + realizedPriceRatioPercentiles: createRatioPattern(client, _m(acc, 'realized_price_ratio')), + realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), + realizedProfitEma1w: createMetricPattern1(client, _m(acc, 'realized_profit_ema_1w')), + realizedProfitRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')), + sentInLoss: createBaseCumulativePattern(client, _m(acc, 'sent_in_loss')), + sentInLossEma: create_2wPattern(client, _m(acc, 'sent_in_loss_ema_2w')), + sentInProfit: createBaseCumulativePattern(client, _m(acc, 'sent_in_profit')), + sentInProfitEma: create_2wPattern(client, _m(acc, 'sent_in_profit_ema_2w')), + sopr: create_1m1w1y24hPattern(client, _m(acc, 'sopr')), + sopr24hEma: create_1m1wPattern(client, _m(acc, 'sopr_24h_ema')), + valueCreated: createMetricPattern1(client, _m(acc, 'value_created')), + valueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_created')), + valueDestroyed: createMetricPattern1(client, _m(acc, 'value_destroyed')), + valueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_destroyed')), + }; +} + /** * @typedef {Object} InvestedNegNetNuplSupplyUnrealizedPattern3 * @property {BpsPercentRatioPattern} investedCapitalInLossRelToRealizedCap @@ -2030,59 +1891,6 @@ function createInvestedNegNetNuplSupplyUnrealizedPattern3(client, acc) { }; } -/** - * @typedef {Object} GrossMvrvNegNetRealizedSoprPattern - * @property {CentsUsdPattern} grossPnl - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} negRealizedLoss - * @property {CumulativeHeightPattern} netRealizedPnl - * @property {MetricPattern1} netRealizedPnlEma1w - * @property {BpsPercentRatioPattern} netRealizedPnlRelToRealizedCap - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {MetricPattern1} realizedCapChange1m - * @property {CumulativeHeightPattern} realizedLoss - * @property {MetricPattern1} realizedLossEma1w - * @property {BpsPercentRatioPattern} realizedLossRelToRealizedCap - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {CumulativeHeightPattern} realizedProfit - * @property {MetricPattern1} realizedProfitEma1w - * @property {BpsPercentRatioPattern} realizedProfitRelToRealizedCap - * @property {_1m1w1y24hPattern} sopr - * @property {_1m1wPattern} sopr24hEma - */ - -/** - * Create a GrossMvrvNegNetRealizedSoprPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {GrossMvrvNegNetRealizedSoprPattern} - */ -function createGrossMvrvNegNetRealizedSoprPattern(client, acc) { - return { - grossPnl: createCentsUsdPattern(client, _m(acc, 'realized_gross_pnl')), - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - negRealizedLoss: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), - netRealizedPnl: createCumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')), - netRealizedPnlEma1w: createMetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')), - netRealizedPnlRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedCapChange1m: createMetricPattern1(client, _m(acc, 'realized_cap_change_1m')), - realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), - realizedLossEma1w: createMetricPattern1(client, _m(acc, 'realized_loss_ema_1w')), - realizedLossRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), - realizedProfitEma1w: createMetricPattern1(client, _m(acc, 'realized_profit_ema_1w')), - realizedProfitRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')), - sopr: create_1m1w1y24hPattern(client, _m(acc, 'sopr')), - sopr24hEma: create_1m1wPattern(client, _m(acc, 'sopr_24h_ema')), - }; -} - /** * @typedef {Object} Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern * @property {CentsSatsUsdPattern} pct05 @@ -2499,6 +2307,41 @@ function createAverageGainsLossesRsiStochPattern(client, acc) { }; } +/** + * @typedef {Object} NegNetNuplSupplyUnrealizedPattern + * @property {BpsPercentRatioPattern} negUnrealizedLossRelToMarketCap + * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToMarketCap + * @property {MetricPattern1} nupl + * @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply + * @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply + * @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply + * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply + * @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply + * @property {BpsPercentRatioPattern} unrealizedLossRelToMarketCap + * @property {BpsPercentRatioPattern} unrealizedProfitRelToMarketCap + */ + +/** + * Create a NegNetNuplSupplyUnrealizedPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {NegNetNuplSupplyUnrealizedPattern} + */ +function createNegNetNuplSupplyUnrealizedPattern(client, acc) { + return { + negUnrealizedLossRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'neg_unrealized_loss_rel_to_market_cap')), + netUnrealizedPnlRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_market_cap')), + nupl: createMetricPattern1(client, _m(acc, 'nupl')), + supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_circulating_supply')), + supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_own_supply')), + supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_circulating_supply')), + supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_own_supply')), + supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_rel_to_circulating_supply')), + unrealizedLossRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')), + unrealizedProfitRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')), + }; +} + /** * @typedef {Object} AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern * @property {ChangeCountPattern} all @@ -2598,39 +2441,6 @@ function createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, acc) { }; } -/** - * @typedef {Object} NetNuplSupplyUnrealizedPattern - * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToMarketCap - * @property {MetricPattern1} nupl - * @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply - * @property {BpsPercentRatioPattern} unrealizedLossRelToMarketCap - * @property {BpsPercentRatioPattern} unrealizedProfitRelToMarketCap - */ - -/** - * Create a NetNuplSupplyUnrealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {NetNuplSupplyUnrealizedPattern} - */ -function createNetNuplSupplyUnrealizedPattern(client, acc) { - return { - netUnrealizedPnlRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_market_cap')), - nupl: createMetricPattern1(client, _m(acc, 'nupl')), - supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_circulating_supply')), - supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_own_supply')), - supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_circulating_supply')), - supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_own_supply')), - supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_rel_to_circulating_supply')), - unrealizedLossRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')), - unrealizedProfitRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')), - }; -} - /** * @template T * @typedef {Object} AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern @@ -2703,10 +2513,10 @@ function create_1m1w1y24hBtcCentsSatsUsdPattern(client, acc) { * @property {MetricPattern1} addrCount * @property {MetricPattern1} addrCountChange1m * @property {UtxoPattern} outputs - * @property {GrossMvrvNegNetRealizedSoprPattern} realized - * @property {NetNuplSupplyUnrealizedPattern} relative + * @property {MvrvRealizedPattern} realized + * @property {SupplyPattern} relative * @property {ChangeHalvedTotalPattern} supply - * @property {NegNetSupplyUnrealizedPattern} unrealized + * @property {SupplyPattern2} unrealized */ /** @@ -2721,10 +2531,10 @@ function createActivityAddrOutputsRealizedRelativeSupplyUnrealizedPattern(client addrCount: createMetricPattern1(client, _m(acc, 'addr_count')), addrCountChange1m: createMetricPattern1(client, _m(acc, 'addr_count_change_1m')), outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createGrossMvrvNegNetRealizedSoprPattern(client, acc), - relative: createNetNuplSupplyUnrealizedPattern(client, acc), + realized: createMvrvRealizedPattern(client, acc), + relative: createSupplyPattern(client, _m(acc, 'supply_in')), supply: createChangeHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createNegNetSupplyUnrealizedPattern(client, acc), + unrealized: createSupplyPattern2(client, _m(acc, 'supply_in')), }; } @@ -2795,7 +2605,7 @@ function create_10y2y3y4y5y6y8yPattern(client, acc) { * @property {CoinblocksCoindaysSentPattern} activity * @property {MaxMinPattern} costBasis * @property {UtxoPattern} outputs - * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized + * @property {GrossMvrvNegNetRealizedSentSoprValuePattern} realized * @property {InvestedNegNetNuplSupplyUnrealizedPattern} relative * @property {ChangeHalvedTotalPattern} supply * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized @@ -2812,7 +2622,7 @@ function createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern(client activity: createCoinblocksCoindaysSentPattern(client, acc), costBasis: createMaxMinPattern(client, _m(acc, 'cost_basis')), outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, acc), + realized: createGrossMvrvNegNetRealizedSentSoprValuePattern(client, acc), relative: createInvestedNegNetNuplSupplyUnrealizedPattern(client, acc), supply: createChangeHalvedTotalPattern(client, _m(acc, 'supply')), unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, acc), @@ -2820,31 +2630,60 @@ function createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern(client } /** - * @typedef {Object} ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 - * @property {CoinblocksCoindaysSentPattern} activity - * @property {MaxMinPattern} costBasis - * @property {UtxoPattern} outputs - * @property {CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern} realized - * @property {NetNuplSupplyUnrealizedPattern} relative - * @property {ChangeHalvedTotalPattern} supply - * @property {NegNetSupplyUnrealizedPattern} unrealized + * @typedef {Object} GrossNegNetSupplyUnrealizedPattern + * @property {CentsUsdPattern} grossPnl + * @property {MetricPattern1} negUnrealizedLoss + * @property {CentsUsdPattern} netUnrealizedPnl + * @property {BtcCentsSatsUsdPattern} supplyInLoss + * @property {BtcCentsSatsUsdPattern} supplyInProfit + * @property {CentsUsdPattern} unrealizedLoss + * @property {CentsUsdPattern} unrealizedProfit */ /** - * Create a ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 pattern node + * Create a GrossNegNetSupplyUnrealizedPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} + * @returns {GrossNegNetSupplyUnrealizedPattern} */ -function createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, acc) { +function createGrossNegNetSupplyUnrealizedPattern(client, acc) { return { - activity: createCoinblocksCoindaysSentPattern(client, acc), - costBasis: createMaxMinPattern(client, _m(acc, 'cost_basis')), - outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createCapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern(client, acc), - relative: createNetNuplSupplyUnrealizedPattern(client, acc), - supply: createChangeHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createNegNetSupplyUnrealizedPattern(client, acc), + grossPnl: createCentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')), + negUnrealizedLoss: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), + netUnrealizedPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), + supplyInLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')), + supplyInProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')), + unrealizedLoss: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), + unrealizedProfit: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), + }; +} + +/** + * @typedef {Object} MvrvRealizedPattern + * @property {MetricPattern1} mvrv + * @property {MetricPattern1} realizedCap + * @property {MetricPattern1} realizedCapCents + * @property {CumulativeHeightPattern} realizedLoss + * @property {CentsSatsUsdPattern} realizedPrice + * @property {BpsRatioPattern} realizedPriceRatio + * @property {CumulativeHeightPattern} realizedProfit + */ + +/** + * Create a MvrvRealizedPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {MvrvRealizedPattern} + */ +function createMvrvRealizedPattern(client, acc) { + return { + mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), + realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), + realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), + realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), + realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), + realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), }; } @@ -2875,14 +2714,41 @@ function create_1m1w1y24hBaseCumulativePattern(client, acc) { }; } +/** + * @typedef {Object} ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 + * @property {SentPattern} activity + * @property {UtxoPattern} outputs + * @property {GrossMvrvNegNetRealizedSentSoprValuePattern} realized + * @property {NegNetNuplSupplyUnrealizedPattern} relative + * @property {ChangeHalvedTotalPattern} supply + * @property {GrossNegNetSupplyUnrealizedPattern} unrealized + */ + +/** + * Create a ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} + */ +function createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, acc) { + return { + activity: createSentPattern(client, _m(acc, 'sent')), + outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), + realized: createGrossMvrvNegNetRealizedSentSoprValuePattern(client, acc), + relative: createNegNetNuplSupplyUnrealizedPattern(client, acc), + supply: createChangeHalvedTotalPattern(client, _m(acc, 'supply')), + unrealized: createGrossNegNetSupplyUnrealizedPattern(client, acc), + }; +} + /** * @typedef {Object} ActivityOutputsRealizedRelativeSupplyUnrealizedPattern * @property {SentPattern} activity * @property {UtxoPattern} outputs - * @property {GrossMvrvNegNetRealizedSoprPattern} realized - * @property {NetNuplSupplyUnrealizedPattern} relative + * @property {MvrvRealizedPattern} realized + * @property {SupplyPattern} relative * @property {ChangeHalvedTotalPattern} supply - * @property {NegNetSupplyUnrealizedPattern} unrealized + * @property {SupplyPattern2} unrealized */ /** @@ -2895,10 +2761,10 @@ function createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, ac return { activity: createSentPattern(client, _m(acc, 'sent')), outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createGrossMvrvNegNetRealizedSoprPattern(client, acc), - relative: createNetNuplSupplyUnrealizedPattern(client, acc), + realized: createMvrvRealizedPattern(client, acc), + relative: createSupplyPattern(client, _m(acc, 'supply_in')), supply: createChangeHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createNegNetSupplyUnrealizedPattern(client, acc), + unrealized: createSupplyPattern2(client, _m(acc, 'supply_in')), }; } @@ -2929,33 +2795,6 @@ function createBalanceBothReactivatedReceivingSendingPattern(client, acc) { }; } -/** - * @typedef {Object} NegNetSupplyUnrealizedPattern - * @property {MetricPattern1} negUnrealizedLoss - * @property {CentsUsdPattern} netUnrealizedPnl - * @property {BtcCentsSatsUsdPattern} supplyInLoss - * @property {BtcCentsSatsUsdPattern} supplyInProfit - * @property {CentsUsdPattern} unrealizedLoss - * @property {CentsUsdPattern} unrealizedProfit - */ - -/** - * Create a NegNetSupplyUnrealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {NegNetSupplyUnrealizedPattern} - */ -function createNegNetSupplyUnrealizedPattern(client, acc) { - return { - negUnrealizedLoss: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - netUnrealizedPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - supplyInLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')), - supplyInProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')), - unrealizedLoss: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - unrealizedProfit: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), - }; -} - /** * @typedef {Object} EmaHistogramLineSignalPattern * @property {MetricPattern1} emaFast @@ -2981,56 +2820,6 @@ function createEmaHistogramLineSignalPattern(client, acc) { }; } -/** - * @typedef {Object} MvrvRealizedPattern - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - */ - -/** - * Create a MvrvRealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {MvrvRealizedPattern} - */ -function createMvrvRealizedPattern(client, acc) { - return { - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - }; -} - -/** - * @typedef {Object} OutputsRealizedRelativeSupplyUnrealizedPattern - * @property {UtxoPattern} outputs - * @property {MvrvRealizedPattern} realized - * @property {SupplyPattern} relative - * @property {ChangeHalvedTotalPattern} supply - * @property {SupplyPattern2} unrealized - */ - -/** - * Create a OutputsRealizedRelativeSupplyUnrealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {OutputsRealizedRelativeSupplyUnrealizedPattern} - */ -function createOutputsRealizedRelativeSupplyUnrealizedPattern(client, acc) { - return { - outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createMvrvRealizedPattern(client, acc), - relative: createSupplyPattern(client, _m(acc, 'supply_in')), - supply: createChangeHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createSupplyPattern2(client, _m(acc, 'supply_in')), - }; -} - /** * @typedef {Object} _1m1w1y24hPattern2 * @property {BpsPercentRatioPattern} _1m @@ -4912,11 +4701,11 @@ function create_2wPattern(client, acc) { * @property {MetricsTree_Distribution_UtxoCohorts_AgeRange} ageRange * @property {MetricsTree_Distribution_UtxoCohorts_MaxAge} maxAge * @property {MetricsTree_Distribution_UtxoCohorts_MinAge} minAge + * @property {MetricsTree_Distribution_UtxoCohorts_Epoch} epoch + * @property {MetricsTree_Distribution_UtxoCohorts_Class} class * @property {MetricsTree_Distribution_UtxoCohorts_GeAmount} geAmount * @property {MetricsTree_Distribution_UtxoCohorts_AmountRange} amountRange * @property {MetricsTree_Distribution_UtxoCohorts_LtAmount} ltAmount - * @property {MetricsTree_Distribution_UtxoCohorts_Epoch} epoch - * @property {MetricsTree_Distribution_UtxoCohorts_Class} class * @property {MetricsTree_Distribution_UtxoCohorts_Type} type */ @@ -4925,15 +4714,27 @@ function create_2wPattern(client, acc) { * @property {ChangeHalvedTotalPattern} supply * @property {UtxoPattern} outputs * @property {CoinblocksCoindaysSentPattern} activity - * @property {AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized + * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized * @property {InvestedMaxMinPercentilesPattern} costBasis * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized + * @property {MetricsTree_Distribution_UtxoCohorts_All_Adjusted} adjusted * @property {MetricsTree_Distribution_UtxoCohorts_All_Relative} relative + * @property {MetricPattern1} dormancy + * @property {MetricPattern1} velocity + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Adjusted + * @property {MetricPattern1} adjustedValueCreated + * @property {MetricPattern1} adjustedValueDestroyed + * @property {_1m1w1y24hPattern} adjustedValueCreatedSum + * @property {_1m1w1y24hPattern} adjustedValueDestroyedSum + * @property {_1m1w1y24hPattern} adjustedSopr + * @property {_1m1wPattern} adjustedSoprEma */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Relative - * @property {BpsPercentRatioPattern} negUnrealizedLossRelToMarketCap * @property {BpsPercentRatioPattern} investedCapitalInProfitRelToRealizedCap * @property {BpsPercentRatioPattern} investedCapitalInLossRelToRealizedCap * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply @@ -4941,6 +4742,7 @@ function create_2wPattern(client, acc) { * @property {BpsPercentRatioPattern} unrealizedProfitRelToMarketCap * @property {BpsPercentRatioPattern} unrealizedLossRelToMarketCap * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToMarketCap + * @property {BpsPercentRatioPattern} negUnrealizedLossRelToMarketCap * @property {MetricPattern1} nupl * @property {BpsPercentRatioPattern} unrealizedProfitRelToOwnGrossPnl * @property {BpsPercentRatioPattern} unrealizedLossRelToOwnGrossPnl @@ -4953,10 +4755,18 @@ function create_2wPattern(client, acc) { * @property {ChangeHalvedTotalPattern} supply * @property {UtxoPattern} outputs * @property {CoinblocksCoindaysSentPattern} activity - * @property {AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized + * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized * @property {InvestedMaxMinPercentilesPattern} costBasis * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized * @property {InvestedNegNetNuplSupplyUnrealizedPattern3} relative + * @property {MetricPattern1} dormancy + * @property {MetricPattern1} velocity + * @property {MetricPattern1} adjustedValueCreated + * @property {MetricPattern1} adjustedValueDestroyed + * @property {_1m1w1y24hPattern} adjustedValueCreatedSum + * @property {_1m1w1y24hPattern} adjustedValueDestroyedSum + * @property {_1m1w1y24hPattern} adjustedSopr + * @property {_1m1wPattern} adjustedSoprEma */ /** @@ -4964,69 +4774,12 @@ function create_2wPattern(client, acc) { * @property {ChangeHalvedTotalPattern} supply * @property {UtxoPattern} outputs * @property {CoinblocksCoindaysSentPattern} activity - * @property {MetricsTree_Distribution_UtxoCohorts_Lth_Realized} realized + * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized * @property {InvestedMaxMinPercentilesPattern} costBasis * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized * @property {InvestedNegNetNuplSupplyUnrealizedPattern3} relative - */ - -/** - * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Lth_Realized - * @property {CentsSatsUsdPattern} investorPrice - * @property {BpsRatioPattern} investorPriceRatio - * @property {CentsSatsUsdPattern} lowerPriceBand - * @property {CentsSatsUsdPattern} upperPriceBand - * @property {MetricPattern18} capRaw - * @property {MetricPattern18} investorCapRaw - * @property {_1m1w1y24hPattern2} sellSideRiskRatio - * @property {_1m1wPattern2} sellSideRiskRatio24hEma - * @property {CumulativeHeightPattern} peakRegret - * @property {BpsPercentRatioPattern} peakRegretRelToRealizedCap - * @property {MetricPattern1} profitValueCreated - * @property {MetricPattern1} profitValueDestroyed - * @property {MetricPattern1} lossValueCreated - * @property {MetricPattern1} lossValueDestroyed - * @property {MetricPattern1} valueCreated - * @property {MetricPattern1} valueDestroyed - * @property {MetricPattern1} capitulationFlow - * @property {MetricPattern1} profitFlow - * @property {_1m1w1y24hPattern} valueCreatedSum - * @property {_1m1w1y24hPattern} valueDestroyedSum - * @property {_1m1w1y24hPattern} grossPnlSum - * @property {MetricPattern1} netPnlChange1m - * @property {BpsPercentRatioPattern} netPnlChange1mRelToRealizedCap - * @property {BpsPercentRatioPattern} netPnlChange1mRelToMarketCap - * @property {BaseCumulativePattern} sentInProfit - * @property {_2wPattern} sentInProfitEma - * @property {BaseCumulativePattern} sentInLoss - * @property {_2wPattern} sentInLossEma - * @property {MetricPattern1} realizedCapCents - * @property {CumulativeHeightPattern} realizedProfit - * @property {CumulativeHeightPattern} realizedLoss - * @property {MetricPattern1} realizedCap - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {MetricPattern1} realizedCapChange1m - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} negRealizedLoss - * @property {CumulativeHeightPattern} netRealizedPnl - * @property {MetricPattern1} netRealizedPnlEma1w - * @property {CentsUsdPattern} grossPnl - * @property {MetricPattern1} realizedProfitEma1w - * @property {MetricPattern1} realizedLossEma1w - * @property {_1m1w1y24hPattern} sopr - * @property {_1m1wPattern} sopr24hEma - * @property {BpsPercentRatioPattern} realizedProfitRelToRealizedCap - * @property {BpsPercentRatioPattern} realizedLossRelToRealizedCap - * @property {BpsPercentRatioPattern} netRealizedPnlRelToRealizedCap - * @property {BpsPercentRatioPattern} realizedCapRelToOwnMarketCap - * @property {_1m1w1y24hPattern} realizedProfitSum - * @property {_1m1w1y24hPattern} realizedLossSum - * @property {_1m1w1y24hPattern} realizedProfitToLossRatio - * @property {RatioPattern} realizedPriceRatioPercentiles - * @property {RatioPattern2} realizedPriceRatioStdDev - * @property {RatioPattern} investorPriceRatioPercentiles - * @property {RatioPattern2} investorPriceRatioStdDev + * @property {MetricPattern1} dormancy + * @property {MetricPattern1} velocity */ /** @@ -5056,46 +4809,77 @@ function create_2wPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_MaxAge - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _1w - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _1m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _2m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _3m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _4m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _5m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _6m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _1y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _2y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _3y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _4y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _5y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _6y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _7y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _8y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _10y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _12y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _15y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1w + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _3m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _4m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _5m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _6m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _3y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _4y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _5y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _6y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _7y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _8y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _10y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _12y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _15y */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_MinAge - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _1d - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _1w - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _1m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _2m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _3m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _4m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _5m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _6m - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _1y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _2y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _3y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _4y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _5y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _6y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _7y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _8y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _10y - * @property {ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4} _12y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1d + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1w + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _3m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _4m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _5m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _6m + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _3y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _4y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _5y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _6y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _7y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _8y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _10y + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _12y + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Epoch + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _0 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _1 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _3 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _4 + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Class + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2009 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2010 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2011 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2012 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2013 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2014 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2015 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2016 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2017 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2018 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2019 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2020 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2021 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2022 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2023 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2024 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2025 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} _2026 */ /** @@ -5151,50 +4935,19 @@ function create_2wPattern(client, acc) { * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _100kBtc */ -/** - * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Epoch - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _0 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _1 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _3 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _4 - */ - -/** - * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Class - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2009 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2010 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2011 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2012 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2013 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2014 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2015 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2016 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2017 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2018 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2019 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2020 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2021 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2022 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2023 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2024 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2025 - * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} _2026 - */ - /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Type - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2pk65 - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2pk33 - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2pkh - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2ms - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2sh - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2wpkh - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2wsh - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2tr - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} p2a - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} unknown - * @property {OutputsRealizedRelativeSupplyUnrealizedPattern} empty + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2pk65 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2pk33 + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2pkh + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2ms + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2sh + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2wpkh + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2wsh + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2tr + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} p2a + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} unknown + * @property {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} empty */ /** @@ -7185,11 +6938,18 @@ class BrkClient extends BrkClientBase { supply: createChangeHalvedTotalPattern(this, 'supply'), outputs: createUtxoPattern(this, 'utxo_count'), activity: createCoinblocksCoindaysSentPattern(this, ''), - realized: createAdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, ''), + realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, ''), costBasis: createInvestedMaxMinPercentilesPattern(this, ''), unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, ''), + adjusted: { + adjustedValueCreated: createMetricPattern1(this, 'adjusted_value_created'), + adjustedValueDestroyed: createMetricPattern1(this, 'adjusted_value_destroyed'), + adjustedValueCreatedSum: create_1m1w1y24hPattern(this, 'adjusted_value_created'), + adjustedValueDestroyedSum: create_1m1w1y24hPattern(this, 'adjusted_value_destroyed'), + adjustedSopr: create_1m1w1y24hPattern(this, 'adjusted_sopr'), + adjustedSoprEma: create_1m1wPattern(this, 'adjusted_sopr_24h_ema'), + }, relative: { - negUnrealizedLossRelToMarketCap: createBpsPercentRatioPattern(this, 'neg_unrealized_loss_rel_to_market_cap'), investedCapitalInProfitRelToRealizedCap: createBpsPercentRatioPattern(this, 'invested_capital_in_profit_rel_to_realized_cap'), investedCapitalInLossRelToRealizedCap: createBpsPercentRatioPattern(this, 'invested_capital_in_loss_rel_to_realized_cap'), supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_profit_rel_to_own_supply'), @@ -7197,86 +6957,43 @@ class BrkClient extends BrkClientBase { 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'), + negUnrealizedLossRelToMarketCap: createBpsPercentRatioPattern(this, 'neg_unrealized_loss_rel_to_market_cap'), nupl: createMetricPattern1(this, 'nupl'), unrealizedProfitRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_own_gross_pnl'), unrealizedLossRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_own_gross_pnl'), negUnrealizedLossRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'neg_unrealized_loss_rel_to_own_gross_pnl'), netUnrealizedPnlRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'), }, + dormancy: createMetricPattern1(this, 'dormancy'), + velocity: createMetricPattern1(this, 'velocity'), }, sth: { supply: createChangeHalvedTotalPattern(this, 'sth_supply'), outputs: createUtxoPattern(this, 'sth_utxo_count'), activity: createCoinblocksCoindaysSentPattern(this, 'sth'), - realized: createAdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, 'sth'), + realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, 'sth'), costBasis: createInvestedMaxMinPercentilesPattern(this, 'sth'), unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, 'sth'), relative: createInvestedNegNetNuplSupplyUnrealizedPattern3(this, 'sth'), + dormancy: createMetricPattern1(this, 'sth_dormancy'), + velocity: createMetricPattern1(this, 'sth_velocity'), + adjustedValueCreated: createMetricPattern1(this, 'sth_adjusted_value_created'), + adjustedValueDestroyed: createMetricPattern1(this, 'sth_adjusted_value_destroyed'), + adjustedValueCreatedSum: create_1m1w1y24hPattern(this, 'sth_adjusted_value_created'), + adjustedValueDestroyedSum: create_1m1w1y24hPattern(this, 'sth_adjusted_value_destroyed'), + adjustedSopr: create_1m1w1y24hPattern(this, 'sth_adjusted_sopr'), + adjustedSoprEma: create_1m1wPattern(this, 'sth_adjusted_sopr_24h_ema'), }, lth: { supply: createChangeHalvedTotalPattern(this, 'lth_supply'), outputs: createUtxoPattern(this, 'lth_utxo_count'), activity: createCoinblocksCoindaysSentPattern(this, 'lth'), - realized: { - investorPrice: createCentsSatsUsdPattern(this, 'lth_investor_price'), - investorPriceRatio: createBpsRatioPattern(this, 'lth_investor_price_ratio'), - lowerPriceBand: createCentsSatsUsdPattern(this, 'lth_lower_price_band'), - upperPriceBand: createCentsSatsUsdPattern(this, 'lth_upper_price_band'), - capRaw: createMetricPattern18(this, 'lth_cap_raw'), - investorCapRaw: createMetricPattern18(this, 'lth_investor_cap_raw'), - sellSideRiskRatio: create_1m1w1y24hPattern2(this, 'lth_sell_side_risk_ratio'), - sellSideRiskRatio24hEma: create_1m1wPattern2(this, 'lth_sell_side_risk_ratio_24h_ema'), - peakRegret: createCumulativeHeightPattern(this, 'lth_realized_peak_regret'), - peakRegretRelToRealizedCap: createBpsPercentRatioPattern(this, 'lth_realized_peak_regret_rel_to_realized_cap'), - profitValueCreated: createMetricPattern1(this, 'lth_profit_value_created'), - profitValueDestroyed: createMetricPattern1(this, 'lth_profit_value_destroyed'), - lossValueCreated: createMetricPattern1(this, 'lth_loss_value_created'), - lossValueDestroyed: createMetricPattern1(this, 'lth_loss_value_destroyed'), - valueCreated: createMetricPattern1(this, 'lth_value_created'), - valueDestroyed: createMetricPattern1(this, 'lth_value_destroyed'), - capitulationFlow: createMetricPattern1(this, 'lth_capitulation_flow'), - profitFlow: createMetricPattern1(this, 'lth_profit_flow'), - valueCreatedSum: create_1m1w1y24hPattern(this, 'lth_value_created'), - valueDestroyedSum: create_1m1w1y24hPattern(this, 'lth_value_destroyed'), - grossPnlSum: create_1m1w1y24hPattern(this, 'lth_gross_pnl_sum'), - netPnlChange1m: createMetricPattern1(this, 'lth_net_pnl_change_1m'), - netPnlChange1mRelToRealizedCap: createBpsPercentRatioPattern(this, 'lth_net_pnl_change_1m_rel_to_realized_cap'), - netPnlChange1mRelToMarketCap: createBpsPercentRatioPattern(this, 'lth_net_pnl_change_1m_rel_to_market_cap'), - sentInProfit: createBaseCumulativePattern(this, 'lth_sent_in_profit'), - sentInProfitEma: create_2wPattern(this, 'lth_sent_in_profit_ema_2w'), - sentInLoss: createBaseCumulativePattern(this, 'lth_sent_in_loss'), - sentInLossEma: create_2wPattern(this, 'lth_sent_in_loss_ema_2w'), - realizedCapCents: createMetricPattern1(this, 'lth_realized_cap_cents'), - realizedProfit: createCumulativeHeightPattern(this, 'lth_realized_profit'), - realizedLoss: createCumulativeHeightPattern(this, 'lth_realized_loss'), - realizedCap: createMetricPattern1(this, 'lth_realized_cap'), - realizedPrice: createCentsSatsUsdPattern(this, 'lth_realized_price'), - realizedPriceRatio: createBpsRatioPattern(this, 'lth_realized_price_ratio'), - realizedCapChange1m: createMetricPattern1(this, 'lth_realized_cap_change_1m'), - mvrv: createMetricPattern1(this, 'lth_mvrv'), - negRealizedLoss: createMetricPattern1(this, 'lth_neg_realized_loss'), - netRealizedPnl: createCumulativeHeightPattern(this, 'lth_net_realized_pnl'), - netRealizedPnlEma1w: createMetricPattern1(this, 'lth_net_realized_pnl_ema_1w'), - grossPnl: createCentsUsdPattern(this, 'lth_realized_gross_pnl'), - realizedProfitEma1w: createMetricPattern1(this, 'lth_realized_profit_ema_1w'), - realizedLossEma1w: createMetricPattern1(this, 'lth_realized_loss_ema_1w'), - sopr: create_1m1w1y24hPattern(this, 'lth_sopr'), - sopr24hEma: create_1m1wPattern(this, 'lth_sopr_24h_ema'), - realizedProfitRelToRealizedCap: createBpsPercentRatioPattern(this, 'lth_realized_profit_rel_to_realized_cap'), - realizedLossRelToRealizedCap: createBpsPercentRatioPattern(this, 'lth_realized_loss_rel_to_realized_cap'), - netRealizedPnlRelToRealizedCap: createBpsPercentRatioPattern(this, 'lth_net_realized_pnl_rel_to_realized_cap'), - realizedCapRelToOwnMarketCap: createBpsPercentRatioPattern(this, 'lth_realized_cap_rel_to_own_market_cap'), - realizedProfitSum: create_1m1w1y24hPattern(this, 'lth_realized_profit'), - realizedLossSum: create_1m1w1y24hPattern(this, 'lth_realized_loss'), - realizedProfitToLossRatio: create_1m1w1y24hPattern(this, 'lth_realized_profit_to_loss_ratio'), - realizedPriceRatioPercentiles: createRatioPattern(this, 'lth_realized_price_ratio'), - realizedPriceRatioStdDev: createRatioPattern2(this, 'lth_realized_price_ratio'), - investorPriceRatioPercentiles: createRatioPattern(this, 'lth_investor_price_ratio'), - investorPriceRatioStdDev: createRatioPattern2(this, 'lth_investor_price_ratio'), - }, + realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, 'lth'), costBasis: createInvestedMaxMinPercentilesPattern(this, 'lth'), unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, 'lth'), relative: createInvestedNegNetNuplSupplyUnrealizedPattern3(this, 'lth'), + dormancy: createMetricPattern1(this, 'lth_dormancy'), + velocity: createMetricPattern1(this, 'lth_velocity'), }, ageRange: { upTo1h: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'utxos_under_1h_old'), @@ -7302,44 +7019,71 @@ class BrkClient extends BrkClientBase { from15y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'utxos_over_15y_old'), }, maxAge: { - _1w: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_1w_old'), - _1m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_1m_old'), - _2m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_2m_old'), - _3m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_3m_old'), - _4m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_4m_old'), - _5m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_5m_old'), - _6m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_6m_old'), - _1y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_1y_old'), - _2y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_2y_old'), - _3y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_3y_old'), - _4y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_4y_old'), - _5y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_5y_old'), - _6y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_6y_old'), - _7y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_7y_old'), - _8y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_8y_old'), - _10y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_10y_old'), - _12y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_12y_old'), - _15y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_under_15y_old'), + _1w: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_1w_old'), + _1m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_1m_old'), + _2m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_2m_old'), + _3m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_3m_old'), + _4m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_4m_old'), + _5m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_5m_old'), + _6m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_6m_old'), + _1y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_1y_old'), + _2y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_2y_old'), + _3y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_3y_old'), + _4y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_4y_old'), + _5y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_5y_old'), + _6y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_6y_old'), + _7y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_7y_old'), + _8y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_8y_old'), + _10y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_10y_old'), + _12y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_12y_old'), + _15y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_under_15y_old'), }, minAge: { - _1d: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_1d_old'), - _1w: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_1w_old'), - _1m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_1m_old'), - _2m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_2m_old'), - _3m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_3m_old'), - _4m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_4m_old'), - _5m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_5m_old'), - _6m: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_6m_old'), - _1y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_1y_old'), - _2y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_2y_old'), - _3y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_3y_old'), - _4y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_4y_old'), - _5y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_5y_old'), - _6y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_6y_old'), - _7y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_7y_old'), - _8y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_8y_old'), - _10y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_10y_old'), - _12y: createActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(this, 'utxos_over_12y_old'), + _1d: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_1d_old'), + _1w: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_1w_old'), + _1m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_1m_old'), + _2m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_2m_old'), + _3m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_3m_old'), + _4m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_4m_old'), + _5m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_5m_old'), + _6m: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_6m_old'), + _1y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_1y_old'), + _2y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_2y_old'), + _3y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_3y_old'), + _4y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_4y_old'), + _5y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_5y_old'), + _6y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_6y_old'), + _7y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_7y_old'), + _8y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_8y_old'), + _10y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_10y_old'), + _12y: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'utxos_over_12y_old'), + }, + epoch: { + _0: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'epoch_0'), + _1: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'epoch_1'), + _2: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'epoch_2'), + _3: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'epoch_3'), + _4: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'epoch_4'), + }, + class: { + _2009: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2009'), + _2010: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2010'), + _2011: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2011'), + _2012: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2012'), + _2013: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2013'), + _2014: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2014'), + _2015: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2015'), + _2016: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2016'), + _2017: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2017'), + _2018: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2018'), + _2019: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2019'), + _2020: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2020'), + _2021: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2021'), + _2022: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2022'), + _2023: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2023'), + _2024: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2024'), + _2025: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2025'), + _2026: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2026'), }, geAmount: { _1sat: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'utxos_over_1sat'), @@ -7388,45 +7132,18 @@ class BrkClient extends BrkClientBase { _10kBtc: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'utxos_under_10k_btc'), _100kBtc: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'utxos_under_100k_btc'), }, - epoch: { - _0: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'epoch_0'), - _1: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'epoch_1'), - _2: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'epoch_2'), - _3: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'epoch_3'), - _4: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'epoch_4'), - }, - class: { - _2009: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2009'), - _2010: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2010'), - _2011: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2011'), - _2012: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2012'), - _2013: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2013'), - _2014: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2014'), - _2015: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2015'), - _2016: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2016'), - _2017: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2017'), - _2018: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2018'), - _2019: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2019'), - _2020: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2020'), - _2021: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2021'), - _2022: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2022'), - _2023: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2023'), - _2024: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2024'), - _2025: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2025'), - _2026: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'class_2026'), - }, type: { - p2pk65: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2pk65'), - p2pk33: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2pk33'), - p2pkh: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2pkh'), - p2ms: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2ms'), - p2sh: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2sh'), - p2wpkh: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2wpkh'), - p2wsh: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2wsh'), - p2tr: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2tr'), - p2a: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2a'), - unknown: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'unknown_outputs'), - empty: createOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'empty_outputs'), + p2pk65: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2pk65'), + p2pk33: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2pk33'), + p2pkh: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2pkh'), + p2ms: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2ms'), + p2sh: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2sh'), + p2wpkh: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2wpkh'), + p2wsh: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2wsh'), + p2tr: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2tr'), + p2a: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'p2a'), + unknown: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'unknown_outputs'), + empty: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'empty_outputs'), }, }, addressCohorts: { diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 622ab4ab5..ab7fc0709 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2064,17 +2064,11 @@ class MetricPattern35(Generic[T]): # Reusable structural pattern classes -class AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern: +class CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.adjusted_sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'adjusted_sopr')) - self.adjusted_sopr_ema: _1m1wPattern = _1m1wPattern(client, _m(acc, 'adjusted_sopr_24h_ema')) - self.adjusted_value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'adjusted_value_created')) - self.adjusted_value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'adjusted_value_created')) - self.adjusted_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'adjusted_value_destroyed')) - self.adjusted_value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'adjusted_value_destroyed')) self.cap_raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'cap_raw')) self.capitulation_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'capitulation_flow')) self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_gross_pnl')) @@ -2131,102 +2125,6 @@ class AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedS self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_destroyed')) -class CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cap_raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'cap_raw')) - self.capitulation_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'capitulation_flow')) - self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_gross_pnl')) - self.gross_pnl_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')) - self.investor_cap_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, _m(acc, 'investor_cap_raw')) - self.investor_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'investor_price')) - self.investor_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'investor_price_ratio')) - self.loss_value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_created')) - self.loss_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_destroyed')) - self.lower_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'lower_price_band')) - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) - self.net_pnl_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_pnl_change_1m')) - self.net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_market_cap')) - self.net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_realized_cap')) - self.net_realized_pnl: CumulativeHeightPattern[CentsSigned] = CumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')) - self.net_realized_pnl_ema_1w: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')) - self.net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')) - self.peak_regret: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_peak_regret')) - self.peak_regret_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_peak_regret_rel_to_realized_cap')) - self.profit_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'profit_flow')) - self.profit_value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_created')) - self.profit_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_destroyed')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_cap_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_cap_change_1m')) - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) - self.realized_loss_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_ema_1w')) - self.realized_loss_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_profit_ema_1w')) - self.realized_profit_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')) - self.sell_side_risk_ratio: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')) - self.sell_side_risk_ratio_24h_ema: _1m1wPattern2 = _1m1wPattern2(client, _m(acc, 'sell_side_risk_ratio_24h_ema')) - self.sent_in_loss: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent_in_loss')) - self.sent_in_loss_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_in_loss_ema_2w')) - self.sent_in_profit: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent_in_profit')) - self.sent_in_profit_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_in_profit_ema_2w')) - self.sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'sopr')) - self.sopr_24h_ema: _1m1wPattern = _1m1wPattern(client, _m(acc, 'sopr_24h_ema')) - self.upper_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'upper_price_band')) - self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_created')) - self.value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_created')) - self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) - self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_destroyed')) - -class CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.capitulation_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'capitulation_flow')) - self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_gross_pnl')) - self.gross_pnl_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')) - self.loss_value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_created')) - self.loss_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_destroyed')) - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) - self.net_pnl_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_pnl_change_1m')) - self.net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_market_cap')) - self.net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_realized_cap')) - self.net_realized_pnl: CumulativeHeightPattern[CentsSigned] = CumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')) - self.net_realized_pnl_ema_1w: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')) - self.net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')) - self.profit_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'profit_flow')) - self.profit_value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_created')) - self.profit_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_destroyed')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_cap_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_cap_change_1m')) - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) - self.realized_loss_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_ema_1w')) - self.realized_loss_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_profit_ema_1w')) - self.realized_profit_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')) - self.sent_in_loss: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent_in_loss')) - self.sent_in_loss_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_in_loss_ema_2w')) - self.sent_in_profit: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent_in_profit')) - self.sent_in_profit_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_in_profit_ema_2w')) - self.sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'sopr')) - self.sopr_24h_ema: _1m1wPattern = _1m1wPattern(client, _m(acc, 'sopr_24h_ema')) - self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_created')) - self.value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_created')) - self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) - self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_destroyed')) - class _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern: """Pattern struct for repeated tree structure.""" @@ -2261,6 +2159,40 @@ class _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern: self.sma: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sma_4y')) self.zscore: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'zscore_4y')) +class GrossMvrvNegNetRealizedSentSoprValuePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_gross_pnl')) + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) + self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) + self.net_realized_pnl: CumulativeHeightPattern[CentsSigned] = CumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')) + self.net_realized_pnl_ema_1w: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')) + self.net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')) + self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) + self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) + self.realized_cap_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_cap_change_1m')) + self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) + self.realized_loss_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_ema_1w')) + self.realized_loss_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')) + self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) + self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) + self.realized_price_ratio_percentiles: RatioPattern = RatioPattern(client, _m(acc, 'realized_price_ratio')) + self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) + self.realized_profit_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_profit_ema_1w')) + self.realized_profit_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')) + self.sent_in_loss: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent_in_loss')) + self.sent_in_loss_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_in_loss_ema_2w')) + self.sent_in_profit: BaseCumulativePattern = BaseCumulativePattern(client, _m(acc, 'sent_in_profit')) + self.sent_in_profit_ema: _2wPattern = _2wPattern(client, _m(acc, 'sent_in_profit_ema_2w')) + self.sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'sopr')) + self.sopr_24h_ema: _1m1wPattern = _1m1wPattern(client, _m(acc, 'sopr_24h_ema')) + self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_created')) + self.value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_created')) + self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) + self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_destroyed')) + class InvestedNegNetNuplSupplyUnrealizedPattern3: """Pattern struct for repeated tree structure.""" @@ -2287,31 +2219,6 @@ class InvestedNegNetNuplSupplyUnrealizedPattern3: self.unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_gross_pnl')) self.unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_market_cap')) -class GrossMvrvNegNetRealizedSoprPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_gross_pnl')) - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) - self.net_realized_pnl: CumulativeHeightPattern[CentsSigned] = CumulativeHeightPattern(client, _m(acc, 'net_realized_pnl')) - self.net_realized_pnl_ema_1w: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl_ema_1w')) - self.net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_cap_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_cap_change_1m')) - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) - self.realized_loss_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_ema_1w')) - self.realized_loss_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_profit_ema_1w')) - self.realized_profit_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')) - self.sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'sopr')) - self.sopr_24h_ema: _1m1wPattern = _1m1wPattern(client, _m(acc, 'sopr_24h_ema')) - class Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern: """Pattern struct for repeated tree structure.""" @@ -2505,6 +2412,22 @@ class AverageGainsLossesRsiStochPattern: self.stoch_rsi_d: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'stoch_d_24h')) self.stoch_rsi_k: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'stoch_k_24h')) +class NegNetNuplSupplyUnrealizedPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'neg_unrealized_loss_rel_to_market_cap')) + self.net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_market_cap')) + self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'nupl')) + self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_circulating_supply')) + self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_own_supply')) + self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_circulating_supply')) + self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_own_supply')) + self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_rel_to_circulating_supply')) + self.unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')) + self.unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')) + class AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern: """Pattern struct for repeated tree structure.""" @@ -2550,21 +2473,6 @@ class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern: self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p90')) self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'sum')) -class NetNuplSupplyUnrealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_market_cap')) - self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'nupl')) - self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_circulating_supply')) - self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_own_supply')) - self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_circulating_supply')) - self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_own_supply')) - self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_rel_to_circulating_supply')) - self.unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')) - self.unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')) - class AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2603,10 +2511,10 @@ class ActivityAddrOutputsRealizedRelativeSupplyUnrealizedPattern: self.addr_count: MetricPattern1[StoredU64] = MetricPattern1(client, _m(acc, 'addr_count')) self.addr_count_change_1m: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'addr_count_change_1m')) self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: GrossMvrvNegNetRealizedSoprPattern = GrossMvrvNegNetRealizedSoprPattern(client, acc) - self.relative: NetNuplSupplyUnrealizedPattern = NetNuplSupplyUnrealizedPattern(client, acc) + self.realized: MvrvRealizedPattern = MvrvRealizedPattern(client, acc) + self.relative: SupplyPattern = SupplyPattern(client, _m(acc, 'supply_in')) self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: NegNetSupplyUnrealizedPattern = NegNetSupplyUnrealizedPattern(client, acc) + self.unrealized: SupplyPattern2 = SupplyPattern2(client, _m(acc, 'supply_in')) class AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2643,23 +2551,36 @@ class ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern: self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, acc) self.cost_basis: MaxMinPattern = MaxMinPattern(client, _m(acc, 'cost_basis')) self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, acc) + self.realized: GrossMvrvNegNetRealizedSentSoprValuePattern = GrossMvrvNegNetRealizedSentSoprValuePattern(client, acc) self.relative: InvestedNegNetNuplSupplyUnrealizedPattern = InvestedNegNetNuplSupplyUnrealizedPattern(client, acc) self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, _m(acc, 'supply')) self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, acc) -class ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4: +class GrossNegNetSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, acc) - self.cost_basis: MaxMinPattern = MaxMinPattern(client, _m(acc, 'cost_basis')) - self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern = CapitulationGrossLossMvrvNegNetProfitRealizedSentSoprValuePattern(client, acc) - self.relative: NetNuplSupplyUnrealizedPattern = NetNuplSupplyUnrealizedPattern(client, acc) - self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: NegNetSupplyUnrealizedPattern = NegNetSupplyUnrealizedPattern(client, acc) + self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')) + self.neg_unrealized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) + self.net_unrealized_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) + self.supply_in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')) + self.supply_in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')) + self.unrealized_loss: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) + self.unrealized_profit: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) + +class MvrvRealizedPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) + self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) + self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) + self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) + self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) + self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) + self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) class _1m1w1y24hBaseCumulativePattern: """Pattern struct for repeated tree structure.""" @@ -2673,6 +2594,18 @@ class _1m1w1y24hBaseCumulativePattern: self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')) +class ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.activity: SentPattern = SentPattern(client, _m(acc, 'sent')) + self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) + self.realized: GrossMvrvNegNetRealizedSentSoprValuePattern = GrossMvrvNegNetRealizedSentSoprValuePattern(client, acc) + self.relative: NegNetNuplSupplyUnrealizedPattern = NegNetNuplSupplyUnrealizedPattern(client, acc) + self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, _m(acc, 'supply')) + self.unrealized: GrossNegNetSupplyUnrealizedPattern = GrossNegNetSupplyUnrealizedPattern(client, acc) + class ActivityOutputsRealizedRelativeSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -2680,10 +2613,10 @@ class ActivityOutputsRealizedRelativeSupplyUnrealizedPattern: """Create pattern node with accumulated metric name.""" self.activity: SentPattern = SentPattern(client, _m(acc, 'sent')) self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: GrossMvrvNegNetRealizedSoprPattern = GrossMvrvNegNetRealizedSoprPattern(client, acc) - self.relative: NetNuplSupplyUnrealizedPattern = NetNuplSupplyUnrealizedPattern(client, acc) + self.realized: MvrvRealizedPattern = MvrvRealizedPattern(client, acc) + self.relative: SupplyPattern = SupplyPattern(client, _m(acc, 'supply_in')) self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: NegNetSupplyUnrealizedPattern = NegNetSupplyUnrealizedPattern(client, acc) + self.unrealized: SupplyPattern2 = SupplyPattern2(client, _m(acc, 'supply_in')) class BalanceBothReactivatedReceivingSendingPattern: """Pattern struct for repeated tree structure.""" @@ -2697,18 +2630,6 @@ class BalanceBothReactivatedReceivingSendingPattern: self.receiving: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern[StoredU32] = AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, _m(acc, 'receiving')) self.sending: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern[StoredU32] = AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, _m(acc, 'sending')) -class NegNetSupplyUnrealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.neg_unrealized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.net_unrealized_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.supply_in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')) - self.supply_in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')) - self.unrealized_loss: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.unrealized_profit: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) - class EmaHistogramLineSignalPattern: """Pattern struct for repeated tree structure.""" @@ -2720,28 +2641,6 @@ class EmaHistogramLineSignalPattern: self.line: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'line_24h')) self.signal: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'signal_24h')) -class MvrvRealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - -class OutputsRealizedRelativeSupplyUnrealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: MvrvRealizedPattern = MvrvRealizedPattern(client, acc) - self.relative: SupplyPattern = SupplyPattern(client, _m(acc, 'supply_in')) - self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: SupplyPattern2 = SupplyPattern2(client, _m(acc, 'supply_in')) - class _1m1w1y24hPattern2: """Pattern struct for repeated tree structure.""" @@ -4307,11 +4206,21 @@ class MetricsTree_Distribution_AddressesData: self.funded: MetricPattern34[FundedAddressData] = MetricPattern34(client, 'fundedaddressdata') self.empty: MetricPattern35[EmptyAddressData] = MetricPattern35(client, 'emptyaddressdata') +class MetricsTree_Distribution_UtxoCohorts_All_Adjusted: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.adjusted_value_created: MetricPattern1[Cents] = MetricPattern1(client, 'adjusted_value_created') + self.adjusted_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, 'adjusted_value_destroyed') + self.adjusted_value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'adjusted_value_created') + self.adjusted_value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'adjusted_value_destroyed') + self.adjusted_sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'adjusted_sopr') + self.adjusted_sopr_ema: _1m1wPattern = _1m1wPattern(client, 'adjusted_sopr_24h_ema') + class MetricsTree_Distribution_UtxoCohorts_All_Relative: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'neg_unrealized_loss_rel_to_market_cap') self.invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'invested_capital_in_profit_rel_to_realized_cap') self.invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'invested_capital_in_loss_rel_to_realized_cap') self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_profit_rel_to_own_supply') @@ -4319,6 +4228,7 @@ class MetricsTree_Distribution_UtxoCohorts_All_Relative: 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.neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'neg_unrealized_loss_rel_to_market_cap') self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, 'nupl') 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') @@ -4332,10 +4242,13 @@ class MetricsTree_Distribution_UtxoCohorts_All: self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, 'supply') self.outputs: UtxoPattern = UtxoPattern(client, 'utxo_count') self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, '') - self.realized: AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, '') + self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, '') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, '') self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, '') + self.adjusted: MetricsTree_Distribution_UtxoCohorts_All_Adjusted = MetricsTree_Distribution_UtxoCohorts_All_Adjusted(client) self.relative: MetricsTree_Distribution_UtxoCohorts_All_Relative = MetricsTree_Distribution_UtxoCohorts_All_Relative(client) + self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, 'dormancy') + self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, 'velocity') class MetricsTree_Distribution_UtxoCohorts_Sth: """Metrics tree node.""" @@ -4344,70 +4257,18 @@ class MetricsTree_Distribution_UtxoCohorts_Sth: self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, 'sth_supply') self.outputs: UtxoPattern = UtxoPattern(client, 'sth_utxo_count') self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, 'sth') - self.realized: AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, 'sth') + self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, 'sth') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'sth') self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, 'sth') self.relative: InvestedNegNetNuplSupplyUnrealizedPattern3 = InvestedNegNetNuplSupplyUnrealizedPattern3(client, 'sth') - -class MetricsTree_Distribution_UtxoCohorts_Lth_Realized: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.investor_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'lth_investor_price') - self.investor_price_ratio: BpsRatioPattern = BpsRatioPattern(client, 'lth_investor_price_ratio') - self.lower_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'lth_lower_price_band') - self.upper_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'lth_upper_price_band') - self.cap_raw: MetricPattern18[CentsSats] = MetricPattern18(client, 'lth_cap_raw') - self.investor_cap_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, 'lth_investor_cap_raw') - self.sell_side_risk_ratio: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, 'lth_sell_side_risk_ratio') - self.sell_side_risk_ratio_24h_ema: _1m1wPattern2 = _1m1wPattern2(client, 'lth_sell_side_risk_ratio_24h_ema') - self.peak_regret: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, 'lth_realized_peak_regret') - self.peak_regret_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_realized_peak_regret_rel_to_realized_cap') - self.profit_value_created: MetricPattern1[Cents] = MetricPattern1(client, 'lth_profit_value_created') - self.profit_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, 'lth_profit_value_destroyed') - self.loss_value_created: MetricPattern1[Cents] = MetricPattern1(client, 'lth_loss_value_created') - self.loss_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, 'lth_loss_value_destroyed') - self.value_created: MetricPattern1[Cents] = MetricPattern1(client, 'lth_value_created') - self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, 'lth_value_destroyed') - self.capitulation_flow: MetricPattern1[Dollars] = MetricPattern1(client, 'lth_capitulation_flow') - self.profit_flow: MetricPattern1[Dollars] = MetricPattern1(client, 'lth_profit_flow') - self.value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'lth_value_created') - self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'lth_value_destroyed') - self.gross_pnl_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'lth_gross_pnl_sum') - self.net_pnl_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, 'lth_net_pnl_change_1m') - self.net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_net_pnl_change_1m_rel_to_realized_cap') - self.net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_net_pnl_change_1m_rel_to_market_cap') - self.sent_in_profit: BaseCumulativePattern = BaseCumulativePattern(client, 'lth_sent_in_profit') - self.sent_in_profit_ema: _2wPattern = _2wPattern(client, 'lth_sent_in_profit_ema_2w') - self.sent_in_loss: BaseCumulativePattern = BaseCumulativePattern(client, 'lth_sent_in_loss') - self.sent_in_loss_ema: _2wPattern = _2wPattern(client, 'lth_sent_in_loss_ema_2w') - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, 'lth_realized_cap_cents') - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, 'lth_realized_profit') - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, 'lth_realized_loss') - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, 'lth_realized_cap') - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'lth_realized_price') - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, 'lth_realized_price_ratio') - self.realized_cap_change_1m: MetricPattern1[CentsSigned] = MetricPattern1(client, 'lth_realized_cap_change_1m') - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_mvrv') - self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, 'lth_neg_realized_loss') - self.net_realized_pnl: CumulativeHeightPattern[CentsSigned] = CumulativeHeightPattern(client, 'lth_net_realized_pnl') - self.net_realized_pnl_ema_1w: MetricPattern1[CentsSigned] = MetricPattern1(client, 'lth_net_realized_pnl_ema_1w') - self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, 'lth_realized_gross_pnl') - self.realized_profit_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, 'lth_realized_profit_ema_1w') - self.realized_loss_ema_1w: MetricPattern1[Cents] = MetricPattern1(client, 'lth_realized_loss_ema_1w') - self.sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_sopr') - self.sopr_24h_ema: _1m1wPattern = _1m1wPattern(client, 'lth_sopr_24h_ema') - self.realized_profit_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_realized_profit_rel_to_realized_cap') - self.realized_loss_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_realized_loss_rel_to_realized_cap') - self.net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_net_realized_pnl_rel_to_realized_cap') - self.realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'lth_realized_cap_rel_to_own_market_cap') - self.realized_profit_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'lth_realized_profit') - self.realized_loss_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'lth_realized_loss') - self.realized_profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_realized_profit_to_loss_ratio') - self.realized_price_ratio_percentiles: RatioPattern = RatioPattern(client, 'lth_realized_price_ratio') - self.realized_price_ratio_std_dev: RatioPattern2 = RatioPattern2(client, 'lth_realized_price_ratio') - self.investor_price_ratio_percentiles: RatioPattern = RatioPattern(client, 'lth_investor_price_ratio') - self.investor_price_ratio_std_dev: RatioPattern2 = RatioPattern2(client, 'lth_investor_price_ratio') + self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, 'sth_dormancy') + self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, 'sth_velocity') + self.adjusted_value_created: MetricPattern1[Cents] = MetricPattern1(client, 'sth_adjusted_value_created') + self.adjusted_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, 'sth_adjusted_value_destroyed') + self.adjusted_value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'sth_adjusted_value_created') + self.adjusted_value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'sth_adjusted_value_destroyed') + self.adjusted_sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'sth_adjusted_sopr') + self.adjusted_sopr_ema: _1m1wPattern = _1m1wPattern(client, 'sth_adjusted_sopr_24h_ema') class MetricsTree_Distribution_UtxoCohorts_Lth: """Metrics tree node.""" @@ -4416,10 +4277,12 @@ class MetricsTree_Distribution_UtxoCohorts_Lth: self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, 'lth_supply') self.outputs: UtxoPattern = UtxoPattern(client, 'lth_utxo_count') self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, 'lth') - self.realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized = MetricsTree_Distribution_UtxoCohorts_Lth_Realized(client) + self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, 'lth') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'lth') self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, 'lth') self.relative: InvestedNegNetNuplSupplyUnrealizedPattern3 = InvestedNegNetNuplSupplyUnrealizedPattern3(client, 'lth') + self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_dormancy') + self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_velocity') class MetricsTree_Distribution_UtxoCohorts_AgeRange: """Metrics tree node.""" @@ -4451,47 +4314,80 @@ class MetricsTree_Distribution_UtxoCohorts_MaxAge: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1w: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_1w_old') - self._1m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_1m_old') - self._2m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_2m_old') - self._3m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_3m_old') - self._4m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_4m_old') - self._5m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_5m_old') - self._6m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_6m_old') - self._1y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_1y_old') - self._2y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_2y_old') - self._3y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_3y_old') - self._4y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_4y_old') - self._5y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_5y_old') - self._6y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_6y_old') - self._7y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_7y_old') - self._8y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_8y_old') - self._10y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_10y_old') - self._12y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_12y_old') - self._15y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_under_15y_old') + self._1w: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_1w_old') + self._1m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_1m_old') + self._2m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_2m_old') + self._3m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_3m_old') + self._4m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_4m_old') + self._5m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_5m_old') + self._6m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_6m_old') + self._1y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_1y_old') + self._2y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_2y_old') + self._3y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_3y_old') + self._4y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_4y_old') + self._5y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_5y_old') + self._6y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_6y_old') + self._7y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_7y_old') + self._8y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_8y_old') + self._10y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_10y_old') + self._12y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_12y_old') + self._15y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_under_15y_old') class MetricsTree_Distribution_UtxoCohorts_MinAge: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1d: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_1d_old') - self._1w: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_1w_old') - self._1m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_1m_old') - self._2m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_2m_old') - self._3m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_3m_old') - self._4m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_4m_old') - self._5m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_5m_old') - self._6m: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_6m_old') - self._1y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_1y_old') - self._2y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_2y_old') - self._3y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_3y_old') - self._4y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_4y_old') - self._5y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_5y_old') - self._6y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_6y_old') - self._7y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_7y_old') - self._8y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_8y_old') - self._10y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_10y_old') - self._12y: ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4 = ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern4(client, 'utxos_over_12y_old') + self._1d: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_1d_old') + self._1w: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_1w_old') + self._1m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_1m_old') + self._2m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_2m_old') + self._3m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_3m_old') + self._4m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_4m_old') + self._5m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_5m_old') + self._6m: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_6m_old') + self._1y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_1y_old') + self._2y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_2y_old') + self._3y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_3y_old') + self._4y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_4y_old') + self._5y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_5y_old') + self._6y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_6y_old') + self._7y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_7y_old') + self._8y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_8y_old') + self._10y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_10y_old') + self._12y: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'utxos_over_12y_old') + +class MetricsTree_Distribution_UtxoCohorts_Epoch: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self._0: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'epoch_0') + self._1: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'epoch_1') + self._2: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'epoch_2') + self._3: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'epoch_3') + self._4: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'epoch_4') + +class MetricsTree_Distribution_UtxoCohorts_Class: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self._2009: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2009') + self._2010: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2010') + self._2011: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2011') + self._2012: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2012') + self._2013: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2013') + self._2014: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2014') + self._2015: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2015') + self._2016: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2016') + self._2017: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2017') + self._2018: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2018') + self._2019: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2019') + self._2020: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2020') + self._2021: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2021') + self._2022: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2022') + self._2023: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2023') + self._2024: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2024') + self._2025: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2025') + self._2026: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, 'class_2026') class MetricsTree_Distribution_UtxoCohorts_GeAmount: """Metrics tree node.""" @@ -4549,54 +4445,21 @@ class MetricsTree_Distribution_UtxoCohorts_LtAmount: self._10k_btc: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'utxos_under_10k_btc') self._100k_btc: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'utxos_under_100k_btc') -class MetricsTree_Distribution_UtxoCohorts_Epoch: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self._0: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'epoch_0') - self._1: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'epoch_1') - self._2: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'epoch_2') - self._3: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'epoch_3') - self._4: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'epoch_4') - -class MetricsTree_Distribution_UtxoCohorts_Class: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self._2009: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2009') - self._2010: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2010') - self._2011: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2011') - self._2012: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2012') - self._2013: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2013') - self._2014: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2014') - self._2015: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2015') - self._2016: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2016') - self._2017: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2017') - self._2018: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2018') - self._2019: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2019') - self._2020: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2020') - self._2021: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2021') - self._2022: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2022') - self._2023: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2023') - self._2024: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2024') - self._2025: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2025') - self._2026: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'class_2026') - class MetricsTree_Distribution_UtxoCohorts_Type: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.p2pk65: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2pk65') - self.p2pk33: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2pk33') - self.p2pkh: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2pkh') - self.p2ms: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2ms') - self.p2sh: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2sh') - self.p2wpkh: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2wpkh') - self.p2wsh: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2wsh') - self.p2tr: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2tr') - self.p2a: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2a') - self.unknown: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'unknown_outputs') - self.empty: OutputsRealizedRelativeSupplyUnrealizedPattern = OutputsRealizedRelativeSupplyUnrealizedPattern(client, 'empty_outputs') + self.p2pk65: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2pk65') + self.p2pk33: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2pk33') + self.p2pkh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2pkh') + self.p2ms: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2ms') + self.p2sh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2sh') + self.p2wpkh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2wpkh') + self.p2wsh: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2wsh') + self.p2tr: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2tr') + self.p2a: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'p2a') + self.unknown: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'unknown_outputs') + self.empty: ActivityOutputsRealizedRelativeSupplyUnrealizedPattern = ActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, 'empty_outputs') class MetricsTree_Distribution_UtxoCohorts: """Metrics tree node.""" @@ -4608,11 +4471,11 @@ class MetricsTree_Distribution_UtxoCohorts: self.age_range: MetricsTree_Distribution_UtxoCohorts_AgeRange = MetricsTree_Distribution_UtxoCohorts_AgeRange(client) self.max_age: MetricsTree_Distribution_UtxoCohorts_MaxAge = MetricsTree_Distribution_UtxoCohorts_MaxAge(client) self.min_age: MetricsTree_Distribution_UtxoCohorts_MinAge = MetricsTree_Distribution_UtxoCohorts_MinAge(client) + self.epoch: MetricsTree_Distribution_UtxoCohorts_Epoch = MetricsTree_Distribution_UtxoCohorts_Epoch(client) + self.class: MetricsTree_Distribution_UtxoCohorts_Class = MetricsTree_Distribution_UtxoCohorts_Class(client) self.ge_amount: MetricsTree_Distribution_UtxoCohorts_GeAmount = MetricsTree_Distribution_UtxoCohorts_GeAmount(client) self.amount_range: MetricsTree_Distribution_UtxoCohorts_AmountRange = MetricsTree_Distribution_UtxoCohorts_AmountRange(client) self.lt_amount: MetricsTree_Distribution_UtxoCohorts_LtAmount = MetricsTree_Distribution_UtxoCohorts_LtAmount(client) - self.epoch: MetricsTree_Distribution_UtxoCohorts_Epoch = MetricsTree_Distribution_UtxoCohorts_Epoch(client) - self.class: MetricsTree_Distribution_UtxoCohorts_Class = MetricsTree_Distribution_UtxoCohorts_Class(client) self.type_: MetricsTree_Distribution_UtxoCohorts_Type = MetricsTree_Distribution_UtxoCohorts_Type(client) class MetricsTree_Distribution_AddressCohorts_GeAmount: