From ee59731ed293b28150373d6c5ea089072b5fbeea Mon Sep 17 00:00:00 2001 From: nym21 Date: Sat, 7 Mar 2026 20:54:28 +0100 Subject: [PATCH] global: snapshot --- crates/brk_client/src/lib.rs | 82 +++++++++----- .../src/cointime/activity/compute.rs | 6 +- .../src/distribution/metrics/activity/base.rs | 74 ++++++++----- .../src/distribution/metrics/activity/core.rs | 73 +++++++++++++ .../src/distribution/metrics/activity/full.rs | 102 +++++++----------- .../src/distribution/metrics/activity/mod.rs | 70 ++++++++++++ .../src/distribution/metrics/cohort/all.rs | 1 + .../src/distribution/metrics/cohort/basic.rs | 7 +- .../src/distribution/metrics/cohort/core.rs | 8 +- .../distribution/metrics/cohort/extended.rs | 1 + .../metrics/cohort/extended_adjusted.rs | 5 +- .../distribution/metrics/cohort/minimal.rs | 6 +- .../src/distribution/metrics/config.rs | 11 +- .../src/distribution/metrics/mod.rs | 17 +-- .../distribution/metrics/realized/adjusted.rs | 13 +-- .../src/distribution/metrics/realized/full.rs | 57 +--------- .../src/internal/containers/emas.rs | 30 ------ .../src/internal/containers/mod.rs | 2 - .../src/internal/from_height/value/base.rs | 23 ---- .../src/internal/rolling/emas/mod.rs | 7 -- .../internal/rolling/emas/percent_1w_1m.rs | 54 ---------- .../brk_computer/src/internal/rolling/mod.rs | 2 - crates/brk_types/src/difficultyepoch.rs | 2 +- crates/brk_types/src/halvingepoch.rs | 2 +- crates/brk_types/src/stored_u16.rs | 3 +- crates/brk_types/src/stored_u32.rs | 3 +- crates/brk_types/src/stored_u64.rs | 2 +- crates/brk_types/src/stored_u8.rs | 3 +- crates/brk_types/src/timestamp.rs | 3 +- crates/brk_types/src/vsize.rs | 6 +- crates/brk_types/src/weight.rs | 2 +- modules/brk-client/index.js | 91 ++++++++++------ packages/brk_client/brk_client/__init__.py | 41 ++++--- 33 files changed, 419 insertions(+), 390 deletions(-) create mode 100644 crates/brk_computer/src/distribution/metrics/activity/core.rs delete mode 100644 crates/brk_computer/src/internal/containers/emas.rs delete mode 100644 crates/brk_computer/src/internal/rolling/emas/mod.rs delete mode 100644 crates/brk_computer/src/internal/rolling/emas/percent_1w_1m.rs diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index ee3dc6c12..76519ebd6 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -1797,6 +1797,34 @@ impl _1m1w1y24hBtcCentsSatsUsdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CoinblocksCoindaysSentPattern2 { + pub coinblocks_destroyed: MetricPattern1, + pub coinblocks_destroyed_cumulative: MetricPattern1, + pub coindays_destroyed: MetricPattern1, + pub coindays_destroyed_cumulative: MetricPattern1, + pub coindays_destroyed_sum: _1m1w1y24hPattern, + pub sent: MetricPattern1, + pub sent_sum: _24hPattern, + pub sent_sum_extended: _1m1w1yPattern, +} + +impl CoinblocksCoindaysSentPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + coinblocks_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinblocks_destroyed")), + coinblocks_destroyed_cumulative: MetricPattern1::new(client.clone(), _m(&acc, "coinblocks_destroyed_cumulative")), + coindays_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed")), + coindays_destroyed_cumulative: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed_cumulative")), + coindays_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + sent: MetricPattern1::new(client.clone(), _m(&acc, "sent")), + sent_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_24h")), + sent_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sent")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { pub average: MetricPattern18, @@ -2021,28 +2049,6 @@ impl BaseBtcCentsSatsUsdPattern { } } -/// Pattern struct for repeated tree structure. -pub struct CoinblocksCoindaysSentPattern { - pub coinblocks_destroyed: CumulativeHeightPattern, - pub coindays_destroyed: CumulativeHeightSumPattern, - pub sent: MetricPattern1, - pub sent_sum: _24hPattern, - pub sent_sum_extended: _1m1w1yPattern, -} - -impl CoinblocksCoindaysSentPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - coinblocks_destroyed: CumulativeHeightPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")), - coindays_destroyed: CumulativeHeightSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - sent: MetricPattern1::new(client.clone(), _m(&acc, "sent")), - sent_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_24h")), - sent_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sent")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct EmaHistogramLineSignalPattern { pub ema_fast: MetricPattern1, @@ -2187,6 +2193,26 @@ impl BtcCentsSatsUsdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CoinblocksCoindaysSentPattern { + pub coinblocks_destroyed: MetricPattern1, + pub coindays_destroyed: MetricPattern1, + pub sent: MetricPattern1, + pub sent_sum: _24hPattern, +} + +impl CoinblocksCoindaysSentPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + coinblocks_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinblocks_destroyed")), + coindays_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed")), + sent: MetricPattern1::new(client.clone(), _m(&acc, "sent")), + sent_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_24h")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct InvestedMaxMinPercentilesPattern { pub invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, @@ -5507,7 +5533,7 @@ impl MetricsTree_Distribution_UtxoCohorts { pub struct MetricsTree_Distribution_UtxoCohorts_All { pub supply: ChangeHalvedTotalPattern, pub outputs: UtxoPattern, - pub activity: CoinblocksCoindaysSentPattern, + pub activity: CoinblocksCoindaysSentPattern2, pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, pub cost_basis: InvestedMaxMinPercentilesPattern, pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, @@ -5522,7 +5548,7 @@ impl MetricsTree_Distribution_UtxoCohorts_All { Self { supply: ChangeHalvedTotalPattern::new(client.clone(), "supply".to_string()), outputs: UtxoPattern::new(client.clone(), "utxo_count".to_string()), - activity: CoinblocksCoindaysSentPattern::new(client.clone(), "".to_string()), + activity: CoinblocksCoindaysSentPattern2::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()), @@ -5590,7 +5616,7 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Relative { pub struct MetricsTree_Distribution_UtxoCohorts_Sth { pub supply: ChangeHalvedTotalPattern, pub outputs: UtxoPattern, - pub activity: CoinblocksCoindaysSentPattern, + pub activity: CoinblocksCoindaysSentPattern2, pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, pub cost_basis: InvestedMaxMinPercentilesPattern, pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, @@ -5610,7 +5636,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Sth { Self { 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()), + activity: CoinblocksCoindaysSentPattern2::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()), @@ -5631,7 +5657,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Sth { pub struct MetricsTree_Distribution_UtxoCohorts_Lth { pub supply: ChangeHalvedTotalPattern, pub outputs: UtxoPattern, - pub activity: CoinblocksCoindaysSentPattern, + pub activity: CoinblocksCoindaysSentPattern2, pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, pub cost_basis: InvestedMaxMinPercentilesPattern, pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, @@ -5645,7 +5671,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Lth { Self { 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()), + activity: CoinblocksCoindaysSentPattern2::new(client.clone(), "lth".to_string()), 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()), diff --git a/crates/brk_computer/src/cointime/activity/compute.rs b/crates/brk_computer/src/cointime/activity/compute.rs index ed00bd677..171bb49e9 100644 --- a/crates/brk_computer/src/cointime/activity/compute.rs +++ b/crates/brk_computer/src/cointime/activity/compute.rs @@ -29,14 +29,12 @@ impl Vecs { Ok(()) })?; - let coinblocks_destroyed = &all_metrics.activity.coinblocks_destroyed; - self.coinblocks_stored .compute(starting_indexes.height, &window_starts, exit, |vec| { vec.compute_subtract( starting_indexes.height, &self.coinblocks_created.height, - &coinblocks_destroyed.height, + &all_metrics.activity.coinblocks_destroyed.height, exit, )?; Ok(()) @@ -44,7 +42,7 @@ impl Vecs { self.liveliness.height.compute_divide( starting_indexes.height, - &coinblocks_destroyed.cumulative.height, + &all_metrics.activity.coinblocks_destroyed_cumulative.height, &self.coinblocks_created.cumulative.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/activity/base.rs b/crates/brk_computer/src/distribution/metrics/activity/base.rs index 73a49817f..192e4beba 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/base.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/base.rs @@ -1,38 +1,68 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Height, Indexes, Sats, Version}; +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::{ComputedFromHeight, RollingWindow24h}; +use crate::internal::ComputedFromHeight; use crate::{blocks, distribution::metrics::ImportConfig}; -#[derive(Traversable)] +use super::ActivityCore; + +#[derive(Deref, DerefMut, Traversable)] pub struct ActivityBase { - pub sent: ComputedFromHeight, - pub sent_sum: RollingWindow24h, + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub core: ActivityCore, + + pub coinblocks_destroyed: ComputedFromHeight, + pub coindays_destroyed: ComputedFromHeight, } impl ActivityBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v1 = Version::ONE; Ok(Self { - sent: cfg.import("sent", v1)?, - sent_sum: cfg.import("sent", v1)?, + core: ActivityCore::forced_import(cfg)?, + coinblocks_destroyed: cfg.import("coinblocks_destroyed", v1)?, + coindays_destroyed: cfg.import("coindays_destroyed", v1)?, }) } pub(crate) fn min_len(&self) -> usize { - self.sent.height.len() + self.core + .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) -> Result<()> { - self.sent.height.truncate_push(height, sent)?; + 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)), + )?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![&mut self.sent.height as &mut dyn AnyStoredVec] + vec![ + &mut self.core.sent.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<()> { @@ -45,14 +75,12 @@ impl ActivityBase { others: &[&Self], exit: &Exit, ) -> Result<()> { - self.sent.height.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.sent.height) - .collect::>(), - exit, - )?; + 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); Ok(()) } @@ -62,12 +90,8 @@ impl ActivityBase { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.sent_sum.compute_rolling_sum( - starting_indexes.height, - &blocks.count.height_24h_ago, - &self.sent.height, - exit, - )?; + self.core + .compute_rest_part1(blocks, starting_indexes, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/activity/core.rs b/crates/brk_computer/src/distribution/metrics/activity/core.rs new file mode 100644 index 000000000..3550f277c --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/activity/core.rs @@ -0,0 +1,73 @@ +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::{ComputedFromHeight, RollingWindow24h}; + +use crate::{blocks, distribution::metrics::ImportConfig}; + +#[derive(Traversable)] +pub struct ActivityCore { + pub sent: ComputedFromHeight, + pub sent_sum: RollingWindow24h, +} + +impl ActivityCore { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let v1 = Version::ONE; + Ok(Self { + sent: cfg.import("sent", v1)?, + sent_sum: cfg.import("sent", v1)?, + }) + } + + pub(crate) fn min_len(&self) -> usize { + self.sent.height.len() + } + + pub(crate) fn truncate_push(&mut self, height: Height, sent: Sats) -> Result<()> { + self.sent.height.truncate_push(height, sent)?; + Ok(()) + } + + pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + vec![&mut self.sent.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.height.compute_sum_of_others( + starting_indexes.height, + &others + .iter() + .map(|v| &v.sent.height) + .collect::>(), + exit, + )?; + Ok(()) + } + + pub(crate) fn compute_rest_part1( + &mut self, + blocks: &blocks::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.sent_sum.compute_rolling_sum( + starting_indexes.height, + &blocks.count.height_24h_ago, + &self.sent.height, + exit, + )?; + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index 32b22c32b..3e533ceb3 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -1,12 +1,10 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF64, Version}; +use brk_types::{Indexes, Sats, StoredF64, Version}; use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; +use vecdb::{Exit, Rw, StorageMode}; -use crate::internal::{ - ComputedFromHeightCumulative, ComputedFromHeightCumulativeSum, RollingWindowsFrom1w, -}; +use crate::internal::{ComputedFromHeight, RollingWindows, RollingWindowsFrom1w}; use crate::{blocks, distribution::metrics::ImportConfig}; @@ -17,10 +15,11 @@ pub struct ActivityFull { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: ActivityBase, + pub inner: ActivityBase, - pub coinblocks_destroyed: ComputedFromHeightCumulative, - pub coindays_destroyed: ComputedFromHeightCumulativeSum, + pub coinblocks_destroyed_cumulative: ComputedFromHeight, + pub coindays_destroyed_cumulative: ComputedFromHeight, + pub coindays_destroyed_sum: RollingWindows, pub sent_sum_extended: RollingWindowsFrom1w, } @@ -29,65 +28,23 @@ impl ActivityFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v1 = Version::ONE; Ok(Self { - base: ActivityBase::forced_import(cfg)?, - coinblocks_destroyed: cfg - .import("coinblocks_destroyed", v1)?, - coindays_destroyed: cfg.import("coindays_destroyed", v1)?, + inner: ActivityBase::forced_import(cfg)?, + coinblocks_destroyed_cumulative: cfg + .import("coinblocks_destroyed_cumulative", v1)?, + coindays_destroyed_cumulative: cfg.import("coindays_destroyed_cumulative", v1)?, + coindays_destroyed_sum: cfg.import("coindays_destroyed", v1)?, sent_sum_extended: cfg.import("sent", v1)?, }) } - 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.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], + others: &[&ActivityBase], 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(()) + self.inner + .compute_from_stateful(starting_indexes, others, exit) } pub(crate) fn compute_rest_part1( @@ -96,20 +53,37 @@ impl ActivityFull { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.base + self.inner .compute_rest_part1(blocks, starting_indexes, exit)?; - self.coinblocks_destroyed - .compute_rest(starting_indexes.height, exit)?; + self.coinblocks_destroyed_cumulative + .height + .compute_cumulative( + starting_indexes.height, + &self.inner.coinblocks_destroyed.height, + exit, + )?; + + self.coindays_destroyed_cumulative + .height + .compute_cumulative( + starting_indexes.height, + &self.inner.coindays_destroyed.height, + exit, + )?; let window_starts = blocks.count.window_starts(); - self.coindays_destroyed - .compute_rest(starting_indexes.height, &window_starts, exit)?; + self.coindays_destroyed_sum.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.inner.coindays_destroyed.height, + exit, + )?; self.sent_sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.base.sent.height, + &self.inner.core.sent.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/activity/mod.rs b/crates/brk_computer/src/distribution/metrics/activity/mod.rs index 10f131f7f..541f8c3ad 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/mod.rs @@ -1,5 +1,75 @@ mod base; +mod core; mod full; pub use base::ActivityBase; +pub use self::core::ActivityCore; pub use full::ActivityFull; + +use brk_error::Result; +use brk_types::{Height, Indexes, Sats, Version}; +use vecdb::Exit; + +use crate::blocks; + +pub trait ActivityLike: Send + Sync { + fn as_base(&self) -> &ActivityBase; + fn as_base_mut(&mut self) -> &mut ActivityBase; + fn min_len(&self) -> usize; + fn truncate_push( + &mut self, + height: Height, + sent: Sats, + satblocks_destroyed: Sats, + satdays_destroyed: Sats, + ) -> Result<()>; + fn validate_computed_versions(&mut self, base_version: Version) -> Result<()>; + fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&ActivityBase], + exit: &Exit, + ) -> Result<()>; + fn compute_rest_part1( + &mut self, + blocks: &blocks::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()>; +} + +impl ActivityLike for ActivityBase { + fn as_base(&self) -> &ActivityBase { self } + fn as_base_mut(&mut self) -> &mut ActivityBase { self } + fn min_len(&self) -> usize { self.min_len() } + fn truncate_push(&mut self, height: Height, sent: Sats, satblocks_destroyed: Sats, satdays_destroyed: Sats) -> Result<()> { + self.truncate_push(height, sent, satblocks_destroyed, satdays_destroyed) + } + fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { + self.validate_computed_versions(base_version) + } + fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityBase], exit: &Exit) -> Result<()> { + self.compute_from_stateful(starting_indexes, others, exit) + } + fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { + self.compute_rest_part1(blocks, starting_indexes, exit) + } +} + +impl ActivityLike for ActivityFull { + fn as_base(&self) -> &ActivityBase { &self.inner } + fn as_base_mut(&mut self) -> &mut ActivityBase { &mut self.inner } + fn min_len(&self) -> usize { self.inner.min_len() } + fn truncate_push(&mut self, height: Height, sent: Sats, satblocks_destroyed: Sats, satdays_destroyed: Sats) -> Result<()> { + self.inner.truncate_push(height, sent, satblocks_destroyed, satdays_destroyed) + } + fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { + self.inner.validate_computed_versions(base_version) + } + fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityBase], exit: &Exit) -> Result<()> { + self.compute_from_stateful(starting_indexes, others, exit) + } + fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { + self.compute_rest_part1(blocks, starting_indexes, exit) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index 9acb0d434..1733769b8 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -34,6 +34,7 @@ pub struct AllCohortMetrics { } impl CohortMetricsBase for AllCohortMetrics { + type ActivityVecs = ActivityFull; type RealizedVecs = RealizedFull; type UnrealizedVecs = UnrealizedFull; type CostBasisVecs = CostBasisWithExtended; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs index 8cbec8ca8..1767b1663 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs @@ -7,7 +7,7 @@ use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityFull, CohortMetricsBase, CostBasisBase, ImportConfig, OutputsMetrics, RealizedBase, + ActivityBase, CohortMetricsBase, CostBasisBase, ImportConfig, OutputsMetrics, RealizedBase, RelativeToAll, SupplyMetrics, UnrealizedBase, }; @@ -19,7 +19,7 @@ pub struct BasicCohortMetrics { pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, + pub activity: Box>, pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, @@ -27,6 +27,7 @@ pub struct BasicCohortMetrics { } impl CohortMetricsBase for BasicCohortMetrics { + type ActivityVecs = ActivityBase; type RealizedVecs = RealizedBase; type UnrealizedVecs = UnrealizedBase; type CostBasisVecs = CostBasisBase; @@ -57,7 +58,7 @@ impl BasicCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(supply), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityFull::forced_import(cfg)?), + activity: Box::new(ActivityBase::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasisBase::forced_import(cfg)?), unrealized: Box::new(unrealized), diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index 9f27fb3ca..62f4c48e3 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -7,7 +7,7 @@ use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityBase, CohortMetricsBase, RealizedCore, ImportConfig, OutputsMetrics, + ActivityCore, CohortMetricsBase, RealizedCore, ImportConfig, OutputsMetrics, RelativeToAll, SupplyMetrics, UnrealizedCore, }; @@ -17,7 +17,7 @@ pub struct CoreCohortMetrics { pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, + pub activity: Box>, pub realized: Box>, pub unrealized: Box>, pub relative: Box>, @@ -29,7 +29,7 @@ impl CoreCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(SupplyMetrics::forced_import(cfg)?), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityBase::forced_import(cfg)?), + activity: Box::new(ActivityCore::forced_import(cfg)?), realized: Box::new(RealizedCore::forced_import(cfg)?), unrealized: Box::new(UnrealizedCore::forced_import(cfg)?), relative: Box::new(RelativeToAll::forced_import(cfg)?), @@ -80,7 +80,7 @@ impl CoreCohortMetrics { )?; self.activity.compute_from_stateful( starting_indexes, - &others.iter().map(|v| &v.activity().base).collect::>(), + &others.iter().map(|v| &v.activity_base().core).collect::>(), exit, )?; self.realized.compute_from_stateful( diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index e9620a62d..9b4754a5b 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -32,6 +32,7 @@ pub struct ExtendedCohortMetrics { } impl CohortMetricsBase for ExtendedCohortMetrics { + type ActivityVecs = ActivityFull; type RealizedVecs = RealizedFull; type UnrealizedVecs = UnrealizedFull; type CostBasisVecs = CostBasisWithExtended; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs index 249ec3121..f701a70ab 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs @@ -7,8 +7,8 @@ use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - CohortMetricsBase, CostBasisWithExtended, ImportConfig, RealizedAdjusted, RealizedFull, - UnrealizedFull, + ActivityFull, CohortMetricsBase, CostBasisWithExtended, ImportConfig, RealizedAdjusted, + RealizedFull, UnrealizedFull, }; use super::ExtendedCohortMetrics; @@ -27,6 +27,7 @@ pub struct ExtendedAdjustedCohortMetrics { } impl CohortMetricsBase for ExtendedAdjustedCohortMetrics { + type ActivityVecs = ActivityFull; type RealizedVecs = RealizedFull; type UnrealizedVecs = UnrealizedFull; type CostBasisVecs = CostBasisWithExtended; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs index 143f51c9e..378aff593 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs @@ -9,7 +9,7 @@ use crate::{blocks, prices}; use crate::internal::ValueFromHeight; use crate::distribution::{ - metrics::{ActivityBase, ImportConfig, OutputsMetrics, RealizedMinimal, SupplyMetrics}, + metrics::{ActivityCore, ImportConfig, OutputsMetrics, RealizedMinimal, SupplyMetrics}, state::UnrealizedState, }; @@ -31,7 +31,7 @@ pub struct MinimalCohortMetrics { pub filter: Filter, pub supply: Box>, pub outputs: Box>, - pub activity: Box>, + pub activity: Box>, pub realized: Box>, pub unrealized: Box>, } @@ -106,7 +106,7 @@ impl MinimalCohortMetrics { filter: cfg.filter.clone(), supply: Box::new(SupplyMetrics::forced_import(cfg)?), outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityBase::forced_import(cfg)?), + activity: Box::new(ActivityCore::forced_import(cfg)?), realized: Box::new(RealizedMinimal::forced_import(cfg)?), unrealized: Box::new(MinimalUnrealized::forced_import(cfg)?), }) diff --git a/crates/brk_computer/src/distribution/metrics/config.rs b/crates/brk_computer/src/distribution/metrics/config.rs index 3793d2248..25d8e2620 100644 --- a/crates/brk_computer/src/distribution/metrics/config.rs +++ b/crates/brk_computer/src/distribution/metrics/config.rs @@ -11,8 +11,8 @@ use crate::{ internal::{ CentsType, ComputedFromHeight, ComputedFromHeightCumulative, ComputedFromHeightCumulativeSum, ComputedFromHeightRatio, FiatFromHeight, NumericValue, - PercentFromHeight, PercentRollingEmas1w1m, PercentRollingWindows, Price, RollingEmas1w1m, - RollingEmas2w, RollingWindow24h, RollingWindows, RollingWindowsFrom1w, + PercentFromHeight, PercentRollingWindows, Price, + RollingWindow24h, RollingWindows, RollingWindowsFrom1w, ValueFromHeight, ValueFromHeightChange, ValueFromHeightCumulative, }, }; @@ -41,12 +41,10 @@ impl_config_import!( ValueFromHeightCumulative, ValueFromHeightChange, ComputedFromHeightRatio, - RollingEmas2w, PercentFromHeight, PercentFromHeight, PercentFromHeight, PercentRollingWindows, - PercentRollingEmas1w1m, Price>, ); @@ -81,11 +79,6 @@ impl ConfigImport for RollingWindowsFrom1w { Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) } } -impl ConfigImport for RollingEmas1w1m { - fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { - Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) - } -} impl ConfigImport for FiatFromHeight { fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index 4a32a7d8b..8e37760b5 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -23,8 +23,8 @@ macro_rules! impl_cohort_accessors { 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::ActivityFull { &self.activity } - fn activity_mut(&mut self) -> &mut $crate::distribution::metrics::ActivityFull { &mut self.activity } + fn activity(&self) -> &Self::ActivityVecs { &self.activity } + fn activity_mut(&mut self) -> &mut Self::ActivityVecs { &mut self.activity } fn realized(&self) -> &Self::RealizedVecs { &self.realized } fn realized_mut(&mut self) -> &mut Self::RealizedVecs { &mut self.realized } fn unrealized(&self) -> &Self::UnrealizedVecs { &self.unrealized } @@ -43,7 +43,7 @@ mod relative; mod supply; mod unrealized; -pub use activity::{ActivityBase, ActivityFull}; +pub use activity::{ActivityBase, ActivityCore, ActivityFull, ActivityLike}; pub use cohort::{ AllCohortMetrics, BasicCohortMetrics, CoreCohortMetrics, ExtendedAdjustedCohortMetrics, ExtendedCohortMetrics, MinimalCohortMetrics, @@ -91,6 +91,7 @@ impl CohortMetricsState for AllCohortMetrics { } pub trait CohortMetricsBase: CohortMetricsState + Send + Sync { + type ActivityVecs: ActivityLike; type RealizedVecs: RealizedLike; type UnrealizedVecs: UnrealizedLike; type CostBasisVecs: CostBasisLike; @@ -100,8 +101,8 @@ 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) -> &ActivityFull; - fn activity_mut(&mut self) -> &mut ActivityFull; + fn activity(&self) -> &Self::ActivityVecs; + fn activity_mut(&mut self) -> &mut Self::ActivityVecs; fn realized(&self) -> &Self::RealizedVecs; fn realized_mut(&mut self) -> &mut Self::RealizedVecs; fn unrealized(&self) -> &Self::UnrealizedVecs; @@ -109,6 +110,10 @@ pub trait CohortMetricsBase: CohortMetricsState + Send fn cost_basis(&self) -> &Self::CostBasisVecs; fn cost_basis_mut(&mut self) -> &mut Self::CostBasisVecs; + /// Convenience: access activity as `&ActivityBase` (via `ActivityLike::as_base`). + fn activity_base(&self) -> &ActivityBase { self.activity().as_base() } + fn activity_base_mut(&mut self) -> &mut ActivityBase { self.activity_mut().as_base_mut() } + /// Convenience: access realized as `&RealizedBase` (via `RealizedLike::as_base`). fn realized_base(&self) -> &RealizedBase { self.realized().as_base() } fn realized_base_mut(&mut self) -> &mut RealizedBase { self.realized_mut().as_base_mut() } @@ -240,7 +245,7 @@ pub trait CohortMetricsBase: CohortMetricsState + Send )?; self.activity_mut().compute_from_stateful( starting_indexes, - &others.iter().map(|v| v.activity()).collect::>(), + &others.iter().map(|v| v.activity_base()).collect::>(), exit, )?; self.realized_mut().compute_from_stateful( diff --git a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs index 026be7135..8791f17a7 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs @@ -5,7 +5,7 @@ use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::{ blocks, - internal::{ComputedFromHeight, RatioCents64, RollingEmas1w1m, RollingWindows}, + internal::{ComputedFromHeight, RatioCents64, RollingWindows}, }; use crate::distribution::metrics::ImportConfig; @@ -19,7 +19,6 @@ pub struct RealizedAdjusted { pub adjusted_value_destroyed_sum: RollingWindows, pub adjusted_sopr: RollingWindows, - pub adjusted_sopr_ema: RollingEmas1w1m, } impl RealizedAdjusted { @@ -30,7 +29,6 @@ impl RealizedAdjusted { adjusted_value_created_sum: cfg.import("adjusted_value_created", Version::ONE)?, adjusted_value_destroyed_sum: cfg.import("adjusted_value_destroyed", Version::ONE)?, adjusted_sopr: cfg.import("adjusted_sopr", Version::ONE)?, - adjusted_sopr_ema: cfg.import("adjusted_sopr_24h", Version::ONE)?, }) } @@ -90,15 +88,6 @@ impl RealizedAdjusted { )?; } - // Adjusted SOPR EMAs (based on 24h window) - self.adjusted_sopr_ema.compute_from_24h( - starting_indexes.height, - &blocks.count.height_1w_ago, - &blocks.count.height_1m_ago, - &self.adjusted_sopr._24h.height, - exit, - )?; - Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/realized/full.rs b/crates/brk_computer/src/distribution/metrics/realized/full.rs index 7f2df1f7d..eebbd3943 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -17,9 +17,9 @@ use crate::{ CentsUnsignedToDollars, ComputedFromHeight, ComputedFromHeightCumulative, FiatFromHeight, ComputedFromHeightRatio, ComputedFromHeightRatioPercentiles, ComputedFromHeightRatioStdDevBands, LazyFromHeight, PercentFromHeight, - PercentRollingEmas1w1m, PercentRollingWindows, Price, RatioCents64, RatioCentsBp32, + PercentRollingWindows, Price, RatioCents64, RatioCentsBp32, RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RatioDollarsBp32, - RollingEmas1w1m, RollingWindows, RollingWindowsFrom1w, + RollingWindows, RollingWindowsFrom1w, }, prices, }; @@ -65,7 +65,6 @@ pub struct RealizedFull { pub investor_cap_raw: M::Stored>, pub sell_side_risk_ratio: PercentRollingWindows, - pub sell_side_risk_ratio_24h_ema: PercentRollingEmas1w1m, pub peak_regret: ComputedFromHeightCumulative, pub peak_regret_rel_to_realized_cap: PercentFromHeight, @@ -76,12 +75,6 @@ pub struct RealizedFull { pub realized_loss_sum: RollingWindows, pub realized_profit_to_loss_ratio: RollingWindows, - pub realized_profit_ema_1w: ComputedFromHeight, - pub realized_loss_ema_1w: ComputedFromHeight, - pub net_realized_pnl_ema_1w: ComputedFromHeight, - - pub sopr_24h_ema: RollingEmas1w1m, - pub value_created_sum_extended: RollingWindowsFrom1w, pub value_destroyed_sum_extended: RollingWindowsFrom1w, pub sopr_extended: RollingWindowsFrom1w, @@ -135,8 +128,6 @@ impl RealizedFull { let sell_side_risk_ratio = cfg.import("sell_side_risk_ratio", Version::new(2))?; - let sell_side_risk_ratio_24h_ema = - cfg.import("sell_side_risk_ratio_24h", Version::new(2))?; let peak_regret = cfg.import("realized_peak_regret", Version::new(2))?; let peak_regret_rel_to_realized_cap = @@ -154,10 +145,6 @@ impl RealizedFull { let net_realized_pnl_rel_to_realized_cap = cfg.import("net_realized_pnl_rel_to_realized_cap", Version::new(2))?; - let realized_profit_ema_1w = cfg.import("realized_profit_ema_1w", v0)?; - let realized_loss_ema_1w = cfg.import("realized_loss_ema_1w", v0)?; - let net_realized_pnl_ema_1w = cfg.import("net_realized_pnl_ema_1w", v0)?; - let sopr_24h_ema = cfg.import("sopr_24h", v1)?; let value_created_sum_extended = cfg.import("value_created", v1)?; let value_destroyed_sum_extended = cfg.import("value_destroyed", v1)?; let sopr_extended = cfg.import("sopr", v1)?; @@ -187,7 +174,6 @@ impl RealizedFull { cap_raw, investor_cap_raw, sell_side_risk_ratio, - sell_side_risk_ratio_24h_ema, peak_regret, peak_regret_rel_to_realized_cap, realized_cap_rel_to_own_market_cap: cfg @@ -196,10 +182,6 @@ impl RealizedFull { realized_loss_sum: cfg.import("realized_loss", v1)?, realized_profit_to_loss_ratio: cfg .import("realized_profit_to_loss_ratio", v1)?, - realized_profit_ema_1w, - realized_loss_ema_1w, - net_realized_pnl_ema_1w, - sopr_24h_ema, value_created_sum_extended, value_destroyed_sum_extended, sopr_extended, @@ -372,33 +354,6 @@ impl RealizedFull { exit, )?; - // EMAs - self.realized_profit_ema_1w.height.compute_rolling_ema( - starting_indexes.height, - &blocks.count.height_1w_ago, - &self.base.core.minimal.realized_profit.height, - exit, - )?; - self.realized_loss_ema_1w.height.compute_rolling_ema( - starting_indexes.height, - &blocks.count.height_1w_ago, - &self.base.core.minimal.realized_loss.height, - exit, - )?; - self.net_realized_pnl_ema_1w.height.compute_rolling_ema( - starting_indexes.height, - &blocks.count.height_1w_ago, - &self.base.core.net_realized_pnl.height, - exit, - )?; - self.sopr_24h_ema.compute_from_24h( - starting_indexes.height, - &blocks.count.height_1w_ago, - &blocks.count.height_1m_ago, - &self.base.core.sopr._24h.height, - exit, - )?; - // Sent in profit/loss rolling sums let window_starts = blocks.count.window_starts(); self.sent_in_profit_sum.compute_rolling_sum( @@ -516,14 +471,6 @@ impl RealizedFull { )?; } - self.sell_side_risk_ratio_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, - exit, - )?; - // Extended: realized profit/loss rolling sums let window_starts = blocks.count.window_starts(); self.realized_profit_sum.compute_rolling_sum( diff --git a/crates/brk_computer/src/internal/containers/emas.rs b/crates/brk_computer/src/internal/containers/emas.rs deleted file mode 100644 index c2a91bc2f..000000000 --- a/crates/brk_computer/src/internal/containers/emas.rs +++ /dev/null @@ -1,30 +0,0 @@ -use brk_traversable::Traversable; - -#[derive(Clone, Traversable)] -pub struct Emas1w1m { - #[traversable(rename = "1w")] - pub _1w: A, - #[traversable(rename = "1m")] - pub _1m: A, -} - -impl Emas1w1m { - pub const SUFFIXES: [&'static str; 2] = ["ema_1w", "ema_1m"]; - - pub fn try_from_fn( - mut f: impl FnMut(&str) -> std::result::Result, - ) -> std::result::Result { - Ok(Self { - _1w: f(Self::SUFFIXES[0])?, - _1m: f(Self::SUFFIXES[1])?, - }) - } - - pub fn as_array(&self) -> [&A; 2] { - [&self._1w, &self._1m] - } - - pub fn as_mut_array(&mut self) -> [&mut A; 2] { - [&mut self._1w, &mut self._1m] - } -} diff --git a/crates/brk_computer/src/internal/containers/mod.rs b/crates/brk_computer/src/internal/containers/mod.rs index 34c63d30f..d7168714e 100644 --- a/crates/brk_computer/src/internal/containers/mod.rs +++ b/crates/brk_computer/src/internal/containers/mod.rs @@ -1,9 +1,7 @@ mod distribution_stats; -mod emas; mod per_period; mod windows; pub use distribution_stats::*; -pub use emas::*; pub use per_period::*; pub use windows::*; diff --git a/crates/brk_computer/src/internal/from_height/value/base.rs b/crates/brk_computer/src/internal/from_height/value/base.rs index 446090a48..57f1e702b 100644 --- a/crates/brk_computer/src/internal/from_height/value/base.rs +++ b/crates/brk_computer/src/internal/from_height/value/base.rs @@ -66,27 +66,4 @@ impl ValueFromHeight { .compute_rolling_sum(max_from, window_starts, cents_source, exit)?; Ok(()) } - - pub(crate) fn compute_ema( - &mut self, - starting_height: Height, - window_starts: &impl ReadableVec, - sats_source: &impl ReadableVec, - cents_source: &(impl ReadableVec + Sync), - exit: &Exit, - ) -> Result<()> { - self.base.sats.height.compute_rolling_ema( - starting_height, - window_starts, - sats_source, - exit, - )?; - self.base.cents.height.compute_rolling_ema( - starting_height, - window_starts, - cents_source, - exit, - )?; - Ok(()) - } } diff --git a/crates/brk_computer/src/internal/rolling/emas/mod.rs b/crates/brk_computer/src/internal/rolling/emas/mod.rs deleted file mode 100644 index a01b8d4d8..000000000 --- a/crates/brk_computer/src/internal/rolling/emas/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod _1w_1m; -mod _2w; -mod percent_1w_1m; - -pub use _1w_1m::*; -pub use _2w::*; -pub use percent_1w_1m::*; diff --git a/crates/brk_computer/src/internal/rolling/emas/percent_1w_1m.rs b/crates/brk_computer/src/internal/rolling/emas/percent_1w_1m.rs deleted file mode 100644 index f0992e0f1..000000000 --- a/crates/brk_computer/src/internal/rolling/emas/percent_1w_1m.rs +++ /dev/null @@ -1,54 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; - -use crate::{ - indexes, - internal::{BpsType, Emas1w1m, PercentFromHeight}, -}; - -/// 2 EMA vecs (1w, 1m) sourced from 24h rolling window, -/// each storing basis points with lazy ratio and percent float views. -#[derive(Deref, DerefMut, Traversable)] -#[traversable(transparent)] -pub struct PercentRollingEmas1w1m( - pub Emas1w1m>, -); - -impl PercentRollingEmas1w1m { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self(Emas1w1m::try_from_fn(|suffix| { - PercentFromHeight::forced_import(db, &format!("{name}_{suffix}"), version, indexes) - })?)) - } - - pub(crate) fn compute_from_24h( - &mut self, - max_from: Height, - height_1w_ago: &impl ReadableVec, - height_1m_ago: &impl ReadableVec, - source: &impl ReadableVec, - exit: &Exit, - ) -> Result<()> - where - f64: From, - B: From + Default, - { - self._1w - .bps - .height - .compute_rolling_ema(max_from, height_1w_ago, source, exit)?; - self._1m - .bps - .height - .compute_rolling_ema(max_from, height_1m_ago, source, exit)?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/rolling/mod.rs b/crates/brk_computer/src/internal/rolling/mod.rs index 3050a0a0e..74cef4cc3 100644 --- a/crates/brk_computer/src/internal/rolling/mod.rs +++ b/crates/brk_computer/src/internal/rolling/mod.rs @@ -1,12 +1,10 @@ mod distribution; -mod emas; mod full; mod percent_windows; mod value_windows; mod windows; pub use distribution::*; -pub use emas::*; pub use full::*; pub use percent_windows::*; pub use value_windows::*; diff --git a/crates/brk_types/src/difficultyepoch.rs b/crates/brk_types/src/difficultyepoch.rs index 0dbd866f8..3af287694 100644 --- a/crates/brk_types/src/difficultyepoch.rs +++ b/crates/brk_types/src/difficultyepoch.rs @@ -119,7 +119,7 @@ impl Formattable for DifficultyEpoch { impl From for DifficultyEpoch { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0); + let value = value.max(0.0); Self(value.round() as u16) } } diff --git a/crates/brk_types/src/halvingepoch.rs b/crates/brk_types/src/halvingepoch.rs index 14f7877a9..7947ab593 100644 --- a/crates/brk_types/src/halvingepoch.rs +++ b/crates/brk_types/src/halvingepoch.rs @@ -125,7 +125,7 @@ impl Formattable for HalvingEpoch { impl From for HalvingEpoch { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0); + let value = value.max(0.0); Self(value.round() as u8) } } diff --git a/crates/brk_types/src/stored_u16.rs b/crates/brk_types/src/stored_u16.rs index 54c5818a5..7ed663b53 100644 --- a/crates/brk_types/src/stored_u16.rs +++ b/crates/brk_types/src/stored_u16.rs @@ -83,7 +83,8 @@ impl AddAssign for StoredU16 { impl From for StoredU16 { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0 && value <= u16::MAX as f64); + let value = value.max(0.0); + debug_assert!(value <= u16::MAX as f64); Self(value as u16) } } diff --git a/crates/brk_types/src/stored_u32.rs b/crates/brk_types/src/stored_u32.rs index b697b9aa9..e249430ce 100644 --- a/crates/brk_types/src/stored_u32.rs +++ b/crates/brk_types/src/stored_u32.rs @@ -135,7 +135,8 @@ impl Mul for StoredU32 { impl From for StoredU32 { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0 && value <= u32::MAX as f64); + let value = value.max(0.0); + debug_assert!(value <= u32::MAX as f64); Self(value as u32) } } diff --git a/crates/brk_types/src/stored_u64.rs b/crates/brk_types/src/stored_u64.rs index ddd7f9137..d13cfa36f 100644 --- a/crates/brk_types/src/stored_u64.rs +++ b/crates/brk_types/src/stored_u64.rs @@ -108,7 +108,7 @@ impl SubAssign for StoredU64 { impl From for StoredU64 { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0); + let value = value.max(0.0); Self(value as u64) } } diff --git a/crates/brk_types/src/stored_u8.rs b/crates/brk_types/src/stored_u8.rs index 32698f49b..705470a24 100644 --- a/crates/brk_types/src/stored_u8.rs +++ b/crates/brk_types/src/stored_u8.rs @@ -60,7 +60,8 @@ impl AddAssign for StoredU8 { impl From for StoredU8 { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0 && value <= u8::MAX as f64); + let value = value.max(0.0); + debug_assert!(value <= u8::MAX as f64); Self(value as u8) } } diff --git a/crates/brk_types/src/timestamp.rs b/crates/brk_types/src/timestamp.rs index 00091d549..9e56e884f 100644 --- a/crates/brk_types/src/timestamp.rs +++ b/crates/brk_types/src/timestamp.rs @@ -165,7 +165,8 @@ impl AddAssign for Timestamp { impl From for Timestamp { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0 && value <= u32::MAX as f64); + let value = value.max(0.0); + debug_assert!(value <= u32::MAX as f64); Self(value as u32) } } diff --git a/crates/brk_types/src/vsize.rs b/crates/brk_types/src/vsize.rs index fec226b09..ff339d693 100644 --- a/crates/brk_types/src/vsize.rs +++ b/crates/brk_types/src/vsize.rs @@ -63,10 +63,8 @@ impl From for VSize { impl From for VSize { #[inline] fn from(value: f64) -> Self { - debug_assert!( - value >= 0.0 && value.fract() == 0.0, - "VSize must be a non-negative integer" - ); + let value = value.max(0.0); + debug_assert!(value.fract() == 0.0, "VSize must be an integer"); Self(value as u64) } } diff --git a/crates/brk_types/src/weight.rs b/crates/brk_types/src/weight.rs index 21ff506fc..a5b41db43 100644 --- a/crates/brk_types/src/weight.rs +++ b/crates/brk_types/src/weight.rs @@ -76,7 +76,7 @@ impl From for Weight { impl From for Weight { #[inline] fn from(value: f64) -> Self { - debug_assert!(value >= 0.0); + let value = value.max(0.0); Self(value as u64) } } diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 7205df6d6..4863b99ea 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -2492,6 +2492,37 @@ function create_1m1w1y24hBtcCentsSatsUsdPattern(client, acc) { }; } +/** + * @typedef {Object} CoinblocksCoindaysSentPattern2 + * @property {MetricPattern1} coinblocksDestroyed + * @property {MetricPattern1} coinblocksDestroyedCumulative + * @property {MetricPattern1} coindaysDestroyed + * @property {MetricPattern1} coindaysDestroyedCumulative + * @property {_1m1w1y24hPattern} coindaysDestroyedSum + * @property {MetricPattern1} sent + * @property {_24hPattern} sentSum + * @property {_1m1w1yPattern} sentSumExtended + */ + +/** + * Create a CoinblocksCoindaysSentPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoinblocksCoindaysSentPattern2} + */ +function createCoinblocksCoindaysSentPattern2(client, acc) { + return { + coinblocksDestroyed: createMetricPattern1(client, _m(acc, 'coinblocks_destroyed')), + coinblocksDestroyedCumulative: createMetricPattern1(client, _m(acc, 'coinblocks_destroyed_cumulative')), + coindaysDestroyed: createMetricPattern1(client, _m(acc, 'coindays_destroyed')), + coindaysDestroyedCumulative: createMetricPattern1(client, _m(acc, 'coindays_destroyed_cumulative')), + coindaysDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'coindays_destroyed')), + sent: createMetricPattern1(client, _m(acc, 'sent')), + sentSum: create_24hPattern(client, _m(acc, 'sent_24h')), + sentSumExtended: create_1m1w1yPattern(client, _m(acc, 'sent')), + }; +} + /** * @template T * @typedef {Object} AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern @@ -2745,31 +2776,6 @@ function createBaseBtcCentsSatsUsdPattern(client, acc) { }; } -/** - * @typedef {Object} CoinblocksCoindaysSentPattern - * @property {CumulativeHeightPattern} coinblocksDestroyed - * @property {CumulativeHeightSumPattern} coindaysDestroyed - * @property {MetricPattern1} sent - * @property {_24hPattern} sentSum - * @property {_1m1w1yPattern} sentSumExtended - */ - -/** - * Create a CoinblocksCoindaysSentPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CoinblocksCoindaysSentPattern} - */ -function createCoinblocksCoindaysSentPattern(client, acc) { - return { - coinblocksDestroyed: createCumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')), - coindaysDestroyed: createCumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')), - sent: createMetricPattern1(client, _m(acc, 'sent')), - sentSum: create_24hPattern(client, _m(acc, 'sent_24h')), - sentSumExtended: create_1m1w1yPattern(client, _m(acc, 'sent')), - }; -} - /** * @typedef {Object} EmaHistogramLineSignalPattern * @property {MetricPattern1} emaFast @@ -2937,6 +2943,29 @@ function createBtcCentsSatsUsdPattern(client, acc) { }; } +/** + * @typedef {Object} CoinblocksCoindaysSentPattern + * @property {MetricPattern1} coinblocksDestroyed + * @property {MetricPattern1} coindaysDestroyed + * @property {MetricPattern1} sent + * @property {_24hPattern} sentSum + */ + +/** + * Create a CoinblocksCoindaysSentPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoinblocksCoindaysSentPattern} + */ +function createCoinblocksCoindaysSentPattern(client, acc) { + return { + coinblocksDestroyed: createMetricPattern1(client, _m(acc, 'coinblocks_destroyed')), + coindaysDestroyed: createMetricPattern1(client, _m(acc, 'coindays_destroyed')), + sent: createMetricPattern1(client, _m(acc, 'sent')), + sentSum: create_24hPattern(client, _m(acc, 'sent_24h')), + }; +} + /** * @typedef {Object} InvestedMaxMinPercentilesPattern * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} investedCapital @@ -4762,7 +4791,7 @@ function create_24hPattern(client, acc) { * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All * @property {ChangeHalvedTotalPattern} supply * @property {UtxoPattern} outputs - * @property {CoinblocksCoindaysSentPattern} activity + * @property {CoinblocksCoindaysSentPattern2} activity * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized * @property {InvestedMaxMinPercentilesPattern} costBasis * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized @@ -4799,7 +4828,7 @@ function create_24hPattern(client, acc) { * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Sth * @property {ChangeHalvedTotalPattern} supply * @property {UtxoPattern} outputs - * @property {CoinblocksCoindaysSentPattern} activity + * @property {CoinblocksCoindaysSentPattern2} activity * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized * @property {InvestedMaxMinPercentilesPattern} costBasis * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized @@ -4818,7 +4847,7 @@ function create_24hPattern(client, acc) { * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Lth * @property {ChangeHalvedTotalPattern} supply * @property {UtxoPattern} outputs - * @property {CoinblocksCoindaysSentPattern} activity + * @property {CoinblocksCoindaysSentPattern2} activity * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized * @property {InvestedMaxMinPercentilesPattern} costBasis * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized @@ -6982,7 +7011,7 @@ class BrkClient extends BrkClientBase { all: { supply: createChangeHalvedTotalPattern(this, 'supply'), outputs: createUtxoPattern(this, 'utxo_count'), - activity: createCoinblocksCoindaysSentPattern(this, ''), + activity: createCoinblocksCoindaysSentPattern2(this, ''), realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, ''), costBasis: createInvestedMaxMinPercentilesPattern(this, ''), unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, ''), @@ -7011,7 +7040,7 @@ class BrkClient extends BrkClientBase { sth: { supply: createChangeHalvedTotalPattern(this, 'sth_supply'), outputs: createUtxoPattern(this, 'sth_utxo_count'), - activity: createCoinblocksCoindaysSentPattern(this, 'sth'), + activity: createCoinblocksCoindaysSentPattern2(this, 'sth'), realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, 'sth'), costBasis: createInvestedMaxMinPercentilesPattern(this, 'sth'), unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, 'sth'), @@ -7028,7 +7057,7 @@ class BrkClient extends BrkClientBase { lth: { supply: createChangeHalvedTotalPattern(this, 'lth_supply'), outputs: createUtxoPattern(this, 'lth_utxo_count'), - activity: createCoinblocksCoindaysSentPattern(this, 'lth'), + activity: createCoinblocksCoindaysSentPattern2(this, 'lth'), realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, 'lth'), costBasis: createInvestedMaxMinPercentilesPattern(this, 'lth'), unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, 'lth'), diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 236f7cf97..77f0ac920 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2495,6 +2495,20 @@ class _1m1w1y24hBtcCentsSatsUsdPattern: self.sats: MetricPattern18[Sats] = MetricPattern18(client, acc) self.usd: MetricPattern18[Dollars] = MetricPattern18(client, _m(acc, 'usd')) +class CoinblocksCoindaysSentPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.coinblocks_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinblocks_destroyed')) + self.coinblocks_destroyed_cumulative: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinblocks_destroyed_cumulative')) + self.coindays_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coindays_destroyed')) + self.coindays_destroyed_cumulative: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coindays_destroyed_cumulative')) + self.coindays_destroyed_sum: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'coindays_destroyed')) + self.sent: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent')) + self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_24h')) + self.sent_sum_extended: _1m1w1yPattern[Sats] = _1m1w1yPattern(client, _m(acc, 'sent')) + class AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2607,17 +2621,6 @@ class BaseBtcCentsSatsUsdPattern: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'rewards_cumulative')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'rewards_cumulative_usd')) -class CoinblocksCoindaysSentPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.coinblocks_destroyed: CumulativeHeightPattern[StoredF64] = CumulativeHeightPattern(client, _m(acc, 'coinblocks_destroyed')) - self.coindays_destroyed: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, _m(acc, 'coindays_destroyed')) - self.sent: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent')) - self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_24h')) - self.sent_sum_extended: _1m1w1yPattern[Sats] = _1m1w1yPattern(client, _m(acc, 'sent')) - class EmaHistogramLineSignalPattern: """Pattern struct for repeated tree structure.""" @@ -2690,6 +2693,16 @@ class BtcCentsSatsUsdPattern: self.sats: MetricPattern1[Sats] = MetricPattern1(client, acc) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) +class CoinblocksCoindaysSentPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.coinblocks_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinblocks_destroyed')) + self.coindays_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coindays_destroyed')) + self.sent: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent')) + self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_24h')) + class InvestedMaxMinPercentilesPattern: """Pattern struct for repeated tree structure.""" @@ -4270,7 +4283,7 @@ class MetricsTree_Distribution_UtxoCohorts_All: def __init__(self, client: BrkClientBase, base_path: str = ''): self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, 'supply') self.outputs: UtxoPattern = UtxoPattern(client, 'utxo_count') - self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, '') + self.activity: CoinblocksCoindaysSentPattern2 = CoinblocksCoindaysSentPattern2(client, '') self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, '') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, '') self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, '') @@ -4285,7 +4298,7 @@ class MetricsTree_Distribution_UtxoCohorts_Sth: def __init__(self, client: BrkClientBase, base_path: str = ''): self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, 'sth_supply') self.outputs: UtxoPattern = UtxoPattern(client, 'sth_utxo_count') - self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, 'sth') + self.activity: CoinblocksCoindaysSentPattern2 = CoinblocksCoindaysSentPattern2(client, 'sth') self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, 'sth') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'sth') self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, 'sth') @@ -4305,7 +4318,7 @@ class MetricsTree_Distribution_UtxoCohorts_Lth: def __init__(self, client: BrkClientBase, base_path: str = ''): self.supply: ChangeHalvedTotalPattern = ChangeHalvedTotalPattern(client, 'lth_supply') self.outputs: UtxoPattern = UtxoPattern(client, 'lth_utxo_count') - self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, 'lth') + self.activity: CoinblocksCoindaysSentPattern2 = CoinblocksCoindaysSentPattern2(client, 'lth') self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, 'lth') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'lth') self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, 'lth')