diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index b349c8270..e972848a4 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -1861,28 +1861,6 @@ pub struct InvestedMaxMinPercentilesSupplyPattern { pub supply_density: BpsPercentRatioPattern3, } -/// Pattern struct for repeated tree structure. -pub struct MvrvNuplRealizedSupplyPattern { - pub mvrv: MetricPattern1, - pub nupl: BpsRatioPattern, - pub realized_cap: AllSthPattern, - pub realized_price: BpsCentsRatioSatsUsdPattern, - pub supply: AllSthPattern2, -} - -impl MvrvNuplRealizedSupplyPattern { - /// 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")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), - realized_cap: AllSthPattern::new(client.clone(), acc.clone()), - realized_price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - supply: AllSthPattern2::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct PhsReboundThsPattern { pub phs: MetricPattern1, @@ -2555,6 +2533,24 @@ pub struct LowerPriceUpperPattern { pub upper_price_band: CentsSatsUsdPattern, } +/// Pattern struct for repeated tree structure. +pub struct NuplRealizedSupplyPattern { + pub nupl: BpsRatioPattern, + pub realized_cap: AllSthPattern, + pub supply: AllSthPattern2, +} + +impl NuplRealizedSupplyPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + realized_cap: AllSthPattern::new(client.clone(), acc.clone()), + supply: AllSthPattern2::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct RatioValuePattern2 { pub ratio: _1m1w1y24hPattern, @@ -8054,129 +8050,129 @@ impl MetricsTree_Cohorts_Utxo_Profitability { /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_Profitability_Range { - pub over_1000pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _500pct_to_1000pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _300pct_to_500pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _200pct_to_300pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _100pct_to_200pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _90pct_to_100pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _80pct_to_90pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _70pct_to_80pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _60pct_to_70pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _50pct_to_60pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _40pct_to_50pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _30pct_to_40pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _20pct_to_30pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _10pct_to_20pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _0pct_to_10pct_in_profit: MvrvNuplRealizedSupplyPattern, - pub _0pct_to_10pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _10pct_to_20pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _20pct_to_30pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _30pct_to_40pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _40pct_to_50pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _50pct_to_60pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _60pct_to_70pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _70pct_to_80pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _80pct_to_90pct_in_loss: MvrvNuplRealizedSupplyPattern, - pub _90pct_to_100pct_in_loss: MvrvNuplRealizedSupplyPattern, + pub over_1000pct_in_profit: NuplRealizedSupplyPattern, + pub _500pct_to_1000pct_in_profit: NuplRealizedSupplyPattern, + pub _300pct_to_500pct_in_profit: NuplRealizedSupplyPattern, + pub _200pct_to_300pct_in_profit: NuplRealizedSupplyPattern, + pub _100pct_to_200pct_in_profit: NuplRealizedSupplyPattern, + pub _90pct_to_100pct_in_profit: NuplRealizedSupplyPattern, + pub _80pct_to_90pct_in_profit: NuplRealizedSupplyPattern, + pub _70pct_to_80pct_in_profit: NuplRealizedSupplyPattern, + pub _60pct_to_70pct_in_profit: NuplRealizedSupplyPattern, + pub _50pct_to_60pct_in_profit: NuplRealizedSupplyPattern, + pub _40pct_to_50pct_in_profit: NuplRealizedSupplyPattern, + pub _30pct_to_40pct_in_profit: NuplRealizedSupplyPattern, + pub _20pct_to_30pct_in_profit: NuplRealizedSupplyPattern, + pub _10pct_to_20pct_in_profit: NuplRealizedSupplyPattern, + pub _0pct_to_10pct_in_profit: NuplRealizedSupplyPattern, + pub _0pct_to_10pct_in_loss: NuplRealizedSupplyPattern, + pub _10pct_to_20pct_in_loss: NuplRealizedSupplyPattern, + pub _20pct_to_30pct_in_loss: NuplRealizedSupplyPattern, + pub _30pct_to_40pct_in_loss: NuplRealizedSupplyPattern, + pub _40pct_to_50pct_in_loss: NuplRealizedSupplyPattern, + pub _50pct_to_60pct_in_loss: NuplRealizedSupplyPattern, + pub _60pct_to_70pct_in_loss: NuplRealizedSupplyPattern, + pub _70pct_to_80pct_in_loss: NuplRealizedSupplyPattern, + pub _80pct_to_90pct_in_loss: NuplRealizedSupplyPattern, + pub _90pct_to_100pct_in_loss: NuplRealizedSupplyPattern, } impl MetricsTree_Cohorts_Utxo_Profitability_Range { pub fn new(client: Arc, base_path: String) -> Self { Self { - over_1000pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_1000pct_in_profit".to_string()), - _500pct_to_1000pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_500pct_to_1000pct_in_profit".to_string()), - _300pct_to_500pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_300pct_to_500pct_in_profit".to_string()), - _200pct_to_300pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_200pct_to_300pct_in_profit".to_string()), - _100pct_to_200pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_100pct_to_200pct_in_profit".to_string()), - _90pct_to_100pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_90pct_to_100pct_in_profit".to_string()), - _80pct_to_90pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_80pct_to_90pct_in_profit".to_string()), - _70pct_to_80pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_70pct_to_80pct_in_profit".to_string()), - _60pct_to_70pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_60pct_to_70pct_in_profit".to_string()), - _50pct_to_60pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_50pct_to_60pct_in_profit".to_string()), - _40pct_to_50pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_40pct_to_50pct_in_profit".to_string()), - _30pct_to_40pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_30pct_to_40pct_in_profit".to_string()), - _20pct_to_30pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_20pct_to_30pct_in_profit".to_string()), - _10pct_to_20pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_10pct_to_20pct_in_profit".to_string()), - _0pct_to_10pct_in_profit: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_0pct_to_10pct_in_profit".to_string()), - _0pct_to_10pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_0pct_to_10pct_in_loss".to_string()), - _10pct_to_20pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_10pct_to_20pct_in_loss".to_string()), - _20pct_to_30pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_20pct_to_30pct_in_loss".to_string()), - _30pct_to_40pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_30pct_to_40pct_in_loss".to_string()), - _40pct_to_50pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_40pct_to_50pct_in_loss".to_string()), - _50pct_to_60pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_50pct_to_60pct_in_loss".to_string()), - _60pct_to_70pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_60pct_to_70pct_in_loss".to_string()), - _70pct_to_80pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_70pct_to_80pct_in_loss".to_string()), - _80pct_to_90pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_80pct_to_90pct_in_loss".to_string()), - _90pct_to_100pct_in_loss: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_90pct_to_100pct_in_loss".to_string()), + over_1000pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_1000pct_in_profit".to_string()), + _500pct_to_1000pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_500pct_to_1000pct_in_profit".to_string()), + _300pct_to_500pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_300pct_to_500pct_in_profit".to_string()), + _200pct_to_300pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_200pct_to_300pct_in_profit".to_string()), + _100pct_to_200pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_100pct_to_200pct_in_profit".to_string()), + _90pct_to_100pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_90pct_to_100pct_in_profit".to_string()), + _80pct_to_90pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_80pct_to_90pct_in_profit".to_string()), + _70pct_to_80pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_70pct_to_80pct_in_profit".to_string()), + _60pct_to_70pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_60pct_to_70pct_in_profit".to_string()), + _50pct_to_60pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_50pct_to_60pct_in_profit".to_string()), + _40pct_to_50pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_40pct_to_50pct_in_profit".to_string()), + _30pct_to_40pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_30pct_to_40pct_in_profit".to_string()), + _20pct_to_30pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_20pct_to_30pct_in_profit".to_string()), + _10pct_to_20pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_10pct_to_20pct_in_profit".to_string()), + _0pct_to_10pct_in_profit: NuplRealizedSupplyPattern::new(client.clone(), "utxos_0pct_to_10pct_in_profit".to_string()), + _0pct_to_10pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_0pct_to_10pct_in_loss".to_string()), + _10pct_to_20pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_10pct_to_20pct_in_loss".to_string()), + _20pct_to_30pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_20pct_to_30pct_in_loss".to_string()), + _30pct_to_40pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_30pct_to_40pct_in_loss".to_string()), + _40pct_to_50pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_40pct_to_50pct_in_loss".to_string()), + _50pct_to_60pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_50pct_to_60pct_in_loss".to_string()), + _60pct_to_70pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_60pct_to_70pct_in_loss".to_string()), + _70pct_to_80pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_70pct_to_80pct_in_loss".to_string()), + _80pct_to_90pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_80pct_to_90pct_in_loss".to_string()), + _90pct_to_100pct_in_loss: NuplRealizedSupplyPattern::new(client.clone(), "utxos_90pct_to_100pct_in_loss".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_Profitability_Profit { - pub breakeven: MvrvNuplRealizedSupplyPattern, - pub _10pct: MvrvNuplRealizedSupplyPattern, - pub _20pct: MvrvNuplRealizedSupplyPattern, - pub _30pct: MvrvNuplRealizedSupplyPattern, - pub _40pct: MvrvNuplRealizedSupplyPattern, - pub _50pct: MvrvNuplRealizedSupplyPattern, - pub _60pct: MvrvNuplRealizedSupplyPattern, - pub _70pct: MvrvNuplRealizedSupplyPattern, - pub _80pct: MvrvNuplRealizedSupplyPattern, - pub _90pct: MvrvNuplRealizedSupplyPattern, - pub _100pct: MvrvNuplRealizedSupplyPattern, - pub _200pct: MvrvNuplRealizedSupplyPattern, - pub _300pct: MvrvNuplRealizedSupplyPattern, - pub _500pct: MvrvNuplRealizedSupplyPattern, + pub breakeven: NuplRealizedSupplyPattern, + pub _10pct: NuplRealizedSupplyPattern, + pub _20pct: NuplRealizedSupplyPattern, + pub _30pct: NuplRealizedSupplyPattern, + pub _40pct: NuplRealizedSupplyPattern, + pub _50pct: NuplRealizedSupplyPattern, + pub _60pct: NuplRealizedSupplyPattern, + pub _70pct: NuplRealizedSupplyPattern, + pub _80pct: NuplRealizedSupplyPattern, + pub _90pct: NuplRealizedSupplyPattern, + pub _100pct: NuplRealizedSupplyPattern, + pub _200pct: NuplRealizedSupplyPattern, + pub _300pct: NuplRealizedSupplyPattern, + pub _500pct: NuplRealizedSupplyPattern, } impl MetricsTree_Cohorts_Utxo_Profitability_Profit { pub fn new(client: Arc, base_path: String) -> Self { Self { - breakeven: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_in_profit".to_string()), - _10pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_10pct_in_profit".to_string()), - _20pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_20pct_in_profit".to_string()), - _30pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_30pct_in_profit".to_string()), - _40pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_40pct_in_profit".to_string()), - _50pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_50pct_in_profit".to_string()), - _60pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_60pct_in_profit".to_string()), - _70pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_70pct_in_profit".to_string()), - _80pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_80pct_in_profit".to_string()), - _90pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_90pct_in_profit".to_string()), - _100pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_100pct_in_profit".to_string()), - _200pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_200pct_in_profit".to_string()), - _300pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_300pct_in_profit".to_string()), - _500pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_500pct_in_profit".to_string()), + breakeven: NuplRealizedSupplyPattern::new(client.clone(), "utxos_in_profit".to_string()), + _10pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_10pct_in_profit".to_string()), + _20pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_20pct_in_profit".to_string()), + _30pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_30pct_in_profit".to_string()), + _40pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_40pct_in_profit".to_string()), + _50pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_50pct_in_profit".to_string()), + _60pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_60pct_in_profit".to_string()), + _70pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_70pct_in_profit".to_string()), + _80pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_80pct_in_profit".to_string()), + _90pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_90pct_in_profit".to_string()), + _100pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_100pct_in_profit".to_string()), + _200pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_200pct_in_profit".to_string()), + _300pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_300pct_in_profit".to_string()), + _500pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_500pct_in_profit".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_Profitability_Loss { - pub breakeven: MvrvNuplRealizedSupplyPattern, - pub _10pct: MvrvNuplRealizedSupplyPattern, - pub _20pct: MvrvNuplRealizedSupplyPattern, - pub _30pct: MvrvNuplRealizedSupplyPattern, - pub _40pct: MvrvNuplRealizedSupplyPattern, - pub _50pct: MvrvNuplRealizedSupplyPattern, - pub _60pct: MvrvNuplRealizedSupplyPattern, - pub _70pct: MvrvNuplRealizedSupplyPattern, - pub _80pct: MvrvNuplRealizedSupplyPattern, + pub breakeven: NuplRealizedSupplyPattern, + pub _10pct: NuplRealizedSupplyPattern, + pub _20pct: NuplRealizedSupplyPattern, + pub _30pct: NuplRealizedSupplyPattern, + pub _40pct: NuplRealizedSupplyPattern, + pub _50pct: NuplRealizedSupplyPattern, + pub _60pct: NuplRealizedSupplyPattern, + pub _70pct: NuplRealizedSupplyPattern, + pub _80pct: NuplRealizedSupplyPattern, } impl MetricsTree_Cohorts_Utxo_Profitability_Loss { pub fn new(client: Arc, base_path: String) -> Self { Self { - breakeven: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_in_loss".to_string()), - _10pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_10pct_in_loss".to_string()), - _20pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_20pct_in_loss".to_string()), - _30pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_30pct_in_loss".to_string()), - _40pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_40pct_in_loss".to_string()), - _50pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_50pct_in_loss".to_string()), - _60pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_60pct_in_loss".to_string()), - _70pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_70pct_in_loss".to_string()), - _80pct: MvrvNuplRealizedSupplyPattern::new(client.clone(), "utxos_over_80pct_in_loss".to_string()), + breakeven: NuplRealizedSupplyPattern::new(client.clone(), "utxos_in_loss".to_string()), + _10pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_10pct_in_loss".to_string()), + _20pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_20pct_in_loss".to_string()), + _30pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_30pct_in_loss".to_string()), + _40pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_40pct_in_loss".to_string()), + _50pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_50pct_in_loss".to_string()), + _60pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_60pct_in_loss".to_string()), + _70pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_70pct_in_loss".to_string()), + _80pct: NuplRealizedSupplyPattern::new(client.clone(), "utxos_over_80pct_in_loss".to_string()), } } } diff --git a/crates/brk_computer/src/distribution/metrics/profitability.rs b/crates/brk_computer/src/distribution/metrics/profitability.rs index 938e72cbd..4e71acca2 100644 --- a/crates/brk_computer/src/distribution/metrics/profitability.rs +++ b/crates/brk_computer/src/distribution/metrics/profitability.rs @@ -1,17 +1,12 @@ use brk_cohort::{Loss, Profit, ProfitabilityRange}; use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{ - BasisPoints32, BasisPointsSigned32, Cents, Dollars, Indexes, Sats, StoredF32, Version, -}; +use brk_types::{BasisPointsSigned32, Cents, Dollars, Indexes, Sats, Version}; use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec}; use crate::{ indexes, - internal::{ - AmountPerBlock, AmountPerBlockWithDeltas, CachedWindowStarts, Identity, LazyPerBlock, - PerBlock, PriceWithRatioPerBlock, RatioPerBlock, - }, + internal::{AmountPerBlock, AmountPerBlockWithDeltas, CachedWindowStarts, PerBlock, RatioPerBlock}, prices, }; @@ -25,8 +20,6 @@ pub struct WithSth { pub struct ProfitabilityBucket { pub supply: WithSth, AmountPerBlock>, pub realized_cap: WithSth>, - pub realized_price: PriceWithRatioPerBlock, - pub mvrv: LazyPerBlock, pub nupl: RatioPerBlock, } @@ -49,19 +42,6 @@ impl ProfitabilityBucket { indexes: &indexes::Vecs, cached_starts: &CachedWindowStarts, ) -> Result { - let realized_price = PriceWithRatioPerBlock::forced_import( - db, - &format!("{name}_realized_price"), - version, - indexes, - )?; - - let mvrv = LazyPerBlock::from_lazy::, BasisPoints32>( - &format!("{name}_mvrv"), - version, - &realized_price.ratio, - ); - Ok(Self { supply: WithSth { all: AmountPerBlockWithDeltas::forced_import( @@ -92,8 +72,6 @@ impl ProfitabilityBucket { indexes, )?, }, - realized_price, - mvrv, nupl: RatioPerBlock::forced_import_raw( db, &format!("{name}_nupl"), @@ -128,38 +106,20 @@ impl ProfitabilityBucket { self.supply.all.compute(prices, max_from, exit)?; self.supply.sth.compute(prices, max_from, exit)?; - // Realized price cents = realized_cap_cents × ONE_BTC / supply_sats - self.realized_price.cents.height.compute_transform2( - max_from, - &self.realized_cap.all.height, - &self.supply.all.sats.height, - |(i, cap_dollars, supply_sats, ..)| { - let cap_cents = Cents::from(cap_dollars).as_u128(); - let supply = supply_sats.as_u128(); - if supply == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(cap_cents * Sats::ONE_BTC_U128 / supply)) - } - }, - exit, - )?; - - // Ratio (spot / realized_price) → feeds MVRV lazily - self.realized_price - .compute_ratio(starting_indexes, &prices.spot.cents.height, exit)?; - // NUPL = (spot - realized_price) / spot - self.nupl.bps.height.compute_transform2( + // where realized_price = realized_cap_cents × ONE_BTC / supply_sats + self.nupl.bps.height.compute_transform3( max_from, &prices.spot.cents.height, - &self.realized_price.cents.height, - |(i, spot, realized, ..)| { + &self.realized_cap.all.height, + &self.supply.all.sats.height, + |(i, spot, cap_dollars, supply_sats, ..)| { let p = spot.as_u128(); - if p == 0 { + let supply = supply_sats.as_u128(); + if p == 0 || supply == 0 { (i, BasisPointsSigned32::ZERO) } else { - let rp = realized.as_u128(); + let rp = Cents::from(cap_dollars).as_u128() * Sats::ONE_BTC_U128 / supply; let bps = ((p as i128 - rp as i128) * 10000) / p as i128; (i, BasisPointsSigned32::from(bps as i32)) } @@ -173,14 +133,12 @@ impl ProfitabilityBucket { pub(crate) fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { vec![ &mut self.supply.all.inner.sats.height as &mut dyn AnyStoredVec, - &mut self.supply.all.inner.cents.height as &mut dyn AnyStoredVec, - &mut self.supply.sth.sats.height as &mut dyn AnyStoredVec, - &mut self.supply.sth.cents.height as &mut dyn AnyStoredVec, - &mut self.realized_cap.all.height as &mut dyn AnyStoredVec, - &mut self.realized_cap.sth.height as &mut dyn AnyStoredVec, - &mut self.realized_price.cents.height as &mut dyn AnyStoredVec, - &mut self.realized_price.bps.height as &mut dyn AnyStoredVec, - &mut self.nupl.bps.height as &mut dyn AnyStoredVec, + &mut self.supply.all.inner.cents.height, + &mut self.supply.sth.sats.height, + &mut self.supply.sth.cents.height, + &mut self.realized_cap.all.height, + &mut self.realized_cap.sth.height, + &mut self.nupl.bps.height, ] } } diff --git a/crates/brk_fetcher/src/brk.rs b/crates/brk_fetcher/src/brk.rs index cef4aaf65..94e1cb971 100644 --- a/crates/brk_fetcher/src/brk.rs +++ b/crates/brk_fetcher/src/brk.rs @@ -19,6 +19,7 @@ pub struct BRK { } impl BRK { + #[allow(clippy::new_without_default)] pub fn new() -> Self { Self::new_with_agent(crate::new_agent(30)) } diff --git a/crates/brk_fetcher/src/kraken.rs b/crates/brk_fetcher/src/kraken.rs index ae287d4c4..1ed3fea14 100644 --- a/crates/brk_fetcher/src/kraken.rs +++ b/crates/brk_fetcher/src/kraken.rs @@ -19,6 +19,7 @@ pub struct Kraken { } impl Kraken { + #[allow(clippy::new_without_default)] pub fn new() -> Self { Self::new_with_agent(crate::new_agent(30)) } @@ -38,7 +39,11 @@ impl Kraken { timestamp: Timestamp, previous_timestamp: Option, ) -> Result { - if self._1mn.as_ref().and_then(|m| m.last_key_value()).is_none_or(|(k, _)| k <= ×tamp) + if self + ._1mn + .as_ref() + .and_then(|m| m.last_key_value()) + .is_none_or(|(k, _)| k <= ×tamp) { self._1mn.replace(self.fetch_1mn()?); } @@ -62,7 +67,12 @@ impl Kraken { } fn get_from_1d(&mut self, date: &Date) -> Result { - if self._1d.as_ref().and_then(|m| m.last_key_value()).is_none_or(|(k, _)| k <= date) { + if self + ._1d + .as_ref() + .and_then(|m| m.last_key_value()) + .is_none_or(|(k, _)| k <= date) + { self._1d.replace(self.fetch_1d()?); } self._1d @@ -114,7 +124,9 @@ impl Kraken { } pub fn ping(&self) -> Result<()> { - self.agent.get("https://api.kraken.com/0/public/Time").call()?; + self.agent + .get("https://api.kraken.com/0/public/Time") + .call()?; Ok(()) } } diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index cee512f95..d0d0be69b 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -2630,31 +2630,6 @@ function createDeltaHalfInTotalPattern2(client, acc) { * @property {BpsPercentRatioPattern3} supplyDensity */ -/** - * @typedef {Object} MvrvNuplRealizedSupplyPattern - * @property {MetricPattern1} mvrv - * @property {BpsRatioPattern} nupl - * @property {AllSthPattern} realizedCap - * @property {BpsCentsRatioSatsUsdPattern} realizedPrice - * @property {AllSthPattern2} supply - */ - -/** - * Create a MvrvNuplRealizedSupplyPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {MvrvNuplRealizedSupplyPattern} - */ -function createMvrvNuplRealizedSupplyPattern(client, acc) { - return { - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), - realizedCap: createAllSthPattern(client, acc), - realizedPrice: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), - supply: createAllSthPattern2(client, acc), - }; -} - /** * @typedef {Object} PhsReboundThsPattern * @property {MetricPattern1} phs @@ -3432,6 +3407,27 @@ function createLossNuplProfitPattern(client, acc) { * @property {CentsSatsUsdPattern} upperPriceBand */ +/** + * @typedef {Object} NuplRealizedSupplyPattern + * @property {BpsRatioPattern} nupl + * @property {AllSthPattern} realizedCap + * @property {AllSthPattern2} supply + */ + +/** + * Create a NuplRealizedSupplyPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {NuplRealizedSupplyPattern} + */ +function createNuplRealizedSupplyPattern(client, acc) { + return { + nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + realizedCap: createAllSthPattern(client, acc), + supply: createAllSthPattern2(client, acc), + }; +} + /** * @typedef {Object} RatioValuePattern2 * @property {_1m1w1y24hPattern} ratio @@ -6117,62 +6113,62 @@ function createUnspentPattern(client, acc) { /** * @typedef {Object} MetricsTree_Cohorts_Utxo_Profitability_Range - * @property {MvrvNuplRealizedSupplyPattern} over1000pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _500pctTo1000pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _300pctTo500pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _200pctTo300pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _100pctTo200pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _90pctTo100pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _80pctTo90pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _70pctTo80pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _60pctTo70pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _50pctTo60pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _40pctTo50pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _30pctTo40pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _20pctTo30pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _10pctTo20pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _0pctTo10pctInProfit - * @property {MvrvNuplRealizedSupplyPattern} _0pctTo10pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _10pctTo20pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _20pctTo30pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _30pctTo40pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _40pctTo50pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _50pctTo60pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _60pctTo70pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _70pctTo80pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _80pctTo90pctInLoss - * @property {MvrvNuplRealizedSupplyPattern} _90pctTo100pctInLoss + * @property {NuplRealizedSupplyPattern} over1000pctInProfit + * @property {NuplRealizedSupplyPattern} _500pctTo1000pctInProfit + * @property {NuplRealizedSupplyPattern} _300pctTo500pctInProfit + * @property {NuplRealizedSupplyPattern} _200pctTo300pctInProfit + * @property {NuplRealizedSupplyPattern} _100pctTo200pctInProfit + * @property {NuplRealizedSupplyPattern} _90pctTo100pctInProfit + * @property {NuplRealizedSupplyPattern} _80pctTo90pctInProfit + * @property {NuplRealizedSupplyPattern} _70pctTo80pctInProfit + * @property {NuplRealizedSupplyPattern} _60pctTo70pctInProfit + * @property {NuplRealizedSupplyPattern} _50pctTo60pctInProfit + * @property {NuplRealizedSupplyPattern} _40pctTo50pctInProfit + * @property {NuplRealizedSupplyPattern} _30pctTo40pctInProfit + * @property {NuplRealizedSupplyPattern} _20pctTo30pctInProfit + * @property {NuplRealizedSupplyPattern} _10pctTo20pctInProfit + * @property {NuplRealizedSupplyPattern} _0pctTo10pctInProfit + * @property {NuplRealizedSupplyPattern} _0pctTo10pctInLoss + * @property {NuplRealizedSupplyPattern} _10pctTo20pctInLoss + * @property {NuplRealizedSupplyPattern} _20pctTo30pctInLoss + * @property {NuplRealizedSupplyPattern} _30pctTo40pctInLoss + * @property {NuplRealizedSupplyPattern} _40pctTo50pctInLoss + * @property {NuplRealizedSupplyPattern} _50pctTo60pctInLoss + * @property {NuplRealizedSupplyPattern} _60pctTo70pctInLoss + * @property {NuplRealizedSupplyPattern} _70pctTo80pctInLoss + * @property {NuplRealizedSupplyPattern} _80pctTo90pctInLoss + * @property {NuplRealizedSupplyPattern} _90pctTo100pctInLoss */ /** * @typedef {Object} MetricsTree_Cohorts_Utxo_Profitability_Profit - * @property {MvrvNuplRealizedSupplyPattern} breakeven - * @property {MvrvNuplRealizedSupplyPattern} _10pct - * @property {MvrvNuplRealizedSupplyPattern} _20pct - * @property {MvrvNuplRealizedSupplyPattern} _30pct - * @property {MvrvNuplRealizedSupplyPattern} _40pct - * @property {MvrvNuplRealizedSupplyPattern} _50pct - * @property {MvrvNuplRealizedSupplyPattern} _60pct - * @property {MvrvNuplRealizedSupplyPattern} _70pct - * @property {MvrvNuplRealizedSupplyPattern} _80pct - * @property {MvrvNuplRealizedSupplyPattern} _90pct - * @property {MvrvNuplRealizedSupplyPattern} _100pct - * @property {MvrvNuplRealizedSupplyPattern} _200pct - * @property {MvrvNuplRealizedSupplyPattern} _300pct - * @property {MvrvNuplRealizedSupplyPattern} _500pct + * @property {NuplRealizedSupplyPattern} breakeven + * @property {NuplRealizedSupplyPattern} _10pct + * @property {NuplRealizedSupplyPattern} _20pct + * @property {NuplRealizedSupplyPattern} _30pct + * @property {NuplRealizedSupplyPattern} _40pct + * @property {NuplRealizedSupplyPattern} _50pct + * @property {NuplRealizedSupplyPattern} _60pct + * @property {NuplRealizedSupplyPattern} _70pct + * @property {NuplRealizedSupplyPattern} _80pct + * @property {NuplRealizedSupplyPattern} _90pct + * @property {NuplRealizedSupplyPattern} _100pct + * @property {NuplRealizedSupplyPattern} _200pct + * @property {NuplRealizedSupplyPattern} _300pct + * @property {NuplRealizedSupplyPattern} _500pct */ /** * @typedef {Object} MetricsTree_Cohorts_Utxo_Profitability_Loss - * @property {MvrvNuplRealizedSupplyPattern} breakeven - * @property {MvrvNuplRealizedSupplyPattern} _10pct - * @property {MvrvNuplRealizedSupplyPattern} _20pct - * @property {MvrvNuplRealizedSupplyPattern} _30pct - * @property {MvrvNuplRealizedSupplyPattern} _40pct - * @property {MvrvNuplRealizedSupplyPattern} _50pct - * @property {MvrvNuplRealizedSupplyPattern} _60pct - * @property {MvrvNuplRealizedSupplyPattern} _70pct - * @property {MvrvNuplRealizedSupplyPattern} _80pct + * @property {NuplRealizedSupplyPattern} breakeven + * @property {NuplRealizedSupplyPattern} _10pct + * @property {NuplRealizedSupplyPattern} _20pct + * @property {NuplRealizedSupplyPattern} _30pct + * @property {NuplRealizedSupplyPattern} _40pct + * @property {NuplRealizedSupplyPattern} _50pct + * @property {NuplRealizedSupplyPattern} _60pct + * @property {NuplRealizedSupplyPattern} _70pct + * @property {NuplRealizedSupplyPattern} _80pct */ /** @@ -9092,58 +9088,58 @@ class BrkClient extends BrkClientBase { }, profitability: { range: { - over1000pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_1000pct_in_profit'), - _500pctTo1000pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_500pct_to_1000pct_in_profit'), - _300pctTo500pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_300pct_to_500pct_in_profit'), - _200pctTo300pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_200pct_to_300pct_in_profit'), - _100pctTo200pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_100pct_to_200pct_in_profit'), - _90pctTo100pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_profit'), - _80pctTo90pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_profit'), - _70pctTo80pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_profit'), - _60pctTo70pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_profit'), - _50pctTo60pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_profit'), - _40pctTo50pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_profit'), - _30pctTo40pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_profit'), - _20pctTo30pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_profit'), - _10pctTo20pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_profit'), - _0pctTo10pctInProfit: createMvrvNuplRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_profit'), - _0pctTo10pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_loss'), - _10pctTo20pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_loss'), - _20pctTo30pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_loss'), - _30pctTo40pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_loss'), - _40pctTo50pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_loss'), - _50pctTo60pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_loss'), - _60pctTo70pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_loss'), - _70pctTo80pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_loss'), - _80pctTo90pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_loss'), - _90pctTo100pctInLoss: createMvrvNuplRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_loss'), + over1000pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_over_1000pct_in_profit'), + _500pctTo1000pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_500pct_to_1000pct_in_profit'), + _300pctTo500pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_300pct_to_500pct_in_profit'), + _200pctTo300pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_200pct_to_300pct_in_profit'), + _100pctTo200pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_100pct_to_200pct_in_profit'), + _90pctTo100pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_profit'), + _80pctTo90pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_profit'), + _70pctTo80pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_profit'), + _60pctTo70pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_profit'), + _50pctTo60pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_profit'), + _40pctTo50pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_profit'), + _30pctTo40pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_profit'), + _20pctTo30pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_profit'), + _10pctTo20pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_profit'), + _0pctTo10pctInProfit: createNuplRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_profit'), + _0pctTo10pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_0pct_to_10pct_in_loss'), + _10pctTo20pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_10pct_to_20pct_in_loss'), + _20pctTo30pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_20pct_to_30pct_in_loss'), + _30pctTo40pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_30pct_to_40pct_in_loss'), + _40pctTo50pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_40pct_to_50pct_in_loss'), + _50pctTo60pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_50pct_to_60pct_in_loss'), + _60pctTo70pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_60pct_to_70pct_in_loss'), + _70pctTo80pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_70pct_to_80pct_in_loss'), + _80pctTo90pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_80pct_to_90pct_in_loss'), + _90pctTo100pctInLoss: createNuplRealizedSupplyPattern(this, 'utxos_90pct_to_100pct_in_loss'), }, profit: { - breakeven: createMvrvNuplRealizedSupplyPattern(this, 'utxos_in_profit'), - _10pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_10pct_in_profit'), - _20pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_20pct_in_profit'), - _30pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_30pct_in_profit'), - _40pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_40pct_in_profit'), - _50pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_50pct_in_profit'), - _60pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_60pct_in_profit'), - _70pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_70pct_in_profit'), - _80pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_80pct_in_profit'), - _90pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_90pct_in_profit'), - _100pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_100pct_in_profit'), - _200pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_200pct_in_profit'), - _300pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_300pct_in_profit'), - _500pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_500pct_in_profit'), + breakeven: createNuplRealizedSupplyPattern(this, 'utxos_in_profit'), + _10pct: createNuplRealizedSupplyPattern(this, 'utxos_over_10pct_in_profit'), + _20pct: createNuplRealizedSupplyPattern(this, 'utxos_over_20pct_in_profit'), + _30pct: createNuplRealizedSupplyPattern(this, 'utxos_over_30pct_in_profit'), + _40pct: createNuplRealizedSupplyPattern(this, 'utxos_over_40pct_in_profit'), + _50pct: createNuplRealizedSupplyPattern(this, 'utxos_over_50pct_in_profit'), + _60pct: createNuplRealizedSupplyPattern(this, 'utxos_over_60pct_in_profit'), + _70pct: createNuplRealizedSupplyPattern(this, 'utxos_over_70pct_in_profit'), + _80pct: createNuplRealizedSupplyPattern(this, 'utxos_over_80pct_in_profit'), + _90pct: createNuplRealizedSupplyPattern(this, 'utxos_over_90pct_in_profit'), + _100pct: createNuplRealizedSupplyPattern(this, 'utxos_over_100pct_in_profit'), + _200pct: createNuplRealizedSupplyPattern(this, 'utxos_over_200pct_in_profit'), + _300pct: createNuplRealizedSupplyPattern(this, 'utxos_over_300pct_in_profit'), + _500pct: createNuplRealizedSupplyPattern(this, 'utxos_over_500pct_in_profit'), }, loss: { - breakeven: createMvrvNuplRealizedSupplyPattern(this, 'utxos_in_loss'), - _10pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_10pct_in_loss'), - _20pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_20pct_in_loss'), - _30pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_30pct_in_loss'), - _40pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_40pct_in_loss'), - _50pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_50pct_in_loss'), - _60pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_60pct_in_loss'), - _70pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_70pct_in_loss'), - _80pct: createMvrvNuplRealizedSupplyPattern(this, 'utxos_over_80pct_in_loss'), + breakeven: createNuplRealizedSupplyPattern(this, 'utxos_in_loss'), + _10pct: createNuplRealizedSupplyPattern(this, 'utxos_over_10pct_in_loss'), + _20pct: createNuplRealizedSupplyPattern(this, 'utxos_over_20pct_in_loss'), + _30pct: createNuplRealizedSupplyPattern(this, 'utxos_over_30pct_in_loss'), + _40pct: createNuplRealizedSupplyPattern(this, 'utxos_over_40pct_in_loss'), + _50pct: createNuplRealizedSupplyPattern(this, 'utxos_over_50pct_in_loss'), + _60pct: createNuplRealizedSupplyPattern(this, 'utxos_over_60pct_in_loss'), + _70pct: createNuplRealizedSupplyPattern(this, 'utxos_over_70pct_in_loss'), + _80pct: createNuplRealizedSupplyPattern(this, 'utxos_over_80pct_in_loss'), }, }, matured: { diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 4632882a5..382fb9c3d 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2569,17 +2569,6 @@ class InvestedMaxMinPercentilesSupplyPattern: """Pattern struct for repeated tree structure.""" pass -class MvrvNuplRealizedSupplyPattern: - """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.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) - self.realized_cap: AllSthPattern = AllSthPattern(client, acc) - self.realized_price: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) - self.supply: AllSthPattern2 = AllSthPattern2(client, acc) - class PhsReboundThsPattern: """Pattern struct for repeated tree structure.""" @@ -2917,6 +2906,15 @@ class LowerPriceUpperPattern: """Pattern struct for repeated tree structure.""" pass +class NuplRealizedSupplyPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.realized_cap: AllSthPattern = AllSthPattern(client, acc) + self.supply: AllSthPattern2 = AllSthPattern2(client, acc) + class RatioValuePattern2: """Pattern struct for repeated tree structure.""" pass @@ -5514,64 +5512,64 @@ class MetricsTree_Cohorts_Utxo_Profitability_Range: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.over_1000pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_1000pct_in_profit') - self._500pct_to_1000pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_500pct_to_1000pct_in_profit') - self._300pct_to_500pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_300pct_to_500pct_in_profit') - self._200pct_to_300pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_200pct_to_300pct_in_profit') - self._100pct_to_200pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_100pct_to_200pct_in_profit') - self._90pct_to_100pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_90pct_to_100pct_in_profit') - self._80pct_to_90pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_80pct_to_90pct_in_profit') - self._70pct_to_80pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_70pct_to_80pct_in_profit') - self._60pct_to_70pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_60pct_to_70pct_in_profit') - self._50pct_to_60pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_50pct_to_60pct_in_profit') - self._40pct_to_50pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_40pct_to_50pct_in_profit') - self._30pct_to_40pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_30pct_to_40pct_in_profit') - self._20pct_to_30pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_20pct_to_30pct_in_profit') - self._10pct_to_20pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_10pct_to_20pct_in_profit') - self._0pct_to_10pct_in_profit: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_0pct_to_10pct_in_profit') - self._0pct_to_10pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_0pct_to_10pct_in_loss') - self._10pct_to_20pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_10pct_to_20pct_in_loss') - self._20pct_to_30pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_20pct_to_30pct_in_loss') - self._30pct_to_40pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_30pct_to_40pct_in_loss') - self._40pct_to_50pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_40pct_to_50pct_in_loss') - self._50pct_to_60pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_50pct_to_60pct_in_loss') - self._60pct_to_70pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_60pct_to_70pct_in_loss') - self._70pct_to_80pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_70pct_to_80pct_in_loss') - self._80pct_to_90pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_80pct_to_90pct_in_loss') - self._90pct_to_100pct_in_loss: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_90pct_to_100pct_in_loss') + self.over_1000pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_1000pct_in_profit') + self._500pct_to_1000pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_500pct_to_1000pct_in_profit') + self._300pct_to_500pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_300pct_to_500pct_in_profit') + self._200pct_to_300pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_200pct_to_300pct_in_profit') + self._100pct_to_200pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_100pct_to_200pct_in_profit') + self._90pct_to_100pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_90pct_to_100pct_in_profit') + self._80pct_to_90pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_80pct_to_90pct_in_profit') + self._70pct_to_80pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_70pct_to_80pct_in_profit') + self._60pct_to_70pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_60pct_to_70pct_in_profit') + self._50pct_to_60pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_50pct_to_60pct_in_profit') + self._40pct_to_50pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_40pct_to_50pct_in_profit') + self._30pct_to_40pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_30pct_to_40pct_in_profit') + self._20pct_to_30pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_20pct_to_30pct_in_profit') + self._10pct_to_20pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_10pct_to_20pct_in_profit') + self._0pct_to_10pct_in_profit: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_0pct_to_10pct_in_profit') + self._0pct_to_10pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_0pct_to_10pct_in_loss') + self._10pct_to_20pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_10pct_to_20pct_in_loss') + self._20pct_to_30pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_20pct_to_30pct_in_loss') + self._30pct_to_40pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_30pct_to_40pct_in_loss') + self._40pct_to_50pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_40pct_to_50pct_in_loss') + self._50pct_to_60pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_50pct_to_60pct_in_loss') + self._60pct_to_70pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_60pct_to_70pct_in_loss') + self._70pct_to_80pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_70pct_to_80pct_in_loss') + self._80pct_to_90pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_80pct_to_90pct_in_loss') + self._90pct_to_100pct_in_loss: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_90pct_to_100pct_in_loss') class MetricsTree_Cohorts_Utxo_Profitability_Profit: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.breakeven: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_in_profit') - self._10pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_10pct_in_profit') - self._20pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_20pct_in_profit') - self._30pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_30pct_in_profit') - self._40pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_40pct_in_profit') - self._50pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_50pct_in_profit') - self._60pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_60pct_in_profit') - self._70pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_70pct_in_profit') - self._80pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_80pct_in_profit') - self._90pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_90pct_in_profit') - self._100pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_100pct_in_profit') - self._200pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_200pct_in_profit') - self._300pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_300pct_in_profit') - self._500pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_500pct_in_profit') + self.breakeven: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_in_profit') + self._10pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_10pct_in_profit') + self._20pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_20pct_in_profit') + self._30pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_30pct_in_profit') + self._40pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_40pct_in_profit') + self._50pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_50pct_in_profit') + self._60pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_60pct_in_profit') + self._70pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_70pct_in_profit') + self._80pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_80pct_in_profit') + self._90pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_90pct_in_profit') + self._100pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_100pct_in_profit') + self._200pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_200pct_in_profit') + self._300pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_300pct_in_profit') + self._500pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_500pct_in_profit') class MetricsTree_Cohorts_Utxo_Profitability_Loss: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.breakeven: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_in_loss') - self._10pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_10pct_in_loss') - self._20pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_20pct_in_loss') - self._30pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_30pct_in_loss') - self._40pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_40pct_in_loss') - self._50pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_50pct_in_loss') - self._60pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_60pct_in_loss') - self._70pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_70pct_in_loss') - self._80pct: MvrvNuplRealizedSupplyPattern = MvrvNuplRealizedSupplyPattern(client, 'utxos_over_80pct_in_loss') + self.breakeven: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_in_loss') + self._10pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_10pct_in_loss') + self._20pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_20pct_in_loss') + self._30pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_30pct_in_loss') + self._40pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_40pct_in_loss') + self._50pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_50pct_in_loss') + self._60pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_60pct_in_loss') + self._70pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_70pct_in_loss') + self._80pct: NuplRealizedSupplyPattern = NuplRealizedSupplyPattern(client, 'utxos_over_80pct_in_loss') class MetricsTree_Cohorts_Utxo_Profitability: """Metrics tree node.""" diff --git a/packages/brk_client/tests/test_basic.py b/packages/brk_client/tests/test_basic.py index 992767d4f..7f743f564 100644 --- a/packages/brk_client/tests/test_basic.py +++ b/packages/brk_client/tests/test_basic.py @@ -37,14 +37,14 @@ def test_fetch_csv_metric(): def test_fetch_typed_metric(): client = BrkClient("http://localhost:3110") # Using new idiomatic API: tail(10).fetch() or [-10:].fetch() - a = client.metrics.constants.constant_0.by.day1().tail(10).fetch() + a = client.metrics.constants._0.by.day1().tail(10).fetch() print(a) - b = client.metrics.outputs.count.utxo_count.by.height().tail(10).fetch() + b = client.metrics.outputs.count.unspent.by.height().tail(10).fetch() print(b) c = client.metrics.prices.split.close.usd.by.day1().tail(10).fetch() print(c) d = ( - client.metrics.market.dca.period_lump_sum_stack._10y.usd.by.day1() + client.metrics.market.dca.period.lump_sum_stack._10y.usd.by.day1() .tail(10) .fetch() ) @@ -55,11 +55,5 @@ def test_fetch_typed_metric(): .fetch() ) print(e) - f = ( - client.metrics.distribution.address_cohorts.amount_range._10k_sats_to_100k_sats.activity.sent.cumulative.usd.by.day1() - .tail(10) - .fetch() - ) + f = client.metrics.prices.ohlc.usd.by.day1().tail(10).fetch() print(f) - g = client.metrics.prices.ohlc.usd.by.day1().tail(10).fetch() - print(g) diff --git a/website/scripts/options/distribution/index.js b/website/scripts/options/distribution/index.js index 8e5ffe841..ba7d21bd9 100644 --- a/website/scripts/options/distribution/index.js +++ b/website/scripts/options/distribution/index.js @@ -10,7 +10,7 @@ * - activity.js: SOPR, Volume, Lifespan */ -import { formatCohortTitle, satsBtcUsd, satsBtcUsdFullTree, simplePriceRatioTree, groupedSimplePriceRatioTree } from "../shared.js"; +import { formatCohortTitle, satsBtcUsd, satsBtcUsdFullTree } from "../shared.js"; import { ROLLING_WINDOWS, line, baseline, percentRatio, rollingWindowsTree, rollingPercentRatioTree } from "../series.js"; import { Unit } from "../../utils/units.js"; @@ -635,15 +635,6 @@ function singleBucketFolder({ name, color, pattern }) { }, ], }, - { - name: "Realized Price", - tree: simplePriceRatioTree({ - pattern: pattern.realizedPrice, - title: `${name}: Realized Price`, - legend: name, - color, - }), - }, { name: "NUPL", title: `${name}: NUPL`, @@ -745,13 +736,6 @@ function groupedBucketCharts(list, titlePrefix) { }, ], }, - { - name: "Realized Price", - tree: groupedSimplePriceRatioTree({ - list: list.map(({ name, color, pattern }) => ({ name, color, pattern: pattern.realizedPrice })), - title: `${titlePrefix}: Realized Price`, - }), - }, { name: "NUPL", title: `${titlePrefix}: NUPL`,