diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 83d0b308b..153b4cb15 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -1915,28 +1915,6 @@ impl BtcCentsRelSatsUsdPattern2 { } } -/// Pattern struct for repeated tree structure. -pub struct CoindaysCoinyearsDormancySentVelocityPattern { - pub coindays_destroyed: BaseCumulativeSumPattern, - pub coinyears_destroyed: MetricPattern1, - pub dormancy: MetricPattern1, - pub sent: BaseCumulativeInSumPattern, - pub velocity: MetricPattern1, -} - -impl CoindaysCoinyearsDormancySentVelocityPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - coindays_destroyed: BaseCumulativeSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - coinyears_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), - dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), - sent: BaseCumulativeInSumPattern::new(client.clone(), _m(&acc, "sent")), - velocity: MetricPattern1::new(client.clone(), _m(&acc, "velocity")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct DeltaHalfInTotalPattern2 { pub delta: ChangeRatePattern, @@ -2327,6 +2305,26 @@ impl CentsRelUsdPattern2 { } } +/// Pattern struct for repeated tree structure. +pub struct CoindaysCoinyearsDormancySentPattern { + pub coindays_destroyed: BaseCumulativeSumPattern, + pub coinyears_destroyed: MetricPattern1, + pub dormancy: MetricPattern1, + pub sent: BaseCumulativeInSumPattern, +} + +impl CoindaysCoinyearsDormancySentPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + coindays_destroyed: BaseCumulativeSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + coinyears_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), + dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), + sent: BaseCumulativeInSumPattern::new(client.clone(), _m(&acc, "sent")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct LossNetNuplProfitPattern { pub loss: BaseCumulativeNegativeSumPattern, @@ -3122,9 +3120,9 @@ pub struct MetricsTree_Blocks { pub count: MetricsTree_Blocks_Count, pub lookback: MetricsTree_Blocks_Lookback, pub interval: _1m1w1y24hHeightPattern, - pub halving: MetricsTree_Blocks_Halving, pub vbytes: AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern, pub fullness: MetricsTree_Blocks_Fullness, + pub halving: MetricsTree_Blocks_Halving, } impl MetricsTree_Blocks { @@ -3138,9 +3136,9 @@ impl MetricsTree_Blocks { count: MetricsTree_Blocks_Count::new(client.clone(), format!("{base_path}_count")), lookback: MetricsTree_Blocks_Lookback::new(client.clone(), format!("{base_path}_lookback")), interval: _1m1w1y24hHeightPattern::new(client.clone(), "block_interval".to_string()), - halving: MetricsTree_Blocks_Halving::new(client.clone(), format!("{base_path}_halving")), vbytes: AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), "block_vbytes".to_string()), fullness: MetricsTree_Blocks_Fullness::new(client.clone(), format!("{base_path}_fullness")), + halving: MetricsTree_Blocks_Halving::new(client.clone(), format!("{base_path}_halving")), } } } @@ -3363,23 +3361,6 @@ impl MetricsTree_Blocks_Lookback { } } -/// Metrics tree node. -pub struct MetricsTree_Blocks_Halving { - pub epoch: MetricPattern1, - pub blocks_before_next: MetricPattern1, - pub days_before_next: MetricPattern1, -} - -impl MetricsTree_Blocks_Halving { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - epoch: MetricPattern1::new(client.clone(), "halving_epoch".to_string()), - blocks_before_next: MetricPattern1::new(client.clone(), "blocks_before_next_halving".to_string()), - days_before_next: MetricPattern1::new(client.clone(), "days_before_next_halving".to_string()), - } - } -} - /// Metrics tree node. pub struct MetricsTree_Blocks_Fullness { pub bps: _1m1w1y24hHeightPattern, @@ -3397,6 +3378,23 @@ impl MetricsTree_Blocks_Fullness { } } +/// Metrics tree node. +pub struct MetricsTree_Blocks_Halving { + pub epoch: MetricPattern1, + pub blocks_before_next: MetricPattern1, + pub days_before_next: MetricPattern1, +} + +impl MetricsTree_Blocks_Halving { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + epoch: MetricPattern1::new(client.clone(), "halving_epoch".to_string()), + blocks_before_next: MetricPattern1::new(client.clone(), "blocks_before_next_halving".to_string()), + days_before_next: MetricPattern1::new(client.clone(), "days_before_next_halving".to_string()), + } + } +} + /// Metrics tree node. pub struct MetricsTree_Transactions { pub raw: MetricsTree_Transactions_Raw, @@ -6423,6 +6421,7 @@ impl MetricsTree_Prices_Spot { /// Metrics tree node. pub struct MetricsTree_Supply { + pub state: MetricPattern18, pub circulating: BtcCentsSatsUsdPattern, pub burned: MetricsTree_Supply_Burned, pub inflation_rate: BpsPercentRatioPattern, @@ -6430,12 +6429,12 @@ pub struct MetricsTree_Supply { pub market_cap: CentsDeltaUsdPattern, pub market_minus_realized_cap_growth_rate: _1m1w1y24hPattern, pub hodled_or_lost: BtcCentsSatsUsdPattern, - pub state: MetricPattern18, } impl MetricsTree_Supply { pub fn new(client: Arc, base_path: String) -> Self { Self { + state: MetricPattern18::new(client.clone(), "supply_state".to_string()), circulating: BtcCentsSatsUsdPattern::new(client.clone(), "circulating_supply".to_string()), burned: MetricsTree_Supply_Burned::new(client.clone(), format!("{base_path}_burned")), inflation_rate: BpsPercentRatioPattern::new(client.clone(), "inflation_rate".to_string()), @@ -6443,7 +6442,6 @@ impl MetricsTree_Supply { market_cap: CentsDeltaUsdPattern::new(client.clone(), "market_cap".to_string()), market_minus_realized_cap_growth_rate: _1m1w1y24hPattern::new(client.clone(), "market_minus_realized_cap_growth_rate".to_string()), hodled_or_lost: BtcCentsSatsUsdPattern::new(client.clone(), "hodled_or_lost_coins".to_string()), - state: MetricPattern18::new(client.clone(), "supply_state".to_string()), } } } @@ -6465,15 +6463,15 @@ impl MetricsTree_Supply_Burned { /// Metrics tree node. pub struct MetricsTree_Supply_Velocity { - pub btc: MetricPattern1, - pub usd: MetricPattern1, + pub native: MetricPattern1, + pub fiat: MetricPattern1, } impl MetricsTree_Supply_Velocity { pub fn new(client: Arc, base_path: String) -> Self { Self { - btc: MetricPattern1::new(client.clone(), "velocity_btc".to_string()), - usd: MetricPattern1::new(client.clone(), "velocity_usd".to_string()), + native: MetricPattern1::new(client.clone(), "velocity".to_string()), + fiat: MetricPattern1::new(client.clone(), "velocity_fiat".to_string()), } } } @@ -6536,7 +6534,7 @@ impl MetricsTree_Cohorts_Utxo { pub struct MetricsTree_Cohorts_Utxo_All { pub supply: MetricsTree_Cohorts_Utxo_All_Supply, pub outputs: UnspentPattern, - pub activity: CoindaysCoinyearsDormancySentVelocityPattern, + pub activity: CoindaysCoinyearsDormancySentPattern, pub realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern, pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, pub unrealized: MetricsTree_Cohorts_Utxo_All_Unrealized, @@ -6547,7 +6545,7 @@ impl MetricsTree_Cohorts_Utxo_All { Self { supply: MetricsTree_Cohorts_Utxo_All_Supply::new(client.clone(), format!("{base_path}_supply")), outputs: UnspentPattern::new(client.clone(), "utxo_count".to_string()), - activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "".to_string()), + activity: CoindaysCoinyearsDormancySentPattern::new(client.clone(), "".to_string()), realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern::new(client.clone(), "".to_string()), cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "".to_string()), unrealized: MetricsTree_Cohorts_Utxo_All_Unrealized::new(client.clone(), format!("{base_path}_unrealized")), @@ -6557,86 +6555,46 @@ impl MetricsTree_Cohorts_Utxo_All { /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_All_Supply { - pub in_profit: BtcCentsRelSatsUsdPattern2, - pub in_loss: BtcCentsRelSatsUsdPattern2, pub total: BtcCentsSatsUsdPattern, pub half: BtcCentsSatsUsdPattern, pub delta: ChangeRatePattern, + pub in_profit: BtcCentsRelSatsUsdPattern2, + pub in_loss: BtcCentsRelSatsUsdPattern2, } impl MetricsTree_Cohorts_Utxo_All_Supply { pub fn new(client: Arc, base_path: String) -> Self { Self { - in_profit: BtcCentsRelSatsUsdPattern2::new(client.clone(), "supply_in_profit".to_string()), - in_loss: BtcCentsRelSatsUsdPattern2::new(client.clone(), "supply_in_loss".to_string()), total: BtcCentsSatsUsdPattern::new(client.clone(), "supply".to_string()), half: BtcCentsSatsUsdPattern::new(client.clone(), "supply_half".to_string()), delta: ChangeRatePattern::new(client.clone(), "supply_delta".to_string()), + in_profit: BtcCentsRelSatsUsdPattern2::new(client.clone(), "supply_in_profit".to_string()), + in_loss: BtcCentsRelSatsUsdPattern2::new(client.clone(), "supply_in_loss".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_All_Unrealized { + pub nupl: BpsRatioPattern, + pub profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit, + pub loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss, + pub net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl, pub gross_pnl: CentsUsdPattern2, pub invested_capital: InPattern, pub sentiment: GreedNetPainPattern, - pub loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss, - pub net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl, - pub profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit, - pub nupl: BpsRatioPattern, } impl MetricsTree_Cohorts_Utxo_All_Unrealized { pub fn new(client: Arc, base_path: String) -> Self { Self { + nupl: BpsRatioPattern::new(client.clone(), "nupl".to_string()), + profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit::new(client.clone(), format!("{base_path}_profit")), + loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss::new(client.clone(), format!("{base_path}_loss")), + net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), gross_pnl: CentsUsdPattern2::new(client.clone(), "unrealized_gross_pnl".to_string()), invested_capital: InPattern::new(client.clone(), "invested_capital_in".to_string()), sentiment: GreedNetPainPattern::new(client.clone(), "".to_string()), - loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss::new(client.clone(), format!("{base_path}_loss")), - net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), - profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit::new(client.clone(), format!("{base_path}_profit")), - nupl: BpsRatioPattern::new(client.clone(), "nupl".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Cohorts_Utxo_All_Unrealized_Loss { - pub negative: MetricPattern1, - pub base: CentsUsdPattern2, - pub cumulative: CentsUsdPattern2, - pub sum: _1m1w1y24hPattern4, - pub rel_to_mcap: BpsPercentRatioPattern3, - pub rel_to_own_gross: BpsPercentRatioPattern3, -} - -impl MetricsTree_Cohorts_Utxo_All_Unrealized_Loss { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - negative: MetricPattern1::new(client.clone(), "neg_unrealized_loss".to_string()), - base: CentsUsdPattern2::new(client.clone(), "unrealized_loss".to_string()), - cumulative: CentsUsdPattern2::new(client.clone(), "unrealized_loss_cumulative".to_string()), - sum: _1m1w1y24hPattern4::new(client.clone(), "unrealized_loss_sum".to_string()), - rel_to_mcap: BpsPercentRatioPattern3::new(client.clone(), "unrealized_loss_rel_to_mcap".to_string()), - rel_to_own_gross: BpsPercentRatioPattern3::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl { - pub cents: MetricPattern1, - pub usd: MetricPattern1, - pub rel_to_own_gross: BpsPercentRatioPattern, -} - -impl MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - cents: MetricPattern1::new(client.clone(), "net_unrealized_pnl_cents".to_string()), - usd: MetricPattern1::new(client.clone(), "net_unrealized_pnl".to_string()), - rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_own_gross_pnl".to_string()), } } } @@ -6662,12 +6620,52 @@ impl MetricsTree_Cohorts_Utxo_All_Unrealized_Profit { } } +/// Metrics tree node. +pub struct MetricsTree_Cohorts_Utxo_All_Unrealized_Loss { + pub base: CentsUsdPattern2, + pub cumulative: CentsUsdPattern2, + pub sum: _1m1w1y24hPattern4, + pub negative: MetricPattern1, + pub rel_to_mcap: BpsPercentRatioPattern3, + pub rel_to_own_gross: BpsPercentRatioPattern3, +} + +impl MetricsTree_Cohorts_Utxo_All_Unrealized_Loss { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + base: CentsUsdPattern2::new(client.clone(), "unrealized_loss".to_string()), + cumulative: CentsUsdPattern2::new(client.clone(), "unrealized_loss_cumulative".to_string()), + sum: _1m1w1y24hPattern4::new(client.clone(), "unrealized_loss_sum".to_string()), + negative: MetricPattern1::new(client.clone(), "neg_unrealized_loss".to_string()), + rel_to_mcap: BpsPercentRatioPattern3::new(client.clone(), "unrealized_loss_rel_to_mcap".to_string()), + rel_to_own_gross: BpsPercentRatioPattern3::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl { + pub cents: MetricPattern1, + pub usd: MetricPattern1, + pub rel_to_own_gross: BpsPercentRatioPattern, +} + +impl MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), "net_unrealized_pnl_cents".to_string()), + usd: MetricPattern1::new(client.clone(), "net_unrealized_pnl".to_string()), + rel_to_own_gross: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_own_gross_pnl".to_string()), + } + } +} + /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_Sth { - pub realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern, pub supply: DeltaHalfInRelTotalPattern2, pub outputs: UnspentPattern, - pub activity: CoindaysCoinyearsDormancySentVelocityPattern, + pub activity: CoindaysCoinyearsDormancySentPattern, + pub realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern, pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, pub unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2, } @@ -6675,10 +6673,10 @@ pub struct MetricsTree_Cohorts_Utxo_Sth { impl MetricsTree_Cohorts_Utxo_Sth { pub fn new(client: Arc, base_path: String) -> Self { Self { - realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern::new(client.clone(), "sth".to_string()), supply: DeltaHalfInRelTotalPattern2::new(client.clone(), "sth_supply".to_string()), outputs: UnspentPattern::new(client.clone(), "sth_utxo_count".to_string()), - activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "sth".to_string()), + activity: CoindaysCoinyearsDormancySentPattern::new(client.clone(), "sth".to_string()), + realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern::new(client.clone(), "sth".to_string()), cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "sth".to_string()), unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2::new(client.clone(), "sth".to_string()), } @@ -6689,7 +6687,7 @@ impl MetricsTree_Cohorts_Utxo_Sth { pub struct MetricsTree_Cohorts_Utxo_Lth { pub supply: DeltaHalfInRelTotalPattern2, pub outputs: UnspentPattern, - pub activity: CoindaysCoinyearsDormancySentVelocityPattern, + pub activity: CoindaysCoinyearsDormancySentPattern, pub realized: MetricsTree_Cohorts_Utxo_Lth_Realized, pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, pub unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2, @@ -6700,7 +6698,7 @@ impl MetricsTree_Cohorts_Utxo_Lth { Self { supply: DeltaHalfInRelTotalPattern2::new(client.clone(), "lth_supply".to_string()), outputs: UnspentPattern::new(client.clone(), "lth_utxo_count".to_string()), - activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "lth".to_string()), + activity: CoindaysCoinyearsDormancySentPattern::new(client.clone(), "lth".to_string()), realized: MetricsTree_Cohorts_Utxo_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "lth".to_string()), unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2::new(client.clone(), "lth".to_string()), @@ -6710,52 +6708,52 @@ impl MetricsTree_Cohorts_Utxo_Lth { /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_Lth_Realized { + pub cap: CentsDeltaRelUsdPattern, pub profit: BaseCumulativeDistributionRelSumValuePattern, pub loss: BaseCapitulationCumulativeNegativeRelSumValuePattern, + pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, + pub mvrv: MetricPattern1, + pub sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr, + pub net_pnl: BaseChangeCumulativeDeltaRelSumPattern, pub gross_pnl: BaseCumulativeSumPattern3, pub sell_side_risk_ratio: _1m1w1y24hPattern6, - pub net_pnl: BaseChangeCumulativeDeltaRelSumPattern, - pub sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr, pub peak_regret: BaseCumulativeRelPattern, pub investor: LowerPriceUpperPattern, pub profit_to_loss_ratio: _1m1w1y24hPattern, - pub cap: CentsDeltaRelUsdPattern, - pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, - pub mvrv: MetricPattern1, } impl MetricsTree_Cohorts_Utxo_Lth_Realized { pub fn new(client: Arc, base_path: String) -> Self { Self { + cap: CentsDeltaRelUsdPattern::new(client.clone(), "lth_realized_cap".to_string()), profit: BaseCumulativeDistributionRelSumValuePattern::new(client.clone(), "lth".to_string()), loss: BaseCapitulationCumulativeNegativeRelSumValuePattern::new(client.clone(), "lth".to_string()), + price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern::new(client.clone(), "lth_realized_price".to_string()), + mvrv: MetricPattern1::new(client.clone(), "lth_mvrv".to_string()), + sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr::new(client.clone(), format!("{base_path}_sopr")), + net_pnl: BaseChangeCumulativeDeltaRelSumPattern::new(client.clone(), "lth_net".to_string()), gross_pnl: BaseCumulativeSumPattern3::new(client.clone(), "lth_realized_gross_pnl".to_string()), sell_side_risk_ratio: _1m1w1y24hPattern6::new(client.clone(), "lth_sell_side_risk_ratio".to_string()), - net_pnl: BaseChangeCumulativeDeltaRelSumPattern::new(client.clone(), "lth_net".to_string()), - sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr::new(client.clone(), format!("{base_path}_sopr")), peak_regret: BaseCumulativeRelPattern::new(client.clone(), "lth_realized_peak_regret".to_string()), investor: LowerPriceUpperPattern::new(client.clone(), "lth".to_string()), profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "lth_realized_profit_to_loss_ratio".to_string()), - cap: CentsDeltaRelUsdPattern::new(client.clone(), "lth_realized_cap".to_string()), - price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern::new(client.clone(), "lth_realized_price".to_string()), - mvrv: MetricPattern1::new(client.clone(), "lth_mvrv".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr { - pub ratio: _1m1w1y24hPattern, pub value_created: BaseCumulativeSumPattern, pub value_destroyed: BaseCumulativeSumPattern, + pub ratio: _1m1w1y24hPattern, } impl MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr { pub fn new(client: Arc, base_path: String) -> Self { Self { - ratio: _1m1w1y24hPattern::new(client.clone(), "lth_sopr".to_string()), value_created: BaseCumulativeSumPattern::new(client.clone(), "lth_value_created".to_string()), value_destroyed: BaseCumulativeSumPattern::new(client.clone(), "lth_value_destroyed".to_string()), + ratio: _1m1w1y24hPattern::new(client.clone(), "lth_sopr".to_string()), } } } diff --git a/crates/brk_computer/src/cointime/adjusted/compute.rs b/crates/brk_computer/src/cointime/adjusted/compute.rs index fad9ad36b..09a0767e2 100644 --- a/crates/brk_computer/src/cointime/adjusted/compute.rs +++ b/crates/brk_computer/src/cointime/adjusted/compute.rs @@ -30,14 +30,14 @@ impl Vecs { self.tx_velocity_btc.height.compute_multiply( starting_indexes.height, &activity.ratio.height, - &supply.velocity.btc.height, + &supply.velocity.native.height, exit, )?; self.tx_velocity_usd.height.compute_multiply( starting_indexes.height, &activity.ratio.height, - &supply.velocity.usd.height, + &supply.velocity.fiat.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index 05f605e31..374fd4cb4 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -1,10 +1,10 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF32, StoredF64, Version}; +use brk_types::{Bitcoin, Height, Indexes, StoredF32, StoredF64, Version}; use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; +use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, Rw, StorageMode}; -use crate::internal::{PerBlock, Identity, LazyPerBlock}; +use crate::internal::{Identity, LazyPerBlock, PerBlock}; use crate::distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}; @@ -20,7 +20,6 @@ pub struct ActivityFull { pub coinyears_destroyed: LazyPerBlock, pub dormancy: PerBlock, - pub velocity: PerBlock, } impl ActivityFull { @@ -39,7 +38,6 @@ impl ActivityFull { inner, coinyears_destroyed, dormancy: cfg.import("dormancy", v1)?, - velocity: cfg.import("velocity", v1)?, }) } @@ -58,7 +56,6 @@ impl ActivityFull { pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { let mut vecs = self.inner.collect_vecs_mut(); vecs.push(&mut self.dormancy.height); - vecs.push(&mut self.velocity.height); vecs } @@ -83,7 +80,6 @@ impl ActivityFull { pub(crate) fn compute_rest_part2( &mut self, starting_indexes: &Indexes, - supply_total_sats: &impl ReadableVec, exit: &Exit, ) -> Result<()> { self.dormancy.height.compute_transform2( @@ -101,21 +97,6 @@ impl ActivityFull { exit, )?; - self.velocity.height.compute_transform2( - starting_indexes.height, - &self.inner.sent.base.height, - supply_total_sats, - |(i, sent_sats, supply_sats, ..)| { - let supply = supply_sats.as_u128() as f64; - if supply == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((sent_sats.as_u128() as f64 / supply) as f32)) - } - }, - exit, - )?; - Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index 563258043..02ca730c5 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -145,7 +145,6 @@ impl AllCohortMetrics { self.activity.compute_rest_part2( starting_indexes, - &self.supply.total.sats.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index f5add33e9..7d0037bdd 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -125,7 +125,6 @@ impl ExtendedCohortMetrics { self.activity.compute_rest_part2( starting_indexes, - &self.supply.total.sats.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs index a7389efb3..0f021392f 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs @@ -10,17 +10,17 @@ use crate::{ #[derive(Traversable)] pub struct AdjustedSopr { + pub ratio: RollingWindows, pub value_created: PerBlockCumulativeWithSums, pub value_destroyed: PerBlockCumulativeWithSums, - pub ratio: RollingWindows, } impl AdjustedSopr { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { + ratio: cfg.import("asopr", Version::ONE)?, value_created: cfg.import("adj_value_created", Version::ONE)?, value_destroyed: cfg.import("adj_value_destroyed", Version::ONE)?, - ratio: cfg.import("asopr", Version::ONE)?, }) } diff --git a/crates/brk_computer/src/supply/velocity/compute.rs b/crates/brk_computer/src/supply/velocity/compute.rs index 47154534f..b876e107b 100644 --- a/crates/brk_computer/src/supply/velocity/compute.rs +++ b/crates/brk_computer/src/supply/velocity/compute.rs @@ -17,8 +17,8 @@ impl Vecs { // velocity = rolling_1y_sum(volume) / circulating_supply let circulating_supply = &distribution.utxo_cohorts.all.metrics.supply.total; - // BTC velocity at height level - self.btc.height.compute_rolling_ratio( + // Native velocity at height level + self.native.height.compute_rolling_ratio( starting_indexes.height, &blocks.lookback._1y, &transactions.volume.sent_sum.base.sats.height, @@ -26,8 +26,8 @@ impl Vecs { exit, )?; - // USD velocity at height level - self.usd.height.compute_rolling_ratio( + // Fiat velocity at height level + self.fiat.height.compute_rolling_ratio( starting_indexes.height, &blocks.lookback._1y, &transactions.volume.sent_sum.base.usd.height, diff --git a/crates/brk_computer/src/supply/velocity/import.rs b/crates/brk_computer/src/supply/velocity/import.rs index af93a41bd..a95cd164c 100644 --- a/crates/brk_computer/src/supply/velocity/import.rs +++ b/crates/brk_computer/src/supply/velocity/import.rs @@ -12,8 +12,8 @@ impl Vecs { indexes: &indexes::Vecs, ) -> Result { Ok(Self { - btc: PerBlock::forced_import(db, "velocity_btc", version, indexes)?, - usd: PerBlock::forced_import(db, "velocity_usd", version, indexes)?, + native: PerBlock::forced_import(db, "velocity", version, indexes)?, + fiat: PerBlock::forced_import(db, "velocity_fiat", version, indexes)?, }) } } diff --git a/crates/brk_computer/src/supply/velocity/vecs.rs b/crates/brk_computer/src/supply/velocity/vecs.rs index 0ca397ba3..7eeb65eb6 100644 --- a/crates/brk_computer/src/supply/velocity/vecs.rs +++ b/crates/brk_computer/src/supply/velocity/vecs.rs @@ -6,6 +6,6 @@ use crate::internal::PerBlock; #[derive(Traversable)] pub struct Vecs { - pub btc: PerBlock, - pub usd: PerBlock, + pub native: PerBlock, + pub fiat: PerBlock, } diff --git a/crates/brk_traversable_derive/src/lib.rs b/crates/brk_traversable_derive/src/lib.rs index ffeede040..aaf3f42e9 100644 --- a/crates/brk_traversable_derive/src/lib.rs +++ b/crates/brk_traversable_derive/src/lib.rs @@ -394,90 +394,95 @@ fn build_where_clause( } fn generate_field_traversals(infos: &[FieldInfo], merge: bool) -> proc_macro2::TokenStream { - let normal_entries: Vec<_> = infos + // Process all fields in declaration order (interleaving normal and flatten) + // so that struct field order determines tree key order. + let field_operations: Vec<_> = infos .iter() - .filter(|i| matches!(i.attr, FieldAttr::Normal) && !i.hidden) + .filter(|i| !i.hidden) .map(|info| { - let field_name = info.name; - let field_name_str = { - let s = field_name.to_string(); - let s = s.strip_prefix("r#").unwrap_or(&s).to_string(); - s.strip_prefix('_').map(String::from).unwrap_or(s) - }; + match info.attr { + FieldAttr::Normal => { + let field_name = info.name; + let field_name_str = { + let s = field_name.to_string(); + let s = s.strip_prefix("r#").unwrap_or(&s).to_string(); + s.strip_prefix('_').map(String::from).unwrap_or(s) + }; - // Determine the tree key and optional wrapping path. - // wrap = "a/b" means: outer_key = "a", wrap the node under "b" then under the rename/field name. - // wrap = "a" means: outer_key = "a", wrap under rename or field name. - // No wrap: outer_key = rename or field name, no wrapping. - let (outer_key, wrap_path): (String, Vec<&str>) = - match (info.wrap.as_deref(), info.rename.as_deref()) { - (Some(wrap), Some(rename)) => { - let parts: Vec<&str> = wrap.split('/').collect(); - let outer = parts[0].to_string(); - let mut path: Vec<&str> = parts[1..].to_vec(); - path.push(rename); - (outer, path) - } - (Some(wrap), None) => { - let parts: Vec<&str> = wrap.split('/').collect(); - let outer = parts[0].to_string(); - let mut path: Vec<&str> = parts[1..].to_vec(); - path.push(&field_name_str); - (outer, path) - } - (None, Some(rename)) => (rename.to_string(), vec![]), - (None, None) => (field_name_str.clone(), vec![]), - }; + // Determine the tree key and optional wrapping path. + // wrap = "a/b" means: outer_key = "a", wrap the node under "b" then under the rename/field name. + // wrap = "a" means: outer_key = "a", wrap under rename or field name. + // No wrap: outer_key = rename or field name, no wrapping. + let (outer_key, wrap_path): (String, Vec<&str>) = + match (info.wrap.as_deref(), info.rename.as_deref()) { + (Some(wrap), Some(rename)) => { + let parts: Vec<&str> = wrap.split('/').collect(); + let outer = parts[0].to_string(); + let mut path: Vec<&str> = parts[1..].to_vec(); + path.push(rename); + (outer, path) + } + (Some(wrap), None) => { + let parts: Vec<&str> = wrap.split('/').collect(); + let outer = parts[0].to_string(); + let mut path: Vec<&str> = parts[1..].to_vec(); + path.push(&field_name_str); + (outer, path) + } + (None, Some(rename)) => (rename.to_string(), vec![]), + (None, None) => (field_name_str.clone(), vec![]), + }; - // Build nested wrapping: wrap(path[last], wrap(path[last-1], ... node)) - let build_wrapped = |base: proc_macro2::TokenStream| -> proc_macro2::TokenStream { - wrap_path.iter().rev().fold(base, |inner, key| { - quote! { brk_traversable::TreeNode::wrap(#key, #inner) } - }) - }; + // Build nested wrapping: wrap(path[last], wrap(path[last-1], ... node)) + let build_wrapped = |base: proc_macro2::TokenStream| -> proc_macro2::TokenStream { + wrap_path.iter().rev().fold(base, |inner, key| { + quote! { brk_traversable::TreeNode::wrap(#key, #inner) } + }) + }; - if info.is_option { - let node_expr = build_wrapped(quote! { nested.to_tree_node() }); - quote! { - self.#field_name.as_ref().map(|nested| (String::from(#outer_key), #node_expr)) - } - } else { - let node_expr_self = build_wrapped(quote! { self.#field_name.to_tree_node() }); - quote! { - Some((String::from(#outer_key), #node_expr_self)) - } - } - }) - .collect(); - - let flatten_entries: Vec<_> = infos - .iter() - .filter(|i| matches!(i.attr, FieldAttr::Flatten) && !i.hidden) - .map(|info| { - let field_name = info.name; - let merge_branch = quote! { - brk_traversable::TreeNode::Branch(map) => { - for (key, node) in map { - brk_traversable::TreeNode::merge_node(&mut collected, key, node) - .expect("Conflicting values for same key during flatten"); + if info.is_option { + let node_expr = build_wrapped(quote! { nested.to_tree_node() }); + quote! { + if let Some(entry) = self.#field_name.as_ref().map(|nested| (String::from(#outer_key), #node_expr)) { + brk_traversable::TreeNode::merge_node(&mut collected, entry.0, entry.1) + .expect("Conflicting values for same key"); + } + } + } else { + let node_expr_self = build_wrapped(quote! { self.#field_name.to_tree_node() }); + quote! { + brk_traversable::TreeNode::merge_node(&mut collected, String::from(#outer_key), #node_expr_self) + .expect("Conflicting values for same key"); + } } } - leaf @ brk_traversable::TreeNode::Leaf(_) => { - brk_traversable::TreeNode::merge_node(&mut collected, String::from(stringify!(#field_name)), leaf) - .expect("Conflicting values for same key during flatten"); - } - }; + FieldAttr::Flatten => { + let field_name = info.name; + let merge_branch = quote! { + brk_traversable::TreeNode::Branch(map) => { + for (key, node) in map { + brk_traversable::TreeNode::merge_node(&mut collected, key, node) + .expect("Conflicting values for same key during flatten"); + } + } + leaf @ brk_traversable::TreeNode::Leaf(_) => { + brk_traversable::TreeNode::merge_node(&mut collected, String::from(stringify!(#field_name)), leaf) + .expect("Conflicting values for same key during flatten"); + } + }; - if info.is_option { - quote! { - if let Some(ref nested) = self.#field_name { - match nested.to_tree_node() { #merge_branch } + if info.is_option { + quote! { + if let Some(ref nested) = self.#field_name { + match nested.to_tree_node() { #merge_branch } + } + } + } else { + quote! { + match self.#field_name.to_tree_node() { #merge_branch } + } } } - } else { - quote! { - match self.#field_name.to_tree_node() { #merge_branch } - } } }) .collect(); @@ -493,23 +498,9 @@ fn generate_field_traversals(infos: &[FieldInfo], merge: bool) -> proc_macro2::T brk_traversable::IndexMap::new(); }; - let normal_insert = if !normal_entries.is_empty() { - quote! { - for entry in [#(#normal_entries,)*].into_iter().flatten() { - brk_traversable::TreeNode::merge_node(&mut collected, entry.0, entry.1) - .expect("Conflicting values for same key"); - } - } - } else { - quote! {} - }; - - let flatten_insert = quote! { #(#flatten_entries)* }; - quote! { #init_collected - #normal_insert - #flatten_insert + #(#field_operations)* #final_expr } } diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 9d3f2f166..a36ce4ff7 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -2687,31 +2687,6 @@ function createBtcCentsRelSatsUsdPattern2(client, acc) { }; } -/** - * @typedef {Object} CoindaysCoinyearsDormancySentVelocityPattern - * @property {BaseCumulativeSumPattern} coindaysDestroyed - * @property {MetricPattern1} coinyearsDestroyed - * @property {MetricPattern1} dormancy - * @property {BaseCumulativeInSumPattern} sent - * @property {MetricPattern1} velocity - */ - -/** - * Create a CoindaysCoinyearsDormancySentVelocityPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CoindaysCoinyearsDormancySentVelocityPattern} - */ -function createCoindaysCoinyearsDormancySentVelocityPattern(client, acc) { - return { - coindaysDestroyed: createBaseCumulativeSumPattern(client, _m(acc, 'coindays_destroyed')), - coinyearsDestroyed: createMetricPattern1(client, _m(acc, 'coinyears_destroyed')), - dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), - sent: createBaseCumulativeInSumPattern(client, _m(acc, 'sent')), - velocity: createMetricPattern1(client, _m(acc, 'velocity')), - }; -} - /** * @typedef {Object} DeltaHalfInTotalPattern2 * @property {ChangeRatePattern} delta @@ -3161,6 +3136,29 @@ function createCentsRelUsdPattern2(client, acc) { }; } +/** + * @typedef {Object} CoindaysCoinyearsDormancySentPattern + * @property {BaseCumulativeSumPattern} coindaysDestroyed + * @property {MetricPattern1} coinyearsDestroyed + * @property {MetricPattern1} dormancy + * @property {BaseCumulativeInSumPattern} sent + */ + +/** + * Create a CoindaysCoinyearsDormancySentPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoindaysCoinyearsDormancySentPattern} + */ +function createCoindaysCoinyearsDormancySentPattern(client, acc) { + return { + coindaysDestroyed: createBaseCumulativeSumPattern(client, _m(acc, 'coindays_destroyed')), + coinyearsDestroyed: createMetricPattern1(client, _m(acc, 'coinyears_destroyed')), + dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), + sent: createBaseCumulativeInSumPattern(client, _m(acc, 'sent')), + }; +} + /** * @typedef {Object} LossNetNuplProfitPattern * @property {BaseCumulativeNegativeSumPattern} loss @@ -4068,9 +4066,9 @@ function createUnspentPattern(client, acc) { * @property {MetricsTree_Blocks_Count} count * @property {MetricsTree_Blocks_Lookback} lookback * @property {_1m1w1y24hHeightPattern} interval - * @property {MetricsTree_Blocks_Halving} halving * @property {AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern} vbytes * @property {MetricsTree_Blocks_Fullness} fullness + * @property {MetricsTree_Blocks_Halving} halving */ /** @@ -4173,13 +4171,6 @@ function createUnspentPattern(client, acc) { * @property {MetricPattern18} _26y */ -/** - * @typedef {Object} MetricsTree_Blocks_Halving - * @property {MetricPattern1} epoch - * @property {MetricPattern1} blocksBeforeNext - * @property {MetricPattern1} daysBeforeNext - */ - /** * @typedef {Object} MetricsTree_Blocks_Fullness * @property {_1m1w1y24hHeightPattern} bps @@ -4187,6 +4178,13 @@ function createUnspentPattern(client, acc) { * @property {MetricPattern1} percent */ +/** + * @typedef {Object} MetricsTree_Blocks_Halving + * @property {MetricPattern1} epoch + * @property {MetricPattern1} blocksBeforeNext + * @property {MetricPattern1} daysBeforeNext + */ + /** * @typedef {Object} MetricsTree_Transactions * @property {MetricsTree_Transactions_Raw} raw @@ -5503,6 +5501,7 @@ function createUnspentPattern(client, acc) { /** * @typedef {Object} MetricsTree_Supply + * @property {MetricPattern18} state * @property {BtcCentsSatsUsdPattern} circulating * @property {MetricsTree_Supply_Burned} burned * @property {BpsPercentRatioPattern} inflationRate @@ -5510,7 +5509,6 @@ function createUnspentPattern(client, acc) { * @property {CentsDeltaUsdPattern} marketCap * @property {_1m1w1y24hPattern} marketMinusRealizedCapGrowthRate * @property {BtcCentsSatsUsdPattern} hodledOrLost - * @property {MetricPattern18} state */ /** @@ -5521,8 +5519,8 @@ function createUnspentPattern(client, acc) { /** * @typedef {Object} MetricsTree_Supply_Velocity - * @property {MetricPattern1} btc - * @property {MetricPattern1} usd + * @property {MetricPattern1} native + * @property {MetricPattern1} fiat */ /** @@ -5553,7 +5551,7 @@ function createUnspentPattern(client, acc) { * @typedef {Object} MetricsTree_Cohorts_Utxo_All * @property {MetricsTree_Cohorts_Utxo_All_Supply} supply * @property {UnspentPattern} outputs - * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity + * @property {CoindaysCoinyearsDormancySentPattern} activity * @property {CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} realized * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis * @property {MetricsTree_Cohorts_Utxo_All_Unrealized} unrealized @@ -5561,39 +5559,22 @@ function createUnspentPattern(client, acc) { /** * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Supply - * @property {BtcCentsRelSatsUsdPattern2} inProfit - * @property {BtcCentsRelSatsUsdPattern2} inLoss * @property {BtcCentsSatsUsdPattern} total * @property {BtcCentsSatsUsdPattern} half * @property {ChangeRatePattern} delta + * @property {BtcCentsRelSatsUsdPattern2} inProfit + * @property {BtcCentsRelSatsUsdPattern2} inLoss */ /** * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized + * @property {BpsRatioPattern} nupl + * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_Profit} profit + * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_Loss} loss + * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl} netPnl * @property {CentsUsdPattern2} grossPnl * @property {InPattern} investedCapital * @property {GreedNetPainPattern} sentiment - * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_Loss} loss - * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl} netPnl - * @property {MetricsTree_Cohorts_Utxo_All_Unrealized_Profit} profit - * @property {BpsRatioPattern} nupl - */ - -/** - * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized_Loss - * @property {MetricPattern1} negative - * @property {CentsUsdPattern2} base - * @property {CentsUsdPattern2} cumulative - * @property {_1m1w1y24hPattern4} sum - * @property {BpsPercentRatioPattern3} relToMcap - * @property {BpsPercentRatioPattern3} relToOwnGross - */ - -/** - * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl - * @property {MetricPattern1} cents - * @property {MetricPattern1} usd - * @property {BpsPercentRatioPattern} relToOwnGross */ /** @@ -5605,12 +5586,29 @@ function createUnspentPattern(client, acc) { * @property {BpsPercentRatioPattern3} relToOwnGross */ +/** + * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized_Loss + * @property {CentsUsdPattern2} base + * @property {CentsUsdPattern2} cumulative + * @property {_1m1w1y24hPattern4} sum + * @property {MetricPattern1} negative + * @property {BpsPercentRatioPattern3} relToMcap + * @property {BpsPercentRatioPattern3} relToOwnGross + */ + +/** + * @typedef {Object} MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl + * @property {MetricPattern1} cents + * @property {MetricPattern1} usd + * @property {BpsPercentRatioPattern} relToOwnGross + */ + /** * @typedef {Object} MetricsTree_Cohorts_Utxo_Sth - * @property {CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} realized * @property {DeltaHalfInRelTotalPattern2} supply * @property {UnspentPattern} outputs - * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity + * @property {CoindaysCoinyearsDormancySentPattern} activity + * @property {CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern} realized * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis * @property {GrossInvestedLossNetNuplProfitSentimentPattern2} unrealized */ @@ -5619,7 +5617,7 @@ function createUnspentPattern(client, acc) { * @typedef {Object} MetricsTree_Cohorts_Utxo_Lth * @property {DeltaHalfInRelTotalPattern2} supply * @property {UnspentPattern} outputs - * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity + * @property {CoindaysCoinyearsDormancySentPattern} activity * @property {MetricsTree_Cohorts_Utxo_Lth_Realized} realized * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis * @property {GrossInvestedLossNetNuplProfitSentimentPattern2} unrealized @@ -5627,25 +5625,25 @@ function createUnspentPattern(client, acc) { /** * @typedef {Object} MetricsTree_Cohorts_Utxo_Lth_Realized + * @property {CentsDeltaRelUsdPattern} cap * @property {BaseCumulativeDistributionRelSumValuePattern} profit * @property {BaseCapitulationCumulativeNegativeRelSumValuePattern} loss + * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price + * @property {MetricPattern1} mvrv + * @property {MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr} sopr + * @property {BaseChangeCumulativeDeltaRelSumPattern} netPnl * @property {BaseCumulativeSumPattern3} grossPnl * @property {_1m1w1y24hPattern6} sellSideRiskRatio - * @property {BaseChangeCumulativeDeltaRelSumPattern} netPnl - * @property {MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr} sopr * @property {BaseCumulativeRelPattern} peakRegret * @property {LowerPriceUpperPattern} investor * @property {_1m1w1y24hPattern} profitToLossRatio - * @property {CentsDeltaRelUsdPattern} cap - * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price - * @property {MetricPattern1} mvrv */ /** * @typedef {Object} MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr - * @property {_1m1w1y24hPattern} ratio * @property {BaseCumulativeSumPattern} valueCreated * @property {BaseCumulativeSumPattern} valueDestroyed + * @property {_1m1w1y24hPattern} ratio */ /** @@ -7004,17 +7002,17 @@ class BrkClient extends BrkClientBase { _26y: createMetricPattern18(this, 'height_26y_ago'), }, interval: create_1m1w1y24hHeightPattern(this, 'block_interval'), - halving: { - epoch: createMetricPattern1(this, 'halving_epoch'), - blocksBeforeNext: createMetricPattern1(this, 'blocks_before_next_halving'), - daysBeforeNext: createMetricPattern1(this, 'days_before_next_halving'), - }, vbytes: createAverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern(this, 'block_vbytes'), fullness: { bps: create_1m1w1y24hHeightPattern(this, 'block_fullness_bps'), ratio: createMetricPattern1(this, 'block_fullness_ratio'), percent: createMetricPattern1(this, 'block_fullness'), }, + halving: { + epoch: createMetricPattern1(this, 'halving_epoch'), + blocksBeforeNext: createMetricPattern1(this, 'blocks_before_next_halving'), + daysBeforeNext: createMetricPattern1(this, 'days_before_next_halving'), + }, }, transactions: { raw: { @@ -7948,6 +7946,7 @@ class BrkClient extends BrkClientBase { }, }, supply: { + state: createMetricPattern18(this, 'supply_state'), circulating: createBtcCentsSatsUsdPattern(this, 'circulating_supply'), burned: { opReturn: createBaseCumulativeSumPattern4(this, 'op_return_supply'), @@ -7955,37 +7954,41 @@ class BrkClient extends BrkClientBase { }, inflationRate: createBpsPercentRatioPattern(this, 'inflation_rate'), velocity: { - btc: createMetricPattern1(this, 'velocity_btc'), - usd: createMetricPattern1(this, 'velocity_usd'), + native: createMetricPattern1(this, 'velocity'), + fiat: createMetricPattern1(this, 'velocity_fiat'), }, marketCap: createCentsDeltaUsdPattern(this, 'market_cap'), marketMinusRealizedCapGrowthRate: create_1m1w1y24hPattern(this, 'market_minus_realized_cap_growth_rate'), hodledOrLost: createBtcCentsSatsUsdPattern(this, 'hodled_or_lost_coins'), - state: createMetricPattern18(this, 'supply_state'), }, cohorts: { utxo: { all: { supply: { - inProfit: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_profit'), - inLoss: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_loss'), total: createBtcCentsSatsUsdPattern(this, 'supply'), half: createBtcCentsSatsUsdPattern(this, 'supply_half'), delta: createChangeRatePattern(this, 'supply_delta'), + inProfit: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_profit'), + inLoss: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_loss'), }, outputs: createUnspentPattern(this, 'utxo_count'), - activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, ''), + activity: createCoindaysCoinyearsDormancySentPattern(this, ''), realized: createCapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(this, ''), costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, ''), unrealized: { - grossPnl: createCentsUsdPattern2(this, 'unrealized_gross_pnl'), - investedCapital: createInPattern(this, 'invested_capital_in'), - sentiment: createGreedNetPainPattern(this, ''), + nupl: createBpsRatioPattern(this, 'nupl'), + profit: { + base: createCentsUsdPattern2(this, 'unrealized_profit'), + cumulative: createCentsUsdPattern2(this, 'unrealized_profit_cumulative'), + sum: create_1m1w1y24hPattern4(this, 'unrealized_profit_sum'), + relToMcap: createBpsPercentRatioPattern3(this, 'unrealized_profit_rel_to_mcap'), + relToOwnGross: createBpsPercentRatioPattern3(this, 'unrealized_profit_rel_to_own_gross_pnl'), + }, loss: { - negative: createMetricPattern1(this, 'neg_unrealized_loss'), base: createCentsUsdPattern2(this, 'unrealized_loss'), cumulative: createCentsUsdPattern2(this, 'unrealized_loss_cumulative'), sum: create_1m1w1y24hPattern4(this, 'unrealized_loss_sum'), + negative: createMetricPattern1(this, 'neg_unrealized_loss'), relToMcap: createBpsPercentRatioPattern3(this, 'unrealized_loss_rel_to_mcap'), relToOwnGross: createBpsPercentRatioPattern3(this, 'unrealized_loss_rel_to_own_gross_pnl'), }, @@ -7994,45 +7997,40 @@ class BrkClient extends BrkClientBase { usd: createMetricPattern1(this, 'net_unrealized_pnl'), relToOwnGross: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'), }, - profit: { - base: createCentsUsdPattern2(this, 'unrealized_profit'), - cumulative: createCentsUsdPattern2(this, 'unrealized_profit_cumulative'), - sum: create_1m1w1y24hPattern4(this, 'unrealized_profit_sum'), - relToMcap: createBpsPercentRatioPattern3(this, 'unrealized_profit_rel_to_mcap'), - relToOwnGross: createBpsPercentRatioPattern3(this, 'unrealized_profit_rel_to_own_gross_pnl'), - }, - nupl: createBpsRatioPattern(this, 'nupl'), + grossPnl: createCentsUsdPattern2(this, 'unrealized_gross_pnl'), + investedCapital: createInPattern(this, 'invested_capital_in'), + sentiment: createGreedNetPainPattern(this, ''), }, }, sth: { - realized: createCapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(this, 'sth'), supply: createDeltaHalfInRelTotalPattern2(this, 'sth_supply'), outputs: createUnspentPattern(this, 'sth_utxo_count'), - activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'sth'), + activity: createCoindaysCoinyearsDormancySentPattern(this, 'sth'), + realized: createCapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(this, 'sth'), costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'sth'), unrealized: createGrossInvestedLossNetNuplProfitSentimentPattern2(this, 'sth'), }, lth: { supply: createDeltaHalfInRelTotalPattern2(this, 'lth_supply'), outputs: createUnspentPattern(this, 'lth_utxo_count'), - activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'lth'), + activity: createCoindaysCoinyearsDormancySentPattern(this, 'lth'), realized: { + cap: createCentsDeltaRelUsdPattern(this, 'lth_realized_cap'), profit: createBaseCumulativeDistributionRelSumValuePattern(this, 'lth'), loss: createBaseCapitulationCumulativeNegativeRelSumValuePattern(this, 'lth'), - grossPnl: createBaseCumulativeSumPattern3(this, 'lth_realized_gross_pnl'), - sellSideRiskRatio: create_1m1w1y24hPattern6(this, 'lth_sell_side_risk_ratio'), - netPnl: createBaseChangeCumulativeDeltaRelSumPattern(this, 'lth_net'), + price: createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(this, 'lth_realized_price'), + mvrv: createMetricPattern1(this, 'lth_mvrv'), sopr: { - ratio: create_1m1w1y24hPattern(this, 'lth_sopr'), valueCreated: createBaseCumulativeSumPattern(this, 'lth_value_created'), valueDestroyed: createBaseCumulativeSumPattern(this, 'lth_value_destroyed'), + ratio: create_1m1w1y24hPattern(this, 'lth_sopr'), }, + netPnl: createBaseChangeCumulativeDeltaRelSumPattern(this, 'lth_net'), + grossPnl: createBaseCumulativeSumPattern3(this, 'lth_realized_gross_pnl'), + sellSideRiskRatio: create_1m1w1y24hPattern6(this, 'lth_sell_side_risk_ratio'), peakRegret: createBaseCumulativeRelPattern(this, 'lth_realized_peak_regret'), investor: createLowerPriceUpperPattern(this, 'lth'), profitToLossRatio: create_1m1w1y24hPattern(this, 'lth_realized_profit_to_loss_ratio'), - cap: createCentsDeltaRelUsdPattern(this, 'lth_realized_cap'), - price: createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(this, 'lth_realized_price'), - mvrv: createMetricPattern1(this, 'lth_mvrv'), }, costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'lth'), unrealized: createGrossInvestedLossNetNuplProfitSentimentPattern2(this, 'lth'), diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 2e24be4c7..007bdbff5 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2608,17 +2608,6 @@ class BtcCentsRelSatsUsdPattern2: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) -class CoindaysCoinyearsDormancySentVelocityPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.coindays_destroyed: BaseCumulativeSumPattern[StoredF64] = BaseCumulativeSumPattern(client, _m(acc, 'coindays_destroyed')) - self.coinyears_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinyears_destroyed')) - self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) - self.sent: BaseCumulativeInSumPattern = BaseCumulativeInSumPattern(client, _m(acc, 'sent')) - self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'velocity')) - class DeltaHalfInTotalPattern2: """Pattern struct for repeated tree structure.""" @@ -2814,6 +2803,16 @@ class CentsRelUsdPattern2: self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_mcap')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) +class CoindaysCoinyearsDormancySentPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.coindays_destroyed: BaseCumulativeSumPattern[StoredF64] = BaseCumulativeSumPattern(client, _m(acc, 'coindays_destroyed')) + self.coinyears_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinyears_destroyed')) + self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) + self.sent: BaseCumulativeInSumPattern = BaseCumulativeInSumPattern(client, _m(acc, 'sent')) + class LossNetNuplProfitPattern: """Pattern struct for repeated tree structure.""" @@ -3292,14 +3291,6 @@ class MetricsTree_Blocks_Lookback: self._14y: MetricPattern18[Height] = MetricPattern18(client, 'height_14y_ago') self._26y: MetricPattern18[Height] = MetricPattern18(client, 'height_26y_ago') -class MetricsTree_Blocks_Halving: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.epoch: MetricPattern1[Halving] = MetricPattern1(client, 'halving_epoch') - self.blocks_before_next: MetricPattern1[StoredU32] = MetricPattern1(client, 'blocks_before_next_halving') - self.days_before_next: MetricPattern1[StoredF32] = MetricPattern1(client, 'days_before_next_halving') - class MetricsTree_Blocks_Fullness: """Metrics tree node.""" @@ -3308,6 +3299,14 @@ class MetricsTree_Blocks_Fullness: self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'block_fullness_ratio') self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, 'block_fullness') +class MetricsTree_Blocks_Halving: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.epoch: MetricPattern1[Halving] = MetricPattern1(client, 'halving_epoch') + self.blocks_before_next: MetricPattern1[StoredU32] = MetricPattern1(client, 'blocks_before_next_halving') + self.days_before_next: MetricPattern1[StoredF32] = MetricPattern1(client, 'days_before_next_halving') + class MetricsTree_Blocks: """Metrics tree node.""" @@ -3320,9 +3319,9 @@ class MetricsTree_Blocks: self.count: MetricsTree_Blocks_Count = MetricsTree_Blocks_Count(client) self.lookback: MetricsTree_Blocks_Lookback = MetricsTree_Blocks_Lookback(client) self.interval: _1m1w1y24hHeightPattern[Timestamp] = _1m1w1y24hHeightPattern(client, 'block_interval') - self.halving: MetricsTree_Blocks_Halving = MetricsTree_Blocks_Halving(client) self.vbytes: AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern = AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, 'block_vbytes') self.fullness: MetricsTree_Blocks_Fullness = MetricsTree_Blocks_Fullness(client) + self.halving: MetricsTree_Blocks_Halving = MetricsTree_Blocks_Halving(client) class MetricsTree_Transactions_Raw: """Metrics tree node.""" @@ -4781,13 +4780,14 @@ class MetricsTree_Supply_Velocity: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.btc: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_btc') - self.usd: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_usd') + self.native: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity') + self.fiat: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_fiat') class MetricsTree_Supply: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): + self.state: MetricPattern18[SupplyState] = MetricPattern18(client, 'supply_state') self.circulating: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'circulating_supply') self.burned: MetricsTree_Supply_Burned = MetricsTree_Supply_Burned(client) self.inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'inflation_rate') @@ -4795,36 +4795,16 @@ class MetricsTree_Supply: self.market_cap: CentsDeltaUsdPattern = CentsDeltaUsdPattern(client, 'market_cap') self.market_minus_realized_cap_growth_rate: _1m1w1y24hPattern[BasisPointsSigned32] = _1m1w1y24hPattern(client, 'market_minus_realized_cap_growth_rate') self.hodled_or_lost: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'hodled_or_lost_coins') - self.state: MetricPattern18[SupplyState] = MetricPattern18(client, 'supply_state') class MetricsTree_Cohorts_Utxo_All_Supply: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.in_profit: BtcCentsRelSatsUsdPattern2 = BtcCentsRelSatsUsdPattern2(client, 'supply_in_profit') - self.in_loss: BtcCentsRelSatsUsdPattern2 = BtcCentsRelSatsUsdPattern2(client, 'supply_in_loss') self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'supply') self.half: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'supply_half') self.delta: ChangeRatePattern = ChangeRatePattern(client, 'supply_delta') - -class MetricsTree_Cohorts_Utxo_All_Unrealized_Loss: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.negative: MetricPattern1[Dollars] = MetricPattern1(client, 'neg_unrealized_loss') - self.base: CentsUsdPattern2 = CentsUsdPattern2(client, 'unrealized_loss') - self.cumulative: CentsUsdPattern2 = CentsUsdPattern2(client, 'unrealized_loss_cumulative') - self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, 'unrealized_loss_sum') - self.rel_to_mcap: BpsPercentRatioPattern3 = BpsPercentRatioPattern3(client, 'unrealized_loss_rel_to_mcap') - self.rel_to_own_gross: BpsPercentRatioPattern3 = BpsPercentRatioPattern3(client, 'unrealized_loss_rel_to_own_gross_pnl') - -class MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.cents: MetricPattern1[CentsSigned] = MetricPattern1(client, 'net_unrealized_pnl_cents') - self.usd: MetricPattern1[Dollars] = MetricPattern1(client, 'net_unrealized_pnl') - self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_own_gross_pnl') + self.in_profit: BtcCentsRelSatsUsdPattern2 = BtcCentsRelSatsUsdPattern2(client, 'supply_in_profit') + self.in_loss: BtcCentsRelSatsUsdPattern2 = BtcCentsRelSatsUsdPattern2(client, 'supply_in_loss') class MetricsTree_Cohorts_Utxo_All_Unrealized_Profit: """Metrics tree node.""" @@ -4836,17 +4816,36 @@ class MetricsTree_Cohorts_Utxo_All_Unrealized_Profit: self.rel_to_mcap: BpsPercentRatioPattern3 = BpsPercentRatioPattern3(client, 'unrealized_profit_rel_to_mcap') self.rel_to_own_gross: BpsPercentRatioPattern3 = BpsPercentRatioPattern3(client, 'unrealized_profit_rel_to_own_gross_pnl') +class MetricsTree_Cohorts_Utxo_All_Unrealized_Loss: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.base: CentsUsdPattern2 = CentsUsdPattern2(client, 'unrealized_loss') + self.cumulative: CentsUsdPattern2 = CentsUsdPattern2(client, 'unrealized_loss_cumulative') + self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, 'unrealized_loss_sum') + self.negative: MetricPattern1[Dollars] = MetricPattern1(client, 'neg_unrealized_loss') + self.rel_to_mcap: BpsPercentRatioPattern3 = BpsPercentRatioPattern3(client, 'unrealized_loss_rel_to_mcap') + self.rel_to_own_gross: BpsPercentRatioPattern3 = BpsPercentRatioPattern3(client, 'unrealized_loss_rel_to_own_gross_pnl') + +class MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.cents: MetricPattern1[CentsSigned] = MetricPattern1(client, 'net_unrealized_pnl_cents') + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, 'net_unrealized_pnl') + self.rel_to_own_gross: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_own_gross_pnl') + class MetricsTree_Cohorts_Utxo_All_Unrealized: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): + self.nupl: BpsRatioPattern = BpsRatioPattern(client, 'nupl') + self.profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit = MetricsTree_Cohorts_Utxo_All_Unrealized_Profit(client) + self.loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss = MetricsTree_Cohorts_Utxo_All_Unrealized_Loss(client) + self.net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl = MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl(client) self.gross_pnl: CentsUsdPattern2 = CentsUsdPattern2(client, 'unrealized_gross_pnl') self.invested_capital: InPattern = InPattern(client, 'invested_capital_in') self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, '') - self.loss: MetricsTree_Cohorts_Utxo_All_Unrealized_Loss = MetricsTree_Cohorts_Utxo_All_Unrealized_Loss(client) - self.net_pnl: MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl = MetricsTree_Cohorts_Utxo_All_Unrealized_NetPnl(client) - self.profit: MetricsTree_Cohorts_Utxo_All_Unrealized_Profit = MetricsTree_Cohorts_Utxo_All_Unrealized_Profit(client) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, 'nupl') class MetricsTree_Cohorts_Utxo_All: """Metrics tree node.""" @@ -4854,7 +4853,7 @@ class MetricsTree_Cohorts_Utxo_All: def __init__(self, client: BrkClientBase, base_path: str = ''): self.supply: MetricsTree_Cohorts_Utxo_All_Supply = MetricsTree_Cohorts_Utxo_All_Supply(client) self.outputs: UnspentPattern = UnspentPattern(client, 'utxo_count') - self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, '') + self.activity: CoindaysCoinyearsDormancySentPattern = CoindaysCoinyearsDormancySentPattern(client, '') self.realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern = CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(client, '') self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, '') self.unrealized: MetricsTree_Cohorts_Utxo_All_Unrealized = MetricsTree_Cohorts_Utxo_All_Unrealized(client) @@ -4863,10 +4862,10 @@ class MetricsTree_Cohorts_Utxo_Sth: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern = CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(client, 'sth') self.supply: DeltaHalfInRelTotalPattern2 = DeltaHalfInRelTotalPattern2(client, 'sth_supply') self.outputs: UnspentPattern = UnspentPattern(client, 'sth_utxo_count') - self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'sth') + self.activity: CoindaysCoinyearsDormancySentPattern = CoindaysCoinyearsDormancySentPattern(client, 'sth') + self.realized: CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern = CapGrossInvestorLossMvrvNetPeakPriceProfitSellSoprPattern(client, 'sth') self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, 'sth') self.unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2 = GrossInvestedLossNetNuplProfitSentimentPattern2(client, 'sth') @@ -4874,26 +4873,26 @@ class MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_sopr') self.value_created: BaseCumulativeSumPattern[Cents] = BaseCumulativeSumPattern(client, 'lth_value_created') self.value_destroyed: BaseCumulativeSumPattern[Cents] = BaseCumulativeSumPattern(client, 'lth_value_destroyed') + self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_sopr') class MetricsTree_Cohorts_Utxo_Lth_Realized: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): + self.cap: CentsDeltaRelUsdPattern = CentsDeltaRelUsdPattern(client, 'lth_realized_cap') self.profit: BaseCumulativeDistributionRelSumValuePattern = BaseCumulativeDistributionRelSumValuePattern(client, 'lth') self.loss: BaseCapitulationCumulativeNegativeRelSumValuePattern = BaseCapitulationCumulativeNegativeRelSumValuePattern(client, 'lth') + self.price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern = BpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, 'lth_realized_price') + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_mvrv') + self.sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr = MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr(client) + self.net_pnl: BaseChangeCumulativeDeltaRelSumPattern = BaseChangeCumulativeDeltaRelSumPattern(client, 'lth_net') self.gross_pnl: BaseCumulativeSumPattern3 = BaseCumulativeSumPattern3(client, 'lth_realized_gross_pnl') self.sell_side_risk_ratio: _1m1w1y24hPattern6 = _1m1w1y24hPattern6(client, 'lth_sell_side_risk_ratio') - self.net_pnl: BaseChangeCumulativeDeltaRelSumPattern = BaseChangeCumulativeDeltaRelSumPattern(client, 'lth_net') - self.sopr: MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr = MetricsTree_Cohorts_Utxo_Lth_Realized_Sopr(client) self.peak_regret: BaseCumulativeRelPattern = BaseCumulativeRelPattern(client, 'lth_realized_peak_regret') self.investor: LowerPriceUpperPattern = LowerPriceUpperPattern(client, 'lth') self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_realized_profit_to_loss_ratio') - self.cap: CentsDeltaRelUsdPattern = CentsDeltaRelUsdPattern(client, 'lth_realized_cap') - self.price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern = BpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, 'lth_realized_price') - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_mvrv') class MetricsTree_Cohorts_Utxo_Lth: """Metrics tree node.""" @@ -4901,7 +4900,7 @@ class MetricsTree_Cohorts_Utxo_Lth: def __init__(self, client: BrkClientBase, base_path: str = ''): self.supply: DeltaHalfInRelTotalPattern2 = DeltaHalfInRelTotalPattern2(client, 'lth_supply') self.outputs: UnspentPattern = UnspentPattern(client, 'lth_utxo_count') - self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'lth') + self.activity: CoindaysCoinyearsDormancySentPattern = CoindaysCoinyearsDormancySentPattern(client, 'lth') self.realized: MetricsTree_Cohorts_Utxo_Lth_Realized = MetricsTree_Cohorts_Utxo_Lth_Realized(client) self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, 'lth') self.unrealized: GrossInvestedLossNetNuplProfitSentimentPattern2 = GrossInvestedLossNetNuplProfitSentimentPattern2(client, 'lth') diff --git a/website/scripts/options/cointime.js b/website/scripts/options/cointime.js index 7bb765aa3..88a801a6a 100644 --- a/website/scripts/options/cointime.js +++ b/website/scripts/options/cointime.js @@ -1,7 +1,7 @@ import { colors } from "../utils/colors.js"; import { brk } from "../client.js"; import { Unit } from "../utils/units.js"; -import { dots, line, baseline, price, rollingWindowsTree } from "./series.js"; +import { dots, line, baseline, price, rollingWindowsTree, percentRatioDots } from "./series.js"; import { satsBtcUsd } from "./shared.js"; /** @@ -53,6 +53,26 @@ export function createCointimeSection() { name: "Cointime", color: colors.cointime, }, + { + pattern: cointimePrices.transfer, + name: "Transfer", + color: colors.transfer, + }, + { + pattern: cointimePrices.balanced, + name: "Balanced", + color: colors.balanced, + }, + { + pattern: cointimePrices.terminal, + name: "Terminal", + color: colors.terminal, + }, + { + pattern: cointimePrices.delta, + name: "Delta", + color: colors.delta, + }, ]); const caps = /** @type {const} */ ([ @@ -158,12 +178,16 @@ export function createCointimeSection() { const pctUsd = /** @type {const} */ ([ { name: "pct95", prop: p.pct95.price, color: colors.ratioPct._95 }, { name: "pct5", prop: p.pct5.price, color: colors.ratioPct._5 }, + { name: "pct98", prop: p.pct98.price, color: colors.ratioPct._98 }, + { name: "pct2", prop: p.pct2.price, color: colors.ratioPct._2 }, { name: "pct99", prop: p.pct99.price, color: colors.ratioPct._99 }, { name: "pct1", prop: p.pct1.price, color: colors.ratioPct._1 }, ]); const pctRatio = /** @type {const} */ ([ { name: "pct95", prop: p.pct95.ratio, color: colors.ratioPct._95 }, { name: "pct5", prop: p.pct5.ratio, color: colors.ratioPct._5 }, + { name: "pct98", prop: p.pct98.ratio, color: colors.ratioPct._98 }, + { name: "pct2", prop: p.pct2.ratio, color: colors.ratioPct._2 }, { name: "pct99", prop: p.pct99.ratio, color: colors.ratioPct._99 }, { name: "pct1", prop: p.pct1.ratio, color: colors.ratioPct._1 }, ]); @@ -463,6 +487,19 @@ export function createCointimeSection() { }), ], }, + { + name: "AVIV", + title: "AVIV Ratio", + bottom: [ + baseline({ + metric: cap.aviv.ratio, + name: "Ratio", + color: colors.reserveRisk, + unit: Unit.ratio, + base: 1, + }), + ], + }, { name: "HODL Bank", title: "HODL Bank", @@ -492,11 +529,10 @@ export function createCointimeSection() { color: colors.base, unit: Unit.percentage, }), - dots({ - metric: adjusted.inflationRate.percent, + ...percentRatioDots({ + pattern: adjusted.inflationRate, name: "Cointime-Adjusted", color: colors.adjusted, - unit: Unit.percentage, }), ], }, @@ -508,7 +544,7 @@ export function createCointimeSection() { title: "Cointime-Adjusted BTC Velocity", bottom: [ line({ - metric: supply.velocity.btc, + metric: supply.velocity.native, name: "Base", color: colors.base, unit: Unit.ratio, @@ -526,7 +562,7 @@ export function createCointimeSection() { title: "Cointime-Adjusted USD Velocity", bottom: [ line({ - metric: supply.velocity.usd, + metric: supply.velocity.fiat, name: "Base", color: colors.thermo, unit: Unit.ratio, diff --git a/website/scripts/options/distribution/profitability.js b/website/scripts/options/distribution/profitability.js index cb3cc5295..a93332f86 100644 --- a/website/scripts/options/distribution/profitability.js +++ b/website/scripts/options/distribution/profitability.js @@ -327,16 +327,16 @@ function singleRollingRealizedTreeFull(r, title) { name: "Compare", title: title("Rolling Realized P/L Ratio"), bottom: [ - baseline({ metric: r.profitToLossRatio._24h, name: "24h", color: colors.time._24h, unit: Unit.ratio }), - baseline({ metric: r.profitToLossRatio._1w, name: "7d", color: colors.time._1w, unit: Unit.ratio }), - baseline({ metric: r.profitToLossRatio._1m, name: "30d", color: colors.time._1m, unit: Unit.ratio }), - baseline({ metric: r.profitToLossRatio._1y, name: "1y", color: colors.time._1y, unit: Unit.ratio }), + baseline({ metric: r.profitToLossRatio._24h, name: "24h", color: colors.time._24h, unit: Unit.ratio, base: 1 }), + baseline({ metric: r.profitToLossRatio._1w, name: "7d", color: colors.time._1w, unit: Unit.ratio, base: 1 }), + baseline({ metric: r.profitToLossRatio._1m, name: "30d", color: colors.time._1m, unit: Unit.ratio, base: 1 }), + baseline({ metric: r.profitToLossRatio._1y, name: "1y", color: colors.time._1y, unit: Unit.ratio, base: 1 }), ], }, - { name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: [baseline({ metric: r.profitToLossRatio._24h, name: "P/L Ratio", unit: Unit.ratio })] }, - { name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: [baseline({ metric: r.profitToLossRatio._1w, name: "P/L Ratio", unit: Unit.ratio })] }, - { name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: [baseline({ metric: r.profitToLossRatio._1m, name: "P/L Ratio", unit: Unit.ratio })] }, - { name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio })] }, + { name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: [baseline({ metric: r.profitToLossRatio._24h, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] }, + { name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: [baseline({ metric: r.profitToLossRatio._1w, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] }, + { name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: [baseline({ metric: r.profitToLossRatio._1m, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] }, + { name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio, base: 1 })] }, ], }, ]; @@ -397,7 +397,7 @@ function realizedSubfolderFull(r, title) { { name: "P/L Ratio", title: title("Realized Profit/Loss Ratio"), - bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio })], + bottom: [baseline({ metric: r.profitToLossRatio._1y, name: "P/L Ratio", unit: Unit.ratio, base: 1 })], }, { name: "Peak Regret", @@ -750,7 +750,7 @@ function groupedRealizedPnlSumFull(list, all, title) { name: "P/L Ratio", title: title("Realized Profit/Loss Ratio"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => - baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio }), + baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio, base: 1 }), ), }, ]; @@ -801,10 +801,10 @@ function groupedRollingRealizedChartsFull(list, all, title) { { name: "P/L Ratio", tree: [ - { name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._24h, name, color, unit: Unit.ratio })) }, - { name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1w, name, color, unit: Unit.ratio })) }, - { name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1m, name, color, unit: Unit.ratio })) }, - { name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio })) }, + { name: "24h", title: title("Realized P/L Ratio (24h)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._24h, name, color, unit: Unit.ratio, base: 1 })) }, + { name: "7d", title: title("Realized P/L Ratio (7d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1w, name, color, unit: Unit.ratio, base: 1 })) }, + { name: "30d", title: title("Realized P/L Ratio (30d)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1m, name, color, unit: Unit.ratio, base: 1 })) }, + { name: "1y", title: title("Realized P/L Ratio (1y)"), bottom: mapCohortsWithAll(list, all, ({ name, color, tree }) => baseline({ metric: tree.realized.profitToLossRatio._1y, name, color, unit: Unit.ratio, base: 1 })) }, ], }, ]; diff --git a/website/scripts/options/market.js b/website/scripts/options/market.js index 4fd87e1aa..1273e7f90 100644 --- a/website/scripts/options/market.js +++ b/website/scripts/options/market.js @@ -12,6 +12,7 @@ import { price, percentRatio, percentRatioBaseline, + ROLLING_WINDOWS, } from "./series.js"; import { periodIdToName } from "./utils.js"; @@ -996,98 +997,15 @@ export function createMarketSection() { }), ], }, - { - name: "1 Day", - title: "MACD (1d)", + ...ROLLING_WINDOWS.map((w) => ({ + name: w.name, + title: `MACD (${w.name})`, bottom: [ - line({ - metric: technical.macd._24h.line, - name: "MACD", - color: colors.indicator.fast, - unit: Unit.usd, - }), - line({ - metric: technical.macd._24h.signal, - name: "Signal", - color: colors.indicator.slow, - unit: Unit.usd, - }), - histogram({ - metric: technical.macd._24h.histogram, - name: "Histogram", - unit: Unit.usd, - }), + line({ metric: technical.macd[w.key].line, name: "MACD", color: colors.indicator.fast, unit: Unit.usd }), + line({ metric: technical.macd[w.key].signal, name: "Signal", color: colors.indicator.slow, unit: Unit.usd }), + histogram({ metric: technical.macd[w.key].histogram, name: "Histogram", unit: Unit.usd }), ], - }, - { - name: "1 Week", - title: "MACD (1w)", - bottom: [ - line({ - metric: technical.macd._1w.line, - name: "MACD", - color: colors.indicator.fast, - unit: Unit.usd, - }), - line({ - metric: technical.macd._1w.signal, - name: "Signal", - color: colors.indicator.slow, - unit: Unit.usd, - }), - histogram({ - metric: technical.macd._1w.histogram, - name: "Histogram", - unit: Unit.usd, - }), - ], - }, - { - name: "1 Month", - title: "MACD (1m)", - bottom: [ - line({ - metric: technical.macd._1m.line, - name: "MACD", - color: colors.indicator.fast, - unit: Unit.usd, - }), - line({ - metric: technical.macd._1m.signal, - name: "Signal", - color: colors.indicator.slow, - unit: Unit.usd, - }), - histogram({ - metric: technical.macd._1m.histogram, - name: "Histogram", - unit: Unit.usd, - }), - ], - }, - { - name: "1 Year", - title: "MACD (1y)", - bottom: [ - line({ - metric: technical.macd._1y.line, - name: "MACD", - color: colors.indicator.fast, - unit: Unit.usd, - }), - line({ - metric: technical.macd._1y.signal, - name: "Signal", - color: colors.indicator.slow, - unit: Unit.usd, - }), - histogram({ - metric: technical.macd._1y.histogram, - name: "Histogram", - unit: Unit.usd, - }), - ], - }, + })), ], }, ], diff --git a/website/scripts/options/mining.js b/website/scripts/options/mining.js index a3c8b3c5d..db22b6b5a 100644 --- a/website/scripts/options/mining.js +++ b/website/scripts/options/mining.js @@ -133,6 +133,23 @@ export function createMiningSection() { name: "sum", }), }, + { + name: "Rolling", + tree: [ + { + name: "Compare", + title: `Rewards: ${name} Rolling`, + bottom: ROLLING_WINDOWS.flatMap((w) => + satsBtcUsd({ pattern: pool.rewards.sum[w.key], name: w.name, color: w.color }), + ), + }, + ...ROLLING_WINDOWS.map((w) => ({ + name: w.name, + title: `Rewards: ${name} (${w.name})`, + bottom: satsBtcUsd({ pattern: pool.rewards.sum[w.key], name: w.name, color: w.color }), + })), + ], + }, { name: "Cumulative", title: `Rewards: ${name} (Total)`, diff --git a/website/scripts/options/network.js b/website/scripts/options/network.js index 300e7bb20..afee59603 100644 --- a/website/scripts/options/network.js +++ b/website/scripts/options/network.js @@ -819,12 +819,12 @@ export function createNetworkSection() { title: "Transaction Velocity", bottom: [ line({ - metric: supply.velocity.btc, + metric: supply.velocity.native, name: "BTC", unit: Unit.ratio, }), line({ - metric: supply.velocity.usd, + metric: supply.velocity.fiat, name: "USD", color: colors.usd, unit: Unit.ratio, diff --git a/website/scripts/utils/colors.js b/website/scripts/utils/colors.js index 05fd2cb25..9c2376af0 100644 --- a/website/scripts/utils/colors.js +++ b/website/scripts/utils/colors.js @@ -153,6 +153,10 @@ export const colors = { destroyed: palette.red, created: palette.orange, stored: palette.green, + transfer: palette.cyan, + balanced: palette.indigo, + terminal: palette.fuchsia, + delta: palette.violet, // Valuations realized: palette.orange,