diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 38424755b..70cb72d57 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -1483,6 +1483,34 @@ impl CapitulationCumulativeNegativeRawRelSumValuePattern { } } +/// Pattern struct for repeated tree structure. +pub struct CoindaysCoinyearsDormancySentVelocityPattern { + pub coindays_destroyed: CumulativeRawSumPattern, + pub coindays_destroyed_supply_adjusted: MetricPattern1, + pub coinyears_destroyed: MetricPattern1, + pub coinyears_destroyed_supply_adjusted: MetricPattern1, + pub dormancy: MetricPattern1, + pub dormancy_supply_adjusted: MetricPattern1, + pub sent: RawSumPattern3, + 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: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + coindays_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed_supply_adjusted")), + coinyears_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), + coinyears_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed_supply_adjusted")), + dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), + dormancy_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "dormancy_supply_adjusted")), + sent: RawSumPattern3::new(client.clone(), _m(&acc, "sent")), + velocity: MetricPattern1::new(client.clone(), _m(&acc, "velocity")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern { pub pct1: BpsPriceRatioPattern, @@ -1591,32 +1619,6 @@ impl _1m1w1y24hBpsPercentRatioPattern { } } -/// Pattern struct for repeated tree structure. -pub struct CoindaysCoinyearsDormancySentVelocityPattern { - pub coindays_destroyed: CumulativeRawSumPattern, - pub coindays_destroyed_supply_adjusted: MetricPattern1, - pub coinyears_destroyed: MetricPattern1, - pub coinyears_destroyed_supply_adjusted: MetricPattern1, - pub dormancy: MetricPattern1, - pub sent: RawSumPattern3, - 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: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - coindays_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed_supply_adjusted")), - coinyears_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), - coinyears_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed_supply_adjusted")), - dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), - sent: RawSumPattern3::new(client.clone(), _m(&acc, "sent")), - velocity: MetricPattern1::new(client.clone(), _m(&acc, "velocity")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct CumulativeDistributionRawRelSumValuePattern { pub cumulative: MetricPattern1, @@ -1648,9 +1650,9 @@ pub struct GrossInvestedInvestorLossNetProfitSentimentPattern2 { pub gross_pnl: CentsUsdPattern, pub invested_capital: InPattern4, pub investor_cap: InPattern2, - pub loss: NegativeRawRelSumSupplyPattern2, + pub loss: NegativeRawRelSumPattern2, pub net_pnl: CentsRelUsdPattern2, - pub profit: RawRelSumSupplyPattern2, + pub profit: RawRelSumPattern2, pub sentiment: GreedNetPainPattern, } @@ -1661,40 +1663,14 @@ impl GrossInvestedInvestorLossNetProfitSentimentPattern2 { gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_gross_pnl")), invested_capital: InPattern4::new(client.clone(), _m(&acc, "invested_capital_in")), investor_cap: InPattern2::new(client.clone(), _m(&acc, "investor_cap_in")), - loss: NegativeRawRelSumSupplyPattern2::new(client.clone(), acc.clone()), + loss: NegativeRawRelSumPattern2::new(client.clone(), acc.clone()), net_pnl: CentsRelUsdPattern2::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - profit: RawRelSumSupplyPattern2::new(client.clone(), acc.clone()), + profit: RawRelSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), sentiment: GreedNetPainPattern::new(client.clone(), acc.clone()), } } } -/// Pattern struct for repeated tree structure. -pub struct NegativeRawRelSumSupplyPattern2 { - pub negative: MetricPattern1, - pub raw: CentsUsdPattern, - pub rel_to_market_cap: BpsPercentRatioPattern, - pub rel_to_own_gross_pnl: BpsPercentRatioPattern, - pub rel_to_own_market_cap: BpsPercentRatioPattern, - pub sum: _24hPattern, - pub supply: BtcCentsRelSatsUsdPattern3, -} - -impl NegativeRawRelSumSupplyPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")), - rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_gross_pnl")), - rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")), - sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_loss_24h")), - supply: BtcCentsRelSatsUsdPattern3::new(client.clone(), _m(&acc, "supply_in_loss")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct BtcCentsRelSatsUsdPattern3 { pub btc: MetricPattern1, @@ -1768,25 +1744,73 @@ impl ChangeCumulativeDeltaRawRelSumPattern { } /// Pattern struct for repeated tree structure. -pub struct RawRelSumSupplyPattern2 { +pub struct DeltaHalvedInRelTotalPattern { + pub delta: ChangeRatePattern, + pub halved: BtcCentsSatsUsdPattern, + pub in_loss: BtcCentsRelSatsUsdPattern, + pub in_profit: BtcCentsRelSatsUsdPattern, + pub rel_to_circulating_supply: BpsPercentRatioPattern, + pub total: BtcCentsSatsUsdPattern, +} + +impl DeltaHalvedInRelTotalPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + delta: ChangeRatePattern::new(client.clone(), _m(&acc, "delta")), + halved: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "halved")), + in_loss: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "in_loss")), + in_profit: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "in_profit")), + rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), + total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct DeltaHalvedInRelTotalPattern2 { + pub delta: ChangeRatePattern2, + pub halved: BtcCentsSatsUsdPattern, + pub in_loss: BtcCentsRelSatsUsdPattern3, + pub in_profit: BtcCentsRelSatsUsdPattern3, + pub rel_to_circulating_supply: BpsPercentRatioPattern, + pub total: BtcCentsSatsUsdPattern, +} + +impl DeltaHalvedInRelTotalPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), + halved: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "halved")), + in_loss: BtcCentsRelSatsUsdPattern3::new(client.clone(), _m(&acc, "in_loss")), + in_profit: BtcCentsRelSatsUsdPattern3::new(client.clone(), _m(&acc, "in_profit")), + rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), + total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct NegativeRawRelSumPattern2 { + pub negative: MetricPattern1, pub raw: CentsUsdPattern, pub rel_to_market_cap: BpsPercentRatioPattern, pub rel_to_own_gross_pnl: BpsPercentRatioPattern, pub rel_to_own_market_cap: BpsPercentRatioPattern, pub sum: _24hPattern, - pub supply: BtcCentsRelSatsUsdPattern3, } -impl RawRelSumSupplyPattern2 { +impl NegativeRawRelSumPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), - rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")), - rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_gross_pnl")), - rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")), - sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_profit_24h")), - supply: BtcCentsRelSatsUsdPattern3::new(client.clone(), _m(&acc, "supply_in_profit")), + negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), + raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), + rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")), + rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_gross_pnl")), + rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")), + sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_loss_24h")), } } } @@ -1796,7 +1820,7 @@ pub struct ActivityOutputsRealizedSupplyUnrealizedPattern { pub activity: CoindaysSentPattern, pub outputs: UtxoPattern2, pub realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern, - pub supply: DeltaHalvedRelTotalPattern, + pub supply: DeltaHalvedInRelTotalPattern, pub unrealized: InvestedInvestorLossNetProfitPattern, } @@ -1807,7 +1831,7 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern { activity: CoindaysSentPattern::new(client.clone(), acc.clone()), outputs: UtxoPattern2::new(client.clone(), _m(&acc, "utxo_count")), realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern::new(client.clone(), acc.clone()), - supply: DeltaHalvedRelTotalPattern::new(client.clone(), _m(&acc, "supply")), + supply: DeltaHalvedInRelTotalPattern::new(client.clone(), _m(&acc, "supply")), unrealized: InvestedInvestorLossNetProfitPattern::new(client.clone(), acc.clone()), } } @@ -1818,7 +1842,7 @@ pub struct ActivityOutputsRealizedSupplyUnrealizedPattern2 { pub activity: CoindaysSentPattern, pub outputs: UtxoPattern2, pub realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern, - pub supply: DeltaHalvedRelTotalPattern, + pub supply: DeltaHalvedInRelTotalPattern, pub unrealized: LossNetProfitPattern, } @@ -1829,7 +1853,7 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern2 { activity: CoindaysSentPattern::new(client.clone(), acc.clone()), outputs: UtxoPattern2::new(client.clone(), _m(&acc, "utxo_count")), realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern::new(client.clone(), acc.clone()), - supply: DeltaHalvedRelTotalPattern::new(client.clone(), _m(&acc, "supply")), + supply: DeltaHalvedInRelTotalPattern::new(client.clone(), _m(&acc, "supply")), unrealized: LossNetProfitPattern::new(client.clone(), acc.clone()), } } @@ -1949,9 +1973,9 @@ impl EmaHistogramLineSignalPattern { pub struct InvestedInvestorLossNetProfitPattern { pub invested_capital: InPattern2, pub investor_cap: InPattern2, - pub loss: NegativeRawSumSupplyPattern, + pub loss: NegativeRawSumPattern, pub net_pnl: CentsUsdPattern, - pub profit: RawSumSupplyPattern, + pub profit: RawSumPattern, } impl InvestedInvestorLossNetProfitPattern { @@ -1960,9 +1984,9 @@ impl InvestedInvestorLossNetProfitPattern { Self { invested_capital: InPattern2::new(client.clone(), _m(&acc, "invested_capital_in")), investor_cap: InPattern2::new(client.clone(), _m(&acc, "investor_cap_in")), - loss: NegativeRawSumSupplyPattern::new(client.clone(), acc.clone()), + loss: NegativeRawSumPattern::new(client.clone(), acc.clone()), net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - profit: RawSumSupplyPattern::new(client.clone(), acc.clone()), + profit: RawSumPattern::new(client.clone(), _m(&acc, "unrealized_profit")), } } } @@ -1989,6 +2013,28 @@ impl PhsReboundThsPattern { } } +/// Pattern struct for repeated tree structure. +pub struct RawRelSumPattern2 { + pub raw: CentsUsdPattern, + pub rel_to_market_cap: BpsPercentRatioPattern, + pub rel_to_own_gross_pnl: BpsPercentRatioPattern, + pub rel_to_own_market_cap: BpsPercentRatioPattern, + pub sum: _24hPattern, +} + +impl RawRelSumPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + raw: CentsUsdPattern::new(client.clone(), acc.clone()), + rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_market_cap")), + rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_own_gross_pnl")), + rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_own_market_cap")), + sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hHeightPattern { pub _1m: MetricPattern1, @@ -2272,40 +2318,20 @@ impl CumulativeNegativeRawSumPattern { } /// Pattern struct for repeated tree structure. -pub struct DeltaHalvedRelTotalPattern { - pub delta: ChangeRatePattern, +pub struct HalvedInTotalPattern { pub halved: BtcCentsSatsUsdPattern, - pub rel_to_circulating_supply: BpsPercentRatioPattern, + pub in_loss: BtcCentsSatsUsdPattern, + pub in_profit: BtcCentsSatsUsdPattern, pub total: BtcCentsSatsUsdPattern, } -impl DeltaHalvedRelTotalPattern { +impl HalvedInTotalPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - delta: ChangeRatePattern::new(client.clone(), _m(&acc, "delta")), halved: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "halved")), - rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), - total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct DeltaHalvedRelTotalPattern2 { - pub delta: ChangeRatePattern2, - pub halved: BtcCentsSatsUsdPattern, - pub rel_to_circulating_supply: BpsPercentRatioPattern, - pub total: BtcCentsSatsUsdPattern, -} - -impl DeltaHalvedRelTotalPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), - halved: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "halved")), - rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), + in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "in_loss")), + in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "in_profit")), total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), } } @@ -2331,31 +2357,11 @@ impl InvestedMaxMinPercentilesPattern { } } -/// Pattern struct for repeated tree structure. -pub struct NegativeRawSumSupplyPattern { - pub negative: MetricPattern1, - pub raw: CentsUsdPattern, - pub sum: _24hPattern, - pub supply: BtcCentsRelSatsUsdPattern, -} - -impl NegativeRawSumSupplyPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_loss_24h")), - supply: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct OutputsRealizedSupplyUnrealizedPattern { pub outputs: UtxoPattern, pub realized: CapLossMvrvNuplPriceProfitSoprPattern, - pub supply: HalvedTotalPattern, + pub supply: HalvedInTotalPattern, pub unrealized: LossProfitPattern2, } @@ -2365,8 +2371,8 @@ impl OutputsRealizedSupplyUnrealizedPattern { Self { outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), realized: CapLossMvrvNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), - supply: HalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: LossProfitPattern2::new(client.clone(), acc.clone()), + supply: HalvedInTotalPattern::new(client.clone(), _m(&acc, "supply")), + unrealized: LossProfitPattern2::new(client.clone(), _m(&acc, "unrealized")), } } } @@ -2591,18 +2597,36 @@ impl GreedNetPainPattern { /// Pattern struct for repeated tree structure. pub struct LossNetProfitPattern { - pub loss: NegativeRawSumSupplyPattern, + pub loss: NegativeRawSumPattern, pub net_pnl: CentsUsdPattern, - pub profit: RawSumSupplyPattern, + pub profit: RawSumPattern, } impl LossNetProfitPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - loss: NegativeRawSumSupplyPattern::new(client.clone(), acc.clone()), + loss: NegativeRawSumPattern::new(client.clone(), acc.clone()), net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - profit: RawSumSupplyPattern::new(client.clone(), acc.clone()), + profit: RawSumPattern::new(client.clone(), _m(&acc, "unrealized_profit")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct NegativeRawSumPattern { + pub negative: MetricPattern1, + pub raw: CentsUsdPattern, + pub sum: _24hPattern, +} + +impl NegativeRawSumPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), + raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), + sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_loss_24h")), } } } @@ -2679,42 +2703,6 @@ impl RawSellSumPattern { } } -/// Pattern struct for repeated tree structure. -pub struct RawSumSupplyPattern { - pub raw: CentsUsdPattern, - pub sum: _24hPattern, - pub supply: BtcCentsRelSatsUsdPattern, -} - -impl RawSumSupplyPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), - sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_profit_24h")), - supply: BtcCentsRelSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RawSumSupplyPattern2 { - pub raw: CentsUsdPattern, - pub sum: _24hPattern, - pub supply: BtcCentsSatsUsdPattern, -} - -impl RawSumSupplyPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - raw: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), - sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_profit_24h")), - supply: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _6bBlockTxindexPattern { pub _6b: AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern, @@ -2993,16 +2981,16 @@ impl InPattern3 { /// Pattern struct for repeated tree structure. pub struct LossProfitPattern2 { - pub loss: RawSumSupplyPattern2, - pub profit: RawSumSupplyPattern2, + pub loss: RawSumPattern, + pub profit: RawSumPattern, } impl LossProfitPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - loss: RawSumSupplyPattern2::new(client.clone(), acc.clone()), - profit: RawSumSupplyPattern2::new(client.clone(), acc.clone()), + loss: RawSumPattern::new(client.clone(), _m(&acc, "loss")), + profit: RawSumPattern::new(client.clone(), _m(&acc, "profit")), } } } @@ -4972,6 +4960,7 @@ pub struct MetricsTree_Indicators { pub nvt: BpsRatioPattern, pub gini: BpsPercentRatioPattern, pub rhodl_ratio: BpsRatioPattern, + pub thermocap_multiple: BpsRatioPattern, } impl MetricsTree_Indicators { @@ -4981,6 +4970,7 @@ impl MetricsTree_Indicators { nvt: BpsRatioPattern::new(client.clone(), "nvt".to_string()), gini: BpsPercentRatioPattern::new(client.clone(), "gini".to_string()), rhodl_ratio: BpsRatioPattern::new(client.clone(), "rhodl_ratio".to_string()), + thermocap_multiple: BpsRatioPattern::new(client.clone(), "thermocap_multiple".to_string()), } } } @@ -6844,6 +6834,8 @@ impl MetricsTree_Distribution_UtxoCohorts_All { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_All_Supply { pub delta: ChangeRatePattern2, + pub in_profit: BtcCentsRelSatsUsdPattern2, + pub in_loss: BtcCentsRelSatsUsdPattern2, pub total: BtcCentsSatsUsdPattern, pub halved: BtcCentsSatsUsdPattern, } @@ -6852,6 +6844,8 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Supply { pub fn new(client: Arc, base_path: String) -> Self { Self { delta: ChangeRatePattern2::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()), total: BtcCentsSatsUsdPattern::new(client.clone(), "supply".to_string()), halved: BtcCentsSatsUsdPattern::new(client.clone(), "supply_halved".to_string()), } @@ -6888,7 +6882,6 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss { pub negative: MetricPattern1, pub raw: CentsUsdPattern, pub sum: _24hPattern, - pub supply: BtcCentsRelSatsUsdPattern2, pub rel_to_market_cap: BpsPercentRatioPattern, pub rel_to_own_gross_pnl: BpsPercentRatioPattern, } @@ -6899,7 +6892,6 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss { negative: MetricPattern1::new(client.clone(), "neg_unrealized_loss".to_string()), raw: CentsUsdPattern::new(client.clone(), "unrealized_loss".to_string()), sum: _24hPattern::new(client.clone(), "unrealized_loss_24h".to_string()), - supply: BtcCentsRelSatsUsdPattern2::new(client.clone(), "supply_in_loss".to_string()), rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_market_cap".to_string()), rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()), } @@ -6927,7 +6919,6 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Unrealized_NetPnl { pub struct MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit { pub raw: CentsUsdPattern, pub sum: _24hPattern, - pub supply: BtcCentsRelSatsUsdPattern2, pub rel_to_market_cap: BpsPercentRatioPattern, pub rel_to_own_gross_pnl: BpsPercentRatioPattern, } @@ -6937,7 +6928,6 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit { Self { raw: CentsUsdPattern::new(client.clone(), "unrealized_profit".to_string()), sum: _24hPattern::new(client.clone(), "unrealized_profit_24h".to_string()), - supply: BtcCentsRelSatsUsdPattern2::new(client.clone(), "supply_in_profit".to_string()), rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_market_cap".to_string()), rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_own_gross_pnl".to_string()), } @@ -6947,7 +6937,7 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_Sth { pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern, - pub supply: DeltaHalvedRelTotalPattern2, + pub supply: DeltaHalvedInRelTotalPattern2, pub outputs: UtxoPattern3, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, pub cost_basis: InvestedMaxMinPercentilesPattern, @@ -6958,7 +6948,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Sth { pub fn new(client: Arc, base_path: String) -> Self { Self { realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern::new(client.clone(), "sth".to_string()), - supply: DeltaHalvedRelTotalPattern2::new(client.clone(), "sth_supply".to_string()), + supply: DeltaHalvedInRelTotalPattern2::new(client.clone(), "sth_supply".to_string()), outputs: UtxoPattern3::new(client.clone(), "sth_utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "sth".to_string()), cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "sth".to_string()), @@ -6969,7 +6959,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Sth { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_Lth { - pub supply: DeltaHalvedRelTotalPattern2, + pub supply: DeltaHalvedInRelTotalPattern2, pub outputs: UtxoPattern3, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, pub realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized, @@ -6980,7 +6970,7 @@ pub struct MetricsTree_Distribution_UtxoCohorts_Lth { impl MetricsTree_Distribution_UtxoCohorts_Lth { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply: DeltaHalvedRelTotalPattern2::new(client.clone(), "lth_supply".to_string()), + supply: DeltaHalvedInRelTotalPattern2::new(client.clone(), "lth_supply".to_string()), outputs: UtxoPattern3::new(client.clone(), "lth_utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "lth".to_string()), realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs index 0d7441b23..b80f458d6 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs @@ -55,6 +55,9 @@ impl DynCohortVecs for UTXOCohortVecs { self.metrics .unrealized .truncate_push(height, &unrealized_state)?; + self.metrics + .supply + .truncate_push_profitability(height, &unrealized_state)?; } Ok(()) } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs index 9efe65111..abd9b6f41 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs @@ -54,6 +54,9 @@ impl DynCohortVecs for UTXOCohortVecs { self.metrics .unrealized .truncate_push(height, &unrealized_state)?; + self.metrics + .supply + .truncate_push_profitability(height, &unrealized_state)?; } Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index 48356e152..674e899c0 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -29,8 +29,6 @@ pub struct ActivityFull { pub dormancy: ComputedPerBlock, pub velocity: ComputedPerBlock, - pub coindays_destroyed_supply_adjusted: ComputedPerBlock, - pub coinyears_destroyed_supply_adjusted: ComputedPerBlock, } impl ActivityFull { @@ -54,8 +52,6 @@ impl ActivityFull { coinyears_destroyed, dormancy: cfg.import("dormancy", v1)?, velocity: cfg.import("velocity", v1)?, - coindays_destroyed_supply_adjusted: cfg.import("coindays_destroyed_supply_adjusted", v1)?, - coinyears_destroyed_supply_adjusted: cfg.import("coinyears_destroyed_supply_adjusted", v1)?, }) } @@ -75,8 +71,6 @@ impl ActivityFull { let mut vecs = self.inner.collect_vecs_mut(); vecs.push(&mut self.dormancy.height); vecs.push(&mut self.velocity.height); - vecs.push(&mut self.coindays_destroyed_supply_adjusted.height); - vecs.push(&mut self.coinyears_destroyed_supply_adjusted.height); vecs } @@ -161,38 +155,6 @@ impl ActivityFull { exit, )?; - // Supply-Adjusted CDD = sum_24h(CDD) / circulating_supply - self.coindays_destroyed_supply_adjusted.height.compute_transform2( - starting_indexes.height, - &self.inner.coindays_destroyed.sum._24h.height, - supply_total_sats, - |(i, cdd_24h, supply_sats, ..)| { - let supply = f64::from(Bitcoin::from(supply_sats)); - if supply == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((f64::from(cdd_24h) / supply) as f32)) - } - }, - exit, - )?; - - // Supply-Adjusted CYD = CYD / circulating_supply (CYD = 1y rolling sum of CDD) - self.coinyears_destroyed_supply_adjusted.height.compute_transform2( - starting_indexes.height, - &self.coinyears_destroyed.height, - supply_total_sats, - |(i, cdd_1y, supply_sats, ..)| { - let supply = f64::from(Bitcoin::from(supply_sats)); - if supply == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((f64::from(cdd_1y) / 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 e7564d37f..9559f6dae 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -139,8 +139,8 @@ impl AllCohortMetrics { self.relative.compute( starting_indexes.height, + &self.supply.core, &self.unrealized, - &self.supply.total.sats.height, height_to_market_cap, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs index 8eaaf1d3f..71629eda3 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs @@ -81,9 +81,7 @@ impl BasicCohortMetrics { self.relative.compute( starting_indexes.height, - &self.unrealized.supply_in_profit.sats.height, - &self.unrealized.supply_in_loss.sats.height, - &self.supply.total.sats.height, + &self.supply.core, all_supply_sats, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index 11d35bdd3..6fc5f21cc 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -118,7 +118,7 @@ impl CoreCohortMetrics { self.realized .compute_rest_part1(blocks, starting_indexes, exit)?; - self.unrealized.compute_rest(blocks, prices, starting_indexes, exit)?; + self.unrealized.compute_rest(blocks, starting_indexes, exit)?; Ok(()) } @@ -141,9 +141,7 @@ impl CoreCohortMetrics { self.relative.compute( starting_indexes.height, - &self.unrealized.supply_in_profit.sats.height, - &self.unrealized.supply_in_loss.sats.height, - &self.supply.total.sats.height, + &self.supply.core, all_supply_sats, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index a9b3117f8..2d5dfc874 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -115,8 +115,8 @@ impl ExtendedCohortMetrics { self.relative.compute( starting_indexes.height, + &self.supply.core, &self.unrealized, - &self.supply.total.sats.height, height_to_market_cap, all_supply_sats, &self.supply.total.usd.height, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/type.rs b/crates/brk_computer/src/distribution/metrics/cohort/type.rs index b4a441a22..d1e86a367 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/type.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/type.rs @@ -7,17 +7,17 @@ use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ImportConfig, OutputsBase, RealizedMinimal, SupplyBase, UnrealizedBasic, + ImportConfig, OutputsBase, RealizedMinimal, SupplyCore, UnrealizedBasic, }; -/// TypeCohortMetrics: supply(base), outputs(base), realized(minimal), unrealized(basic). +/// TypeCohortMetrics: supply(core), outputs(base), realized(minimal), unrealized(basic). /// /// Used for type_ cohorts (p2pkh, p2sh, etc.). #[derive(Traversable)] pub struct TypeCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, + pub supply: Box>, pub outputs: Box>, pub realized: Box>, pub unrealized: Box>, @@ -27,7 +27,7 @@ impl TypeCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { filter: cfg.filter.clone(), - supply: Box::new(SupplyBase::forced_import(cfg)?), + supply: Box::new(SupplyCore::forced_import(cfg)?), outputs: Box::new(OutputsBase::forced_import(cfg)?), realized: Box::new(RealizedMinimal::forced_import(cfg)?), unrealized: Box::new(UnrealizedBasic::forced_import(cfg)?), @@ -62,7 +62,7 @@ impl TypeCohortMetrics { self.realized .compute_rest_part1(blocks, starting_indexes, exit)?; self.unrealized - .compute_rest(blocks, prices, starting_indexes.height, exit)?; + .compute_rest(blocks, starting_indexes.height, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index bd7365519..26d2aa524 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -58,7 +58,7 @@ pub use realized::{ pub use relative::{ RelativeForAll, RelativeToAll, RelativeWithExtended, }; -pub use supply::{SupplyBase, SupplyFull}; +pub use supply::{SupplyBase, SupplyCore, SupplyFull}; pub use unrealized::{UnrealizedBase, UnrealizedBasic, UnrealizedCore, UnrealizedFull, UnrealizedLike}; use brk_cohort::Filter; @@ -148,6 +148,8 @@ pub trait CohortMetricsBase: CohortMetricsState, market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { self.base.compute( max_from, - &unrealized.inner.core, - supply_total_sats, + supply, + &unrealized.inner.core.basic, market_cap, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/relative/full.rs b/crates/brk_computer/src/distribution/metrics/relative/full.rs index 2a4baddbe..ef79b7047 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/full.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/full.rs @@ -4,16 +4,16 @@ use brk_types::{BasisPoints16, Dollars, Height, Sats, Version}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::{ - distribution::metrics::{ImportConfig, UnrealizedCore}, + distribution::metrics::{ImportConfig, SupplyCore, UnrealizedBasic}, internal::{PercentPerBlock, RatioDollarsBp16, RatioSatsBp16}, }; /// Full relative metrics (sth/lth/all tier). #[derive(Traversable)] pub struct RelativeFull { - #[traversable(wrap = "unrealized/profit/supply", rename = "rel_to_own_supply")] + #[traversable(wrap = "supply/in_profit", rename = "rel_to_own_supply")] pub supply_in_profit_rel_to_own_supply: PercentPerBlock, - #[traversable(wrap = "unrealized/loss/supply", rename = "rel_to_own_supply")] + #[traversable(wrap = "supply/in_loss", rename = "rel_to_own_supply")] pub supply_in_loss_rel_to_own_supply: PercentPerBlock, #[traversable(wrap = "unrealized/profit", rename = "rel_to_market_cap")] @@ -41,23 +41,23 @@ impl RelativeFull { pub(crate) fn compute( &mut self, max_from: Height, - unrealized: &UnrealizedCore, - supply_total_sats: &impl ReadableVec, + supply: &SupplyCore, + unrealized: &UnrealizedBasic, market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { self.supply_in_profit_rel_to_own_supply .compute_binary::( max_from, - &unrealized.supply_in_profit.sats.height, - supply_total_sats, + &supply.in_profit.sats.height, + &supply.total.sats.height, exit, )?; self.supply_in_loss_rel_to_own_supply .compute_binary::( max_from, - &unrealized.supply_in_loss.sats.height, - supply_total_sats, + &supply.in_loss.sats.height, + &supply.total.sats.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/relative/to_all.rs b/crates/brk_computer/src/distribution/metrics/relative/to_all.rs index 544ccb631..a0ddab851 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/to_all.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/to_all.rs @@ -5,16 +5,16 @@ use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::internal::{PercentPerBlock, RatioSatsBp16}; -use crate::distribution::metrics::ImportConfig; +use crate::distribution::metrics::{ImportConfig, SupplyCore}; /// Relative-to-all metrics (not present for the "all" cohort itself). #[derive(Traversable)] pub struct RelativeToAll { #[traversable(wrap = "supply", rename = "rel_to_circulating_supply")] pub supply_rel_to_circulating_supply: PercentPerBlock, - #[traversable(wrap = "unrealized/profit/supply", rename = "rel_to_circulating_supply")] + #[traversable(wrap = "supply/in_profit", rename = "rel_to_circulating_supply")] pub supply_in_profit_rel_to_circulating_supply: PercentPerBlock, - #[traversable(wrap = "unrealized/loss/supply", rename = "rel_to_circulating_supply")] + #[traversable(wrap = "supply/in_loss", rename = "rel_to_circulating_supply")] pub supply_in_loss_rel_to_circulating_supply: PercentPerBlock, } @@ -33,30 +33,28 @@ impl RelativeToAll { pub(crate) fn compute( &mut self, max_from: Height, - supply_in_profit_sats: &impl ReadableVec, - supply_in_loss_sats: &impl ReadableVec, - supply_total_sats: &impl ReadableVec, + supply: &SupplyCore, all_supply_sats: &impl ReadableVec, exit: &Exit, ) -> Result<()> { self.supply_rel_to_circulating_supply .compute_binary::( max_from, - supply_total_sats, + &supply.total.sats.height, all_supply_sats, exit, )?; self.supply_in_profit_rel_to_circulating_supply .compute_binary::( max_from, - supply_in_profit_sats, + &supply.in_profit.sats.height, all_supply_sats, exit, )?; self.supply_in_loss_rel_to_circulating_supply .compute_binary::( max_from, - supply_in_loss_sats, + &supply.in_loss.sats.height, all_supply_sats, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs b/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs index fbfc2f994..af52b7ce1 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/with_extended.rs @@ -4,7 +4,7 @@ use brk_types::{Dollars, Height, Sats}; use derive_more::{Deref, DerefMut}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::distribution::metrics::{ImportConfig, UnrealizedFull}; +use crate::distribution::metrics::{ImportConfig, SupplyCore, UnrealizedFull}; use super::{RelativeFull, RelativeExtendedOwnMarketCap, RelativeExtendedOwnPnl, RelativeToAll}; @@ -38,8 +38,8 @@ impl RelativeWithExtended { pub(crate) fn compute( &mut self, max_from: Height, + supply: &SupplyCore, unrealized: &UnrealizedFull, - supply_total_sats: &impl ReadableVec, market_cap: &impl ReadableVec, all_supply_sats: &impl ReadableVec, own_market_cap: &impl ReadableVec, @@ -47,16 +47,14 @@ impl RelativeWithExtended { ) -> Result<()> { self.base.compute( max_from, - &unrealized.inner.core, - supply_total_sats, + supply, + &unrealized.inner.core.basic, market_cap, exit, )?; self.rel_to_all.compute( max_from, - &unrealized.supply_in_profit.sats.height, - &unrealized.supply_in_loss.sats.height, - supply_total_sats, + supply, all_supply_sats, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/supply/full.rs b/crates/brk_computer/src/distribution/metrics/supply/full.rs index dd929f34a..70a3d9cba 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/full.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/full.rs @@ -8,29 +8,29 @@ use crate::{blocks, internal::RollingDelta1m}; use crate::distribution::metrics::ImportConfig; -use super::SupplyBase; +use super::SupplyCore; -/// Full supply metrics: total + delta (4 stored vecs). +/// Full supply metrics: total + in_profit/in_loss + delta (6 stored vecs). #[derive(Deref, DerefMut, Traversable)] pub struct SupplyFull { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: SupplyBase, + pub core: SupplyCore, pub delta: RollingDelta1m, } impl SupplyFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let base = SupplyBase::forced_import(cfg)?; + let core = SupplyCore::forced_import(cfg)?; let delta = cfg.import("supply_delta", Version::ONE)?; - Ok(Self { base, delta }) + Ok(Self { core, delta }) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - self.base.collect_vecs_mut() + self.core.collect_vecs_mut() } pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { @@ -43,8 +43,9 @@ impl SupplyFull { others: &[&Self], exit: &Exit, ) -> Result<()> { - let base_refs: Vec<&SupplyBase> = others.iter().map(|o| &o.base).collect(); - self.base.compute_from_stateful(starting_indexes, &base_refs, exit) + let core_refs: Vec<&SupplyCore> = others.iter().map(|o| &o.core).collect(); + self.core + .compute_from_stateful(starting_indexes, &core_refs, exit) } pub(crate) fn compute_rest_part1( @@ -56,7 +57,7 @@ impl SupplyFull { self.delta.compute( starting_indexes.height, &blocks.lookback.height_1m_ago, - &self.base.total.sats.height, + &self.core.total.sats.height, exit, ) } diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs index 6c3447627..73da43b90 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs @@ -4,7 +4,7 @@ use brk_types::{CentsSats, CentsSquaredSats, Height, Indexes, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, BytesVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; -use crate::{blocks, distribution::{metrics::ImportConfig, state::UnrealizedState}, prices}; +use crate::{blocks, distribution::{metrics::ImportConfig, state::UnrealizedState}}; use super::UnrealizedCore; @@ -166,11 +166,10 @@ impl UnrealizedBase { pub(crate) fn compute_rest( &mut self, blocks: &blocks::Vecs, - prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.core.compute_rest(blocks, prices, starting_indexes, exit)?; + self.core.compute_rest(blocks, starting_indexes, exit)?; Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs index 3a065da05..14d418ce5 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs @@ -1,26 +1,17 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Cents, Height, Indexes, Version}; -use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; use crate::{ blocks, distribution::{metrics::ImportConfig, state::UnrealizedState}, internal::FiatPerBlockWithSum24h, - prices, }; -use super::UnrealizedMinimal; - -/// Basic unrealized metrics: supply in profit/loss + unrealized profit/loss (fiat + 24h sums). -#[derive(Deref, DerefMut, Traversable)] +/// Basic unrealized metrics: unrealized profit/loss (fiat + 24h sums). +#[derive(Traversable)] pub struct UnrealizedBasic { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub minimal: UnrealizedMinimal, - pub profit: FiatPerBlockWithSum24h, pub loss: FiatPerBlockWithSum24h, } @@ -28,24 +19,23 @@ pub struct UnrealizedBasic { impl UnrealizedBasic { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v1 = Version::ONE; - let minimal = UnrealizedMinimal::forced_import(cfg)?; Ok(Self { - minimal, profit: cfg.import("unrealized_profit", v1)?, loss: cfg.import("unrealized_loss", v1)?, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { - self.minimal - .min_stateful_height_len() - .min(self.profit.raw.cents.height.len()) + self.profit + .raw + .cents + .height + .len() .min(self.loss.raw.cents.height.len()) } pub(crate) fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()> { - self.minimal.truncate_push(height, state)?; self.profit .raw .cents @@ -60,10 +50,10 @@ impl UnrealizedBasic { } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - let mut vecs = self.minimal.collect_vecs_mut(); - vecs.push(&mut self.profit.raw.cents.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.loss.raw.cents.height); - vecs + vec![ + &mut self.profit.raw.cents.height as &mut dyn AnyStoredVec, + &mut self.loss.raw.cents.height, + ] } pub(crate) fn compute_from_sources( @@ -72,9 +62,6 @@ impl UnrealizedBasic { others: &[&Self], exit: &Exit, ) -> Result<()> { - let minimal_refs: Vec<&UnrealizedMinimal> = others.iter().map(|o| &o.minimal).collect(); - self.minimal - .compute_from_sources(starting_indexes, &minimal_refs, exit)?; sum_others!(self, starting_indexes, others, exit; profit.raw.cents.height); sum_others!(self, starting_indexes, others, exit; loss.raw.cents.height); Ok(()) @@ -83,12 +70,9 @@ impl UnrealizedBasic { pub(crate) fn compute_rest( &mut self, blocks: &blocks::Vecs, - prices: &prices::Vecs, max_from: Height, exit: &Exit, ) -> Result<()> { - self.minimal.compute_rest(prices, max_from, exit)?; - self.profit.sum.compute_rolling_sum( max_from, &blocks.lookback.height_24h_ago, diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs index dfdd69bac..6d79e357b 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs @@ -11,7 +11,6 @@ use crate::{ state::UnrealizedState, }, internal::{CentsSubtractToCentsSigned, FiatPerBlock, LazyPerBlock, NegCentsUnsignedToDollars}, - prices, }; use brk_types::Dollars; @@ -83,12 +82,11 @@ impl UnrealizedCore { pub(crate) fn compute_rest( &mut self, blocks: &blocks::Vecs, - prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { self.basic - .compute_rest(blocks, prices, starting_indexes.height, exit)?; + .compute_rest(blocks, starting_indexes.height, exit)?; self.net_pnl .cents diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/full.rs b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs index ea4b4e7e0..3d2b2dc19 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs @@ -93,7 +93,7 @@ impl UnrealizedFull { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.inner.compute_rest(blocks, prices, starting_indexes, exit)?; + self.inner.compute_rest(blocks, starting_indexes, exit)?; self.gross_pnl.cents.height.compute_add( starting_indexes.height, diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs b/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs deleted file mode 100644 index 087f07be5..000000000 --- a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs +++ /dev/null @@ -1,80 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Indexes, Version}; -use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; - -use crate::prices; - -use crate::internal::AmountPerBlock; - -use crate::distribution::{metrics::ImportConfig, state::UnrealizedState}; - -/// Minimal unrealized metrics: supply in profit/loss only. -#[derive(Traversable)] -pub struct UnrealizedMinimal { - #[traversable(wrap = "profit", rename = "supply")] - pub supply_in_profit: AmountPerBlock, - #[traversable(wrap = "loss", rename = "supply")] - pub supply_in_loss: AmountPerBlock, -} - -impl UnrealizedMinimal { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v0 = Version::ZERO; - Ok(Self { - supply_in_profit: cfg.import("supply_in_profit", v0)?, - supply_in_loss: cfg.import("supply_in_loss", v0)?, - }) - } - - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.supply_in_profit - .sats - .height - .len() - .min(self.supply_in_loss.sats.height.len()) - } - - pub(crate) fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()> { - self.supply_in_profit - .sats - .height - .truncate_push(height, state.supply_in_profit)?; - self.supply_in_loss - .sats - .height - .truncate_push(height, state.supply_in_loss)?; - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![ - &mut self.supply_in_profit.sats.height as &mut dyn AnyStoredVec, - &mut self.supply_in_profit.cents.height, - &mut self.supply_in_loss.sats.height, - &mut self.supply_in_loss.cents.height, - ] - } - - pub(crate) fn compute_from_sources( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - sum_others!(self, starting_indexes, others, exit; supply_in_profit.sats.height); - sum_others!(self, starting_indexes, others, exit; supply_in_loss.sats.height); - Ok(()) - } - - pub(crate) fn compute_rest( - &mut self, - prices: &prices::Vecs, - max_from: Height, - exit: &Exit, - ) -> Result<()> { - self.supply_in_profit.compute(prices, max_from, exit)?; - self.supply_in_loss.compute(prices, max_from, exit)?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs index 57bb5fc6c..572f7537a 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs @@ -2,13 +2,11 @@ mod base; mod basic; mod core; mod full; -mod minimal; pub use self::core::UnrealizedCore; pub use base::UnrealizedBase; pub use basic::UnrealizedBasic; pub use full::UnrealizedFull; -pub use minimal::UnrealizedMinimal; use brk_error::Result; use brk_types::{Height, Indexes}; @@ -51,11 +49,11 @@ impl UnrealizedLike for UnrealizedBase { fn compute_rest( &mut self, blocks: &blocks::Vecs, - prices: &prices::Vecs, + _prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.compute_rest(blocks, prices, starting_indexes, exit) + self.compute_rest(blocks, starting_indexes, exit) } fn compute_net_sentiment_height( &mut self, diff --git a/crates/brk_computer/src/indicators/compute.rs b/crates/brk_computer/src/indicators/compute.rs index 3106592f5..8ea8d8691 100644 --- a/crates/brk_computer/src/indicators/compute.rs +++ b/crates/brk_computer/src/indicators/compute.rs @@ -1,5 +1,5 @@ use brk_error::Result; -use brk_types::{Dollars, Indexes}; +use brk_types::{Bitcoin, Dollars, Indexes, StoredF32}; use vecdb::Exit; use super::{gini, Vecs}; @@ -71,6 +71,81 @@ impl Vecs { exit, )?; + // Thermocap Multiple: market_cap / thermo_cap + // thermo_cap = cumulative subsidy in USD + self.thermocap_multiple + .bps + .compute_binary::( + starting_indexes.height, + market_cap, + &mining.rewards.subsidy.cumulative.usd.height, + exit, + )?; + + let all_activity = &distribution.utxo_cohorts.all.metrics.activity; + let supply_total_sats = &distribution + .utxo_cohorts + .all + .metrics + .supply + .total + .sats + .height; + + // Supply-Adjusted CDD = sum_24h(CDD) / circulating_supply_btc + self.coindays_destroyed_supply_adjusted + .height + .compute_transform2( + starting_indexes.height, + &all_activity.coindays_destroyed.sum._24h.height, + supply_total_sats, + |(i, cdd_24h, supply_sats, ..)| { + let supply = f64::from(Bitcoin::from(supply_sats)); + if supply == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + (i, StoredF32::from((f64::from(cdd_24h) / supply) as f32)) + } + }, + exit, + )?; + + // Supply-Adjusted CYD = CYD / circulating_supply_btc (CYD = 1y rolling sum of CDD) + self.coinyears_destroyed_supply_adjusted + .height + .compute_transform2( + starting_indexes.height, + &all_activity.coinyears_destroyed.height, + supply_total_sats, + |(i, cyd, supply_sats, ..)| { + let supply = f64::from(Bitcoin::from(supply_sats)); + if supply == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + (i, StoredF32::from((f64::from(cyd) / supply) as f32)) + } + }, + exit, + )?; + + // Supply-Adjusted Dormancy = dormancy / circulating_supply_btc + self.dormancy_supply_adjusted + .height + .compute_transform2( + starting_indexes.height, + &all_activity.dormancy.height, + supply_total_sats, + |(i, dormancy, supply_sats, ..)| { + let supply = f64::from(Bitcoin::from(supply_sats)); + if supply == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + (i, StoredF32::from((f64::from(dormancy) / supply) as f32)) + } + }, + exit, + )?; + let _lock = exit.lock(); self.db.compact()?; Ok(()) diff --git a/crates/brk_computer/src/indicators/import.rs b/crates/brk_computer/src/indicators/import.rs index 9c22def80..6c2c31728 100644 --- a/crates/brk_computer/src/indicators/import.rs +++ b/crates/brk_computer/src/indicators/import.rs @@ -6,7 +6,7 @@ use brk_types::Version; use super::Vecs; use crate::{ indexes, - internal::{finalize_db, open_db, PercentPerBlock, RatioPerBlock}, + internal::{finalize_db, open_db, ComputedPerBlock, PercentPerBlock, RatioPerBlock}, }; const VERSION: Version = Version::new(1); @@ -24,6 +24,14 @@ impl Vecs { let nvt = RatioPerBlock::forced_import_raw(&db, "nvt", v, indexes)?; let gini = PercentPerBlock::forced_import(&db, "gini", v, indexes)?; let rhodl_ratio = RatioPerBlock::forced_import_raw(&db, "rhodl_ratio", v, indexes)?; + let thermocap_multiple = + RatioPerBlock::forced_import_raw(&db, "thermocap_multiple", v, indexes)?; + let coindays_destroyed_supply_adjusted = + ComputedPerBlock::forced_import(&db, "coindays_destroyed_supply_adjusted", v, indexes)?; + let coinyears_destroyed_supply_adjusted = + ComputedPerBlock::forced_import(&db, "coinyears_destroyed_supply_adjusted", v, indexes)?; + let dormancy_supply_adjusted = + ComputedPerBlock::forced_import(&db, "dormancy_supply_adjusted", v, indexes)?; let this = Self { db, @@ -31,6 +39,10 @@ impl Vecs { nvt, gini, rhodl_ratio, + thermocap_multiple, + coindays_destroyed_supply_adjusted, + coinyears_destroyed_supply_adjusted, + dormancy_supply_adjusted, }; finalize_db(&this.db, &this)?; Ok(this) diff --git a/crates/brk_computer/src/indicators/vecs.rs b/crates/brk_computer/src/indicators/vecs.rs index 555fb4069..5c12a0168 100644 --- a/crates/brk_computer/src/indicators/vecs.rs +++ b/crates/brk_computer/src/indicators/vecs.rs @@ -1,8 +1,8 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPoints32}; +use brk_types::{BasisPoints16, BasisPoints32, StoredF32}; use vecdb::{Database, Rw, StorageMode}; -use crate::internal::{PercentPerBlock, RatioPerBlock}; +use crate::internal::{ComputedPerBlock, PercentPerBlock, RatioPerBlock}; #[derive(Traversable)] pub struct Vecs { @@ -12,4 +12,8 @@ pub struct Vecs { pub nvt: RatioPerBlock, pub gini: PercentPerBlock, pub rhodl_ratio: RatioPerBlock, + pub thermocap_multiple: RatioPerBlock, + pub coindays_destroyed_supply_adjusted: ComputedPerBlock, + pub coinyears_destroyed_supply_adjusted: ComputedPerBlock, + pub dormancy_supply_adjusted: ComputedPerBlock, } diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 9022fb440..ada2642fb 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -2185,6 +2185,37 @@ function createCapitulationCumulativeNegativeRawRelSumValuePattern(client, acc) }; } +/** + * @typedef {Object} CoindaysCoinyearsDormancySentVelocityPattern + * @property {CumulativeRawSumPattern} coindaysDestroyed + * @property {MetricPattern1} coindaysDestroyedSupplyAdjusted + * @property {MetricPattern1} coinyearsDestroyed + * @property {MetricPattern1} coinyearsDestroyedSupplyAdjusted + * @property {MetricPattern1} dormancy + * @property {MetricPattern1} dormancySupplyAdjusted + * @property {RawSumPattern3} 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: createCumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')), + coindaysDestroyedSupplyAdjusted: createMetricPattern1(client, _m(acc, 'coindays_destroyed_supply_adjusted')), + coinyearsDestroyed: createMetricPattern1(client, _m(acc, 'coinyears_destroyed')), + coinyearsDestroyedSupplyAdjusted: createMetricPattern1(client, _m(acc, 'coinyears_destroyed_supply_adjusted')), + dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), + dormancySupplyAdjusted: createMetricPattern1(client, _m(acc, 'dormancy_supply_adjusted')), + sent: createRawSumPattern3(client, _m(acc, 'sent')), + velocity: createMetricPattern1(client, _m(acc, 'velocity')), + }; +} + /** * @typedef {Object} Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern * @property {BpsPriceRatioPattern} pct1 @@ -2307,35 +2338,6 @@ function create_1m1w1y24hBpsPercentRatioPattern(client, acc) { }; } -/** - * @typedef {Object} CoindaysCoinyearsDormancySentVelocityPattern - * @property {CumulativeRawSumPattern} coindaysDestroyed - * @property {MetricPattern1} coindaysDestroyedSupplyAdjusted - * @property {MetricPattern1} coinyearsDestroyed - * @property {MetricPattern1} coinyearsDestroyedSupplyAdjusted - * @property {MetricPattern1} dormancy - * @property {RawSumPattern3} 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: createCumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')), - coindaysDestroyedSupplyAdjusted: createMetricPattern1(client, _m(acc, 'coindays_destroyed_supply_adjusted')), - coinyearsDestroyed: createMetricPattern1(client, _m(acc, 'coinyears_destroyed')), - coinyearsDestroyedSupplyAdjusted: createMetricPattern1(client, _m(acc, 'coinyears_destroyed_supply_adjusted')), - dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), - sent: createRawSumPattern3(client, _m(acc, 'sent')), - velocity: createMetricPattern1(client, _m(acc, 'velocity')), - }; -} - /** * @typedef {Object} CumulativeDistributionRawRelSumValuePattern * @property {MetricPattern1} cumulative @@ -2370,9 +2372,9 @@ function createCumulativeDistributionRawRelSumValuePattern(client, acc) { * @property {CentsUsdPattern} grossPnl * @property {InPattern4} investedCapital * @property {InPattern2} investorCap - * @property {NegativeRawRelSumSupplyPattern2} loss + * @property {NegativeRawRelSumPattern2} loss * @property {CentsRelUsdPattern2} netPnl - * @property {RawRelSumSupplyPattern2} profit + * @property {RawRelSumPattern2} profit * @property {GreedNetPainPattern} sentiment */ @@ -2387,42 +2389,13 @@ function createGrossInvestedInvestorLossNetProfitSentimentPattern2(client, acc) grossPnl: createCentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')), investedCapital: createInPattern4(client, _m(acc, 'invested_capital_in')), investorCap: createInPattern2(client, _m(acc, 'investor_cap_in')), - loss: createNegativeRawRelSumSupplyPattern2(client, acc), + loss: createNegativeRawRelSumPattern2(client, acc), netPnl: createCentsRelUsdPattern2(client, _m(acc, 'net_unrealized_pnl')), - profit: createRawRelSumSupplyPattern2(client, acc), + profit: createRawRelSumPattern2(client, _m(acc, 'unrealized_profit')), sentiment: createGreedNetPainPattern(client, acc), }; } -/** - * @typedef {Object} NegativeRawRelSumSupplyPattern2 - * @property {MetricPattern1} negative - * @property {CentsUsdPattern} raw - * @property {BpsPercentRatioPattern} relToMarketCap - * @property {BpsPercentRatioPattern} relToOwnGrossPnl - * @property {BpsPercentRatioPattern} relToOwnMarketCap - * @property {_24hPattern} sum - * @property {BtcCentsRelSatsUsdPattern3} supply - */ - -/** - * Create a NegativeRawRelSumSupplyPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {NegativeRawRelSumSupplyPattern2} - */ -function createNegativeRawRelSumSupplyPattern2(client, acc) { - return { - negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - relToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')), - relToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')), - relToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')), - sum: create_24hPattern(client, _m(acc, 'unrealized_loss_24h')), - supply: createBtcCentsRelSatsUsdPattern3(client, _m(acc, 'supply_in_loss')), - }; -} - /** * @typedef {Object} BtcCentsRelSatsUsdPattern3 * @property {MetricPattern1} btc @@ -2505,29 +2478,83 @@ function createChangeCumulativeDeltaRawRelSumPattern(client, acc) { } /** - * @typedef {Object} RawRelSumSupplyPattern2 + * @typedef {Object} DeltaHalvedInRelTotalPattern + * @property {ChangeRatePattern} delta + * @property {BtcCentsSatsUsdPattern} halved + * @property {BtcCentsRelSatsUsdPattern} inLoss + * @property {BtcCentsRelSatsUsdPattern} inProfit + * @property {BpsPercentRatioPattern} relToCirculatingSupply + * @property {BtcCentsSatsUsdPattern} total + */ + +/** + * Create a DeltaHalvedInRelTotalPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {DeltaHalvedInRelTotalPattern} + */ +function createDeltaHalvedInRelTotalPattern(client, acc) { + return { + delta: createChangeRatePattern(client, _m(acc, 'delta')), + halved: createBtcCentsSatsUsdPattern(client, _m(acc, 'halved')), + inLoss: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'in_loss')), + inProfit: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'in_profit')), + relToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), + total: createBtcCentsSatsUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} DeltaHalvedInRelTotalPattern2 + * @property {ChangeRatePattern2} delta + * @property {BtcCentsSatsUsdPattern} halved + * @property {BtcCentsRelSatsUsdPattern3} inLoss + * @property {BtcCentsRelSatsUsdPattern3} inProfit + * @property {BpsPercentRatioPattern} relToCirculatingSupply + * @property {BtcCentsSatsUsdPattern} total + */ + +/** + * Create a DeltaHalvedInRelTotalPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {DeltaHalvedInRelTotalPattern2} + */ +function createDeltaHalvedInRelTotalPattern2(client, acc) { + return { + delta: createChangeRatePattern2(client, _m(acc, 'delta')), + halved: createBtcCentsSatsUsdPattern(client, _m(acc, 'halved')), + inLoss: createBtcCentsRelSatsUsdPattern3(client, _m(acc, 'in_loss')), + inProfit: createBtcCentsRelSatsUsdPattern3(client, _m(acc, 'in_profit')), + relToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), + total: createBtcCentsSatsUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} NegativeRawRelSumPattern2 + * @property {MetricPattern1} negative * @property {CentsUsdPattern} raw * @property {BpsPercentRatioPattern} relToMarketCap * @property {BpsPercentRatioPattern} relToOwnGrossPnl * @property {BpsPercentRatioPattern} relToOwnMarketCap * @property {_24hPattern} sum - * @property {BtcCentsRelSatsUsdPattern3} supply */ /** - * Create a RawRelSumSupplyPattern2 pattern node + * Create a NegativeRawRelSumPattern2 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {RawRelSumSupplyPattern2} + * @returns {NegativeRawRelSumPattern2} */ -function createRawRelSumSupplyPattern2(client, acc) { +function createNegativeRawRelSumPattern2(client, acc) { return { - raw: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), - relToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')), - relToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_gross_pnl')), - relToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_market_cap')), - sum: create_24hPattern(client, _m(acc, 'unrealized_profit_24h')), - supply: createBtcCentsRelSatsUsdPattern3(client, _m(acc, 'supply_in_profit')), + negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), + raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), + relToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')), + relToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')), + relToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')), + sum: create_24hPattern(client, _m(acc, 'unrealized_loss_24h')), }; } @@ -2536,7 +2563,7 @@ function createRawRelSumSupplyPattern2(client, acc) { * @property {CoindaysSentPattern} activity * @property {UtxoPattern2} outputs * @property {CapLossMvrvNetNuplPriceProfitSentSoprPattern} realized - * @property {DeltaHalvedRelTotalPattern} supply + * @property {DeltaHalvedInRelTotalPattern} supply * @property {InvestedInvestorLossNetProfitPattern} unrealized */ @@ -2551,7 +2578,7 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { activity: createCoindaysSentPattern(client, acc), outputs: createUtxoPattern2(client, _m(acc, 'utxo_count')), realized: createCapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc), - supply: createDeltaHalvedRelTotalPattern(client, _m(acc, 'supply')), + supply: createDeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')), unrealized: createInvestedInvestorLossNetProfitPattern(client, acc), }; } @@ -2561,7 +2588,7 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { * @property {CoindaysSentPattern} activity * @property {UtxoPattern2} outputs * @property {CapLossMvrvNetNuplPriceProfitSentSoprPattern} realized - * @property {DeltaHalvedRelTotalPattern} supply + * @property {DeltaHalvedInRelTotalPattern} supply * @property {LossNetProfitPattern} unrealized */ @@ -2576,7 +2603,7 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern2(client, acc) { activity: createCoindaysSentPattern(client, acc), outputs: createUtxoPattern2(client, _m(acc, 'utxo_count')), realized: createCapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc), - supply: createDeltaHalvedRelTotalPattern(client, _m(acc, 'supply')), + supply: createDeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')), unrealized: createLossNetProfitPattern(client, acc), }; } @@ -2710,9 +2737,9 @@ function createEmaHistogramLineSignalPattern(client, acc) { * @typedef {Object} InvestedInvestorLossNetProfitPattern * @property {InPattern2} investedCapital * @property {InPattern2} investorCap - * @property {NegativeRawSumSupplyPattern} loss + * @property {NegativeRawSumPattern} loss * @property {CentsUsdPattern} netPnl - * @property {RawSumSupplyPattern} profit + * @property {RawSumPattern} profit */ /** @@ -2725,9 +2752,9 @@ function createInvestedInvestorLossNetProfitPattern(client, acc) { return { investedCapital: createInPattern2(client, _m(acc, 'invested_capital_in')), investorCap: createInPattern2(client, _m(acc, 'investor_cap_in')), - loss: createNegativeRawSumSupplyPattern(client, acc), + loss: createNegativeRawSumPattern(client, acc), netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - profit: createRawSumSupplyPattern(client, acc), + profit: createRawSumPattern(client, _m(acc, 'unrealized_profit')), }; } @@ -2756,6 +2783,31 @@ function createPhsReboundThsPattern(client, acc) { }; } +/** + * @typedef {Object} RawRelSumPattern2 + * @property {CentsUsdPattern} raw + * @property {BpsPercentRatioPattern} relToMarketCap + * @property {BpsPercentRatioPattern} relToOwnGrossPnl + * @property {BpsPercentRatioPattern} relToOwnMarketCap + * @property {_24hPattern} sum + */ + +/** + * Create a RawRelSumPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RawRelSumPattern2} + */ +function createRawRelSumPattern2(client, acc) { + return { + raw: createCentsUsdPattern(client, acc), + relToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_market_cap')), + relToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_own_gross_pnl')), + relToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_own_market_cap')), + sum: create_24hPattern(client, _m(acc, '24h')), + }; +} + /** * @template T * @typedef {Object} _1m1w1y24hHeightPattern @@ -3083,47 +3135,24 @@ function createCumulativeNegativeRawSumPattern(client, acc) { } /** - * @typedef {Object} DeltaHalvedRelTotalPattern - * @property {ChangeRatePattern} delta + * @typedef {Object} HalvedInTotalPattern * @property {BtcCentsSatsUsdPattern} halved - * @property {BpsPercentRatioPattern} relToCirculatingSupply + * @property {BtcCentsSatsUsdPattern} inLoss + * @property {BtcCentsSatsUsdPattern} inProfit * @property {BtcCentsSatsUsdPattern} total */ /** - * Create a DeltaHalvedRelTotalPattern pattern node + * Create a HalvedInTotalPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {DeltaHalvedRelTotalPattern} + * @returns {HalvedInTotalPattern} */ -function createDeltaHalvedRelTotalPattern(client, acc) { +function createHalvedInTotalPattern(client, acc) { return { - delta: createChangeRatePattern(client, _m(acc, 'delta')), halved: createBtcCentsSatsUsdPattern(client, _m(acc, 'halved')), - relToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), - total: createBtcCentsSatsUsdPattern(client, acc), - }; -} - -/** - * @typedef {Object} DeltaHalvedRelTotalPattern2 - * @property {ChangeRatePattern2} delta - * @property {BtcCentsSatsUsdPattern} halved - * @property {BpsPercentRatioPattern} relToCirculatingSupply - * @property {BtcCentsSatsUsdPattern} total - */ - -/** - * Create a DeltaHalvedRelTotalPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {DeltaHalvedRelTotalPattern2} - */ -function createDeltaHalvedRelTotalPattern2(client, acc) { - return { - delta: createChangeRatePattern2(client, _m(acc, 'delta')), - halved: createBtcCentsSatsUsdPattern(client, _m(acc, 'halved')), - relToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), + inLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'in_loss')), + inProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'in_profit')), total: createBtcCentsSatsUsdPattern(client, acc), }; } @@ -3151,34 +3180,11 @@ function createInvestedMaxMinPercentilesPattern(client, acc) { }; } -/** - * @typedef {Object} NegativeRawSumSupplyPattern - * @property {MetricPattern1} negative - * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum - * @property {BtcCentsRelSatsUsdPattern} supply - */ - -/** - * Create a NegativeRawSumSupplyPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {NegativeRawSumSupplyPattern} - */ -function createNegativeRawSumSupplyPattern(client, acc) { - return { - negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - sum: create_24hPattern(client, _m(acc, 'unrealized_loss_24h')), - supply: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'supply_in_loss')), - }; -} - /** * @typedef {Object} OutputsRealizedSupplyUnrealizedPattern * @property {UtxoPattern} outputs * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized - * @property {HalvedTotalPattern} supply + * @property {HalvedInTotalPattern} supply * @property {LossProfitPattern2} unrealized */ @@ -3192,8 +3198,8 @@ function createOutputsRealizedSupplyUnrealizedPattern(client, acc) { return { outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), - supply: createHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createLossProfitPattern2(client, acc), + supply: createHalvedInTotalPattern(client, _m(acc, 'supply')), + unrealized: createLossProfitPattern2(client, _m(acc, 'unrealized')), }; } @@ -3455,9 +3461,9 @@ function createGreedNetPainPattern(client, acc) { /** * @typedef {Object} LossNetProfitPattern - * @property {NegativeRawSumSupplyPattern} loss + * @property {NegativeRawSumPattern} loss * @property {CentsUsdPattern} netPnl - * @property {RawSumSupplyPattern} profit + * @property {RawSumPattern} profit */ /** @@ -3468,9 +3474,30 @@ function createGreedNetPainPattern(client, acc) { */ function createLossNetProfitPattern(client, acc) { return { - loss: createNegativeRawSumSupplyPattern(client, acc), + loss: createNegativeRawSumPattern(client, acc), netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - profit: createRawSumSupplyPattern(client, acc), + profit: createRawSumPattern(client, _m(acc, 'unrealized_profit')), + }; +} + +/** + * @typedef {Object} NegativeRawSumPattern + * @property {MetricPattern1} negative + * @property {CentsUsdPattern} raw + * @property {_24hPattern} sum + */ + +/** + * Create a NegativeRawSumPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {NegativeRawSumPattern} + */ +function createNegativeRawSumPattern(client, acc) { + return { + negative: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), + raw: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), + sum: create_24hPattern(client, _m(acc, 'unrealized_loss_24h')), }; } @@ -3558,48 +3585,6 @@ function createRawSellSumPattern(client, acc) { }; } -/** - * @typedef {Object} RawSumSupplyPattern - * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum - * @property {BtcCentsRelSatsUsdPattern} supply - */ - -/** - * Create a RawSumSupplyPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSumSupplyPattern} - */ -function createRawSumSupplyPattern(client, acc) { - return { - raw: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), - sum: create_24hPattern(client, _m(acc, 'unrealized_profit_24h')), - supply: createBtcCentsRelSatsUsdPattern(client, _m(acc, 'supply_in_profit')), - }; -} - -/** - * @typedef {Object} RawSumSupplyPattern2 - * @property {CentsUsdPattern} raw - * @property {_24hPattern} sum - * @property {BtcCentsSatsUsdPattern} supply - */ - -/** - * Create a RawSumSupplyPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RawSumSupplyPattern2} - */ -function createRawSumSupplyPattern2(client, acc) { - return { - raw: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), - sum: create_24hPattern(client, _m(acc, 'unrealized_profit_24h')), - supply: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')), - }; -} - /** * @template T * @typedef {Object} _6bBlockTxindexPattern @@ -3933,8 +3918,8 @@ function createInPattern3(client, acc) { /** * @typedef {Object} LossProfitPattern2 - * @property {RawSumSupplyPattern2} loss - * @property {RawSumSupplyPattern2} profit + * @property {RawSumPattern} loss + * @property {RawSumPattern} profit */ /** @@ -3945,8 +3930,8 @@ function createInPattern3(client, acc) { */ function createLossProfitPattern2(client, acc) { return { - loss: createRawSumSupplyPattern2(client, acc), - profit: createRawSumSupplyPattern2(client, acc), + loss: createRawSumPattern(client, _m(acc, 'loss')), + profit: createRawSumPattern(client, _m(acc, 'profit')), }; } @@ -5059,6 +5044,7 @@ function createRawPattern(client, acc) { * @property {BpsRatioPattern} nvt * @property {BpsPercentRatioPattern} gini * @property {BpsRatioPattern} rhodlRatio + * @property {BpsRatioPattern} thermocapMultiple */ /** @@ -5884,6 +5870,8 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Supply * @property {ChangeRatePattern2} delta + * @property {BtcCentsRelSatsUsdPattern2} inProfit + * @property {BtcCentsRelSatsUsdPattern2} inLoss * @property {BtcCentsSatsUsdPattern} total * @property {BtcCentsSatsUsdPattern} halved */ @@ -5904,7 +5892,6 @@ function createRawPattern(client, acc) { * @property {MetricPattern1} negative * @property {CentsUsdPattern} raw * @property {_24hPattern} sum - * @property {BtcCentsRelSatsUsdPattern2} supply * @property {BpsPercentRatioPattern} relToMarketCap * @property {BpsPercentRatioPattern} relToOwnGrossPnl */ @@ -5920,7 +5907,6 @@ function createRawPattern(client, acc) { * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit * @property {CentsUsdPattern} raw * @property {_24hPattern} sum - * @property {BtcCentsRelSatsUsdPattern2} supply * @property {BpsPercentRatioPattern} relToMarketCap * @property {BpsPercentRatioPattern} relToOwnGrossPnl */ @@ -5928,7 +5914,7 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Sth * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern} realized - * @property {DeltaHalvedRelTotalPattern2} supply + * @property {DeltaHalvedInRelTotalPattern2} supply * @property {UtxoPattern3} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity * @property {InvestedMaxMinPercentilesPattern} costBasis @@ -5937,7 +5923,7 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Lth - * @property {DeltaHalvedRelTotalPattern2} supply + * @property {DeltaHalvedInRelTotalPattern2} supply * @property {UtxoPattern3} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity * @property {MetricsTree_Distribution_UtxoCohorts_Lth_Realized} realized @@ -7792,6 +7778,7 @@ class BrkClient extends BrkClientBase { nvt: createBpsRatioPattern(this, 'nvt'), gini: createBpsPercentRatioPattern(this, 'gini'), rhodlRatio: createBpsRatioPattern(this, 'rhodl_ratio'), + thermocapMultiple: createBpsRatioPattern(this, 'thermocap_multiple'), }, market: { ath: { @@ -8371,6 +8358,8 @@ class BrkClient extends BrkClientBase { all: { supply: { delta: createChangeRatePattern2(this, 'supply_delta'), + inProfit: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_profit'), + inLoss: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_loss'), total: createBtcCentsSatsUsdPattern(this, 'supply'), halved: createBtcCentsSatsUsdPattern(this, 'supply_halved'), }, @@ -8387,7 +8376,6 @@ class BrkClient extends BrkClientBase { negative: createMetricPattern1(this, 'neg_unrealized_loss'), raw: createCentsUsdPattern(this, 'unrealized_loss'), sum: create_24hPattern(this, 'unrealized_loss_24h'), - supply: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_loss'), relToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_market_cap'), relToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_own_gross_pnl'), }, @@ -8399,7 +8387,6 @@ class BrkClient extends BrkClientBase { profit: { raw: createCentsUsdPattern(this, 'unrealized_profit'), sum: create_24hPattern(this, 'unrealized_profit_24h'), - supply: createBtcCentsRelSatsUsdPattern2(this, 'supply_in_profit'), relToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_market_cap'), relToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_own_gross_pnl'), }, @@ -8407,14 +8394,14 @@ class BrkClient extends BrkClientBase { }, sth: { realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(this, 'sth'), - supply: createDeltaHalvedRelTotalPattern2(this, 'sth_supply'), + supply: createDeltaHalvedInRelTotalPattern2(this, 'sth_supply'), outputs: createUtxoPattern3(this, 'sth_utxo_count'), activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'sth'), costBasis: createInvestedMaxMinPercentilesPattern(this, 'sth'), unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern2(this, 'sth'), }, lth: { - supply: createDeltaHalvedRelTotalPattern2(this, 'lth_supply'), + supply: createDeltaHalvedInRelTotalPattern2(this, 'lth_supply'), outputs: createUtxoPattern3(this, 'lth_utxo_count'), activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'lth'), realized: { diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 81cf020ec..6b0aad419 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2369,6 +2369,20 @@ class CapitulationCumulativeNegativeRawRelSumValuePattern: self.value_created: BaseSumPattern = BaseSumPattern(client, _m(acc, 'loss_value_created')) self.value_destroyed: BaseSumPattern = BaseSumPattern(client, _m(acc, 'loss_value_destroyed')) +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: CumulativeRawSumPattern[StoredF64] = CumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')) + self.coindays_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'coindays_destroyed_supply_adjusted')) + self.coinyears_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinyears_destroyed')) + self.coinyears_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'coinyears_destroyed_supply_adjusted')) + self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) + self.dormancy_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy_supply_adjusted')) + self.sent: RawSumPattern3[Sats] = RawSumPattern3(client, _m(acc, 'sent')) + self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'velocity')) + class Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern: """Pattern struct for repeated tree structure.""" @@ -2423,19 +2437,6 @@ class _1m1w1y24hBpsPercentRatioPattern: self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, acc) self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) -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: CumulativeRawSumPattern[StoredF64] = CumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')) - self.coindays_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'coindays_destroyed_supply_adjusted')) - self.coinyears_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinyears_destroyed')) - self.coinyears_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'coinyears_destroyed_supply_adjusted')) - self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) - self.sent: RawSumPattern3[Sats] = RawSumPattern3(client, _m(acc, 'sent')) - self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'velocity')) - class CumulativeDistributionRawRelSumValuePattern: """Pattern struct for repeated tree structure.""" @@ -2457,24 +2458,11 @@ class GrossInvestedInvestorLossNetProfitSentimentPattern2: self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')) self.invested_capital: InPattern4 = InPattern4(client, _m(acc, 'invested_capital_in')) self.investor_cap: InPattern2 = InPattern2(client, _m(acc, 'investor_cap_in')) - self.loss: NegativeRawRelSumSupplyPattern2 = NegativeRawRelSumSupplyPattern2(client, acc) + self.loss: NegativeRawRelSumPattern2 = NegativeRawRelSumPattern2(client, acc) self.net_pnl: CentsRelUsdPattern2 = CentsRelUsdPattern2(client, _m(acc, 'net_unrealized_pnl')) - self.profit: RawRelSumSupplyPattern2 = RawRelSumSupplyPattern2(client, acc) + self.profit: RawRelSumPattern2 = RawRelSumPattern2(client, _m(acc, 'unrealized_profit')) self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, acc) -class NegativeRawRelSumSupplyPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')) - self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')) - self.rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) - self.supply: BtcCentsRelSatsUsdPattern3 = BtcCentsRelSatsUsdPattern3(client, _m(acc, 'supply_in_loss')) - class BtcCentsRelSatsUsdPattern3: """Pattern struct for repeated tree structure.""" @@ -2511,17 +2499,41 @@ class ChangeCumulativeDeltaRawRelSumPattern: self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_pnl_rel_to_realized_cap')) self.sum: _1m1w1y24hPattern[CentsSigned] = _1m1w1y24hPattern(client, _m(acc, 'realized_pnl')) -class RawRelSumSupplyPattern2: +class DeltaHalvedInRelTotalPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) - self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')) - self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_gross_pnl')) - self.rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_market_cap')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_profit_24h')) - self.supply: BtcCentsRelSatsUsdPattern3 = BtcCentsRelSatsUsdPattern3(client, _m(acc, 'supply_in_profit')) + self.delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) + self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) + self.in_loss: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'in_loss')) + self.in_profit: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'in_profit')) + self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) + self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) + +class DeltaHalvedInRelTotalPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) + self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) + self.in_loss: BtcCentsRelSatsUsdPattern3 = BtcCentsRelSatsUsdPattern3(client, _m(acc, 'in_loss')) + self.in_profit: BtcCentsRelSatsUsdPattern3 = BtcCentsRelSatsUsdPattern3(client, _m(acc, 'in_profit')) + self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) + self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) + +class NegativeRawRelSumPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) + self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) + self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')) + self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')) + self.rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) class ActivityOutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -2531,7 +2543,7 @@ class ActivityOutputsRealizedSupplyUnrealizedPattern: self.activity: CoindaysSentPattern = CoindaysSentPattern(client, acc) self.outputs: UtxoPattern2 = UtxoPattern2(client, _m(acc, 'utxo_count')) self.realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern = CapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc) - self.supply: DeltaHalvedRelTotalPattern = DeltaHalvedRelTotalPattern(client, _m(acc, 'supply')) + self.supply: DeltaHalvedInRelTotalPattern = DeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')) self.unrealized: InvestedInvestorLossNetProfitPattern = InvestedInvestorLossNetProfitPattern(client, acc) class ActivityOutputsRealizedSupplyUnrealizedPattern2: @@ -2542,7 +2554,7 @@ class ActivityOutputsRealizedSupplyUnrealizedPattern2: self.activity: CoindaysSentPattern = CoindaysSentPattern(client, acc) self.outputs: UtxoPattern2 = UtxoPattern2(client, _m(acc, 'utxo_count')) self.realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern = CapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc) - self.supply: DeltaHalvedRelTotalPattern = DeltaHalvedRelTotalPattern(client, _m(acc, 'supply')) + self.supply: DeltaHalvedInRelTotalPattern = DeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')) self.unrealized: LossNetProfitPattern = LossNetProfitPattern(client, acc) class AddrOutputsRealizedSupplyPattern: @@ -2607,9 +2619,9 @@ class InvestedInvestorLossNetProfitPattern: """Create pattern node with accumulated metric name.""" self.invested_capital: InPattern2 = InPattern2(client, _m(acc, 'invested_capital_in')) self.investor_cap: InPattern2 = InPattern2(client, _m(acc, 'investor_cap_in')) - self.loss: NegativeRawSumSupplyPattern = NegativeRawSumSupplyPattern(client, acc) + self.loss: NegativeRawSumPattern = NegativeRawSumPattern(client, acc) self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.profit: RawSumSupplyPattern = RawSumSupplyPattern(client, acc) + self.profit: RawSumPattern = RawSumPattern(client, _m(acc, 'unrealized_profit')) class PhsReboundThsPattern: """Pattern struct for repeated tree structure.""" @@ -2622,6 +2634,17 @@ class PhsReboundThsPattern: self.ths: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ths')) self.ths_min: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ths_min')) +class RawRelSumPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.raw: CentsUsdPattern = CentsUsdPattern(client, acc) + self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_market_cap')) + self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_gross_pnl')) + self.rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_own_market_cap')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, '24h')) + class _1m1w1y24hHeightPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2763,24 +2786,14 @@ class CumulativeNegativeRawSumPattern: self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_loss')) self.sum: _24hPattern = _24hPattern(client, _m(acc, 'realized_loss_24h')) -class DeltaHalvedRelTotalPattern: +class HalvedInTotalPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) - self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) - self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) - -class DeltaHalvedRelTotalPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) - self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) - self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) + self.in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'in_loss')) + self.in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'in_profit')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) class InvestedMaxMinPercentilesPattern: @@ -2793,16 +2806,6 @@ class InvestedMaxMinPercentilesPattern: self.min: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')) self.percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis')) -class NegativeRawSumSupplyPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) - self.supply: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'supply_in_loss')) - class OutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -2810,8 +2813,8 @@ class OutputsRealizedSupplyUnrealizedPattern: """Create pattern node with accumulated metric name.""" self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) self.realized: CapLossMvrvNuplPriceProfitSoprPattern = CapLossMvrvNuplPriceProfitSoprPattern(client, acc) - self.supply: HalvedTotalPattern = HalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: LossProfitPattern2 = LossProfitPattern2(client, acc) + self.supply: HalvedInTotalPattern = HalvedInTotalPattern(client, _m(acc, 'supply')) + self.unrealized: LossProfitPattern2 = LossProfitPattern2(client, _m(acc, 'unrealized')) class _1m1w1y24hPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2927,9 +2930,18 @@ class LossNetProfitPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.loss: NegativeRawSumSupplyPattern = NegativeRawSumSupplyPattern(client, acc) + self.loss: NegativeRawSumPattern = NegativeRawSumPattern(client, acc) self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.profit: RawSumSupplyPattern = RawSumSupplyPattern(client, acc) + self.profit: RawSumPattern = RawSumPattern(client, _m(acc, 'unrealized_profit')) + +class NegativeRawSumPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) + self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) class OutputsRealizedSupplyPattern: """Pattern struct for repeated tree structure.""" @@ -2967,24 +2979,6 @@ class RawSellSumPattern: self.sell_side_risk_ratio: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')) self.sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')) -class RawSumSupplyPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_profit_24h')) - self.supply: BtcCentsRelSatsUsdPattern = BtcCentsRelSatsUsdPattern(client, _m(acc, 'supply_in_profit')) - -class RawSumSupplyPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) - self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_profit_24h')) - self.supply: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')) - class _6bBlockTxindexPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -3128,8 +3122,8 @@ class LossProfitPattern2: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.loss: RawSumSupplyPattern2 = RawSumSupplyPattern2(client, acc) - self.profit: RawSumSupplyPattern2 = RawSumSupplyPattern2(client, acc) + self.loss: RawSumPattern = RawSumPattern(client, _m(acc, 'loss')) + self.profit: RawSumPattern = RawSumPattern(client, _m(acc, 'profit')) class PriceValuePattern: """Pattern struct for repeated tree structure.""" @@ -4060,6 +4054,7 @@ class MetricsTree_Indicators: self.nvt: BpsRatioPattern = BpsRatioPattern(client, 'nvt') self.gini: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'gini') self.rhodl_ratio: BpsRatioPattern = BpsRatioPattern(client, 'rhodl_ratio') + self.thermocap_multiple: BpsRatioPattern = BpsRatioPattern(client, 'thermocap_multiple') class MetricsTree_Market_Ath: """Metrics tree node.""" @@ -4909,6 +4904,8 @@ class MetricsTree_Distribution_UtxoCohorts_All_Supply: def __init__(self, client: BrkClientBase, base_path: str = ''): self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, 'supply_delta') + 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.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'supply_halved') @@ -4919,7 +4916,6 @@ class MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss: self.negative: MetricPattern1[Dollars] = MetricPattern1(client, 'neg_unrealized_loss') self.raw: CentsUsdPattern = CentsUsdPattern(client, 'unrealized_loss') self.sum: _24hPattern = _24hPattern(client, 'unrealized_loss_24h') - self.supply: BtcCentsRelSatsUsdPattern2 = BtcCentsRelSatsUsdPattern2(client, 'supply_in_loss') self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_market_cap') self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_own_gross_pnl') @@ -4937,7 +4933,6 @@ class MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit: def __init__(self, client: BrkClientBase, base_path: str = ''): self.raw: CentsUsdPattern = CentsUsdPattern(client, 'unrealized_profit') self.sum: _24hPattern = _24hPattern(client, 'unrealized_profit_24h') - self.supply: BtcCentsRelSatsUsdPattern2 = BtcCentsRelSatsUsdPattern2(client, 'supply_in_profit') self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_market_cap') self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_own_gross_pnl') @@ -4969,7 +4964,7 @@ class MetricsTree_Distribution_UtxoCohorts_Sth: def __init__(self, client: BrkClientBase, base_path: str = ''): self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(client, 'sth') - self.supply: DeltaHalvedRelTotalPattern2 = DeltaHalvedRelTotalPattern2(client, 'sth_supply') + self.supply: DeltaHalvedInRelTotalPattern2 = DeltaHalvedInRelTotalPattern2(client, 'sth_supply') self.outputs: UtxoPattern3 = UtxoPattern3(client, 'sth_utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'sth') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'sth') @@ -5020,7 +5015,7 @@ class MetricsTree_Distribution_UtxoCohorts_Lth: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.supply: DeltaHalvedRelTotalPattern2 = DeltaHalvedRelTotalPattern2(client, 'lth_supply') + self.supply: DeltaHalvedInRelTotalPattern2 = DeltaHalvedInRelTotalPattern2(client, 'lth_supply') self.outputs: UtxoPattern3 = UtxoPattern3(client, 'lth_utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'lth') self.realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized = MetricsTree_Distribution_UtxoCohorts_Lth_Realized(client)