From 46ac55d95037fd3ca3f5e5063e132a22f66709f2 Mon Sep 17 00:00:00 2001 From: nym21 Date: Tue, 10 Mar 2026 01:13:52 +0100 Subject: [PATCH] global: snapshot --- crates/brk_client/src/lib.rs | 4106 ++++++++++------ .../src/cointime/activity/compute.rs | 4 +- .../brk_computer/src/cointime/cap/compute.rs | 2 +- .../src/cointime/value/compute.rs | 4 +- .../src/distribution/cohorts/address/vecs.rs | 27 +- .../src/distribution/cohorts/utxo/groups.rs | 47 +- .../distribution/cohorts/utxo/vecs/core.rs | 84 + .../distribution/cohorts/utxo/vecs/minimal.rs | 80 + .../cohorts/utxo/{vecs.rs => vecs/mod.rs} | 270 +- .../distribution/cohorts/utxo/vecs/type.rs | 83 + .../src/distribution/metrics/activity/base.rs | 97 - .../src/distribution/metrics/activity/core.rs | 56 +- .../src/distribution/metrics/activity/full.rs | 119 +- .../src/distribution/metrics/activity/mod.rs | 42 +- .../src/distribution/metrics/cohort/all.rs | 63 +- .../src/distribution/metrics/cohort/basic.rs | 24 +- .../src/distribution/metrics/cohort/core.rs | 18 +- .../distribution/metrics/cohort/extended.rs | 50 +- .../metrics/cohort/extended_adjusted.rs | 15 +- .../distribution/metrics/cohort/minimal.rs | 54 +- .../src/distribution/metrics/cohort/mod.rs | 2 + .../src/distribution/metrics/cohort/type.rs | 83 + .../src/distribution/metrics/config.rs | 43 +- .../src/distribution/metrics/mod.rs | 67 +- .../src/distribution/metrics/outputs.rs | 77 - .../src/distribution/metrics/outputs/base.rs | 54 + .../src/distribution/metrics/outputs/full.rs | 64 + .../src/distribution/metrics/outputs/mod.rs | 5 + .../distribution/metrics/realized/adjusted.rs | 12 +- .../src/distribution/metrics/realized/base.rs | 106 - .../src/distribution/metrics/realized/core.rs | 161 +- .../src/distribution/metrics/realized/full.rs | 697 +-- .../distribution/metrics/realized/minimal.rs | 155 +- .../src/distribution/metrics/realized/mod.rs | 34 +- .../relative/extended_own_market_cap.rs | 7 +- .../metrics/relative/extended_own_pnl.rs | 7 +- .../src/distribution/metrics/relative/full.rs | 44 +- .../distribution/metrics/relative/to_all.rs | 3 + .../metrics/{supply.rs => supply/base.rs} | 50 +- .../src/distribution/metrics/supply/full.rs | 63 + .../src/distribution/metrics/supply/mod.rs | 5 + .../distribution/metrics/unrealized/base.rs | 9 +- .../distribution/metrics/unrealized/basic.rs | 107 + .../distribution/metrics/unrealized/core.rs | 69 +- .../distribution/metrics/unrealized/full.rs | 52 +- .../metrics/unrealized/minimal.rs | 13 +- .../distribution/metrics/unrealized/mod.rs | 11 +- .../distribution/state/cost_basis/realized.rs | 42 +- crates/brk_computer/src/distribution/vecs.rs | 16 +- crates/brk_computer/src/indexes/epoch.rs | 2 +- crates/brk_computer/src/indexes/halving.rs | 2 +- crates/brk_computer/src/indexes/height.rs | 2 +- .../src/internal/algo/sliding_distribution.rs | 18 +- .../src/internal/containers/mod.rs | 6 + .../src/internal/containers/window_24h.rs | 7 + .../internal/containers/windows_except_1m.rs | 30 + .../internal/containers/windows_from_1w.rs | 30 + .../src/internal/per_block/amount/mod.rs | 2 + .../internal/per_block/amount/rolling_sum.rs | 36 +- .../internal/per_block/amount/with_sum_24h.rs | 14 + .../src/internal/per_block/computed/delta.rs | 70 +- .../internal/per_block/computed/fiat_delta.rs | 118 +- .../src/internal/per_block/computed/mod.rs | 2 + .../per_block/computed/resolutions.rs | 7 +- .../per_block/computed/with_sum_24h.rs | 19 + .../src/internal/per_block/fiat/mod.rs | 2 + .../internal/per_block/fiat/with_sum_24h.rs | 59 + .../src/internal/per_block/ratio/base.rs | 14 +- .../src/internal/per_block/ratio/extended.rs | 4 +- .../internal/per_block/ratio/percentiles.rs | 107 +- .../per_block/ratio/price_extended.rs | 4 +- .../internal/per_block/ratio/std_dev_bands.rs | 24 +- .../src/internal/per_block/rolling/windows.rs | 79 +- .../src/internal/per_block/stddev/extended.rs | 190 +- crates/brk_computer/src/market/ath/compute.rs | 14 +- crates/brk_computer/src/market/ath/import.rs | 28 +- crates/brk_computer/src/market/ath/vecs.rs | 12 +- .../src/market/indicators/compute.rs | 8 +- .../src/market/indicators/vecs.rs | 8 +- .../src/market/moving_average/compute.rs | 64 +- .../src/market/moving_average/import.rs | 102 +- .../src/market/moving_average/vecs.rs | 85 +- .../brk_computer/src/market/range/compute.rs | 30 +- .../brk_computer/src/market/range/import.rs | 28 +- crates/brk_computer/src/market/range/vecs.rs | 25 +- .../src/market/returns/compute.rs | 6 +- .../brk_computer/src/market/returns/import.rs | 56 +- .../brk_computer/src/market/returns/vecs.rs | 19 +- .../src/market/volatility/import.rs | 27 +- .../src/market/volatility/vecs.rs | 6 +- .../src/mining/hashrate/compute.rs | 50 +- .../src/mining/hashrate/import.rs | 179 +- .../brk_computer/src/mining/hashrate/vecs.rs | 34 +- crates/brk_computer/src/supply/compute.rs | 6 +- crates/brk_error/src/lib.rs | 54 +- crates/brk_query/src/impl/block/info.rs | 2 +- crates/brk_query/src/impl/block/timestamp.rs | 2 +- crates/brk_query/src/impl/block/txs.rs | 6 +- crates/brk_query/src/impl/cost_basis.rs | 5 +- crates/brk_query/src/impl/metrics.rs | 26 +- crates/brk_query/src/lib.rs | 39 +- crates/brk_server/src/api/metrics/bulk.rs | 5 +- crates/brk_server/src/api/metrics/data.rs | 5 +- crates/brk_server/src/api/metrics/legacy.rs | 8 +- crates/brk_server/src/api/metrics/mod.rs | 6 +- crates/brk_server/src/api/openapi/mod.rs | 59 +- crates/brk_server/src/api/server/mod.rs | 30 +- crates/brk_server/src/error.rs | 156 +- crates/brk_server/src/extended/header_map.rs | 16 +- crates/brk_server/src/extended/result.rs | 35 +- .../src/extended/transform_operation.rs | 10 +- crates/brk_server/src/lib.rs | 49 +- crates/brk_traversable_derive/src/lib.rs | 42 +- crates/brk_types/src/epoch.rs | 2 +- crates/brk_types/src/halving.rs | 2 +- crates/brk_types/src/health.rs | 5 + crates/brk_types/src/metricdata.rs | 25 +- crates/brk_types/src/syncstatus.rs | 2 + crates/brk_types/src/treenode.rs | 4 +- modules/brk-client/index.js | 4151 +++++++++++------ packages/brk_client/brk_client/__init__.py | 2105 ++++++--- 121 files changed, 9792 insertions(+), 5997 deletions(-) create mode 100644 crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs create mode 100644 crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs rename crates/brk_computer/src/distribution/cohorts/utxo/{vecs.rs => vecs/mod.rs} (54%) create mode 100644 crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/activity/base.rs create mode 100644 crates/brk_computer/src/distribution/metrics/cohort/type.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/outputs.rs create mode 100644 crates/brk_computer/src/distribution/metrics/outputs/base.rs create mode 100644 crates/brk_computer/src/distribution/metrics/outputs/full.rs create mode 100644 crates/brk_computer/src/distribution/metrics/outputs/mod.rs delete mode 100644 crates/brk_computer/src/distribution/metrics/realized/base.rs rename crates/brk_computer/src/distribution/metrics/{supply.rs => supply/base.rs} (55%) create mode 100644 crates/brk_computer/src/distribution/metrics/supply/full.rs create mode 100644 crates/brk_computer/src/distribution/metrics/supply/mod.rs create mode 100644 crates/brk_computer/src/distribution/metrics/unrealized/basic.rs create mode 100644 crates/brk_computer/src/internal/containers/window_24h.rs create mode 100644 crates/brk_computer/src/internal/containers/windows_except_1m.rs create mode 100644 crates/brk_computer/src/internal/containers/windows_from_1w.rs create mode 100644 crates/brk_computer/src/internal/per_block/amount/with_sum_24h.rs create mode 100644 crates/brk_computer/src/internal/per_block/computed/with_sum_24h.rs create mode 100644 crates/brk_computer/src/internal/per_block/fiat/with_sum_24h.rs diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 09a062f7e..b836b557b 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -433,8 +433,8 @@ impl MetricPattern1By { pub fn month6(&self) -> DateMetricEndpointBuilder { _dep(&self.client, &self.name, Index::Month6) } pub fn year1(&self) -> DateMetricEndpointBuilder { _dep(&self.client, &self.name, Index::Year1) } pub fn year10(&self) -> DateMetricEndpointBuilder { _dep(&self.client, &self.name, Index::Year10) } - pub fn halvingepoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Halving) } - pub fn difficultyepoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Epoch) } + pub fn halving(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Halving) } + pub fn epoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Epoch) } pub fn height(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Height) } } @@ -462,8 +462,8 @@ impl MetricPattern2By { pub fn month6(&self) -> DateMetricEndpointBuilder { _dep(&self.client, &self.name, Index::Month6) } pub fn year1(&self) -> DateMetricEndpointBuilder { _dep(&self.client, &self.name, Index::Year1) } pub fn year10(&self) -> DateMetricEndpointBuilder { _dep(&self.client, &self.name, Index::Year10) } - pub fn halvingepoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Halving) } - pub fn difficultyepoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Epoch) } + pub fn halving(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Halving) } + pub fn epoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Epoch) } } pub struct MetricPattern2 { name: Arc, pub by: MetricPattern2By } @@ -659,7 +659,7 @@ impl MetricPattern for MetricPattern15 { fn get(&self pub struct MetricPattern16By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl MetricPattern16By { - pub fn halvingepoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Halving) } + pub fn halving(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Halving) } } pub struct MetricPattern16 { name: Arc, pub by: MetricPattern16By } @@ -673,7 +673,7 @@ impl MetricPattern for MetricPattern16 { fn get(&self pub struct MetricPattern17By { client: Arc, name: Arc, _marker: std::marker::PhantomData } impl MetricPattern17By { - pub fn difficultyepoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Epoch) } + pub fn epoch(&self) -> MetricEndpointBuilder { _ep(&self.client, &self.name, Index::Epoch) } } pub struct MetricPattern17 { name: Arc, pub by: MetricPattern17By } @@ -939,272 +939,6 @@ impl MetricPattern for MetricPattern35 { fn get(&self // Reusable pattern structs -/// Pattern struct for repeated tree structure. -pub struct CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { - pub cap_raw: MetricPattern18, - pub capitulation_flow: MetricPattern1, - pub gross_pnl: CentsUsdPattern, - pub gross_pnl_sum: _1m1w1y24hPattern, - pub investor_cap_raw: MetricPattern18, - pub investor_price: CentsSatsUsdPattern, - pub investor_price_ratio: BpsRatioPattern, - pub investor_price_ratio_percentiles: RatioPattern, - pub loss_value_created: MetricPattern1, - pub loss_value_created_sum: _1m1w1y24hPattern, - pub loss_value_destroyed: MetricPattern1, - pub loss_value_destroyed_sum: _1m1w1y24hPattern, - pub lower_price_band: CentsSatsUsdPattern, - pub mvrv: MetricPattern1, - pub neg_realized_loss: MetricPattern1, - pub net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern, - pub net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern, - pub net_pnl_delta: ChangeRatePattern3, - pub net_pnl_delta_extended: _24hChangeRatePattern, - pub net_realized_pnl: MetricPattern1, - pub net_realized_pnl_cumulative: MetricPattern1, - pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern, - pub net_realized_pnl_sum: _24hPattern, - pub net_realized_pnl_sum_extended: _1m1w1yPattern, - pub peak_regret: CumulativeHeightPattern, - pub peak_regret_rel_to_rcap: BpsPercentRatioPattern, - pub profit_flow: MetricPattern1, - pub profit_value_created: MetricPattern1, - pub profit_value_created_sum: _1m1w1y24hPattern, - pub profit_value_destroyed: MetricPattern1, - pub profit_value_destroyed_sum: _1m1w1y24hPattern, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_cap_delta: ChangeRatePattern3, - pub realized_cap_delta_extended: _24hChangeRatePattern, - pub realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern, - pub realized_loss: CumulativeHeightPattern, - pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_loss_sum: _24hPattern, - pub realized_loss_sum_extended: _1m1w1yPattern, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_price_ratio_percentiles: RatioPattern, - pub realized_price_ratio_std_dev: RatioPattern2, - pub realized_profit: CumulativeHeightPattern, - pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern, - pub realized_profit_sum: _24hPattern, - pub realized_profit_sum_extended: _1m1w1yPattern, - pub realized_profit_to_loss_ratio: _1m1w1y24hPattern, - pub sell_side_risk_ratio: _1m1w1y24hPattern2, - pub sent_in_loss: MetricPattern1, - pub sent_in_loss_sum: _24hPattern, - pub sent_in_loss_sum_extended: _1m1w1yPattern, - pub sent_in_profit: MetricPattern1, - pub sent_in_profit_sum: _24hPattern, - pub sent_in_profit_sum_extended: _1m1w1yPattern, - pub sopr: _24hPattern, - pub sopr_extended: _1m1w1yPattern, - pub upper_price_band: CentsSatsUsdPattern, - pub value_created: MetricPattern1, - pub value_created_sum: _24hPattern, - pub value_created_sum_extended: _1m1w1yPattern, - pub value_destroyed: MetricPattern1, - pub value_destroyed_sum: _24hPattern, - pub value_destroyed_sum_extended: _1m1w1yPattern, -} - -impl CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "cap_raw")), - capitulation_flow: MetricPattern1::new(client.clone(), _m(&acc, "capitulation_flow")), - gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")), - gross_pnl_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "gross_pnl_sum")), - investor_cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_raw")), - investor_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")), - investor_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")), - investor_price_ratio_percentiles: RatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")), - loss_value_created: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_created")), - loss_value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "loss_value_created")), - loss_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_destroyed")), - loss_value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "loss_value_destroyed")), - lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")), - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), - net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_market_cap")), - net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_realized_cap")), - net_pnl_delta: ChangeRatePattern3::new(client.clone(), _m(&acc, "net_pnl_delta")), - net_pnl_delta_extended: _24hChangeRatePattern::new(client.clone(), _m(&acc, "net_pnl_delta")), - net_realized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl")), - net_realized_pnl_cumulative: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl_cumulative")), - net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_realized_pnl_rel_to_realized_cap")), - net_realized_pnl_sum: _24hPattern::new(client.clone(), _m(&acc, "net_realized_pnl_24h")), - net_realized_pnl_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), - peak_regret: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_peak_regret")), - peak_regret_rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_peak_regret_rel_to_realized_cap")), - profit_flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")), - profit_value_created: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_created")), - profit_value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "profit_value_created")), - profit_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_destroyed")), - profit_value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "profit_value_destroyed")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_cap_delta: ChangeRatePattern3::new(client.clone(), _m(&acc, "realized_cap_delta")), - realized_cap_delta_extended: _24hChangeRatePattern::new(client.clone(), _m(&acc, "realized_cap_delta")), - realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_cap_rel_to_own_market_cap")), - realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")), - realized_loss_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_loss_24h")), - realized_loss_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_price_ratio_percentiles: RatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_price_ratio_std_dev: RatioPattern2::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")), - realized_profit_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_profit_24h")), - realized_profit_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit_to_loss_ratio")), - sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio")), - sent_in_loss: MetricPattern1::new(client.clone(), _m(&acc, "sent_in_loss")), - sent_in_loss_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_in_loss_24h")), - sent_in_loss_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sent_in_loss")), - sent_in_profit: MetricPattern1::new(client.clone(), _m(&acc, "sent_in_profit")), - sent_in_profit_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_in_profit_24h")), - sent_in_profit_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sent_in_profit")), - sopr: _24hPattern::new(client.clone(), _m(&acc, "sopr_24h")), - sopr_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sopr")), - upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")), - value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")), - value_created_sum: _24hPattern::new(client.clone(), _m(&acc, "value_created_24h")), - value_created_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "value_created")), - value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")), - value_destroyed_sum: _24hPattern::new(client.clone(), _m(&acc, "value_destroyed_24h")), - value_destroyed_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "value_destroyed")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { - pub _0sd_price: CentsSatsUsdPattern, - pub m0_5sd: MetricPattern1, - pub m0_5sd_price: CentsSatsUsdPattern, - pub m1_5sd: MetricPattern1, - pub m1_5sd_price: CentsSatsUsdPattern, - pub m1sd: MetricPattern1, - pub m1sd_price: CentsSatsUsdPattern, - pub m2_5sd: MetricPattern1, - pub m2_5sd_price: CentsSatsUsdPattern, - pub m2sd: MetricPattern1, - pub m2sd_price: CentsSatsUsdPattern, - pub m3sd: MetricPattern1, - pub m3sd_price: CentsSatsUsdPattern, - pub p0_5sd: MetricPattern1, - pub p0_5sd_price: CentsSatsUsdPattern, - pub p1_5sd: MetricPattern1, - pub p1_5sd_price: CentsSatsUsdPattern, - pub p1sd: MetricPattern1, - pub p1sd_price: CentsSatsUsdPattern, - pub p2_5sd: MetricPattern1, - pub p2_5sd_price: CentsSatsUsdPattern, - pub p2sd: MetricPattern1, - pub p2sd_price: CentsSatsUsdPattern, - pub p3sd: MetricPattern1, - pub p3sd_price: CentsSatsUsdPattern, - pub sd: MetricPattern1, - pub sma: MetricPattern1, - pub zscore: MetricPattern1, -} - -impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _0sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "0sd_4y")), - m0_5sd: MetricPattern1::new(client.clone(), _m(&acc, "m0_5sd_4y")), - m0_5sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "m0_5sd_4y")), - m1_5sd: MetricPattern1::new(client.clone(), _m(&acc, "m1_5sd_4y")), - m1_5sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "m1_5sd_4y")), - m1sd: MetricPattern1::new(client.clone(), _m(&acc, "m1sd_4y")), - m1sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "m1sd_4y")), - m2_5sd: MetricPattern1::new(client.clone(), _m(&acc, "m2_5sd_4y")), - m2_5sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "m2_5sd_4y")), - m2sd: MetricPattern1::new(client.clone(), _m(&acc, "m2sd_4y")), - m2sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "m2sd_4y")), - m3sd: MetricPattern1::new(client.clone(), _m(&acc, "m3sd_4y")), - m3sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "m3sd_4y")), - p0_5sd: MetricPattern1::new(client.clone(), _m(&acc, "p0_5sd_4y")), - p0_5sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "p0_5sd_4y")), - p1_5sd: MetricPattern1::new(client.clone(), _m(&acc, "p1_5sd_4y")), - p1_5sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "p1_5sd_4y")), - p1sd: MetricPattern1::new(client.clone(), _m(&acc, "p1sd_4y")), - p1sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "p1sd_4y")), - p2_5sd: MetricPattern1::new(client.clone(), _m(&acc, "p2_5sd_4y")), - p2_5sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "p2_5sd_4y")), - p2sd: MetricPattern1::new(client.clone(), _m(&acc, "p2sd_4y")), - p2sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "p2sd_4y")), - p3sd: MetricPattern1::new(client.clone(), _m(&acc, "p3sd_4y")), - p3sd_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "p3sd_4y")), - sd: MetricPattern1::new(client.clone(), _m(&acc, "sd_4y")), - sma: MetricPattern1::new(client.clone(), _m(&acc, "sma_4y")), - zscore: MetricPattern1::new(client.clone(), _m(&acc, "zscore_4y")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct MvrvNegNetRealizedSentSoprValuePattern { - pub mvrv: MetricPattern1, - pub neg_realized_loss: MetricPattern1, - pub net_realized_pnl: MetricPattern1, - pub net_realized_pnl_sum: _24hPattern, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_cap_delta: ChangeRatePattern3, - pub realized_loss: CumulativeHeightPattern, - pub realized_loss_sum: _24hPattern, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_profit: CumulativeHeightPattern, - pub realized_profit_sum: _24hPattern, - pub sent_in_loss: MetricPattern1, - pub sent_in_loss_sum: _24hPattern, - pub sent_in_profit: MetricPattern1, - pub sent_in_profit_sum: _24hPattern, - pub sopr: _24hPattern, - pub value_created: MetricPattern1, - pub value_created_sum: _24hPattern, - pub value_destroyed: MetricPattern1, - pub value_destroyed_sum: _24hPattern, -} - -impl MvrvNegNetRealizedSentSoprValuePattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), - net_realized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl")), - net_realized_pnl_sum: _24hPattern::new(client.clone(), _m(&acc, "net_realized_pnl_24h")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_cap_delta: ChangeRatePattern3::new(client.clone(), _m(&acc, "realized_cap_delta")), - realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_loss_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_loss_24h")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_profit_24h")), - sent_in_loss: MetricPattern1::new(client.clone(), _m(&acc, "sent_in_loss")), - sent_in_loss_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_in_loss_24h")), - sent_in_profit: MetricPattern1::new(client.clone(), _m(&acc, "sent_in_profit")), - sent_in_profit_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_in_profit_24h")), - sopr: _24hPattern::new(client.clone(), _m(&acc, "sopr_24h")), - value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")), - value_created_sum: _24hPattern::new(client.clone(), _m(&acc, "value_created_24h")), - value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")), - value_destroyed_sum: _24hPattern::new(client.clone(), _m(&acc, "value_destroyed_24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern { pub pct05: CentsSatsUsdPattern, @@ -1256,219 +990,85 @@ impl Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75 } /// Pattern struct for repeated tree structure. -pub struct MvrvNegNetRealizedSoprValuePattern { +pub struct _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { + pub _0sd: PriceValuePattern, + pub m0_5sd: PriceValuePattern, + pub m1_5sd: PriceValuePattern, + pub m1sd: PriceValuePattern, + pub m2_5sd: PriceValuePattern, + pub m2sd: PriceValuePattern, + pub m3sd: PriceValuePattern, + pub p0_5sd: PriceValuePattern, + pub p1_5sd: PriceValuePattern, + pub p1sd: PriceValuePattern, + pub p2_5sd: PriceValuePattern, + pub p2sd: PriceValuePattern, + pub p3sd: PriceValuePattern, + pub sd: MetricPattern1, + pub sma: MetricPattern1, + pub zscore: MetricPattern1, +} + +impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _0sd: PriceValuePattern::new(client.clone(), _m(&acc, "0sd_4y")), + m0_5sd: PriceValuePattern::new(client.clone(), _m(&acc, "m0_5sd_4y")), + m1_5sd: PriceValuePattern::new(client.clone(), _m(&acc, "m1_5sd_4y")), + m1sd: PriceValuePattern::new(client.clone(), _m(&acc, "m1sd_4y")), + m2_5sd: PriceValuePattern::new(client.clone(), _m(&acc, "m2_5sd_4y")), + m2sd: PriceValuePattern::new(client.clone(), _m(&acc, "m2sd_4y")), + m3sd: PriceValuePattern::new(client.clone(), _m(&acc, "m3sd_4y")), + p0_5sd: PriceValuePattern::new(client.clone(), _m(&acc, "p0_5sd_4y")), + p1_5sd: PriceValuePattern::new(client.clone(), _m(&acc, "p1_5sd_4y")), + p1sd: PriceValuePattern::new(client.clone(), _m(&acc, "p1sd_4y")), + p2_5sd: PriceValuePattern::new(client.clone(), _m(&acc, "p2_5sd_4y")), + p2sd: PriceValuePattern::new(client.clone(), _m(&acc, "p2sd_4y")), + p3sd: PriceValuePattern::new(client.clone(), _m(&acc, "p3sd_4y")), + sd: MetricPattern1::new(client.clone(), _m(&acc, "sd_4y")), + sma: MetricPattern1::new(client.clone(), _m(&acc, "sma_4y")), + zscore: MetricPattern1::new(client.clone(), _m(&acc, "zscore_4y")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern { + pub cap: CentsDeltaRawRelUsdPattern, + pub gross_pnl: CentsSellSumUsdPattern, + pub investor: CapLowerPriceUpperPattern, + pub loss: CapitulationCentsCumulativeNegRelSumUsdValuePattern, pub mvrv: MetricPattern1, - pub neg_realized_loss: MetricPattern1, - pub net_realized_pnl: MetricPattern1, - pub net_realized_pnl_sum: _24hPattern, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_cap_delta: ChangeRatePattern3, - pub realized_loss: CumulativeHeightPattern, - pub realized_loss_sum: _24hPattern, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_profit: CumulativeHeightPattern, - pub realized_profit_sum: _24hPattern, - pub sopr: _24hPattern, - pub value_created: MetricPattern1, - pub value_created_sum: _24hPattern, - pub value_destroyed: MetricPattern1, - pub value_destroyed_sum: _24hPattern, + pub net_pnl: ChangeCumulativeDeltaRawRelSumPattern, + pub nupl: BpsRatioPattern, + pub peak_regret: CumulativeHeightRelPattern, + pub price: CentsSatsUsdPattern, + pub price_ratio: BpsPercentilesRatioStdPattern, + pub profit: CentsCumulativeFlowRelSumUsdValuePattern, + pub profit_to_loss_ratio: _1m1w1y24hPattern, + pub sent: InPattern3, + pub sopr: AdjustedRatioValuePattern, } -impl MvrvNegNetRealizedSoprValuePattern { +impl CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { + cap: CentsDeltaRawRelUsdPattern::new(client.clone(), acc.clone()), + gross_pnl: CentsSellSumUsdPattern::new(client.clone(), acc.clone()), + investor: CapLowerPriceUpperPattern::new(client.clone(), acc.clone()), + loss: CapitulationCentsCumulativeNegRelSumUsdValuePattern::new(client.clone(), acc.clone()), mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), - net_realized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl")), - net_realized_pnl_sum: _24hPattern::new(client.clone(), _m(&acc, "net_realized_pnl_24h")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_cap_delta: ChangeRatePattern3::new(client.clone(), _m(&acc, "realized_cap_delta")), - realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_loss_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_loss_24h")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_profit_24h")), - sopr: _24hPattern::new(client.clone(), _m(&acc, "sopr_24h")), - value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")), - value_created_sum: _24hPattern::new(client.clone(), _m(&acc, "value_created_24h")), - value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")), - value_destroyed_sum: _24hPattern::new(client.clone(), _m(&acc, "value_destroyed_24h")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct BpsRatioPattern2 { - pub bps: MetricPattern1, - pub ratio: MetricPattern1, - pub ratio_pct1: BpsRatioPattern, - pub ratio_pct1_price: CentsSatsUsdPattern, - pub ratio_pct2: BpsRatioPattern, - pub ratio_pct2_price: CentsSatsUsdPattern, - pub ratio_pct5: BpsRatioPattern, - pub ratio_pct5_price: CentsSatsUsdPattern, - pub ratio_pct95: BpsRatioPattern, - pub ratio_pct95_price: CentsSatsUsdPattern, - pub ratio_pct98: BpsRatioPattern, - pub ratio_pct98_price: CentsSatsUsdPattern, - pub ratio_pct99: BpsRatioPattern, - pub ratio_pct99_price: CentsSatsUsdPattern, - pub ratio_sma_1m: BpsRatioPattern, - pub ratio_sma_1w: BpsRatioPattern, -} - -impl BpsRatioPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: MetricPattern1::new(client.clone(), _m(&acc, "bps")), - ratio: MetricPattern1::new(client.clone(), acc.clone()), - ratio_pct1: BpsRatioPattern::new(client.clone(), _m(&acc, "pct1")), - ratio_pct1_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct1")), - ratio_pct2: BpsRatioPattern::new(client.clone(), _m(&acc, "pct2")), - ratio_pct2_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct2")), - ratio_pct5: BpsRatioPattern::new(client.clone(), _m(&acc, "pct5")), - ratio_pct5_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct5")), - ratio_pct95: BpsRatioPattern::new(client.clone(), _m(&acc, "pct95")), - ratio_pct95_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct95")), - ratio_pct98: BpsRatioPattern::new(client.clone(), _m(&acc, "pct98")), - ratio_pct98_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct98")), - ratio_pct99: BpsRatioPattern::new(client.clone(), _m(&acc, "pct99")), - ratio_pct99_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct99")), - ratio_sma_1m: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1m")), - ratio_sma_1w: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1w")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern { - pub greed_index: CentsUsdPattern, - pub gross_pnl: CentsUsdPattern, - pub invested_capital_in_loss: CentsUsdPattern, - pub invested_capital_in_loss_raw: MetricPattern18, - pub invested_capital_in_profit: CentsUsdPattern, - pub invested_capital_in_profit_raw: MetricPattern18, - pub investor_cap_in_loss_raw: MetricPattern18, - pub investor_cap_in_profit_raw: MetricPattern18, - pub neg_unrealized_loss: MetricPattern1, - pub net_sentiment: CentsUsdPattern, - pub net_unrealized_pnl: CentsUsdPattern, - pub pain_index: CentsUsdPattern, - pub supply_in_loss: BtcCentsSatsUsdPattern, - pub supply_in_profit: BtcCentsSatsUsdPattern, - pub unrealized_loss: CentsUsdPattern, - pub unrealized_profit: CentsUsdPattern, -} - -impl GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - greed_index: CentsUsdPattern::new(client.clone(), _m(&acc, "greed_index")), - gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_gross_pnl")), - invested_capital_in_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "invested_capital_in_loss")), - invested_capital_in_loss_raw: MetricPattern18::new(client.clone(), _m(&acc, "invested_capital_in_loss_raw")), - invested_capital_in_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "invested_capital_in_profit")), - invested_capital_in_profit_raw: MetricPattern18::new(client.clone(), _m(&acc, "invested_capital_in_profit_raw")), - investor_cap_in_loss_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_in_loss_raw")), - investor_cap_in_profit_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_in_profit_raw")), - neg_unrealized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - net_sentiment: CentsUsdPattern::new(client.clone(), _m(&acc, "net_sentiment")), - net_unrealized_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - pain_index: CentsUsdPattern::new(client.clone(), _m(&acc, "pain_index")), - supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")), - supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), - unrealized_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - unrealized_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct NetNuplSupplyUnrealizedPattern2 { - pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern, - pub net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern, - pub net_unrealized_pnl_rel_to_own_market_cap: BpsPercentRatioPattern, - pub nupl: MetricPattern1, - pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern, - pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern, - pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern, - pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern, - pub supply_rel_to_circulating_supply: BpsPercentRatioPattern, - pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, - pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern, - pub unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern, - pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern, - pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern, - pub unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern, -} - -impl NetNuplSupplyUnrealizedPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_market_cap")), - net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_gross_pnl")), - net_unrealized_pnl_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_market_cap")), - nupl: MetricPattern1::new(client.clone(), _m(&acc, "nupl")), - supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_circulating_supply")), - supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")), - supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_circulating_supply")), - supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")), - supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_rel_to_circulating_supply")), - unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")), - unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_gross_pnl")), - unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")), - unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")), - unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_gross_pnl")), - unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct RatioPattern { - pub ratio_pct1: BpsRatioPattern, - pub ratio_pct1_price: CentsSatsUsdPattern, - pub ratio_pct2: BpsRatioPattern, - pub ratio_pct2_price: CentsSatsUsdPattern, - pub ratio_pct5: BpsRatioPattern, - pub ratio_pct5_price: CentsSatsUsdPattern, - pub ratio_pct95: BpsRatioPattern, - pub ratio_pct95_price: CentsSatsUsdPattern, - pub ratio_pct98: BpsRatioPattern, - pub ratio_pct98_price: CentsSatsUsdPattern, - pub ratio_pct99: BpsRatioPattern, - pub ratio_pct99_price: CentsSatsUsdPattern, - pub ratio_sma_1m: BpsRatioPattern, - pub ratio_sma_1w: BpsRatioPattern, -} - -impl RatioPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - ratio_pct1: BpsRatioPattern::new(client.clone(), _m(&acc, "pct1")), - ratio_pct1_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct1")), - ratio_pct2: BpsRatioPattern::new(client.clone(), _m(&acc, "pct2")), - ratio_pct2_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct2")), - ratio_pct5: BpsRatioPattern::new(client.clone(), _m(&acc, "pct5")), - ratio_pct5_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct5")), - ratio_pct95: BpsRatioPattern::new(client.clone(), _m(&acc, "pct95")), - ratio_pct95_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct95")), - ratio_pct98: BpsRatioPattern::new(client.clone(), _m(&acc, "pct98")), - ratio_pct98_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct98")), - ratio_pct99: BpsRatioPattern::new(client.clone(), _m(&acc, "pct99")), - ratio_pct99_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct99")), - ratio_sma_1m: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1m")), - ratio_sma_1w: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1w")), + net_pnl: ChangeCumulativeDeltaRawRelSumPattern::new(client.clone(), _m(&acc, "net")), + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), + peak_regret: CumulativeHeightRelPattern::new(client.clone(), _m(&acc, "realized_peak_regret")), + price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + price_ratio: BpsPercentilesRatioStdPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), + profit: CentsCumulativeFlowRelSumUsdValuePattern::new(client.clone(), acc.clone()), + profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit_to_loss_ratio")), + sent: InPattern3::new(client.clone(), _m(&acc, "sent_in")), + sopr: AdjustedRatioValuePattern::new(client.clone(), acc.clone()), } } } @@ -1545,40 +1145,6 @@ impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 { } } -/// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern { - pub _1m: BpsPercentRatioPattern, - pub _1w: BpsPercentRatioPattern, - pub _1y: BpsPercentRatioPattern, - pub _24h: BpsPercentRatioPattern, - pub base: BtcCentsSatsUsdPattern, - pub bps: MetricPattern1, - pub cumulative: BaseBtcCentsSatsUsdPattern, - pub height: MetricPattern18, - pub percent: MetricPattern1, - pub ratio: MetricPattern1, - pub sum: _1m1w1y24hPattern6, -} - -impl _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance_1m")), - _1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance_1w")), - _1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance_1y")), - _24h: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance_24h")), - base: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "rewards")), - bps: MetricPattern1::new(client.clone(), _m(&acc, "dominance_bps")), - cumulative: BaseBtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - height: MetricPattern18::new(client.clone(), _m(&acc, "blocks_mined")), - percent: MetricPattern1::new(client.clone(), _m(&acc, "dominance")), - ratio: MetricPattern1::new(client.clone(), _m(&acc, "dominance_ratio")), - sum: _1m1w1y24hPattern6::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern { pub average: MetricPattern18, @@ -1603,10 +1169,10 @@ impl AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern { max: MetricPattern18::new(client.clone(), _m(&acc, "max")), median: MetricPattern18::new(client.clone(), _m(&acc, "median")), min: MetricPattern18::new(client.clone(), _m(&acc, "min")), - pct10: MetricPattern18::new(client.clone(), _m(&acc, "p10")), - pct25: MetricPattern18::new(client.clone(), _m(&acc, "p25")), - pct75: MetricPattern18::new(client.clone(), _m(&acc, "p75")), - pct90: MetricPattern18::new(client.clone(), _m(&acc, "p90")), + pct10: MetricPattern18::new(client.clone(), _m(&acc, "pct10")), + pct25: MetricPattern18::new(client.clone(), _m(&acc, "pct25")), + pct75: MetricPattern18::new(client.clone(), _m(&acc, "pct75")), + pct90: MetricPattern18::new(client.clone(), _m(&acc, "pct90")), rolling: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), acc.clone()), sum: MetricPattern18::new(client.clone(), _m(&acc, "sum")), } @@ -1638,15 +1204,49 @@ impl AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern { max: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "max")), median: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "median")), min: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "min")), - pct10: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p10")), - pct25: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p25")), - pct75: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p75")), - pct90: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p90")), + pct10: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct10")), + pct25: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct25")), + pct75: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct75")), + pct90: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct90")), sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sum")), } } } +/// Pattern struct for repeated tree structure. +pub struct CapitulationCentsCumulativeNegRelSumUsdValuePattern { + pub capitulation_flow: MetricPattern1, + pub cents: MetricPattern1, + pub cumulative: MetricPattern1, + pub neg: MetricPattern1, + pub rel_to_rcap: BpsPercentRatioPattern, + pub sum: _1m1w1y24hPattern3, + pub usd: MetricPattern1, + pub value_created: MetricPattern1, + pub value_created_sum: _1m1w1y24hPattern, + pub value_destroyed: MetricPattern1, + pub value_destroyed_sum: _1m1w1y24hPattern, +} + +impl CapitulationCentsCumulativeNegRelSumUsdValuePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + capitulation_flow: MetricPattern1::new(client.clone(), _m(&acc, "capitulation_flow")), + cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_cents")), + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_cumulative")), + neg: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), + rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "realized_loss")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss")), + value_created: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_created")), + value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "loss_value_created")), + value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_destroyed")), + value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "loss_value_destroyed")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct AverageGainsLossesRsiStochPattern { pub average_gain: MetricPattern1, @@ -1680,33 +1280,97 @@ impl AverageGainsLossesRsiStochPattern { } /// Pattern struct for repeated tree structure. -pub struct InvestedInvestorNegNetSupplyUnrealizedPattern { - pub invested_capital_in_loss_raw: MetricPattern18, - pub invested_capital_in_profit_raw: MetricPattern18, - pub investor_cap_in_loss_raw: MetricPattern18, - pub investor_cap_in_profit_raw: MetricPattern18, - pub neg_unrealized_loss: MetricPattern1, - pub net_unrealized_pnl: CentsUsdPattern, - pub supply_in_loss: BtcCentsSatsUsdPattern, - pub supply_in_profit: BtcCentsSatsUsdPattern, - pub unrealized_loss: CentsUsdPattern, - pub unrealized_profit: CentsUsdPattern, +pub struct BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern { + pub bps: MetricPattern1, + pub pct1: BpsPriceRatioPattern, + pub pct2: BpsPriceRatioPattern, + pub pct5: BpsPriceRatioPattern, + pub pct95: BpsPriceRatioPattern, + pub pct98: BpsPriceRatioPattern, + pub pct99: BpsPriceRatioPattern, + pub ratio: MetricPattern1, + pub sma_1m: BpsRatioPattern, + pub sma_1w: BpsRatioPattern, } -impl InvestedInvestorNegNetSupplyUnrealizedPattern { +impl BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - invested_capital_in_loss_raw: MetricPattern18::new(client.clone(), _m(&acc, "invested_capital_in_loss_raw")), - invested_capital_in_profit_raw: MetricPattern18::new(client.clone(), _m(&acc, "invested_capital_in_profit_raw")), - investor_cap_in_loss_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_in_loss_raw")), - investor_cap_in_profit_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_in_profit_raw")), - neg_unrealized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - net_unrealized_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")), - supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), - unrealized_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - unrealized_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), + bps: MetricPattern1::new(client.clone(), _m(&acc, "bps")), + pct1: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct1")), + pct2: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct2")), + pct5: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct5")), + pct95: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct95")), + pct98: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct98")), + pct99: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct99")), + ratio: MetricPattern1::new(client.clone(), acc.clone()), + sma_1m: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1m")), + sma_1w: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1w")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CapLossMvrvNetNuplPriceProfitSentSoprPattern { + pub cap: CentsDeltaUsdPattern, + pub loss: CentsCumulativeNegSumUsdPattern, + pub mvrv: MetricPattern1, + pub net_pnl: RawSumPattern, + pub nupl: BpsRatioPattern, + pub price: CentsSatsUsdPattern, + pub price_ratio: BpsRatioPattern, + pub profit: CentsCumulativeSumUsdPattern, + pub sent: InPattern, + pub sopr: RatioValuePattern, +} + +impl CapLossMvrvNetNuplPriceProfitSentSoprPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cap: CentsDeltaUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), + loss: CentsCumulativeNegSumUsdPattern::new(client.clone(), acc.clone()), + mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), + net_pnl: RawSumPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), + price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), + profit: CentsCumulativeSumUsdPattern::new(client.clone(), _m(&acc, "realized_profit")), + sent: InPattern::new(client.clone(), _m(&acc, "sent_in")), + sopr: RatioValuePattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsCumulativeFlowRelSumUsdValuePattern { + pub cents: MetricPattern1, + pub cumulative: MetricPattern1, + pub flow: MetricPattern1, + pub rel_to_rcap: BpsPercentRatioPattern, + pub sum: _1m1w1y24hPattern3, + pub usd: MetricPattern1, + pub value_created: MetricPattern1, + pub value_created_sum: _1m1w1y24hPattern, + pub value_destroyed: MetricPattern1, + pub value_destroyed_sum: _1m1w1y24hPattern, +} + +impl CentsCumulativeFlowRelSumUsdValuePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_cents")), + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_cumulative")), + flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")), + rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")), + sum: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "realized_profit")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit")), + value_created: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_created")), + value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "profit_value_created")), + value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_destroyed")), + value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "profit_value_destroyed")), } } } @@ -1762,10 +1426,10 @@ impl AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 { max: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "max")), median: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "median")), min: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "min")), - pct10: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "p10")), - pct25: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "p25")), - pct75: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "p75")), - pct90: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "p90")), + pct10: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct10")), + pct25: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct25")), + pct75: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct75")), + pct90: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct90")), sum: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "sum")), } } @@ -1792,45 +1456,15 @@ impl AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern { max: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "max")), median: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "median")), min: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "min")), - pct10: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p10")), - pct25: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p25")), - pct75: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p75")), - pct90: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p90")), + pct10: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct10")), + pct25: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct25")), + pct75: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct75")), + pct90: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "pct90")), sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sum")), } } } -/// Pattern struct for repeated tree structure. -pub struct MvrvRealizedPattern { - pub mvrv: MetricPattern1, - pub realized_cap: MetricPattern1, - pub realized_cap_cents: MetricPattern1, - pub realized_loss: CumulativeHeightPattern, - pub realized_loss_sum: _24hPattern, - pub realized_price: CentsSatsUsdPattern, - pub realized_price_ratio: BpsRatioPattern, - pub realized_profit: CumulativeHeightPattern, - pub realized_profit_sum: _24hPattern, -} - -impl MvrvRealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), - realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), - realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")), - realized_loss_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_loss_24h")), - realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), - realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), - realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")), - realized_profit_sum: _24hPattern::new(client.clone(), _m(&acc, "realized_profit_24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hBtcCentsSatsUsdPattern { pub _1m: BtcCentsSatsUsdPattern, @@ -1851,38 +1485,66 @@ impl _1m1w1y24hBtcCentsSatsUsdPattern { _1w: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "1w")), _1y: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "1y")), _24h: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "24h")), - btc: MetricPattern18::new(client.clone(), _m(&acc, "btc")), + btc: MetricPattern18::new(client.clone(), acc.clone()), cents: MetricPattern18::new(client.clone(), _m(&acc, "cents")), - sats: MetricPattern18::new(client.clone(), acc.clone()), + sats: MetricPattern18::new(client.clone(), _m(&acc, "sats")), usd: MetricPattern18::new(client.clone(), _m(&acc, "usd")), } } } /// Pattern struct for repeated tree structure. -pub struct CoinblocksCoindaysSentPattern2 { - pub coinblocks_destroyed: MetricPattern1, - pub coinblocks_destroyed_cumulative: MetricPattern1, - pub coindays_destroyed: MetricPattern1, - pub coindays_destroyed_cumulative: MetricPattern1, - pub coindays_destroyed_sum: _1m1w1y24hPattern, - pub sent: MetricPattern1, - pub sent_sum: _24hPattern, - pub sent_sum_extended: _1m1w1yPattern, +pub struct CapLossMvrvNuplPriceProfitSoprPattern { + pub cap: CentsUsdPattern, + pub loss: CentsSumUsdPattern, + pub mvrv: MetricPattern1, + pub nupl: BpsRatioPattern, + pub price: CentsSatsUsdPattern, + pub price_ratio: BpsRatioPattern, + pub profit: CentsSumUsdPattern, + pub sopr: ValuePattern, } -impl CoinblocksCoindaysSentPattern2 { +impl CapLossMvrvNuplPriceProfitSoprPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - coinblocks_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinblocks_destroyed")), - coinblocks_destroyed_cumulative: MetricPattern1::new(client.clone(), _m(&acc, "coinblocks_destroyed_cumulative")), - coindays_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed")), - coindays_destroyed_cumulative: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed_cumulative")), - coindays_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - sent: MetricPattern1::new(client.clone(), _m(&acc, "sent")), - sent_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_24h")), - sent_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "sent")), + cap: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), + loss: CentsSumUsdPattern::new(client.clone(), _m(&acc, "realized_loss")), + mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), + price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")), + profit: CentsSumUsdPattern::new(client.clone(), _m(&acc, "realized_profit")), + sopr: ValuePattern::new(client.clone(), _m(&acc, "value")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern { + pub pct1: BpsPriceRatioPattern, + pub pct2: BpsPriceRatioPattern, + pub pct5: BpsPriceRatioPattern, + pub pct95: BpsPriceRatioPattern, + pub pct98: BpsPriceRatioPattern, + pub pct99: BpsPriceRatioPattern, + pub sma_1m: BpsRatioPattern, + pub sma_1w: BpsRatioPattern, +} + +impl Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + pct1: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct1")), + pct2: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct2")), + pct5: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct5")), + pct95: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct95")), + pct98: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct98")), + pct99: BpsPriceRatioPattern::new(client.clone(), _m(&acc, "pct99")), + sma_1m: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1m")), + sma_1w: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1w")), } } } @@ -1907,10 +1569,10 @@ impl AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { max: MetricPattern18::new(client.clone(), _m(&acc, "max")), median: MetricPattern18::new(client.clone(), _m(&acc, "median")), min: MetricPattern18::new(client.clone(), _m(&acc, "min")), - pct10: MetricPattern18::new(client.clone(), _m(&acc, "p10")), - pct25: MetricPattern18::new(client.clone(), _m(&acc, "p25")), - pct75: MetricPattern18::new(client.clone(), _m(&acc, "p75")), - pct90: MetricPattern18::new(client.clone(), _m(&acc, "p90")), + pct10: MetricPattern18::new(client.clone(), _m(&acc, "pct10")), + pct25: MetricPattern18::new(client.clone(), _m(&acc, "pct25")), + pct75: MetricPattern18::new(client.clone(), _m(&acc, "pct75")), + pct90: MetricPattern18::new(client.clone(), _m(&acc, "pct90")), } } } @@ -1942,99 +1604,27 @@ impl _10y2y3y4y5y6y8yPattern { } /// Pattern struct for repeated tree structure. -pub struct ActivityAddrOutputsRealizedSupplyUnrealizedPattern { - pub activity: SentPattern, - pub addr_count: MetricPattern1, - pub addr_count_delta: ChangeRatePattern, - pub outputs: UtxoPattern, - pub realized: MvrvRealizedPattern, - pub supply: DeltaHalvedTotalPattern, - pub unrealized: SupplyPattern, +pub struct _1m1w1y24hBpsPercentRatioPattern { + pub _1m: BpsPercentRatioPattern, + pub _1w: BpsPercentRatioPattern, + pub _1y: BpsPercentRatioPattern, + pub _24h: BpsPercentRatioPattern, + pub bps: MetricPattern1, + pub percent: MetricPattern1, + pub ratio: MetricPattern1, } -impl ActivityAddrOutputsRealizedSupplyUnrealizedPattern { +impl _1m1w1y24hBpsPercentRatioPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - activity: SentPattern::new(client.clone(), _m(&acc, "sent")), - addr_count: MetricPattern1::new(client.clone(), _m(&acc, "addr_count")), - addr_count_delta: ChangeRatePattern::new(client.clone(), _m(&acc, "addr_count_delta")), - outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: MvrvRealizedPattern::new(client.clone(), acc.clone()), - supply: DeltaHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: SupplyPattern::new(client.clone(), _m(&acc, "supply_in")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct ActivityOutputsRealizedRelativeSupplyUnrealizedPattern { - pub activity: CoinblocksCoindaysSentPattern, - pub outputs: UtxoPattern, - pub realized: MvrvNegNetRealizedSentSoprValuePattern, - pub relative: SupplyPattern2, - pub supply: DeltaHalvedTotalPattern, - pub unrealized: InvestedInvestorNegNetSupplyUnrealizedPattern, -} - -impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - activity: CoinblocksCoindaysSentPattern::new(client.clone(), acc.clone()), - outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: MvrvNegNetRealizedSentSoprValuePattern::new(client.clone(), acc.clone()), - relative: SupplyPattern2::new(client.clone(), _m(&acc, "supply")), - supply: DeltaHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: InvestedInvestorNegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 { - pub activity: SentPattern, - pub outputs: UtxoPattern, - pub realized: MvrvNegNetRealizedSoprValuePattern, - pub relative: SupplyPattern2, - pub supply: DeltaHalvedTotalPattern, - pub unrealized: NegNetSupplyUnrealizedPattern, -} - -impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - activity: SentPattern::new(client.clone(), _m(&acc, "sent")), - outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: MvrvNegNetRealizedSoprValuePattern::new(client.clone(), acc.clone()), - relative: SupplyPattern2::new(client.clone(), _m(&acc, "supply")), - supply: DeltaHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: NegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct NegNetSupplyUnrealizedPattern { - pub neg_unrealized_loss: MetricPattern1, - pub net_unrealized_pnl: CentsUsdPattern, - pub supply_in_loss: BtcCentsSatsUsdPattern, - pub supply_in_profit: BtcCentsSatsUsdPattern, - pub unrealized_loss: CentsUsdPattern, - pub unrealized_profit: CentsUsdPattern, -} - -impl NegNetSupplyUnrealizedPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - neg_unrealized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), - net_unrealized_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")), - supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), - unrealized_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - unrealized_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")), + _1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1m")), + _1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1w")), + _1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1y")), + _24h: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "24h")), + bps: MetricPattern1::new(client.clone(), _m(&acc, "bps")), + percent: MetricPattern1::new(client.clone(), acc.clone()), + ratio: MetricPattern1::new(client.clone(), _m(&acc, "ratio")), } } } @@ -2042,8 +1632,10 @@ impl NegNetSupplyUnrealizedPattern { /// Pattern struct for repeated tree structure. pub struct _24hChangeRatePattern { pub _24h: BpsCentsPercentRatioUsdPattern, + pub change: _1mPattern3, pub change_1w: CentsUsdPattern, pub change_1y: CentsUsdPattern, + pub rate: _1mPattern2, pub rate_1w: BpsPercentRatioPattern, pub rate_1y: BpsPercentRatioPattern, } @@ -2053,8 +1645,10 @@ impl _24hChangeRatePattern { pub fn new(client: Arc, acc: String) -> Self { Self { _24h: BpsCentsPercentRatioUsdPattern::new(client.clone(), acc.clone()), + change: _1mPattern3::new(client.clone(), _m(&acc, "change_1m")), change_1w: CentsUsdPattern::new(client.clone(), _m(&acc, "change_1w")), change_1y: CentsUsdPattern::new(client.clone(), _m(&acc, "change_1y")), + rate: _1mPattern2::new(client.clone(), _m(&acc, "rate_1m")), rate_1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rate_1w")), rate_1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rate_1y")), } @@ -2062,45 +1656,171 @@ impl _24hChangeRatePattern { } /// Pattern struct for repeated tree structure. -pub struct ActivityOutputsRealizedSupplyUnrealizedPattern { - pub activity: SentPattern, - pub outputs: UtxoPattern, - pub realized: MvrvRealizedPattern, - pub supply: DeltaHalvedTotalPattern, - pub unrealized: SupplyPattern, +pub struct ChangeCumulativeDeltaRawRelSumPattern { + pub change_1m_rel_to_mcap: BpsPercentRatioPattern, + pub change_1m_rel_to_rcap: BpsPercentRatioPattern, + pub cumulative: MetricPattern1, + pub delta: _24hChangeRatePattern, + pub raw: MetricPattern1, + pub rel_to_rcap: BpsPercentRatioPattern, + pub sum: _1m1w1y24hPattern, } -impl ActivityOutputsRealizedSupplyUnrealizedPattern { +impl ChangeCumulativeDeltaRawRelSumPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - activity: SentPattern::new(client.clone(), _m(&acc, "sent")), - outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: MvrvRealizedPattern::new(client.clone(), acc.clone()), - supply: DeltaHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), - unrealized: SupplyPattern::new(client.clone(), _m(&acc, "supply_in")), + change_1m_rel_to_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "pnl_change_1m_rel_to_market_cap")), + change_1m_rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "pnl_change_1m_rel_to_realized_cap")), + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "realized_pnl_cumulative")), + delta: _24hChangeRatePattern::new(client.clone(), _m(&acc, "pnl_delta")), + raw: MetricPattern1::new(client.clone(), _m(&acc, "realized_pnl")), + rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_pnl_rel_to_realized_cap")), + sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_pnl")), } } } /// Pattern struct for repeated tree structure. -pub struct BaseBtcCentsSatsUsdPattern { - pub base: MetricPattern1, - pub btc: MetricPattern1, - pub cents: MetricPattern1, - pub sats: MetricPattern1, - pub usd: MetricPattern1, +pub struct GrossInvestedInvestorLossNetProfitSentimentPattern { + pub gross_pnl: CentsUsdPattern, + pub invested_capital: InPattern5, + pub investor_cap: InPattern2, + pub loss: CentsNegSumSupplyUsdPattern, + pub net_pnl: CentsUsdPattern, + pub profit: CentsSumSupplyUsdPattern, + pub sentiment: GreedNetPainPattern, } -impl BaseBtcCentsSatsUsdPattern { +impl GrossInvestedInvestorLossNetProfitSentimentPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - base: MetricPattern1::new(client.clone(), _m(&acc, "blocks_mined_cumulative")), - btc: MetricPattern1::new(client.clone(), _m(&acc, "rewards_cumulative_btc")), - cents: MetricPattern1::new(client.clone(), _m(&acc, "rewards_cumulative_cents")), - sats: MetricPattern1::new(client.clone(), _m(&acc, "rewards_cumulative")), - usd: MetricPattern1::new(client.clone(), _m(&acc, "rewards_cumulative_usd")), + gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_gross_pnl")), + invested_capital: InPattern5::new(client.clone(), _m(&acc, "invested_capital_in")), + investor_cap: InPattern2::new(client.clone(), _m(&acc, "investor_cap_in")), + loss: CentsNegSumSupplyUsdPattern::new(client.clone(), acc.clone()), + net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), + profit: CentsSumSupplyUsdPattern::new(client.clone(), acc.clone()), + sentiment: GreedNetPainPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct ActivityOutputsRealizedRelativeSupplyUnrealizedPattern { + pub activity: CoindaysSentPattern, + pub outputs: UtxoPattern2, + pub realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern, + pub relative: SupplyPattern, + pub supply: DeltaHalvedTotalPattern, + pub unrealized: InvestedInvestorLossNetProfitPattern, +} + +impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + activity: CoindaysSentPattern::new(client.clone(), acc.clone()), + outputs: UtxoPattern2::new(client.clone(), _m(&acc, "utxo_count")), + realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern::new(client.clone(), acc.clone()), + relative: SupplyPattern::new(client.clone(), _m(&acc, "supply")), + supply: DeltaHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), + unrealized: InvestedInvestorLossNetProfitPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 { + pub activity: CoindaysSentPattern, + pub outputs: UtxoPattern2, + pub realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern, + pub relative: SupplyPattern, + pub supply: DeltaHalvedTotalPattern, + pub unrealized: LossNetProfitPattern2, +} + +impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + activity: CoindaysSentPattern::new(client.clone(), acc.clone()), + outputs: UtxoPattern2::new(client.clone(), _m(&acc, "utxo_count")), + realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern::new(client.clone(), acc.clone()), + relative: SupplyPattern::new(client.clone(), _m(&acc, "supply")), + supply: DeltaHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), + unrealized: LossNetProfitPattern2::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct AdjustedRatioValuePattern { + pub adjusted: RatioValuePattern2, + pub ratio: _1m1w1y24hPattern, + pub value_created: RawSumPattern, + pub value_created_sum: _1m1w1yPattern, + pub value_destroyed: RawSumPattern, + pub value_destroyed_sum: _1m1w1yPattern, +} + +impl AdjustedRatioValuePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + adjusted: RatioValuePattern2::new(client.clone(), _m(&acc, "adjusted")), + ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), + value_created: RawSumPattern::new(client.clone(), _m(&acc, "value_created")), + value_created_sum: _1m1w1yPattern::new(client.clone(), _m(&acc, "value_created")), + value_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "value_destroyed")), + value_destroyed_sum: _1m1w1yPattern::new(client.clone(), _m(&acc, "value_destroyed")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CapLowerPriceUpperPattern { + pub cap_raw: MetricPattern18, + pub lower_price_band: CentsSatsUsdPattern, + pub price: CentsSatsUsdPattern, + pub price_ratio: BpsRatioPattern, + pub price_ratio_percentiles: Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern, + pub upper_price_band: CentsSatsUsdPattern, +} + +impl CapLowerPriceUpperPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_raw")), + lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")), + price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")), + price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")), + price_ratio_percentiles: Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern::new(client.clone(), _m(&acc, "investor_price_ratio")), + upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct AddrOutputsRealizedSupplyPattern { + pub addr_count: MetricPattern1, + pub addr_count_delta: ChangeRatePattern, + pub outputs: UtxoPattern, + pub realized: CapLossMvrvNuplPriceProfitSoprPattern, + pub supply: HalvedTotalPattern, +} + +impl AddrOutputsRealizedSupplyPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + addr_count: MetricPattern1::new(client.clone(), _m(&acc, "addr_count")), + addr_count_delta: ChangeRatePattern::new(client.clone(), _m(&acc, "addr_count_delta")), + outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: CapLossMvrvNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), + supply: HalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), } } } @@ -2122,7 +1842,139 @@ impl BpsCentsPercentRatioUsdPattern { cents: MetricPattern1::new(client.clone(), _m(&acc, "change_24h_cents")), percent: MetricPattern1::new(client.clone(), _m(&acc, "rate_24h")), ratio: MetricPattern1::new(client.clone(), _m(&acc, "rate_24h_ratio")), - usd: MetricPattern1::new(client.clone(), _m(&acc, "change_24h_usd")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "change_24h")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct BtcCentsSatsSumUsdPattern2 { + pub btc: MetricPattern1, + pub cents: MetricPattern1, + pub sats: MetricPattern1, + pub sum: _1m1w1y24hPattern4, + pub usd: MetricPattern1, +} + +impl BtcCentsSatsSumUsdPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + btc: MetricPattern1::new(client.clone(), acc.clone()), + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + sats: MetricPattern1::new(client.clone(), _m(&acc, "sats")), + sum: _1m1w1y24hPattern4::new(client.clone(), acc.clone()), + usd: MetricPattern1::new(client.clone(), _m(&acc, "usd")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct BtcCentsSatsSumUsdPattern { + pub btc: MetricPattern1, + pub cents: MetricPattern1, + pub sats: MetricPattern1, + pub sum: _24hPattern3, + pub usd: MetricPattern1, +} + +impl BtcCentsSatsSumUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + btc: MetricPattern1::new(client.clone(), acc.clone()), + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + sats: MetricPattern1::new(client.clone(), _m(&acc, "sats")), + sum: _24hPattern3::new(client.clone(), _m(&acc, "24h")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "usd")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsCumulativeNegSumUsdPattern { + pub cents: MetricPattern1, + pub cumulative: MetricPattern1, + pub neg: MetricPattern1, + pub sum: _24hPattern, + pub usd: MetricPattern1, +} + +impl CentsCumulativeNegSumUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_cents")), + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_cumulative")), + neg: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), + sum: _24hPattern::new(client.clone(), _m(&acc, "realized_loss_24h")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsDeltaRawRelUsdPattern { + pub cents: MetricPattern1, + pub delta: _24hChangeRatePattern, + pub raw: MetricPattern18, + pub rel_to_own_mcap: BpsPercentRatioPattern, + pub usd: MetricPattern1, +} + +impl CentsDeltaRawRelUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")), + delta: _24hChangeRatePattern::new(client.clone(), _m(&acc, "realized_cap_delta")), + raw: MetricPattern18::new(client.clone(), _m(&acc, "cap_raw")), + rel_to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_cap_rel_to_own_market_cap")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsNegSumSupplyUsdPattern { + pub cents: MetricPattern1, + pub neg: MetricPattern1, + pub sum: _24hPattern, + pub supply: BtcCentsSatsUsdPattern, + pub usd: MetricPattern1, +} + +impl CentsNegSumSupplyUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss_cents")), + neg: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")), + sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_loss_24h")), + supply: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CoinblocksCoindaysDormancySentVelocityPattern { + pub coinblocks_destroyed: CumulativeRawPattern, + pub coindays_destroyed: CumulativeRawSumPattern, + pub dormancy: MetricPattern1, + pub sent: RawSumPattern2, + pub velocity: MetricPattern1, +} + +impl CoinblocksCoindaysDormancySentVelocityPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + coinblocks_destroyed: CumulativeRawPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")), + coindays_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), + sent: RawSumPattern2::new(client.clone(), _m(&acc, "sent")), + velocity: MetricPattern1::new(client.clone(), _m(&acc, "velocity")), } } } @@ -2149,6 +2001,72 @@ impl EmaHistogramLineSignalPattern { } } +/// Pattern struct for repeated tree structure. +pub struct InvestedInvestorLossNetProfitPattern { + pub invested_capital: InPattern2, + pub investor_cap: InPattern2, + pub loss: CentsNegSumSupplyUsdPattern, + pub net_pnl: CentsUsdPattern, + pub profit: CentsSumSupplyUsdPattern, +} + +impl InvestedInvestorLossNetProfitPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + invested_capital: InPattern2::new(client.clone(), _m(&acc, "invested_capital_in")), + investor_cap: InPattern2::new(client.clone(), _m(&acc, "investor_cap_in")), + loss: CentsNegSumSupplyUsdPattern::new(client.clone(), acc.clone()), + net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), + profit: CentsSumSupplyUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct PhsReboundThsPattern { + pub phs: MetricPattern1, + pub phs_min: MetricPattern1, + pub rebound: BpsPercentRatioPattern, + pub ths: MetricPattern1, + pub ths_min: MetricPattern1, +} + +impl PhsReboundThsPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + phs: MetricPattern1::new(client.clone(), _m(&acc, "phs")), + phs_min: MetricPattern1::new(client.clone(), _m(&acc, "phs_min")), + rebound: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rebound")), + ths: MetricPattern1::new(client.clone(), _m(&acc, "ths")), + ths_min: MetricPattern1::new(client.clone(), _m(&acc, "ths_min")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RatioValuePattern2 { + pub ratio: _1m1w1y24hPattern, + pub value_created: MetricPattern1, + pub value_created_sum: _1m1w1y24hPattern, + pub value_destroyed: MetricPattern1, + pub value_destroyed_sum: _1m1w1y24hPattern, +} + +impl RatioValuePattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")), + value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")), + value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_created")), + value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")), + value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_destroyed")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hHeightPattern { pub _1m: MetricPattern1, @@ -2171,48 +2089,6 @@ impl _1m1w1y24hHeightPattern { } } -/// Pattern struct for repeated tree structure. -pub struct _24hChangeRatePattern2 { - pub _24h: BaseBpsPercentRatioPattern, - pub change_1w: MetricPattern1, - pub change_1y: MetricPattern1, - pub rate_1w: BpsPercentRatioPattern, - pub rate_1y: BpsPercentRatioPattern, -} - -impl _24hChangeRatePattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _24h: BaseBpsPercentRatioPattern::new(client.clone(), acc.clone()), - change_1w: MetricPattern1::new(client.clone(), _m(&acc, "change_1w")), - change_1y: MetricPattern1::new(client.clone(), _m(&acc, "change_1y")), - rate_1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rate_1w")), - rate_1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rate_1y")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern6 { - pub _1m: BaseBtcCentsSatsUsdPattern, - pub _1w: BaseBtcCentsSatsUsdPattern, - pub _1y: BaseBtcCentsSatsUsdPattern, - pub _24h: BaseBtcCentsSatsUsdPattern, -} - -impl _1m1w1y24hPattern6 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: BaseBtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - _1w: BaseBtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - _1y: BaseBtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - _24h: BaseBtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hPattern2 { pub _1m: BpsPercentRatioPattern, @@ -2234,14 +2110,14 @@ impl _1m1w1y24hPattern2 { } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern5 { +pub struct _1m1w1y24hPattern7 { pub _1m: BtcCentsSatsUsdPattern, pub _1w: BtcCentsSatsUsdPattern, pub _1y: BtcCentsSatsUsdPattern, pub _24h: BtcCentsSatsUsdPattern, } -impl _1m1w1y24hPattern5 { +impl _1m1w1y24hPattern7 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2254,21 +2130,81 @@ impl _1m1w1y24hPattern5 { } /// Pattern struct for repeated tree structure. -pub struct BaseBpsPercentRatioPattern { - pub base: MetricPattern1, - pub bps: MetricPattern1, - pub percent: MetricPattern1, - pub ratio: MetricPattern1, +pub struct _1m1w1y24hPattern3 { + pub _1m: MetricPattern1, + pub _1w: MetricPattern1, + pub _1y: MetricPattern1, + pub _24h: CentsUsdPattern, } -impl BaseBpsPercentRatioPattern { +impl _1m1w1y24hPattern3 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - base: MetricPattern1::new(client.clone(), _m(&acc, "change_24h")), - bps: MetricPattern1::new(client.clone(), _m(&acc, "rate_24h_bps")), - percent: MetricPattern1::new(client.clone(), _m(&acc, "rate_24h")), - ratio: MetricPattern1::new(client.clone(), _m(&acc, "rate_24h_ratio")), + _1m: MetricPattern1::new(client.clone(), _m(&acc, "1m")), + _1w: MetricPattern1::new(client.clone(), _m(&acc, "1w")), + _1y: MetricPattern1::new(client.clone(), _m(&acc, "1y")), + _24h: CentsUsdPattern::new(client.clone(), _m(&acc, "24h")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1m1w1y2wPattern { + pub _1m: CentsSatsUsdPattern, + pub _1w: CentsSatsUsdPattern, + pub _1y: CentsSatsUsdPattern, + pub _2w: CentsSatsUsdPattern, +} + +impl _1m1w1y2wPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "1m")), + _1w: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "1w")), + _1y: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "1y")), + _2w: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "2w")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1m1w1y24hPattern4 { + pub _1m: MetricPattern1, + pub _1w: MetricPattern1, + pub _1y: MetricPattern1, + pub _24h: BtcCentsSatsUsdPattern, +} + +impl _1m1w1y24hPattern4 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: MetricPattern1::new(client.clone(), _m(&acc, "1m")), + _1w: MetricPattern1::new(client.clone(), _m(&acc, "1w")), + _1y: MetricPattern1::new(client.clone(), _m(&acc, "1y")), + _24h: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "24h")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1y2y4yAllPattern { + pub _1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, + pub _2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, + pub _4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, + pub all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, +} + +impl _1y2y4yAllPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), + _2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), + _4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), + all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), } } } @@ -2293,6 +2229,26 @@ impl BothReactivatedReceivingSendingPattern { } } +/// Pattern struct for repeated tree structure. +pub struct BpsPercentilesRatioStdPattern { + pub bps: MetricPattern1, + pub percentiles: Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern, + pub ratio: MetricPattern1, + pub std_dev: _1y2y4yAllPattern, +} + +impl BpsPercentilesRatioStdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + bps: MetricPattern1::new(client.clone(), _m(&acc, "bps")), + percentiles: Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern::new(client.clone(), acc.clone()), + ratio: MetricPattern1::new(client.clone(), acc.clone()), + std_dev: _1y2y4yAllPattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct BtcCentsSatsUsdPattern { pub btc: MetricPattern1, @@ -2305,30 +2261,70 @@ impl BtcCentsSatsUsdPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - btc: MetricPattern1::new(client.clone(), _m(&acc, "btc")), + btc: MetricPattern1::new(client.clone(), acc.clone()), cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), - sats: MetricPattern1::new(client.clone(), acc.clone()), + sats: MetricPattern1::new(client.clone(), _m(&acc, "sats")), usd: MetricPattern1::new(client.clone(), _m(&acc, "usd")), } } } /// Pattern struct for repeated tree structure. -pub struct CoinblocksCoindaysSentPattern { - pub coinblocks_destroyed: MetricPattern1, - pub coindays_destroyed: MetricPattern1, - pub sent: MetricPattern1, - pub sent_sum: _24hPattern, +pub struct CentsCumulativeSumUsdPattern { + pub cents: MetricPattern1, + pub cumulative: MetricPattern1, + pub sum: _24hPattern, + pub usd: MetricPattern1, } -impl CoinblocksCoindaysSentPattern { +impl CentsCumulativeSumUsdPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - coinblocks_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinblocks_destroyed")), - coindays_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed")), - sent: MetricPattern1::new(client.clone(), _m(&acc, "sent")), - sent_sum: _24hPattern::new(client.clone(), _m(&acc, "sent_24h")), + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), + usd: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsSellSumUsdPattern { + pub cents: MetricPattern1, + pub sell_side_risk_ratio: _1m1w1y24hPattern2, + pub sum: _1m1w1y24hPattern, + pub usd: MetricPattern1, +} + +impl CentsSellSumUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_gross_pnl_cents")), + sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio")), + sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "gross_pnl_sum")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "realized_gross_pnl")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsSumSupplyUsdPattern { + pub cents: MetricPattern1, + pub sum: _24hPattern, + pub supply: BtcCentsSatsUsdPattern, + pub usd: MetricPattern1, +} + +impl CentsSumSupplyUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_profit_cents")), + sum: _24hPattern::new(client.clone(), _m(&acc, "unrealized_profit_24h")), + supply: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_profit")), } } } @@ -2354,21 +2350,21 @@ impl InvestedMaxMinPercentilesPattern { } /// Pattern struct for repeated tree structure. -pub struct RatioPattern2 { - pub ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, - pub ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, - pub ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, - pub ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, +pub struct OutputsRealizedSupplyUnrealizedPattern { + pub outputs: UtxoPattern, + pub realized: CapLossMvrvNuplPriceProfitSoprPattern, + pub supply: HalvedTotalPattern, + pub unrealized: LossProfitPattern2, } -impl RatioPattern2 { +impl OutputsRealizedSupplyUnrealizedPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), - ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), - ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), - ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()), + 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()), } } } @@ -2397,7 +2393,7 @@ impl _1m1w1y24hPattern { pub struct BaseCumulativeSumPattern { pub base: BtcCentsSatsUsdPattern, pub cumulative: BtcCentsSatsUsdPattern, - pub sum: _1m1w1y24hPattern5, + pub sum: _1m1w1y24hPattern7, } impl BaseCumulativeSumPattern { @@ -2406,7 +2402,25 @@ impl BaseCumulativeSumPattern { Self { base: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), cumulative: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "cumulative")), - sum: _1m1w1y24hPattern5::new(client.clone(), _m(&acc, "sum")), + sum: _1m1w1y24hPattern7::new(client.clone(), _m(&acc, "sum")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct BlocksDominanceRewardsPattern { + pub blocks_mined: CumulativeHeightSumPattern, + pub dominance: _1m1w1y24hBpsPercentRatioPattern, + pub rewards: BaseCumulativeSumPattern, +} + +impl BlocksDominanceRewardsPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + blocks_mined: CumulativeHeightSumPattern::new(client.clone(), _m(&acc, "blocks_mined")), + dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance")), + rewards: BaseCumulativeSumPattern::new(client.clone(), _m(&acc, "rewards")), } } } @@ -2440,9 +2454,9 @@ impl BpsPriceRatioPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - bps: MetricPattern1::new(client.clone(), _m(&acc, "ratio_bps")), + bps: MetricPattern1::new(client.clone(), _m(&acc, "bps")), price: CentsSatsUsdPattern::new(client.clone(), acc.clone()), - ratio: MetricPattern1::new(client.clone(), _m(&acc, "ratio")), + ratio: MetricPattern1::new(client.clone(), acc.clone()), } } } @@ -2465,6 +2479,42 @@ impl CentsSatsUsdPattern2 { } } +/// Pattern struct for repeated tree structure. +pub struct CentsDeltaUsdPattern { + pub cents: MetricPattern1, + pub delta: ChangeRatePattern3, + pub usd: MetricPattern1, +} + +impl CentsDeltaUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + delta: ChangeRatePattern3::new(client.clone(), _m(&acc, "delta")), + usd: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsRawUsdPattern { + pub cents: MetricPattern1, + pub raw: MetricPattern18, + pub usd: MetricPattern1, +} + +impl CentsRawUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + raw: MetricPattern18::new(client.clone(), _m(&acc, "raw")), + usd: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct CentsSatsUsdPattern { pub cents: MetricPattern1, @@ -2483,9 +2533,63 @@ impl CentsSatsUsdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CentsSumUsdPattern { + pub cents: MetricPattern1, + pub sum: _24hPattern, + pub usd: MetricPattern1, +} + +impl CentsSumUsdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), + usd: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CumulativeHeightRelPattern { + pub cumulative: MetricPattern1, + pub height: MetricPattern18, + pub rel_to_rcap: BpsPercentRatioPattern, +} + +impl CumulativeHeightRelPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + height: MetricPattern18::new(client.clone(), acc.clone()), + rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_realized_cap")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CumulativeRawSumPattern { + pub cumulative: MetricPattern1, + pub raw: MetricPattern1, + pub sum: _1m1w1y24hPattern, +} + +impl CumulativeRawSumPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + raw: MetricPattern1::new(client.clone(), acc.clone()), + sum: _1m1w1y24hPattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct DeltaHalvedTotalPattern { - pub delta: ChangeRatePattern, + pub delta: ChangeRatePattern, pub halved: BtcCentsSatsUsdPattern, pub total: BtcCentsSatsUsdPattern, } @@ -2502,19 +2606,163 @@ impl DeltaHalvedTotalPattern { } /// Pattern struct for repeated tree structure. -pub struct SupplyPattern2 { - pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern, - pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern, - pub supply_rel_to_circulating_supply: BpsPercentRatioPattern, +pub struct DeltaHalvedTotalPattern2 { + pub delta: ChangeRatePattern2, + pub halved: BtcCentsSatsUsdPattern, + pub total: BtcCentsSatsUsdPattern, } -impl SupplyPattern2 { +impl DeltaHalvedTotalPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_circulating_supply")), - supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_circulating_supply")), - supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), + delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), + halved: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "halved")), + total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct GreedNetPainPattern { + pub greed_index: CentsUsdPattern, + pub net: CentsUsdPattern, + pub pain_index: CentsUsdPattern, +} + +impl GreedNetPainPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + greed_index: CentsUsdPattern::new(client.clone(), _m(&acc, "greed_index")), + net: CentsUsdPattern::new(client.clone(), _m(&acc, "net_sentiment")), + pain_index: CentsUsdPattern::new(client.clone(), _m(&acc, "pain_index")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct InRelPattern { + pub in_loss: RelPattern, + pub in_profit: RelPattern, + pub rel_to_circulating_supply: BpsPercentRatioPattern, +} + +impl InRelPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + in_loss: RelPattern::new(client.clone(), _m(&acc, "in_loss_rel_to_circulating_supply")), + in_profit: RelPattern::new(client.clone(), _m(&acc, "in_profit_rel_to_circulating_supply")), + rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct InRelPattern2 { + pub in_loss: RelPattern5, + pub in_profit: RelPattern5, + pub rel_to_circulating_supply: BpsPercentRatioPattern, +} + +impl InRelPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + in_loss: RelPattern5::new(client.clone(), _m(&acc, "in_loss_rel_to")), + in_profit: RelPattern5::new(client.clone(), _m(&acc, "in_profit_rel_to")), + rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rel_to_circulating_supply")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct LossNetProfitPattern2 { + pub loss: CentsNegSumSupplyUsdPattern, + pub net_pnl: CentsUsdPattern, + pub profit: CentsSumSupplyUsdPattern, +} + +impl LossNetProfitPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + loss: CentsNegSumSupplyUsdPattern::new(client.clone(), acc.clone()), + net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), + profit: CentsSumSupplyUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct LossNetProfitPattern3 { + pub loss: RelPattern6, + pub net_pnl: RelPattern7, + pub profit: RelPattern6, +} + +impl LossNetProfitPattern3 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + loss: RelPattern6::new(client.clone(), _m(&acc, "unrealized_loss_rel_to")), + net_pnl: RelPattern7::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own")), + profit: RelPattern6::new(client.clone(), _m(&acc, "unrealized_profit_rel_to")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct OutputsRealizedSupplyPattern { + pub outputs: UtxoPattern, + pub realized: CapLossMvrvNuplPriceProfitSoprPattern, + pub supply: HalvedTotalPattern, +} + +impl OutputsRealizedSupplyPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: CapLossMvrvNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), + supply: HalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RatioValuePattern { + pub ratio: _24hPattern2, + pub value_created: RawSumPattern, + pub value_destroyed: RawSumPattern, +} + +impl RatioValuePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + ratio: _24hPattern2::new(client.clone(), _m(&acc, "sopr_24h")), + value_created: RawSumPattern::new(client.clone(), _m(&acc, "value_created")), + value_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "value_destroyed")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RelPattern6 { + pub rel_to_market_cap: BpsPercentRatioPattern, + pub rel_to_own_gross_pnl: BpsPercentRatioPattern, + pub rel_to_own_market_cap: BpsPercentRatioPattern, +} + +impl RelPattern6 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "market_cap")), + rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "own_gross_pnl")), + rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "own_market_cap")), } } } @@ -2591,7 +2839,7 @@ impl BaseCumulativePattern { /// Pattern struct for repeated tree structure. pub struct BlocksDominancePattern { - pub blocks_mined: CumulativeHeightPattern, + pub blocks_mined: CumulativeHeightPattern, pub dominance: BpsPercentRatioPattern, } @@ -2632,7 +2880,7 @@ impl CentsUsdPattern { pub fn new(client: Arc, acc: String) -> Self { Self { cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), - usd: MetricPattern1::new(client.clone(), _m(&acc, "usd")), + usd: MetricPattern1::new(client.clone(), acc.clone()), } } } @@ -2653,18 +2901,98 @@ impl ChangeRatePattern2 { } } +/// Pattern struct for repeated tree structure. +pub struct ChangeRatePattern { + pub change: _1mPattern, + pub rate: _1mPattern2, +} + +impl ChangeRatePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + change: _1mPattern::new(client.clone(), _m(&acc, "change_1m")), + rate: _1mPattern2::new(client.clone(), _m(&acc, "rate_1m")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct ChangeRatePattern3 { - pub change_1m: CentsUsdPattern, - pub rate_1m: BpsPercentRatioPattern, + pub change: _1mPattern3, + pub rate: _1mPattern2, } impl ChangeRatePattern3 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - change_1m: CentsUsdPattern::new(client.clone(), _m(&acc, "change_1m")), - rate_1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rate_1m")), + change: _1mPattern3::new(client.clone(), _m(&acc, "change_1m")), + rate: _1mPattern2::new(client.clone(), _m(&acc, "rate_1m")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CoindaysSentPattern { + pub coindays_destroyed: RawSumPattern, + pub sent: RawSumPattern, +} + +impl CoindaysSentPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + coindays_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + sent: RawSumPattern::new(client.clone(), _m(&acc, "sent")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CumulativeRawPattern { + pub cumulative: MetricPattern1, + pub raw: MetricPattern1, +} + +impl CumulativeRawPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + raw: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CumulativeHeightPattern { + pub cumulative: MetricPattern1, + pub height: MetricPattern18, +} + +impl CumulativeHeightPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + height: MetricPattern18::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct HalvedTotalPattern { + pub halved: BtcCentsSatsUsdPattern, + pub total: BtcCentsSatsUsdPattern, +} + +impl HalvedTotalPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + halved: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "halved")), + total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), } } } @@ -2685,6 +3013,118 @@ impl HeightSumPattern { } } +/// Pattern struct for repeated tree structure. +pub struct InPattern { + pub in_loss: BtcCentsSatsSumUsdPattern, + pub in_profit: BtcCentsSatsSumUsdPattern, +} + +impl InPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + in_loss: BtcCentsSatsSumUsdPattern::new(client.clone(), _m(&acc, "loss")), + in_profit: BtcCentsSatsSumUsdPattern::new(client.clone(), _m(&acc, "profit")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct InPattern3 { + pub in_loss: BtcCentsSatsSumUsdPattern2, + pub in_profit: BtcCentsSatsSumUsdPattern2, +} + +impl InPattern3 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + in_loss: BtcCentsSatsSumUsdPattern2::new(client.clone(), _m(&acc, "loss")), + in_profit: BtcCentsSatsSumUsdPattern2::new(client.clone(), _m(&acc, "profit")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct InPattern5 { + pub in_loss: CentsRawUsdPattern, + pub in_profit: CentsRawUsdPattern, +} + +impl InPattern5 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + in_loss: CentsRawUsdPattern::new(client.clone(), _m(&acc, "loss")), + in_profit: CentsRawUsdPattern::new(client.clone(), _m(&acc, "profit")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct InPattern2 { + pub in_loss: RawPattern, + pub in_profit: RawPattern, +} + +impl InPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + in_loss: RawPattern::new(client.clone(), _m(&acc, "loss_raw")), + in_profit: RawPattern::new(client.clone(), _m(&acc, "profit_raw")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct LossProfitPattern2 { + pub loss: CentsSumSupplyUsdPattern, + pub profit: CentsSumSupplyUsdPattern, +} + +impl LossProfitPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + loss: CentsSumSupplyUsdPattern::new(client.clone(), acc.clone()), + profit: CentsSumSupplyUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct PriceValuePattern { + pub price: CentsSatsUsdPattern, + pub value: MetricPattern1, +} + +impl PriceValuePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), acc.clone()), + value: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RawSumPattern2 { + pub raw: MetricPattern1, + pub sum: _1m1w1y24hPattern, +} + +impl RawSumPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + raw: MetricPattern1::new(client.clone(), acc.clone()), + sum: _1m1w1y24hPattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct RealizedSupplyPattern { pub realized_cap: MetricPattern1, @@ -2701,6 +3141,54 @@ impl RealizedSupplyPattern { } } +/// Pattern struct for repeated tree structure. +pub struct RelPattern5 { + pub rel_to_circulating_supply: BpsPercentRatioPattern, + pub rel_to_own_supply: BpsPercentRatioPattern, +} + +impl RelPattern5 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "circulating_supply")), + rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "own_supply")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RelPattern3 { + pub rel_to_market_cap: BpsPercentRatioPattern, + pub rel_to_own_gross_pnl: BpsPercentRatioPattern, +} + +impl RelPattern3 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "market_cap")), + rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "own_gross_pnl")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RelPattern7 { + pub rel_to_own_gross_pnl: BpsPercentRatioPattern, + pub rel_to_own_market_cap: BpsPercentRatioPattern, +} + +impl RelPattern7 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "gross_pnl")), + rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "market_cap")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct SdSmaPattern { pub sd: MetricPattern1, @@ -2718,44 +3206,28 @@ impl SdSmaPattern { } /// Pattern struct for repeated tree structure. -pub struct SentPattern { - pub sent: MetricPattern1, - pub sent_sum: _24hPattern, +pub struct SupplyUnrealizedPattern2 { + pub supply: InRelPattern2, + pub unrealized: LossNetProfitPattern3, } -impl SentPattern { +impl SupplyUnrealizedPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - sent: MetricPattern1::new(client.clone(), acc.clone()), - sent_sum: _24hPattern::new(client.clone(), _m(&acc, "24h")), + supply: InRelPattern2::new(client.clone(), _m(&acc, "supply")), + unrealized: LossNetProfitPattern3::new(client.clone(), acc.clone()), } } } /// Pattern struct for repeated tree structure. -pub struct SupplyPattern { - pub supply_in_loss: BtcCentsSatsUsdPattern, - pub supply_in_profit: BtcCentsSatsUsdPattern, -} - -impl SupplyPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "loss")), - supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "profit")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct UtxoPattern { +pub struct UtxoPattern2 { pub utxo_count: MetricPattern1, - pub utxo_count_delta: ChangeRatePattern, + pub utxo_count_delta: ChangeRatePattern, } -impl UtxoPattern { +impl UtxoPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2766,43 +3238,185 @@ impl UtxoPattern { } /// Pattern struct for repeated tree structure. -pub struct ChangeRatePattern { - pub change_1m: MetricPattern1, - pub rate_1m: BpsPercentRatioPattern, +pub struct UtxoPattern3 { + pub utxo_count: MetricPattern1, + pub utxo_count_delta: ChangeRatePattern2, } -impl ChangeRatePattern { +impl UtxoPattern3 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - change_1m: MetricPattern1::new(client.clone(), _m(&acc, "change_1m")), - rate_1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rate_1m")), + utxo_count: MetricPattern1::new(client.clone(), acc.clone()), + utxo_count_delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), } } } /// Pattern struct for repeated tree structure. -pub struct CumulativeHeightPattern { - pub cumulative: MetricPattern1, - pub height: MetricPattern18, +pub struct ValuePattern { + pub value_created: RawSumPattern, + pub value_destroyed: RawSumPattern, } -impl CumulativeHeightPattern { +impl ValuePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - height: MetricPattern18::new(client.clone(), acc.clone()), + value_created: RawSumPattern::new(client.clone(), _m(&acc, "created")), + value_destroyed: RawSumPattern::new(client.clone(), _m(&acc, "destroyed")), } } } /// Pattern struct for repeated tree structure. -pub struct _24hPattern { +pub struct RawSumPattern { + pub raw: MetricPattern1, + pub sum: _24hPattern2, +} + +impl RawSumPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + raw: MetricPattern1::new(client.clone(), acc.clone()), + sum: _24hPattern2::new(client.clone(), _m(&acc, "24h")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1mPattern2 { + pub _1m: BpsPercentRatioPattern, +} + +impl _1mPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: BpsPercentRatioPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1mPattern3 { + pub _1m: CentsUsdPattern, +} + +impl _1mPattern3 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: CentsUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _24hPattern3 { + pub _24h: BtcCentsSatsUsdPattern, +} + +impl _24hPattern3 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _24h: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _24hPattern { + pub _24h: CentsUsdPattern, +} + +impl _24hPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _24h: CentsUsdPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RelPattern { + pub rel_to_circulating_supply: BpsPercentRatioPattern, +} + +impl RelPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RelPattern2 { + pub rel_to_own_supply: BpsPercentRatioPattern, +} + +impl RelPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct SupplyPattern { + pub supply: InRelPattern, +} + +impl SupplyPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + supply: InRelPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct UtxoPattern { + pub utxo_count: MetricPattern1, +} + +impl UtxoPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + utxo_count: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1mPattern { + pub _1m: MetricPattern1, +} + +impl _1mPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _24hPattern2 { pub _24h: MetricPattern1, } -impl _24hPattern { +impl _24hPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2811,6 +3425,20 @@ impl _24hPattern { } } +/// Pattern struct for repeated tree structure. +pub struct RawPattern { + pub raw: MetricPattern18, +} + +impl RawPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + raw: MetricPattern18::new(client.clone(), acc.clone()), + } + } +} + // Metrics tree /// Metrics tree node. @@ -2861,13 +3489,13 @@ pub struct MetricsTree_Blocks { pub blockhash: MetricPattern18, pub difficulty: MetricsTree_Blocks_Difficulty, pub time: MetricsTree_Blocks_Time, - pub total_size: MetricPattern18, + pub size: MetricsTree_Blocks_Size, pub weight: MetricsTree_Blocks_Weight, pub count: MetricsTree_Blocks_Count, + pub lookback: MetricsTree_Blocks_Lookback, pub interval: _1m1w1y24hHeightPattern, pub halving: MetricsTree_Blocks_Halving, pub vbytes: AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern, - pub size: MetricsTree_Blocks_Size, pub fullness: MetricsTree_Blocks_Fullness, } @@ -2877,13 +3505,13 @@ impl MetricsTree_Blocks { blockhash: MetricPattern18::new(client.clone(), "blockhash".to_string()), difficulty: MetricsTree_Blocks_Difficulty::new(client.clone(), format!("{base_path}_difficulty")), time: MetricsTree_Blocks_Time::new(client.clone(), format!("{base_path}_time")), - total_size: MetricPattern18::new(client.clone(), "total_size".to_string()), + size: MetricsTree_Blocks_Size::new(client.clone(), format!("{base_path}_size")), weight: MetricsTree_Blocks_Weight::new(client.clone(), format!("{base_path}_weight")), count: MetricsTree_Blocks_Count::new(client.clone(), format!("{base_path}_count")), + lookback: MetricsTree_Blocks_Lookback::new(client.clone(), format!("{base_path}_lookback")), interval: _1m1w1y24hHeightPattern::new(client.clone(), "block_interval".to_string()), halving: MetricsTree_Blocks_Halving::new(client.clone(), format!("{base_path}_halving")), vbytes: AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), "block_vbytes".to_string()), - size: MetricsTree_Blocks_Size::new(client.clone(), format!("{base_path}_size")), fullness: MetricsTree_Blocks_Fullness::new(client.clone(), format!("{base_path}_fullness")), } } @@ -2929,6 +3557,39 @@ impl MetricsTree_Blocks_Time { } } +/// Metrics tree node. +pub struct MetricsTree_Blocks_Size { + pub total_size: MetricPattern18, + pub cumulative: MetricPattern1, + pub sum: _1m1w1y24hPattern, + pub average: _1m1w1y24hPattern, + pub min: _1m1w1y24hPattern, + pub max: _1m1w1y24hPattern, + pub pct10: _1m1w1y24hPattern, + pub pct25: _1m1w1y24hPattern, + pub median: _1m1w1y24hPattern, + pub pct75: _1m1w1y24hPattern, + pub pct90: _1m1w1y24hPattern, +} + +impl MetricsTree_Blocks_Size { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + total_size: MetricPattern18::new(client.clone(), "total_size".to_string()), + cumulative: MetricPattern1::new(client.clone(), "block_size_cumulative".to_string()), + sum: _1m1w1y24hPattern::new(client.clone(), "block_size_sum".to_string()), + average: _1m1w1y24hPattern::new(client.clone(), "block_size_average".to_string()), + min: _1m1w1y24hPattern::new(client.clone(), "block_size_min".to_string()), + max: _1m1w1y24hPattern::new(client.clone(), "block_size_max".to_string()), + pct10: _1m1w1y24hPattern::new(client.clone(), "block_size_pct10".to_string()), + pct25: _1m1w1y24hPattern::new(client.clone(), "block_size_pct25".to_string()), + median: _1m1w1y24hPattern::new(client.clone(), "block_size_median".to_string()), + pct75: _1m1w1y24hPattern::new(client.clone(), "block_size_pct75".to_string()), + pct90: _1m1w1y24hPattern::new(client.clone(), "block_size_pct90".to_string()), + } + } +} + /// Metrics tree node. pub struct MetricsTree_Blocks_Weight { pub base: MetricPattern18, @@ -2953,11 +3614,11 @@ impl MetricsTree_Blocks_Weight { average: _1m1w1y24hPattern::new(client.clone(), "block_weight_average".to_string()), min: _1m1w1y24hPattern::new(client.clone(), "block_weight_min".to_string()), max: _1m1w1y24hPattern::new(client.clone(), "block_weight_max".to_string()), - pct10: _1m1w1y24hPattern::new(client.clone(), "block_weight_p10".to_string()), - pct25: _1m1w1y24hPattern::new(client.clone(), "block_weight_p25".to_string()), + pct10: _1m1w1y24hPattern::new(client.clone(), "block_weight_pct10".to_string()), + pct25: _1m1w1y24hPattern::new(client.clone(), "block_weight_pct25".to_string()), median: _1m1w1y24hPattern::new(client.clone(), "block_weight_median".to_string()), - pct75: _1m1w1y24hPattern::new(client.clone(), "block_weight_p75".to_string()), - pct90: _1m1w1y24hPattern::new(client.clone(), "block_weight_p90".to_string()), + pct75: _1m1w1y24hPattern::new(client.clone(), "block_weight_pct75".to_string()), + pct90: _1m1w1y24hPattern::new(client.clone(), "block_weight_pct90".to_string()), } } } @@ -2966,7 +3627,19 @@ impl MetricsTree_Blocks_Weight { pub struct MetricsTree_Blocks_Count { pub block_count_target: MetricPattern1, pub block_count: CumulativeHeightSumPattern, - pub block_count_sum: _1m1w1y24hPattern, +} + +impl MetricsTree_Blocks_Count { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + block_count_target: MetricPattern1::new(client.clone(), "block_count_target".to_string()), + block_count: CumulativeHeightSumPattern::new(client.clone(), "block_count".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Blocks_Lookback { pub height_1h_ago: MetricPattern18, pub height_24h_ago: MetricPattern18, pub height_3d_ago: MetricPattern18, @@ -3012,12 +3685,9 @@ pub struct MetricsTree_Blocks_Count { pub height_26y_ago: MetricPattern18, } -impl MetricsTree_Blocks_Count { +impl MetricsTree_Blocks_Lookback { pub fn new(client: Arc, base_path: String) -> Self { Self { - block_count_target: MetricPattern1::new(client.clone(), "block_count_target".to_string()), - block_count: CumulativeHeightSumPattern::new(client.clone(), "block_count".to_string()), - block_count_sum: _1m1w1y24hPattern::new(client.clone(), "block_count_sum".to_string()), height_1h_ago: MetricPattern18::new(client.clone(), "height_1h_ago".to_string()), height_24h_ago: MetricPattern18::new(client.clone(), "height_24h_ago".to_string()), height_3d_ago: MetricPattern18::new(client.clone(), "height_3d_ago".to_string()), @@ -3082,37 +3752,6 @@ impl MetricsTree_Blocks_Halving { } } -/// Metrics tree node. -pub struct MetricsTree_Blocks_Size { - pub cumulative: MetricPattern1, - pub sum: _1m1w1y24hPattern, - pub average: _1m1w1y24hPattern, - pub min: _1m1w1y24hPattern, - pub max: _1m1w1y24hPattern, - pub pct10: _1m1w1y24hPattern, - pub pct25: _1m1w1y24hPattern, - pub median: _1m1w1y24hPattern, - pub pct75: _1m1w1y24hPattern, - pub pct90: _1m1w1y24hPattern, -} - -impl MetricsTree_Blocks_Size { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - cumulative: MetricPattern1::new(client.clone(), "block_size_cumulative".to_string()), - sum: _1m1w1y24hPattern::new(client.clone(), "block_size_sum".to_string()), - average: _1m1w1y24hPattern::new(client.clone(), "block_size_average".to_string()), - min: _1m1w1y24hPattern::new(client.clone(), "block_size_min".to_string()), - max: _1m1w1y24hPattern::new(client.clone(), "block_size_max".to_string()), - pct10: _1m1w1y24hPattern::new(client.clone(), "block_size_p10".to_string()), - pct25: _1m1w1y24hPattern::new(client.clone(), "block_size_p25".to_string()), - median: _1m1w1y24hPattern::new(client.clone(), "block_size_median".to_string()), - pct75: _1m1w1y24hPattern::new(client.clone(), "block_size_p75".to_string()), - pct90: _1m1w1y24hPattern::new(client.clone(), "block_size_p90".to_string()), - } - } -} - /// Metrics tree node. pub struct MetricsTree_Blocks_Fullness { pub bps: _1m1w1y24hHeightPattern, @@ -3515,10 +4154,8 @@ pub struct MetricsTree_Mining_Rewards { pub subsidy: BaseCumulativePattern, pub fees: MetricsTree_Mining_Rewards_Fees, pub unclaimed_rewards: BaseCumulativeSumPattern, - pub fee_dominance: BpsPercentRatioPattern, - pub fee_dominance_rolling: _1m1w1y24hPattern2, - pub subsidy_dominance: BpsPercentRatioPattern, - pub subsidy_dominance_rolling: _1m1w1y24hPattern2, + pub fee_dominance: _1m1w1y24hBpsPercentRatioPattern, + pub subsidy_dominance: _1m1w1y24hBpsPercentRatioPattern, pub subsidy_sma_1y: CentsUsdPattern, } @@ -3529,10 +4166,8 @@ impl MetricsTree_Mining_Rewards { subsidy: BaseCumulativePattern::new(client.clone(), "subsidy".to_string()), fees: MetricsTree_Mining_Rewards_Fees::new(client.clone(), format!("{base_path}_fees")), unclaimed_rewards: BaseCumulativeSumPattern::new(client.clone(), "unclaimed_rewards".to_string()), - fee_dominance: BpsPercentRatioPattern::new(client.clone(), "fee_dominance".to_string()), - fee_dominance_rolling: _1m1w1y24hPattern2::new(client.clone(), "fee_dominance".to_string()), - subsidy_dominance: BpsPercentRatioPattern::new(client.clone(), "subsidy_dominance".to_string()), - subsidy_dominance_rolling: _1m1w1y24hPattern2::new(client.clone(), "subsidy_dominance".to_string()), + fee_dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "fee_dominance".to_string()), + subsidy_dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "subsidy_dominance".to_string()), subsidy_sma_1y: CentsUsdPattern::new(client.clone(), "subsidy_sma_1y".to_string()), } } @@ -3564,44 +4199,41 @@ impl MetricsTree_Mining_Rewards_Fees { /// Metrics tree node. pub struct MetricsTree_Mining_Hashrate { pub hash_rate: MetricPattern1, - pub hash_rate_sma_1w: MetricPattern1, - pub hash_rate_sma_1m: MetricPattern1, - pub hash_rate_sma_2m: MetricPattern1, - pub hash_rate_sma_1y: MetricPattern1, + pub hash_rate_sma: MetricsTree_Mining_Hashrate_HashRateSma, pub hash_rate_ath: MetricPattern1, pub hash_rate_drawdown: BpsPercentRatioPattern, - pub hash_price_ths: MetricPattern1, - pub hash_price_ths_min: MetricPattern1, - pub hash_price_phs: MetricPattern1, - pub hash_price_phs_min: MetricPattern1, - pub hash_price_rebound: BpsPercentRatioPattern, - pub hash_value_ths: MetricPattern1, - pub hash_value_ths_min: MetricPattern1, - pub hash_value_phs: MetricPattern1, - pub hash_value_phs_min: MetricPattern1, - pub hash_value_rebound: BpsPercentRatioPattern, + pub hash_price: PhsReboundThsPattern, + pub hash_value: PhsReboundThsPattern, } impl MetricsTree_Mining_Hashrate { pub fn new(client: Arc, base_path: String) -> Self { Self { hash_rate: MetricPattern1::new(client.clone(), "hash_rate".to_string()), - hash_rate_sma_1w: MetricPattern1::new(client.clone(), "hash_rate_sma_1w".to_string()), - hash_rate_sma_1m: MetricPattern1::new(client.clone(), "hash_rate_sma_1m".to_string()), - hash_rate_sma_2m: MetricPattern1::new(client.clone(), "hash_rate_sma_2m".to_string()), - hash_rate_sma_1y: MetricPattern1::new(client.clone(), "hash_rate_sma_1y".to_string()), + hash_rate_sma: MetricsTree_Mining_Hashrate_HashRateSma::new(client.clone(), format!("{base_path}_hash_rate_sma")), hash_rate_ath: MetricPattern1::new(client.clone(), "hash_rate_ath".to_string()), hash_rate_drawdown: BpsPercentRatioPattern::new(client.clone(), "hash_rate_drawdown".to_string()), - hash_price_ths: MetricPattern1::new(client.clone(), "hash_price_ths".to_string()), - hash_price_ths_min: MetricPattern1::new(client.clone(), "hash_price_ths_min".to_string()), - hash_price_phs: MetricPattern1::new(client.clone(), "hash_price_phs".to_string()), - hash_price_phs_min: MetricPattern1::new(client.clone(), "hash_price_phs_min".to_string()), - hash_price_rebound: BpsPercentRatioPattern::new(client.clone(), "hash_price_rebound".to_string()), - hash_value_ths: MetricPattern1::new(client.clone(), "hash_value_ths".to_string()), - hash_value_ths_min: MetricPattern1::new(client.clone(), "hash_value_ths_min".to_string()), - hash_value_phs: MetricPattern1::new(client.clone(), "hash_value_phs".to_string()), - hash_value_phs_min: MetricPattern1::new(client.clone(), "hash_value_phs_min".to_string()), - hash_value_rebound: BpsPercentRatioPattern::new(client.clone(), "hash_value_rebound".to_string()), + hash_price: PhsReboundThsPattern::new(client.clone(), "hash_price".to_string()), + hash_value: PhsReboundThsPattern::new(client.clone(), "hash_value".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Mining_Hashrate_HashRateSma { + pub _1w: MetricPattern1, + pub _1m: MetricPattern1, + pub _2m: MetricPattern1, + pub _1y: MetricPattern1, +} + +impl MetricsTree_Mining_Hashrate_HashRateSma { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + _1w: MetricPattern1::new(client.clone(), "hash_rate_sma_1w".to_string()), + _1m: MetricPattern1::new(client.clone(), "hash_rate_sma_1m".to_string()), + _2m: MetricPattern1::new(client.clone(), "hash_rate_sma_2m".to_string()), + _1y: MetricPattern1::new(client.clone(), "hash_rate_sma_1y".to_string()), } } } @@ -3684,18 +4316,18 @@ impl MetricsTree_Cointime_Supply { /// Metrics tree node. pub struct MetricsTree_Cointime_Value { - pub cointime_value_destroyed: CumulativeHeightSumPattern, - pub cointime_value_created: CumulativeHeightSumPattern, - pub cointime_value_stored: CumulativeHeightSumPattern, + pub value_destroyed: CumulativeHeightSumPattern, + pub value_created: CumulativeHeightSumPattern, + pub value_stored: CumulativeHeightSumPattern, pub vocdd: CumulativeHeightSumPattern, } impl MetricsTree_Cointime_Value { pub fn new(client: Arc, base_path: String) -> Self { Self { - cointime_value_destroyed: CumulativeHeightSumPattern::new(client.clone(), "cointime_value_destroyed".to_string()), - cointime_value_created: CumulativeHeightSumPattern::new(client.clone(), "cointime_value_created".to_string()), - cointime_value_stored: CumulativeHeightSumPattern::new(client.clone(), "cointime_value_stored".to_string()), + value_destroyed: CumulativeHeightSumPattern::new(client.clone(), "cointime_value_destroyed".to_string()), + value_created: CumulativeHeightSumPattern::new(client.clone(), "cointime_value_created".to_string()), + value_stored: CumulativeHeightSumPattern::new(client.clone(), "cointime_value_stored".to_string()), vocdd: CumulativeHeightSumPattern::new(client.clone(), "vocdd".to_string()), } } @@ -3725,43 +4357,43 @@ impl MetricsTree_Cointime_Cap { /// Metrics tree node. pub struct MetricsTree_Cointime_Pricing { pub vaulted_price: CentsSatsUsdPattern, - pub vaulted_price_ratio: BpsRatioPattern2, + pub vaulted_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, pub active_price: CentsSatsUsdPattern, - pub active_price_ratio: BpsRatioPattern2, + pub active_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, pub true_market_mean: CentsSatsUsdPattern, - pub true_market_mean_ratio: BpsRatioPattern2, + pub true_market_mean_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, pub cointime_price: CentsSatsUsdPattern, - pub cointime_price_ratio: BpsRatioPattern2, + pub cointime_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, } impl MetricsTree_Cointime_Pricing { pub fn new(client: Arc, base_path: String) -> Self { Self { vaulted_price: CentsSatsUsdPattern::new(client.clone(), "vaulted_price".to_string()), - vaulted_price_ratio: BpsRatioPattern2::new(client.clone(), "vaulted_price_ratio".to_string()), + vaulted_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "vaulted_price_ratio".to_string()), active_price: CentsSatsUsdPattern::new(client.clone(), "active_price".to_string()), - active_price_ratio: BpsRatioPattern2::new(client.clone(), "active_price_ratio".to_string()), + active_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "active_price_ratio".to_string()), true_market_mean: CentsSatsUsdPattern::new(client.clone(), "true_market_mean".to_string()), - true_market_mean_ratio: BpsRatioPattern2::new(client.clone(), "true_market_mean_ratio".to_string()), + true_market_mean_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "true_market_mean_ratio".to_string()), cointime_price: CentsSatsUsdPattern::new(client.clone(), "cointime_price".to_string()), - cointime_price_ratio: BpsRatioPattern2::new(client.clone(), "cointime_price_ratio".to_string()), + cointime_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "cointime_price_ratio".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Cointime_Adjusted { - pub cointime_adj_inflation_rate: BpsPercentRatioPattern, - pub cointime_adj_tx_velocity_btc: MetricPattern1, - pub cointime_adj_tx_velocity_usd: MetricPattern1, + pub adj_inflation_rate: BpsPercentRatioPattern, + pub adj_tx_velocity_btc: MetricPattern1, + pub adj_tx_velocity_usd: MetricPattern1, } impl MetricsTree_Cointime_Adjusted { pub fn new(client: Arc, base_path: String) -> Self { Self { - cointime_adj_inflation_rate: BpsPercentRatioPattern::new(client.clone(), "cointime_adj_inflation_rate".to_string()), - cointime_adj_tx_velocity_btc: MetricPattern1::new(client.clone(), "cointime_adj_tx_velocity_btc".to_string()), - cointime_adj_tx_velocity_usd: MetricPattern1::new(client.clone(), "cointime_adj_tx_velocity_usd".to_string()), + adj_inflation_rate: BpsPercentRatioPattern::new(client.clone(), "cointime_adj_inflation_rate".to_string()), + adj_tx_velocity_btc: MetricPattern1::new(client.clone(), "cointime_adj_tx_velocity_btc".to_string()), + adj_tx_velocity_usd: MetricPattern1::new(client.clone(), "cointime_adj_tx_velocity_usd".to_string()), } } } @@ -3834,8 +4466,8 @@ impl MetricsTree_Constants { pub struct MetricsTree_Indexes { pub address: MetricsTree_Indexes_Address, pub height: MetricsTree_Indexes_Height, - pub difficultyepoch: MetricsTree_Indexes_Difficultyepoch, - pub halvingepoch: MetricsTree_Indexes_Halvingepoch, + pub epoch: MetricsTree_Indexes_Epoch, + pub halving: MetricsTree_Indexes_Halving, pub minute10: MetricsTree_Indexes_Minute10, pub minute30: MetricsTree_Indexes_Minute30, pub hour1: MetricsTree_Indexes_Hour1, @@ -3859,8 +4491,8 @@ impl MetricsTree_Indexes { Self { address: MetricsTree_Indexes_Address::new(client.clone(), format!("{base_path}_address")), height: MetricsTree_Indexes_Height::new(client.clone(), format!("{base_path}_height")), - difficultyepoch: MetricsTree_Indexes_Difficultyepoch::new(client.clone(), format!("{base_path}_difficultyepoch")), - halvingepoch: MetricsTree_Indexes_Halvingepoch::new(client.clone(), format!("{base_path}_halvingepoch")), + epoch: MetricsTree_Indexes_Epoch::new(client.clone(), format!("{base_path}_epoch")), + halving: MetricsTree_Indexes_Halving::new(client.clone(), format!("{base_path}_halving")), minute10: MetricsTree_Indexes_Minute10::new(client.clone(), format!("{base_path}_minute10")), minute30: MetricsTree_Indexes_Minute30::new(client.clone(), format!("{base_path}_minute30")), hour1: MetricsTree_Indexes_Hour1::new(client.clone(), format!("{base_path}_hour1")), @@ -4082,8 +4714,8 @@ pub struct MetricsTree_Indexes_Height { pub hour12: MetricPattern18, pub day1: MetricPattern18, pub day3: MetricPattern18, - pub difficultyepoch: MetricPattern18, - pub halvingepoch: MetricPattern18, + pub epoch: MetricPattern18, + pub halving: MetricPattern18, pub week1: MetricPattern18, pub month1: MetricPattern18, pub month3: MetricPattern18, @@ -4104,8 +4736,8 @@ impl MetricsTree_Indexes_Height { hour12: MetricPattern18::new(client.clone(), "hour12".to_string()), day1: MetricPattern18::new(client.clone(), "day1".to_string()), day3: MetricPattern18::new(client.clone(), "day3".to_string()), - difficultyepoch: MetricPattern18::new(client.clone(), "difficultyepoch".to_string()), - halvingepoch: MetricPattern18::new(client.clone(), "halvingepoch".to_string()), + epoch: MetricPattern18::new(client.clone(), "epoch".to_string()), + halving: MetricPattern18::new(client.clone(), "halving".to_string()), week1: MetricPattern18::new(client.clone(), "week1".to_string()), month1: MetricPattern18::new(client.clone(), "month1".to_string()), month3: MetricPattern18::new(client.clone(), "month3".to_string()), @@ -4118,16 +4750,16 @@ impl MetricsTree_Indexes_Height { } /// Metrics tree node. -pub struct MetricsTree_Indexes_Difficultyepoch { +pub struct MetricsTree_Indexes_Epoch { pub identity: MetricPattern17, pub first_height: MetricPattern17, pub height_count: MetricPattern17, } -impl MetricsTree_Indexes_Difficultyepoch { +impl MetricsTree_Indexes_Epoch { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: MetricPattern17::new(client.clone(), "difficultyepoch".to_string()), + identity: MetricPattern17::new(client.clone(), "epoch".to_string()), first_height: MetricPattern17::new(client.clone(), "first_height".to_string()), height_count: MetricPattern17::new(client.clone(), "height_count".to_string()), } @@ -4135,15 +4767,15 @@ impl MetricsTree_Indexes_Difficultyepoch { } /// Metrics tree node. -pub struct MetricsTree_Indexes_Halvingepoch { +pub struct MetricsTree_Indexes_Halving { pub identity: MetricPattern16, pub first_height: MetricPattern16, } -impl MetricsTree_Indexes_Halvingepoch { +impl MetricsTree_Indexes_Halving { pub fn new(client: Arc, base_path: String) -> Self { Self { - identity: MetricPattern16::new(client.clone(), "halvingepoch".to_string()), + identity: MetricPattern16::new(client.clone(), "halving".to_string()), first_height: MetricPattern16::new(client.clone(), "first_height".to_string()), } } @@ -4408,7 +5040,7 @@ pub struct MetricsTree_Market { pub ath: MetricsTree_Market_Ath, pub lookback: MetricsTree_Market_Lookback, pub returns: MetricsTree_Market_Returns, - pub volatility: MetricsTree_Market_Volatility, + pub volatility: _1m1w1yPattern, pub range: MetricsTree_Market_Range, pub moving_average: MetricsTree_Market_MovingAverage, pub dca: MetricsTree_Market_Dca, @@ -4421,7 +5053,7 @@ impl MetricsTree_Market { ath: MetricsTree_Market_Ath::new(client.clone(), format!("{base_path}_ath")), lookback: MetricsTree_Market_Lookback::new(client.clone(), format!("{base_path}_lookback")), returns: MetricsTree_Market_Returns::new(client.clone(), format!("{base_path}_returns")), - volatility: MetricsTree_Market_Volatility::new(client.clone(), format!("{base_path}_volatility")), + volatility: _1m1w1yPattern::new(client.clone(), "price_volatility".to_string()), range: MetricsTree_Market_Range::new(client.clone(), format!("{base_path}_range")), moving_average: MetricsTree_Market_MovingAverage::new(client.clone(), format!("{base_path}_moving_average")), dca: MetricsTree_Market_Dca::new(client.clone(), format!("{base_path}_dca")), @@ -4432,23 +5064,23 @@ impl MetricsTree_Market { /// Metrics tree node. pub struct MetricsTree_Market_Ath { - pub price_ath: CentsSatsUsdPattern, - pub price_drawdown: BpsPercentRatioPattern, - pub days_since_price_ath: MetricPattern1, - pub years_since_price_ath: MetricPattern2, - pub max_days_between_price_ath: MetricPattern1, - pub max_years_between_price_ath: MetricPattern2, + pub price: CentsSatsUsdPattern, + pub drawdown: BpsPercentRatioPattern, + pub days_since: MetricPattern1, + pub years_since: MetricPattern2, + pub max_days_between: MetricPattern1, + pub max_years_between: MetricPattern2, } impl MetricsTree_Market_Ath { pub fn new(client: Arc, base_path: String) -> Self { Self { - price_ath: CentsSatsUsdPattern::new(client.clone(), "price_ath".to_string()), - price_drawdown: BpsPercentRatioPattern::new(client.clone(), "price_drawdown".to_string()), - days_since_price_ath: MetricPattern1::new(client.clone(), "days_since_price_ath".to_string()), - years_since_price_ath: MetricPattern2::new(client.clone(), "years_since_price_ath".to_string()), - max_days_between_price_ath: MetricPattern1::new(client.clone(), "max_days_between_price_ath".to_string()), - max_years_between_price_ath: MetricPattern2::new(client.clone(), "max_years_between_price_ath".to_string()), + price: CentsSatsUsdPattern::new(client.clone(), "price_ath".to_string()), + drawdown: BpsPercentRatioPattern::new(client.clone(), "price_drawdown".to_string()), + days_since: MetricPattern1::new(client.clone(), "days_since_price_ath".to_string()), + years_since: MetricPattern2::new(client.clone(), "years_since_price_ath".to_string()), + max_days_between: MetricPattern1::new(client.clone(), "max_days_between_price_ath".to_string()), + max_years_between: MetricPattern2::new(client.clone(), "max_years_between_price_ath".to_string()), } } } @@ -4494,9 +5126,7 @@ impl MetricsTree_Market_Lookback { pub struct MetricsTree_Market_Returns { pub price_return: MetricsTree_Market_Returns_PriceReturn, pub price_cagr: _10y2y3y4y5y6y8yPattern, - pub price_return_24h_sd_1w: MetricsTree_Market_Returns_PriceReturn24hSd1w, - pub price_return_24h_sd_1m: MetricsTree_Market_Returns_PriceReturn24hSd1m, - pub price_return_24h_sd_1y: SdSmaPattern, + pub price_return_24h_sd: MetricsTree_Market_Returns_PriceReturn24hSd, } impl MetricsTree_Market_Returns { @@ -4504,9 +5134,7 @@ impl MetricsTree_Market_Returns { Self { price_return: MetricsTree_Market_Returns_PriceReturn::new(client.clone(), format!("{base_path}_price_return")), price_cagr: _10y2y3y4y5y6y8yPattern::new(client.clone(), "price_cagr".to_string()), - price_return_24h_sd_1w: MetricsTree_Market_Returns_PriceReturn24hSd1w::new(client.clone(), format!("{base_path}_price_return_24h_sd_1w")), - price_return_24h_sd_1m: MetricsTree_Market_Returns_PriceReturn24hSd1m::new(client.clone(), format!("{base_path}_price_return_24h_sd_1m")), - price_return_24h_sd_1y: SdSmaPattern::new(client.clone(), "price_return_24h".to_string()), + price_return_24h_sd: MetricsTree_Market_Returns_PriceReturn24hSd::new(client.clone(), format!("{base_path}_price_return_24h_sd")), } } } @@ -4549,12 +5177,29 @@ impl MetricsTree_Market_Returns_PriceReturn { } /// Metrics tree node. -pub struct MetricsTree_Market_Returns_PriceReturn24hSd1w { +pub struct MetricsTree_Market_Returns_PriceReturn24hSd { + pub _1w: MetricsTree_Market_Returns_PriceReturn24hSd_1w, + pub _1m: MetricsTree_Market_Returns_PriceReturn24hSd_1m, + pub _1y: SdSmaPattern, +} + +impl MetricsTree_Market_Returns_PriceReturn24hSd { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + _1w: MetricsTree_Market_Returns_PriceReturn24hSd_1w::new(client.clone(), format!("{base_path}_1w")), + _1m: MetricsTree_Market_Returns_PriceReturn24hSd_1m::new(client.clone(), format!("{base_path}_1m")), + _1y: SdSmaPattern::new(client.clone(), "price_return_24h".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_Returns_PriceReturn24hSd_1w { pub sma: MetricPattern1, pub sd: MetricPattern1, } -impl MetricsTree_Market_Returns_PriceReturn24hSd1w { +impl MetricsTree_Market_Returns_PriceReturn24hSd_1w { pub fn new(client: Arc, base_path: String) -> Self { Self { sma: MetricPattern1::new(client.clone(), "price_return_24h_sma_1w".to_string()), @@ -4564,12 +5209,12 @@ impl MetricsTree_Market_Returns_PriceReturn24hSd1w { } /// Metrics tree node. -pub struct MetricsTree_Market_Returns_PriceReturn24hSd1m { +pub struct MetricsTree_Market_Returns_PriceReturn24hSd_1m { pub sma: MetricPattern1, pub sd: MetricPattern1, } -impl MetricsTree_Market_Returns_PriceReturn24hSd1m { +impl MetricsTree_Market_Returns_PriceReturn24hSd_1m { pub fn new(client: Arc, base_path: String) -> Self { Self { sma: MetricPattern1::new(client.clone(), "price_return_24h_sma_1m".to_string()), @@ -4578,133 +5223,674 @@ impl MetricsTree_Market_Returns_PriceReturn24hSd1m { } } -/// Metrics tree node. -pub struct MetricsTree_Market_Volatility { - pub price_volatility_1w: MetricPattern1, - pub price_volatility_1m: MetricPattern1, - pub price_volatility_1y: MetricPattern1, -} - -impl MetricsTree_Market_Volatility { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - price_volatility_1w: MetricPattern1::new(client.clone(), "price_volatility_1w".to_string()), - price_volatility_1m: MetricPattern1::new(client.clone(), "price_volatility_1m".to_string()), - price_volatility_1y: MetricPattern1::new(client.clone(), "price_volatility_1y".to_string()), - } - } -} - /// Metrics tree node. pub struct MetricsTree_Market_Range { - pub price_min_1w: CentsSatsUsdPattern, - pub price_max_1w: CentsSatsUsdPattern, - pub price_min_2w: CentsSatsUsdPattern, - pub price_max_2w: CentsSatsUsdPattern, - pub price_min_1m: CentsSatsUsdPattern, - pub price_max_1m: CentsSatsUsdPattern, - pub price_min_1y: CentsSatsUsdPattern, - pub price_max_1y: CentsSatsUsdPattern, - pub price_true_range: MetricPattern1, - pub price_true_range_sum_2w: MetricPattern1, - pub price_choppiness_index_2w: BpsPercentRatioPattern, + pub min: _1m1w1y2wPattern, + pub max: _1m1w1y2wPattern, + pub true_range: MetricPattern1, + pub true_range_sum_2w: MetricPattern1, + pub choppiness_index_2w: BpsPercentRatioPattern, } impl MetricsTree_Market_Range { pub fn new(client: Arc, base_path: String) -> Self { Self { - price_min_1w: CentsSatsUsdPattern::new(client.clone(), "price_min_1w".to_string()), - price_max_1w: CentsSatsUsdPattern::new(client.clone(), "price_max_1w".to_string()), - price_min_2w: CentsSatsUsdPattern::new(client.clone(), "price_min_2w".to_string()), - price_max_2w: CentsSatsUsdPattern::new(client.clone(), "price_max_2w".to_string()), - price_min_1m: CentsSatsUsdPattern::new(client.clone(), "price_min_1m".to_string()), - price_max_1m: CentsSatsUsdPattern::new(client.clone(), "price_max_1m".to_string()), - price_min_1y: CentsSatsUsdPattern::new(client.clone(), "price_min_1y".to_string()), - price_max_1y: CentsSatsUsdPattern::new(client.clone(), "price_max_1y".to_string()), - price_true_range: MetricPattern1::new(client.clone(), "price_true_range".to_string()), - price_true_range_sum_2w: MetricPattern1::new(client.clone(), "price_true_range_sum_2w".to_string()), - price_choppiness_index_2w: BpsPercentRatioPattern::new(client.clone(), "price_choppiness_index_2w".to_string()), + min: _1m1w1y2wPattern::new(client.clone(), "price_min".to_string()), + max: _1m1w1y2wPattern::new(client.clone(), "price_max".to_string()), + true_range: MetricPattern1::new(client.clone(), "price_true_range".to_string()), + true_range_sum_2w: MetricPattern1::new(client.clone(), "price_true_range_sum_2w".to_string()), + choppiness_index_2w: BpsPercentRatioPattern::new(client.clone(), "price_choppiness_index_2w".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Market_MovingAverage { - pub price_sma_1w: BpsPriceRatioPattern, - pub price_sma_8d: BpsPriceRatioPattern, - pub price_sma_13d: BpsPriceRatioPattern, - pub price_sma_21d: BpsPriceRatioPattern, - pub price_sma_1m: BpsPriceRatioPattern, - pub price_sma_34d: BpsPriceRatioPattern, - pub price_sma_55d: BpsPriceRatioPattern, - pub price_sma_89d: BpsPriceRatioPattern, - pub price_sma_111d: BpsPriceRatioPattern, - pub price_sma_144d: BpsPriceRatioPattern, - pub price_sma_200d: BpsPriceRatioPattern, - pub price_sma_350d: BpsPriceRatioPattern, - pub price_sma_1y: BpsPriceRatioPattern, - pub price_sma_2y: BpsPriceRatioPattern, - pub price_sma_200w: BpsPriceRatioPattern, - pub price_sma_4y: BpsPriceRatioPattern, - pub price_ema_1w: BpsPriceRatioPattern, - pub price_ema_8d: BpsPriceRatioPattern, - pub price_ema_12d: BpsPriceRatioPattern, - pub price_ema_13d: BpsPriceRatioPattern, - pub price_ema_21d: BpsPriceRatioPattern, - pub price_ema_26d: BpsPriceRatioPattern, - pub price_ema_1m: BpsPriceRatioPattern, - pub price_ema_34d: BpsPriceRatioPattern, - pub price_ema_55d: BpsPriceRatioPattern, - pub price_ema_89d: BpsPriceRatioPattern, - pub price_ema_144d: BpsPriceRatioPattern, - pub price_ema_200d: BpsPriceRatioPattern, - pub price_ema_1y: BpsPriceRatioPattern, - pub price_ema_2y: BpsPriceRatioPattern, - pub price_ema_200w: BpsPriceRatioPattern, - pub price_ema_4y: BpsPriceRatioPattern, - pub price_sma_200d_x2_4: CentsSatsUsdPattern, - pub price_sma_200d_x0_8: CentsSatsUsdPattern, - pub price_sma_350d_x2: CentsSatsUsdPattern, + pub sma: MetricsTree_Market_MovingAverage_Sma, + pub ema: MetricsTree_Market_MovingAverage_Ema, } impl MetricsTree_Market_MovingAverage { pub fn new(client: Arc, base_path: String) -> Self { Self { - price_sma_1w: BpsPriceRatioPattern::new(client.clone(), "price_sma_1w".to_string()), - price_sma_8d: BpsPriceRatioPattern::new(client.clone(), "price_sma_8d".to_string()), - price_sma_13d: BpsPriceRatioPattern::new(client.clone(), "price_sma_13d".to_string()), - price_sma_21d: BpsPriceRatioPattern::new(client.clone(), "price_sma_21d".to_string()), - price_sma_1m: BpsPriceRatioPattern::new(client.clone(), "price_sma_1m".to_string()), - price_sma_34d: BpsPriceRatioPattern::new(client.clone(), "price_sma_34d".to_string()), - price_sma_55d: BpsPriceRatioPattern::new(client.clone(), "price_sma_55d".to_string()), - price_sma_89d: BpsPriceRatioPattern::new(client.clone(), "price_sma_89d".to_string()), - price_sma_111d: BpsPriceRatioPattern::new(client.clone(), "price_sma_111d".to_string()), - price_sma_144d: BpsPriceRatioPattern::new(client.clone(), "price_sma_144d".to_string()), - price_sma_200d: BpsPriceRatioPattern::new(client.clone(), "price_sma_200d".to_string()), - price_sma_350d: BpsPriceRatioPattern::new(client.clone(), "price_sma_350d".to_string()), - price_sma_1y: BpsPriceRatioPattern::new(client.clone(), "price_sma_1y".to_string()), - price_sma_2y: BpsPriceRatioPattern::new(client.clone(), "price_sma_2y".to_string()), - price_sma_200w: BpsPriceRatioPattern::new(client.clone(), "price_sma_200w".to_string()), - price_sma_4y: BpsPriceRatioPattern::new(client.clone(), "price_sma_4y".to_string()), - price_ema_1w: BpsPriceRatioPattern::new(client.clone(), "price_ema_1w".to_string()), - price_ema_8d: BpsPriceRatioPattern::new(client.clone(), "price_ema_8d".to_string()), - price_ema_12d: BpsPriceRatioPattern::new(client.clone(), "price_ema_12d".to_string()), - price_ema_13d: BpsPriceRatioPattern::new(client.clone(), "price_ema_13d".to_string()), - price_ema_21d: BpsPriceRatioPattern::new(client.clone(), "price_ema_21d".to_string()), - price_ema_26d: BpsPriceRatioPattern::new(client.clone(), "price_ema_26d".to_string()), - price_ema_1m: BpsPriceRatioPattern::new(client.clone(), "price_ema_1m".to_string()), - price_ema_34d: BpsPriceRatioPattern::new(client.clone(), "price_ema_34d".to_string()), - price_ema_55d: BpsPriceRatioPattern::new(client.clone(), "price_ema_55d".to_string()), - price_ema_89d: BpsPriceRatioPattern::new(client.clone(), "price_ema_89d".to_string()), - price_ema_144d: BpsPriceRatioPattern::new(client.clone(), "price_ema_144d".to_string()), - price_ema_200d: BpsPriceRatioPattern::new(client.clone(), "price_ema_200d".to_string()), - price_ema_1y: BpsPriceRatioPattern::new(client.clone(), "price_ema_1y".to_string()), - price_ema_2y: BpsPriceRatioPattern::new(client.clone(), "price_ema_2y".to_string()), - price_ema_200w: BpsPriceRatioPattern::new(client.clone(), "price_ema_200w".to_string()), - price_ema_4y: BpsPriceRatioPattern::new(client.clone(), "price_ema_4y".to_string()), - price_sma_200d_x2_4: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x2_4".to_string()), - price_sma_200d_x0_8: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x0_8".to_string()), - price_sma_350d_x2: CentsSatsUsdPattern::new(client.clone(), "price_sma_350d_x2".to_string()), + sma: MetricsTree_Market_MovingAverage_Sma::new(client.clone(), format!("{base_path}_sma")), + ema: MetricsTree_Market_MovingAverage_Ema::new(client.clone(), format!("{base_path}_ema")), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma { + pub _1w: MetricsTree_Market_MovingAverage_Sma_1w, + pub _8d: MetricsTree_Market_MovingAverage_Sma_8d, + pub _13d: MetricsTree_Market_MovingAverage_Sma_13d, + pub _21d: MetricsTree_Market_MovingAverage_Sma_21d, + pub _1m: MetricsTree_Market_MovingAverage_Sma_1m, + pub _34d: MetricsTree_Market_MovingAverage_Sma_34d, + pub _55d: MetricsTree_Market_MovingAverage_Sma_55d, + pub _89d: MetricsTree_Market_MovingAverage_Sma_89d, + pub _111d: MetricsTree_Market_MovingAverage_Sma_111d, + pub _144d: MetricsTree_Market_MovingAverage_Sma_144d, + pub _200d: MetricsTree_Market_MovingAverage_Sma_200d, + pub _350d: MetricsTree_Market_MovingAverage_Sma_350d, + pub _1y: MetricsTree_Market_MovingAverage_Sma_1y, + pub _2y: MetricsTree_Market_MovingAverage_Sma_2y, + pub _200w: MetricsTree_Market_MovingAverage_Sma_200w, + pub _4y: MetricsTree_Market_MovingAverage_Sma_4y, + pub _200d_x2_4: CentsSatsUsdPattern, + pub _200d_x0_8: CentsSatsUsdPattern, + pub _350d_x2: CentsSatsUsdPattern, +} + +impl MetricsTree_Market_MovingAverage_Sma { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + _1w: MetricsTree_Market_MovingAverage_Sma_1w::new(client.clone(), format!("{base_path}_1w")), + _8d: MetricsTree_Market_MovingAverage_Sma_8d::new(client.clone(), format!("{base_path}_8d")), + _13d: MetricsTree_Market_MovingAverage_Sma_13d::new(client.clone(), format!("{base_path}_13d")), + _21d: MetricsTree_Market_MovingAverage_Sma_21d::new(client.clone(), format!("{base_path}_21d")), + _1m: MetricsTree_Market_MovingAverage_Sma_1m::new(client.clone(), format!("{base_path}_1m")), + _34d: MetricsTree_Market_MovingAverage_Sma_34d::new(client.clone(), format!("{base_path}_34d")), + _55d: MetricsTree_Market_MovingAverage_Sma_55d::new(client.clone(), format!("{base_path}_55d")), + _89d: MetricsTree_Market_MovingAverage_Sma_89d::new(client.clone(), format!("{base_path}_89d")), + _111d: MetricsTree_Market_MovingAverage_Sma_111d::new(client.clone(), format!("{base_path}_111d")), + _144d: MetricsTree_Market_MovingAverage_Sma_144d::new(client.clone(), format!("{base_path}_144d")), + _200d: MetricsTree_Market_MovingAverage_Sma_200d::new(client.clone(), format!("{base_path}_200d")), + _350d: MetricsTree_Market_MovingAverage_Sma_350d::new(client.clone(), format!("{base_path}_350d")), + _1y: MetricsTree_Market_MovingAverage_Sma_1y::new(client.clone(), format!("{base_path}_1y")), + _2y: MetricsTree_Market_MovingAverage_Sma_2y::new(client.clone(), format!("{base_path}_2y")), + _200w: MetricsTree_Market_MovingAverage_Sma_200w::new(client.clone(), format!("{base_path}_200w")), + _4y: MetricsTree_Market_MovingAverage_Sma_4y::new(client.clone(), format!("{base_path}_4y")), + _200d_x2_4: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x2_4".to_string()), + _200d_x0_8: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x0_8".to_string()), + _350d_x2: CentsSatsUsdPattern::new(client.clone(), "price_sma_350d_x2".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_1w { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_1w { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_1w".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_1w_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_1w_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_8d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_8d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_8d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_8d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_8d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_13d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_13d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_13d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_13d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_13d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_21d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_21d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_21d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_21d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_21d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_1m { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_1m { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_1m".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_1m_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_1m_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_34d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_34d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_34d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_34d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_34d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_55d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_55d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_55d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_55d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_55d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_89d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_89d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_89d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_89d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_89d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_111d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_111d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_111d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_111d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_111d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_144d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_144d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_144d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_144d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_144d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_200d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_200d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_200d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_200d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_350d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_350d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_350d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_350d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_350d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_1y { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_1y { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_1y".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_1y_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_1y_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_2y { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_2y { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_2y".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_2y_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_2y_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_200w { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_200w { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_200w".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_200w_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_200w_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_4y { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Sma_4y { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_sma_4y".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_4y_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_4y_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema { + pub _1w: MetricsTree_Market_MovingAverage_Ema_1w, + pub _8d: MetricsTree_Market_MovingAverage_Ema_8d, + pub _12d: MetricsTree_Market_MovingAverage_Ema_12d, + pub _13d: MetricsTree_Market_MovingAverage_Ema_13d, + pub _21d: MetricsTree_Market_MovingAverage_Ema_21d, + pub _26d: MetricsTree_Market_MovingAverage_Ema_26d, + pub _1m: MetricsTree_Market_MovingAverage_Ema_1m, + pub _34d: MetricsTree_Market_MovingAverage_Ema_34d, + pub _55d: MetricsTree_Market_MovingAverage_Ema_55d, + pub _89d: MetricsTree_Market_MovingAverage_Ema_89d, + pub _144d: MetricsTree_Market_MovingAverage_Ema_144d, + pub _200d: MetricsTree_Market_MovingAverage_Ema_200d, + pub _1y: MetricsTree_Market_MovingAverage_Ema_1y, + pub _2y: MetricsTree_Market_MovingAverage_Ema_2y, + pub _200w: MetricsTree_Market_MovingAverage_Ema_200w, + pub _4y: MetricsTree_Market_MovingAverage_Ema_4y, +} + +impl MetricsTree_Market_MovingAverage_Ema { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + _1w: MetricsTree_Market_MovingAverage_Ema_1w::new(client.clone(), format!("{base_path}_1w")), + _8d: MetricsTree_Market_MovingAverage_Ema_8d::new(client.clone(), format!("{base_path}_8d")), + _12d: MetricsTree_Market_MovingAverage_Ema_12d::new(client.clone(), format!("{base_path}_12d")), + _13d: MetricsTree_Market_MovingAverage_Ema_13d::new(client.clone(), format!("{base_path}_13d")), + _21d: MetricsTree_Market_MovingAverage_Ema_21d::new(client.clone(), format!("{base_path}_21d")), + _26d: MetricsTree_Market_MovingAverage_Ema_26d::new(client.clone(), format!("{base_path}_26d")), + _1m: MetricsTree_Market_MovingAverage_Ema_1m::new(client.clone(), format!("{base_path}_1m")), + _34d: MetricsTree_Market_MovingAverage_Ema_34d::new(client.clone(), format!("{base_path}_34d")), + _55d: MetricsTree_Market_MovingAverage_Ema_55d::new(client.clone(), format!("{base_path}_55d")), + _89d: MetricsTree_Market_MovingAverage_Ema_89d::new(client.clone(), format!("{base_path}_89d")), + _144d: MetricsTree_Market_MovingAverage_Ema_144d::new(client.clone(), format!("{base_path}_144d")), + _200d: MetricsTree_Market_MovingAverage_Ema_200d::new(client.clone(), format!("{base_path}_200d")), + _1y: MetricsTree_Market_MovingAverage_Ema_1y::new(client.clone(), format!("{base_path}_1y")), + _2y: MetricsTree_Market_MovingAverage_Ema_2y::new(client.clone(), format!("{base_path}_2y")), + _200w: MetricsTree_Market_MovingAverage_Ema_200w::new(client.clone(), format!("{base_path}_200w")), + _4y: MetricsTree_Market_MovingAverage_Ema_4y::new(client.clone(), format!("{base_path}_4y")), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_1w { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_1w { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_1w".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_1w_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_1w_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_8d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_8d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_8d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_8d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_8d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_12d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_12d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_12d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_12d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_12d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_13d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_13d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_13d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_13d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_13d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_21d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_21d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_21d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_21d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_21d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_26d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_26d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_26d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_26d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_26d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_1m { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_1m { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_1m".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_1m_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_1m_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_34d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_34d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_34d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_34d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_34d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_55d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_55d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_55d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_55d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_55d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_89d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_89d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_89d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_89d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_89d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_144d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_144d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_144d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_144d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_144d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_200d { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_200d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_200d".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_200d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_200d_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_1y { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_1y { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_1y".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_1y_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_1y_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_2y { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_2y { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_2y".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_2y_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_2y_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_200w { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_200w { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_200w".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_200w_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_200w_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Ema_4y { + pub price: CentsSatsUsdPattern, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, +} + +impl MetricsTree_Market_MovingAverage_Ema_4y { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), "price_ema_4y".to_string()), + bps: MetricPattern1::new(client.clone(), "price_ema_4y_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_ema_4y_ratio".to_string()), } } } @@ -5120,55 +6306,55 @@ impl MetricsTree_Pools { /// Metrics tree node. pub struct MetricsTree_Pools_Major { - pub unknown: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub luxor: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub btccom: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub btctop: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub btcguild: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub eligius: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub f2pool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub braiinspool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub antpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub btcc: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub bwpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub bitfury: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub viabtc: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub poolin: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub spiderpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub binancepool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub foundryusa: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub sbicrypto: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub marapool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub secpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub ocean: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, - pub whitepool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern, + pub unknown: BlocksDominanceRewardsPattern, + pub luxor: BlocksDominanceRewardsPattern, + pub btccom: BlocksDominanceRewardsPattern, + pub btctop: BlocksDominanceRewardsPattern, + pub btcguild: BlocksDominanceRewardsPattern, + pub eligius: BlocksDominanceRewardsPattern, + pub f2pool: BlocksDominanceRewardsPattern, + pub braiinspool: BlocksDominanceRewardsPattern, + pub antpool: BlocksDominanceRewardsPattern, + pub btcc: BlocksDominanceRewardsPattern, + pub bwpool: BlocksDominanceRewardsPattern, + pub bitfury: BlocksDominanceRewardsPattern, + pub viabtc: BlocksDominanceRewardsPattern, + pub poolin: BlocksDominanceRewardsPattern, + pub spiderpool: BlocksDominanceRewardsPattern, + pub binancepool: BlocksDominanceRewardsPattern, + pub foundryusa: BlocksDominanceRewardsPattern, + pub sbicrypto: BlocksDominanceRewardsPattern, + pub marapool: BlocksDominanceRewardsPattern, + pub secpool: BlocksDominanceRewardsPattern, + pub ocean: BlocksDominanceRewardsPattern, + pub whitepool: BlocksDominanceRewardsPattern, } impl MetricsTree_Pools_Major { pub fn new(client: Arc, base_path: String) -> Self { Self { - unknown: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "unknown".to_string()), - luxor: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "luxor".to_string()), - btccom: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "btccom".to_string()), - btctop: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "btctop".to_string()), - btcguild: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "btcguild".to_string()), - eligius: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "eligius".to_string()), - f2pool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "f2pool".to_string()), - braiinspool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "braiinspool".to_string()), - antpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "antpool".to_string()), - btcc: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "btcc".to_string()), - bwpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "bwpool".to_string()), - bitfury: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "bitfury".to_string()), - viabtc: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "viabtc".to_string()), - poolin: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "poolin".to_string()), - spiderpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "spiderpool".to_string()), - binancepool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "binancepool".to_string()), - foundryusa: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "foundryusa".to_string()), - sbicrypto: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "sbicrypto".to_string()), - marapool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "marapool".to_string()), - secpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "secpool".to_string()), - ocean: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "ocean".to_string()), - whitepool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern::new(client.clone(), "whitepool".to_string()), + unknown: BlocksDominanceRewardsPattern::new(client.clone(), "unknown".to_string()), + luxor: BlocksDominanceRewardsPattern::new(client.clone(), "luxor".to_string()), + btccom: BlocksDominanceRewardsPattern::new(client.clone(), "btccom".to_string()), + btctop: BlocksDominanceRewardsPattern::new(client.clone(), "btctop".to_string()), + btcguild: BlocksDominanceRewardsPattern::new(client.clone(), "btcguild".to_string()), + eligius: BlocksDominanceRewardsPattern::new(client.clone(), "eligius".to_string()), + f2pool: BlocksDominanceRewardsPattern::new(client.clone(), "f2pool".to_string()), + braiinspool: BlocksDominanceRewardsPattern::new(client.clone(), "braiinspool".to_string()), + antpool: BlocksDominanceRewardsPattern::new(client.clone(), "antpool".to_string()), + btcc: BlocksDominanceRewardsPattern::new(client.clone(), "btcc".to_string()), + bwpool: BlocksDominanceRewardsPattern::new(client.clone(), "bwpool".to_string()), + bitfury: BlocksDominanceRewardsPattern::new(client.clone(), "bitfury".to_string()), + viabtc: BlocksDominanceRewardsPattern::new(client.clone(), "viabtc".to_string()), + poolin: BlocksDominanceRewardsPattern::new(client.clone(), "poolin".to_string()), + spiderpool: BlocksDominanceRewardsPattern::new(client.clone(), "spiderpool".to_string()), + binancepool: BlocksDominanceRewardsPattern::new(client.clone(), "binancepool".to_string()), + foundryusa: BlocksDominanceRewardsPattern::new(client.clone(), "foundryusa".to_string()), + sbicrypto: BlocksDominanceRewardsPattern::new(client.clone(), "sbicrypto".to_string()), + marapool: BlocksDominanceRewardsPattern::new(client.clone(), "marapool".to_string()), + secpool: BlocksDominanceRewardsPattern::new(client.clone(), "secpool".to_string()), + ocean: BlocksDominanceRewardsPattern::new(client.clone(), "ocean".to_string()), + whitepool: BlocksDominanceRewardsPattern::new(client.clone(), "whitepool".to_string()), } } } @@ -5564,8 +6750,8 @@ pub struct MetricsTree_Distribution { pub total_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern, pub new_addr_count: MetricsTree_Distribution_NewAddrCount, pub delta: MetricsTree_Distribution_Delta, - pub fundedaddressindex: MetricPattern34, - pub emptyaddressindex: MetricPattern35, + pub funded_address_index: MetricPattern34, + pub empty_address_index: MetricPattern35, } impl MetricsTree_Distribution { @@ -5582,8 +6768,8 @@ impl MetricsTree_Distribution { total_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern::new(client.clone(), "total_addr_count".to_string()), new_addr_count: MetricsTree_Distribution_NewAddrCount::new(client.clone(), format!("{base_path}_new_addr_count")), delta: MetricsTree_Distribution_Delta::new(client.clone(), format!("{base_path}_delta")), - fundedaddressindex: MetricPattern34::new(client.clone(), "fundedaddressindex".to_string()), - emptyaddressindex: MetricPattern35::new(client.clone(), "emptyaddressindex".to_string()), + funded_address_index: MetricPattern34::new(client.clone(), "funded_address_index".to_string()), + empty_address_index: MetricPattern35::new(client.clone(), "empty_address_index".to_string()), } } } @@ -5643,7 +6829,7 @@ pub struct MetricsTree_Distribution_UtxoCohorts { pub ge_amount: MetricsTree_Distribution_UtxoCohorts_GeAmount, pub amount_range: MetricsTree_Distribution_UtxoCohorts_AmountRange, pub lt_amount: MetricsTree_Distribution_UtxoCohorts_LtAmount, - pub type_: MetricsTree_Distribution_UtxoCohorts_Type, + pub r#type: MetricsTree_Distribution_UtxoCohorts_Type, pub profitability: MetricsTree_Distribution_UtxoCohorts_Profitability, pub matured: MetricsTree_Distribution_UtxoCohorts_Matured, } @@ -5662,7 +6848,7 @@ impl MetricsTree_Distribution_UtxoCohorts { ge_amount: MetricsTree_Distribution_UtxoCohorts_GeAmount::new(client.clone(), format!("{base_path}_ge_amount")), amount_range: MetricsTree_Distribution_UtxoCohorts_AmountRange::new(client.clone(), format!("{base_path}_amount_range")), lt_amount: MetricsTree_Distribution_UtxoCohorts_LtAmount::new(client.clone(), format!("{base_path}_lt_amount")), - type_: MetricsTree_Distribution_UtxoCohorts_Type::new(client.clone(), format!("{base_path}_type_")), + r#type: MetricsTree_Distribution_UtxoCohorts_Type::new(client.clone(), format!("{base_path}_type")), profitability: MetricsTree_Distribution_UtxoCohorts_Profitability::new(client.clone(), format!("{base_path}_profitability")), matured: MetricsTree_Distribution_UtxoCohorts_Matured::new(client.clone(), format!("{base_path}_matured")), } @@ -5671,161 +6857,195 @@ impl MetricsTree_Distribution_UtxoCohorts { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_All { - pub supply: DeltaHalvedTotalPattern, - pub outputs: UtxoPattern, - pub activity: CoinblocksCoindaysSentPattern2, - pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, + pub supply: DeltaHalvedTotalPattern2, + pub outputs: UtxoPattern3, + pub activity: CoinblocksCoindaysDormancySentVelocityPattern, + pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern, pub cost_basis: InvestedMaxMinPercentilesPattern, - pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, - pub adjusted: MetricsTree_Distribution_UtxoCohorts_All_Adjusted, + pub unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern, pub relative: MetricsTree_Distribution_UtxoCohorts_All_Relative, - pub dormancy: MetricPattern1, - pub velocity: MetricPattern1, - pub supply_delta_extended: _24hChangeRatePattern2, - pub utxo_count_delta_extended: _24hChangeRatePattern2, } impl MetricsTree_Distribution_UtxoCohorts_All { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply: DeltaHalvedTotalPattern::new(client.clone(), "supply".to_string()), - outputs: UtxoPattern::new(client.clone(), "utxo_count".to_string()), - activity: CoinblocksCoindaysSentPattern2::new(client.clone(), "".to_string()), - realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "".to_string()), + supply: DeltaHalvedTotalPattern2::new(client.clone(), "supply".to_string()), + outputs: UtxoPattern3::new(client.clone(), "utxo_count".to_string()), + activity: CoinblocksCoindaysDormancySentVelocityPattern::new(client.clone(), "".to_string()), + realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern::new(client.clone(), "".to_string()), cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "".to_string()), - unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "".to_string()), - adjusted: MetricsTree_Distribution_UtxoCohorts_All_Adjusted::new(client.clone(), format!("{base_path}_adjusted")), + unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern::new(client.clone(), "".to_string()), relative: MetricsTree_Distribution_UtxoCohorts_All_Relative::new(client.clone(), format!("{base_path}_relative")), - dormancy: MetricPattern1::new(client.clone(), "dormancy".to_string()), - velocity: MetricPattern1::new(client.clone(), "velocity".to_string()), - supply_delta_extended: _24hChangeRatePattern2::new(client.clone(), "supply_delta".to_string()), - utxo_count_delta_extended: _24hChangeRatePattern2::new(client.clone(), "utxo_count_delta".to_string()), - } - } -} - -/// Metrics tree node. -pub struct MetricsTree_Distribution_UtxoCohorts_All_Adjusted { - pub adjusted_value_created: MetricPattern1, - pub adjusted_value_destroyed: MetricPattern1, - pub adjusted_value_created_sum: _1m1w1y24hPattern, - pub adjusted_value_destroyed_sum: _1m1w1y24hPattern, - pub adjusted_sopr: _1m1w1y24hPattern, -} - -impl MetricsTree_Distribution_UtxoCohorts_All_Adjusted { - pub fn new(client: Arc, base_path: String) -> Self { - Self { - adjusted_value_created: MetricPattern1::new(client.clone(), "adjusted_value_created".to_string()), - adjusted_value_destroyed: MetricPattern1::new(client.clone(), "adjusted_value_destroyed".to_string()), - adjusted_value_created_sum: _1m1w1y24hPattern::new(client.clone(), "adjusted_value_created".to_string()), - adjusted_value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), "adjusted_value_destroyed".to_string()), - adjusted_sopr: _1m1w1y24hPattern::new(client.clone(), "adjusted_sopr".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative { - pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern, - pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern, - pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern, - pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern, - pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern, - pub nupl: MetricPattern1, - pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern, - pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern, - pub net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern, + pub supply: MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply, + pub unrealized: MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized, } impl MetricsTree_Distribution_UtxoCohorts_All_Relative { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_profit_rel_to_own_supply".to_string()), - supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_loss_rel_to_own_supply".to_string()), - unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_market_cap".to_string()), - unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_market_cap".to_string()), - net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_market_cap".to_string()), - nupl: MetricPattern1::new(client.clone(), "nupl".to_string()), - unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_own_gross_pnl".to_string()), - unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()), - net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_own_gross_pnl".to_string()), + supply: MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply::new(client.clone(), format!("{base_path}_supply")), + unrealized: MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized::new(client.clone(), format!("{base_path}_unrealized")), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply { + pub in_profit: RelPattern2, + pub in_loss: RelPattern2, +} + +impl MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + in_profit: RelPattern2::new(client.clone(), "supply_in_profit_rel_to_own_supply".to_string()), + in_loss: RelPattern2::new(client.clone(), "supply_in_loss_rel_to_own_supply".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized { + pub profit: RelPattern3, + pub loss: RelPattern3, + pub net_pnl: MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl, +} + +impl MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + profit: RelPattern3::new(client.clone(), "unrealized_profit_rel_to".to_string()), + loss: RelPattern3::new(client.clone(), "unrealized_loss_rel_to".to_string()), + net_pnl: MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl { + pub rel_to_own_gross_pnl: BpsPercentRatioPattern, +} + +impl MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_own_gross_pnl".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_Sth { - pub supply: DeltaHalvedTotalPattern, - pub outputs: UtxoPattern, - pub activity: CoinblocksCoindaysSentPattern2, - pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, + pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern, + pub supply: DeltaHalvedTotalPattern2, + pub outputs: UtxoPattern3, + pub activity: CoinblocksCoindaysDormancySentVelocityPattern, pub cost_basis: InvestedMaxMinPercentilesPattern, - pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, - pub relative: NetNuplSupplyUnrealizedPattern2, - pub dormancy: MetricPattern1, - pub velocity: MetricPattern1, - pub supply_delta_extended: _24hChangeRatePattern2, - pub utxo_count_delta_extended: _24hChangeRatePattern2, - pub adjusted_value_created: MetricPattern1, - pub adjusted_value_destroyed: MetricPattern1, - pub adjusted_value_created_sum: _1m1w1y24hPattern, - pub adjusted_value_destroyed_sum: _1m1w1y24hPattern, - pub adjusted_sopr: _1m1w1y24hPattern, + pub unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern, + pub relative: SupplyUnrealizedPattern2, } impl MetricsTree_Distribution_UtxoCohorts_Sth { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply: DeltaHalvedTotalPattern::new(client.clone(), "sth_supply".to_string()), - outputs: UtxoPattern::new(client.clone(), "sth_utxo_count".to_string()), - activity: CoinblocksCoindaysSentPattern2::new(client.clone(), "sth".to_string()), - realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "sth".to_string()), + realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern::new(client.clone(), "sth".to_string()), + supply: DeltaHalvedTotalPattern2::new(client.clone(), "sth_supply".to_string()), + outputs: UtxoPattern3::new(client.clone(), "sth_utxo_count".to_string()), + activity: CoinblocksCoindaysDormancySentVelocityPattern::new(client.clone(), "sth".to_string()), cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "sth".to_string()), - unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "sth".to_string()), - relative: NetNuplSupplyUnrealizedPattern2::new(client.clone(), "sth".to_string()), - dormancy: MetricPattern1::new(client.clone(), "sth_dormancy".to_string()), - velocity: MetricPattern1::new(client.clone(), "sth_velocity".to_string()), - supply_delta_extended: _24hChangeRatePattern2::new(client.clone(), "sth_supply_delta".to_string()), - utxo_count_delta_extended: _24hChangeRatePattern2::new(client.clone(), "sth_utxo_count_delta".to_string()), - adjusted_value_created: MetricPattern1::new(client.clone(), "sth_adjusted_value_created".to_string()), - adjusted_value_destroyed: MetricPattern1::new(client.clone(), "sth_adjusted_value_destroyed".to_string()), - adjusted_value_created_sum: _1m1w1y24hPattern::new(client.clone(), "sth_adjusted_value_created".to_string()), - adjusted_value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), "sth_adjusted_value_destroyed".to_string()), - adjusted_sopr: _1m1w1y24hPattern::new(client.clone(), "sth_adjusted_sopr".to_string()), + unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern::new(client.clone(), "sth".to_string()), + relative: SupplyUnrealizedPattern2::new(client.clone(), "sth".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_Lth { - pub supply: DeltaHalvedTotalPattern, - pub outputs: UtxoPattern, - pub activity: CoinblocksCoindaysSentPattern2, - pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern, + pub supply: DeltaHalvedTotalPattern2, + pub outputs: UtxoPattern3, + pub activity: CoinblocksCoindaysDormancySentVelocityPattern, + pub realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized, pub cost_basis: InvestedMaxMinPercentilesPattern, - pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern, - pub relative: NetNuplSupplyUnrealizedPattern2, - pub dormancy: MetricPattern1, - pub velocity: MetricPattern1, - pub supply_delta_extended: _24hChangeRatePattern2, - pub utxo_count_delta_extended: _24hChangeRatePattern2, + pub unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern, + pub relative: SupplyUnrealizedPattern2, } impl MetricsTree_Distribution_UtxoCohorts_Lth { pub fn new(client: Arc, base_path: String) -> Self { Self { - supply: DeltaHalvedTotalPattern::new(client.clone(), "lth_supply".to_string()), - outputs: UtxoPattern::new(client.clone(), "lth_utxo_count".to_string()), - activity: CoinblocksCoindaysSentPattern2::new(client.clone(), "lth".to_string()), - realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "lth".to_string()), + supply: DeltaHalvedTotalPattern2::new(client.clone(), "lth_supply".to_string()), + outputs: UtxoPattern3::new(client.clone(), "lth_utxo_count".to_string()), + activity: CoinblocksCoindaysDormancySentVelocityPattern::new(client.clone(), "lth".to_string()), + realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "lth".to_string()), - unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "lth".to_string()), - relative: NetNuplSupplyUnrealizedPattern2::new(client.clone(), "lth".to_string()), - dormancy: MetricPattern1::new(client.clone(), "lth_dormancy".to_string()), - velocity: MetricPattern1::new(client.clone(), "lth_velocity".to_string()), - supply_delta_extended: _24hChangeRatePattern2::new(client.clone(), "lth_supply_delta".to_string()), - utxo_count_delta_extended: _24hChangeRatePattern2::new(client.clone(), "lth_utxo_count_delta".to_string()), + unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern::new(client.clone(), "lth".to_string()), + relative: SupplyUnrealizedPattern2::new(client.clone(), "lth".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_Lth_Realized { + pub profit: CentsCumulativeFlowRelSumUsdValuePattern, + pub loss: CapitulationCentsCumulativeNegRelSumUsdValuePattern, + pub gross_pnl: CentsSellSumUsdPattern, + pub net_pnl: ChangeCumulativeDeltaRawRelSumPattern, + pub sopr: MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr, + pub sent: InPattern3, + pub peak_regret: CumulativeHeightRelPattern, + pub investor: CapLowerPriceUpperPattern, + pub profit_to_loss_ratio: _1m1w1y24hPattern, + pub cap: CentsDeltaRawRelUsdPattern, + pub price_ratio: BpsPercentilesRatioStdPattern, + pub price: CentsSatsUsdPattern, + pub mvrv: MetricPattern1, + pub nupl: BpsRatioPattern, +} + +impl MetricsTree_Distribution_UtxoCohorts_Lth_Realized { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + profit: CentsCumulativeFlowRelSumUsdValuePattern::new(client.clone(), "lth".to_string()), + loss: CapitulationCentsCumulativeNegRelSumUsdValuePattern::new(client.clone(), "lth".to_string()), + gross_pnl: CentsSellSumUsdPattern::new(client.clone(), "lth".to_string()), + net_pnl: ChangeCumulativeDeltaRawRelSumPattern::new(client.clone(), "lth_net".to_string()), + sopr: MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr::new(client.clone(), format!("{base_path}_sopr")), + sent: InPattern3::new(client.clone(), "lth_sent_in".to_string()), + peak_regret: CumulativeHeightRelPattern::new(client.clone(), "lth_realized_peak_regret".to_string()), + investor: CapLowerPriceUpperPattern::new(client.clone(), "lth".to_string()), + profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), "lth_realized_profit_to_loss_ratio".to_string()), + cap: CentsDeltaRawRelUsdPattern::new(client.clone(), "lth".to_string()), + price_ratio: BpsPercentilesRatioStdPattern::new(client.clone(), "lth_realized_price_ratio".to_string()), + price: CentsSatsUsdPattern::new(client.clone(), "lth_realized_price".to_string()), + mvrv: MetricPattern1::new(client.clone(), "lth_mvrv".to_string()), + nupl: BpsRatioPattern::new(client.clone(), "lth_nupl_ratio".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr { + pub value_created_sum: _1m1w1yPattern, + pub value_destroyed_sum: _1m1w1yPattern, + pub ratio: _1m1w1y24hPattern, + pub value_created: RawSumPattern, + pub value_destroyed: RawSumPattern, +} + +impl MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + value_created_sum: _1m1w1yPattern::new(client.clone(), "lth_value_created".to_string()), + value_destroyed_sum: _1m1w1yPattern::new(client.clone(), "lth_value_destroyed".to_string()), + ratio: _1m1w1y24hPattern::new(client.clone(), "lth_sopr".to_string()), + value_created: RawSumPattern::new(client.clone(), "lth_value_created".to_string()), + value_destroyed: RawSumPattern::new(client.clone(), "lth_value_destroyed".to_string()), } } } @@ -6047,148 +7267,148 @@ impl MetricsTree_Distribution_UtxoCohorts_Class { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_GeAmount { - pub _1sat: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _1sat: OutputsRealizedSupplyPattern, + pub _10sats: OutputsRealizedSupplyPattern, + pub _100sats: OutputsRealizedSupplyPattern, + pub _1k_sats: OutputsRealizedSupplyPattern, + pub _10k_sats: OutputsRealizedSupplyPattern, + pub _100k_sats: OutputsRealizedSupplyPattern, + pub _1m_sats: OutputsRealizedSupplyPattern, + pub _10m_sats: OutputsRealizedSupplyPattern, + pub _1btc: OutputsRealizedSupplyPattern, + pub _10btc: OutputsRealizedSupplyPattern, + pub _100btc: OutputsRealizedSupplyPattern, + pub _1k_btc: OutputsRealizedSupplyPattern, + pub _10k_btc: OutputsRealizedSupplyPattern, } impl MetricsTree_Distribution_UtxoCohorts_GeAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1sat: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1sat".to_string()), - _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10sats".to_string()), - _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100sats".to_string()), - _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1k_sats".to_string()), - _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10k_sats".to_string()), - _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100k_sats".to_string()), - _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1m_sats".to_string()), - _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10m_sats".to_string()), - _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1btc".to_string()), - _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10btc".to_string()), - _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_100btc".to_string()), - _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_1k_btc".to_string()), - _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_over_10k_btc".to_string()), + _1sat: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1sat".to_string()), + _10sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10sats".to_string()), + _100sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_100sats".to_string()), + _1k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1k_sats".to_string()), + _10k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10k_sats".to_string()), + _100k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_100k_sats".to_string()), + _1m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1m_sats".to_string()), + _10m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10m_sats".to_string()), + _1btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1btc".to_string()), + _10btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10btc".to_string()), + _100btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_100btc".to_string()), + _1k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_1k_btc".to_string()), + _10k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_over_10k_btc".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_AmountRange { - pub _0sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1sat_to_10sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10sats_to_100sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100sats_to_1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats_to_10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats_to_100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats_to_1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats_to_10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats_to_1btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1btc_to_10btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10btc_to_100btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100btc_to_1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc_to_10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc_to_100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100k_btc_or_more: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _0sats: OutputsRealizedSupplyPattern, + pub _1sat_to_10sats: OutputsRealizedSupplyPattern, + pub _10sats_to_100sats: OutputsRealizedSupplyPattern, + pub _100sats_to_1k_sats: OutputsRealizedSupplyPattern, + pub _1k_sats_to_10k_sats: OutputsRealizedSupplyPattern, + pub _10k_sats_to_100k_sats: OutputsRealizedSupplyPattern, + pub _100k_sats_to_1m_sats: OutputsRealizedSupplyPattern, + pub _1m_sats_to_10m_sats: OutputsRealizedSupplyPattern, + pub _10m_sats_to_1btc: OutputsRealizedSupplyPattern, + pub _1btc_to_10btc: OutputsRealizedSupplyPattern, + pub _10btc_to_100btc: OutputsRealizedSupplyPattern, + pub _100btc_to_1k_btc: OutputsRealizedSupplyPattern, + pub _1k_btc_to_10k_btc: OutputsRealizedSupplyPattern, + pub _10k_btc_to_100k_btc: OutputsRealizedSupplyPattern, + pub _100k_btc_or_more: OutputsRealizedSupplyPattern, } impl MetricsTree_Distribution_UtxoCohorts_AmountRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_with_0sats".to_string()), - _1sat_to_10sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_1sat_under_10sats".to_string()), - _10sats_to_100sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_10sats_under_100sats".to_string()), - _100sats_to_1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_100sats_under_1k_sats".to_string()), - _1k_sats_to_10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_1k_sats_under_10k_sats".to_string()), - _10k_sats_to_100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_10k_sats_under_100k_sats".to_string()), - _100k_sats_to_1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_100k_sats_under_1m_sats".to_string()), - _1m_sats_to_10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_1m_sats_under_10m_sats".to_string()), - _10m_sats_to_1btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_10m_sats_under_1btc".to_string()), - _1btc_to_10btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_1btc_under_10btc".to_string()), - _10btc_to_100btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_10btc_under_100btc".to_string()), - _100btc_to_1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_100btc_under_1k_btc".to_string()), - _1k_btc_to_10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_1k_btc_under_10k_btc".to_string()), - _10k_btc_to_100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_10k_btc_under_100k_btc".to_string()), - _100k_btc_or_more: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_above_100k_btc".to_string()), + _0sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_with_0sats".to_string()), + _1sat_to_10sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_1sat_under_10sats".to_string()), + _10sats_to_100sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_10sats_under_100sats".to_string()), + _100sats_to_1k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_100sats_under_1k_sats".to_string()), + _1k_sats_to_10k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_1k_sats_under_10k_sats".to_string()), + _10k_sats_to_100k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_10k_sats_under_100k_sats".to_string()), + _100k_sats_to_1m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_100k_sats_under_1m_sats".to_string()), + _1m_sats_to_10m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_1m_sats_under_10m_sats".to_string()), + _10m_sats_to_1btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_10m_sats_under_1btc".to_string()), + _1btc_to_10btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_1btc_under_10btc".to_string()), + _10btc_to_100btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_10btc_under_100btc".to_string()), + _100btc_to_1k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_100btc_under_1k_btc".to_string()), + _1k_btc_to_10k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_1k_btc_under_10k_btc".to_string()), + _10k_btc_to_100k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_10k_btc_under_100k_btc".to_string()), + _100k_btc_or_more: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_above_100k_btc".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_LtAmount { - pub _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub _100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub _10sats: OutputsRealizedSupplyPattern, + pub _100sats: OutputsRealizedSupplyPattern, + pub _1k_sats: OutputsRealizedSupplyPattern, + pub _10k_sats: OutputsRealizedSupplyPattern, + pub _100k_sats: OutputsRealizedSupplyPattern, + pub _1m_sats: OutputsRealizedSupplyPattern, + pub _10m_sats: OutputsRealizedSupplyPattern, + pub _1btc: OutputsRealizedSupplyPattern, + pub _10btc: OutputsRealizedSupplyPattern, + pub _100btc: OutputsRealizedSupplyPattern, + pub _1k_btc: OutputsRealizedSupplyPattern, + pub _10k_btc: OutputsRealizedSupplyPattern, + pub _100k_btc: OutputsRealizedSupplyPattern, } impl MetricsTree_Distribution_UtxoCohorts_LtAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _10sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10sats".to_string()), - _100sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100sats".to_string()), - _1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1k_sats".to_string()), - _10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10k_sats".to_string()), - _100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100k_sats".to_string()), - _1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1m_sats".to_string()), - _10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10m_sats".to_string()), - _1btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1btc".to_string()), - _10btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10btc".to_string()), - _100btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100btc".to_string()), - _1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_1k_btc".to_string()), - _10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_10k_btc".to_string()), - _100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "utxos_under_100k_btc".to_string()), + _10sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10sats".to_string()), + _100sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100sats".to_string()), + _1k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1k_sats".to_string()), + _10k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10k_sats".to_string()), + _100k_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100k_sats".to_string()), + _1m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1m_sats".to_string()), + _10m_sats: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10m_sats".to_string()), + _1btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1btc".to_string()), + _10btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10btc".to_string()), + _100btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100btc".to_string()), + _1k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_1k_btc".to_string()), + _10k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_10k_btc".to_string()), + _100k_btc: OutputsRealizedSupplyPattern::new(client.clone(), "utxos_under_100k_btc".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_Type { - pub p2pk65: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2pk33: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2pkh: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2ms: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2sh: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2wpkh: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2wsh: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2tr: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub p2a: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub unknown: ActivityOutputsRealizedSupplyUnrealizedPattern, - pub empty: ActivityOutputsRealizedSupplyUnrealizedPattern, + pub p2pk65: OutputsRealizedSupplyUnrealizedPattern, + pub p2pk33: OutputsRealizedSupplyUnrealizedPattern, + pub p2pkh: OutputsRealizedSupplyUnrealizedPattern, + pub p2ms: OutputsRealizedSupplyUnrealizedPattern, + pub p2sh: OutputsRealizedSupplyUnrealizedPattern, + pub p2wpkh: OutputsRealizedSupplyUnrealizedPattern, + pub p2wsh: OutputsRealizedSupplyUnrealizedPattern, + pub p2tr: OutputsRealizedSupplyUnrealizedPattern, + pub p2a: OutputsRealizedSupplyUnrealizedPattern, + pub unknown: OutputsRealizedSupplyUnrealizedPattern, + pub empty: OutputsRealizedSupplyUnrealizedPattern, } impl MetricsTree_Distribution_UtxoCohorts_Type { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk65: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pk65".to_string()), - p2pk33: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pk33".to_string()), - p2pkh: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pkh".to_string()), - p2ms: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2ms".to_string()), - p2sh: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2sh".to_string()), - p2wpkh: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2wpkh".to_string()), - p2wsh: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2wsh".to_string()), - p2tr: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2tr".to_string()), - p2a: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2a".to_string()), - unknown: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "unknown_outputs".to_string()), - empty: ActivityOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "empty_outputs".to_string()), + p2pk65: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pk65".to_string()), + p2pk33: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pk33".to_string()), + p2pkh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2pkh".to_string()), + p2ms: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2ms".to_string()), + p2sh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2sh".to_string()), + p2wpkh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2wpkh".to_string()), + p2wsh: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2wsh".to_string()), + p2tr: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2tr".to_string()), + p2a: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "p2a".to_string()), + unknown: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "unknown_outputs".to_string()), + empty: OutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "empty_outputs".to_string()), } } } @@ -6415,115 +7635,115 @@ impl MetricsTree_Distribution_AddressCohorts { /// Metrics tree node. pub struct MetricsTree_Distribution_AddressCohorts_GeAmount { - pub _1sat: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, + pub _1sat: AddrOutputsRealizedSupplyPattern, + pub _10sats: AddrOutputsRealizedSupplyPattern, + pub _100sats: AddrOutputsRealizedSupplyPattern, + pub _1k_sats: AddrOutputsRealizedSupplyPattern, + pub _10k_sats: AddrOutputsRealizedSupplyPattern, + pub _100k_sats: AddrOutputsRealizedSupplyPattern, + pub _1m_sats: AddrOutputsRealizedSupplyPattern, + pub _10m_sats: AddrOutputsRealizedSupplyPattern, + pub _1btc: AddrOutputsRealizedSupplyPattern, + pub _10btc: AddrOutputsRealizedSupplyPattern, + pub _100btc: AddrOutputsRealizedSupplyPattern, + pub _1k_btc: AddrOutputsRealizedSupplyPattern, + pub _10k_btc: AddrOutputsRealizedSupplyPattern, } impl MetricsTree_Distribution_AddressCohorts_GeAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _1sat: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1sat".to_string()), - _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10sats".to_string()), - _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100sats".to_string()), - _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_sats".to_string()), - _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_sats".to_string()), - _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100k_sats".to_string()), - _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1m_sats".to_string()), - _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10m_sats".to_string()), - _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1btc".to_string()), - _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10btc".to_string()), - _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_100btc".to_string()), - _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_1k_btc".to_string()), - _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_over_10k_btc".to_string()), + _1sat: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1sat".to_string()), + _10sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10sats".to_string()), + _100sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_100sats".to_string()), + _1k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1k_sats".to_string()), + _10k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10k_sats".to_string()), + _100k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_100k_sats".to_string()), + _1m_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1m_sats".to_string()), + _10m_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10m_sats".to_string()), + _1btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1btc".to_string()), + _10btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10btc".to_string()), + _100btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_100btc".to_string()), + _1k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_1k_btc".to_string()), + _10k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_over_10k_btc".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_AddressCohorts_AmountRange { - pub _0sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1sat_to_10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10sats_to_100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100sats_to_1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats_to_10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats_to_100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats_to_1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats_to_10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats_to_1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1btc_to_10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10btc_to_100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100btc_to_1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc_to_10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc_to_100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100k_btc_or_more: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, + pub _0sats: AddrOutputsRealizedSupplyPattern, + pub _1sat_to_10sats: AddrOutputsRealizedSupplyPattern, + pub _10sats_to_100sats: AddrOutputsRealizedSupplyPattern, + pub _100sats_to_1k_sats: AddrOutputsRealizedSupplyPattern, + pub _1k_sats_to_10k_sats: AddrOutputsRealizedSupplyPattern, + pub _10k_sats_to_100k_sats: AddrOutputsRealizedSupplyPattern, + pub _100k_sats_to_1m_sats: AddrOutputsRealizedSupplyPattern, + pub _1m_sats_to_10m_sats: AddrOutputsRealizedSupplyPattern, + pub _10m_sats_to_1btc: AddrOutputsRealizedSupplyPattern, + pub _1btc_to_10btc: AddrOutputsRealizedSupplyPattern, + pub _10btc_to_100btc: AddrOutputsRealizedSupplyPattern, + pub _100btc_to_1k_btc: AddrOutputsRealizedSupplyPattern, + pub _1k_btc_to_10k_btc: AddrOutputsRealizedSupplyPattern, + pub _10k_btc_to_100k_btc: AddrOutputsRealizedSupplyPattern, + pub _100k_btc_or_more: AddrOutputsRealizedSupplyPattern, } impl MetricsTree_Distribution_AddressCohorts_AmountRange { pub fn new(client: Arc, base_path: String) -> Self { Self { - _0sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_with_0sats".to_string()), - _1sat_to_10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_1sat_under_10sats".to_string()), - _10sats_to_100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_10sats_under_100sats".to_string()), - _100sats_to_1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_100sats_under_1k_sats".to_string()), - _1k_sats_to_10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_1k_sats_under_10k_sats".to_string()), - _10k_sats_to_100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_10k_sats_under_100k_sats".to_string()), - _100k_sats_to_1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_100k_sats_under_1m_sats".to_string()), - _1m_sats_to_10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_1m_sats_under_10m_sats".to_string()), - _10m_sats_to_1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_10m_sats_under_1btc".to_string()), - _1btc_to_10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_1btc_under_10btc".to_string()), - _10btc_to_100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_10btc_under_100btc".to_string()), - _100btc_to_1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_100btc_under_1k_btc".to_string()), - _1k_btc_to_10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_1k_btc_under_10k_btc".to_string()), - _10k_btc_to_100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_10k_btc_under_100k_btc".to_string()), - _100k_btc_or_more: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_above_100k_btc".to_string()), + _0sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_with_0sats".to_string()), + _1sat_to_10sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_1sat_under_10sats".to_string()), + _10sats_to_100sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_10sats_under_100sats".to_string()), + _100sats_to_1k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_100sats_under_1k_sats".to_string()), + _1k_sats_to_10k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_1k_sats_under_10k_sats".to_string()), + _10k_sats_to_100k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_10k_sats_under_100k_sats".to_string()), + _100k_sats_to_1m_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_100k_sats_under_1m_sats".to_string()), + _1m_sats_to_10m_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_1m_sats_under_10m_sats".to_string()), + _10m_sats_to_1btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_10m_sats_under_1btc".to_string()), + _1btc_to_10btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_1btc_under_10btc".to_string()), + _10btc_to_100btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_10btc_under_100btc".to_string()), + _100btc_to_1k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_100btc_under_1k_btc".to_string()), + _1k_btc_to_10k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_1k_btc_under_10k_btc".to_string()), + _10k_btc_to_100k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_10k_btc_under_100k_btc".to_string()), + _100k_btc_or_more: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_above_100k_btc".to_string()), } } } /// Metrics tree node. pub struct MetricsTree_Distribution_AddressCohorts_LtAmount { - pub _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, - pub _100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern, + pub _10sats: AddrOutputsRealizedSupplyPattern, + pub _100sats: AddrOutputsRealizedSupplyPattern, + pub _1k_sats: AddrOutputsRealizedSupplyPattern, + pub _10k_sats: AddrOutputsRealizedSupplyPattern, + pub _100k_sats: AddrOutputsRealizedSupplyPattern, + pub _1m_sats: AddrOutputsRealizedSupplyPattern, + pub _10m_sats: AddrOutputsRealizedSupplyPattern, + pub _1btc: AddrOutputsRealizedSupplyPattern, + pub _10btc: AddrOutputsRealizedSupplyPattern, + pub _100btc: AddrOutputsRealizedSupplyPattern, + pub _1k_btc: AddrOutputsRealizedSupplyPattern, + pub _10k_btc: AddrOutputsRealizedSupplyPattern, + pub _100k_btc: AddrOutputsRealizedSupplyPattern, } impl MetricsTree_Distribution_AddressCohorts_LtAmount { pub fn new(client: Arc, base_path: String) -> Self { Self { - _10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10sats".to_string()), - _100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100sats".to_string()), - _1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_sats".to_string()), - _10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_sats".to_string()), - _100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_sats".to_string()), - _1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1m_sats".to_string()), - _10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10m_sats".to_string()), - _1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1btc".to_string()), - _10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10btc".to_string()), - _100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100btc".to_string()), - _1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_1k_btc".to_string()), - _10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_10k_btc".to_string()), - _100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern::new(client.clone(), "addrs_under_100k_btc".to_string()), + _10sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10sats".to_string()), + _100sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100sats".to_string()), + _1k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1k_sats".to_string()), + _10k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10k_sats".to_string()), + _100k_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100k_sats".to_string()), + _1m_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1m_sats".to_string()), + _10m_sats: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10m_sats".to_string()), + _1btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1btc".to_string()), + _10btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10btc".to_string()), + _100btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100btc".to_string()), + _1k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_1k_btc".to_string()), + _10k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_10k_btc".to_string()), + _100k_btc: AddrOutputsRealizedSupplyPattern::new(client.clone(), "addrs_under_100k_btc".to_string()), } } } diff --git a/crates/brk_computer/src/cointime/activity/compute.rs b/crates/brk_computer/src/cointime/activity/compute.rs index dad3e566e..10b13e9bb 100644 --- a/crates/brk_computer/src/cointime/activity/compute.rs +++ b/crates/brk_computer/src/cointime/activity/compute.rs @@ -34,7 +34,7 @@ impl Vecs { vec.compute_subtract( starting_indexes.height, &self.coinblocks_created.height, - &all_metrics.activity.coinblocks_destroyed.height, + &all_metrics.activity.coinblocks_destroyed.raw.height, exit, )?; Ok(()) @@ -42,7 +42,7 @@ impl Vecs { self.liveliness.height.compute_divide( starting_indexes.height, - &all_metrics.activity.coinblocks_destroyed_cumulative.height, + &all_metrics.activity.coinblocks_destroyed.cumulative.height, &self.coinblocks_created.cumulative.height, exit, )?; diff --git a/crates/brk_computer/src/cointime/cap/compute.rs b/crates/brk_computer/src/cointime/cap/compute.rs index 1bbaa3075..d2bd15faa 100644 --- a/crates/brk_computer/src/cointime/cap/compute.rs +++ b/crates/brk_computer/src/cointime/cap/compute.rs @@ -18,7 +18,7 @@ impl Vecs { exit: &Exit, ) -> Result<()> { let all_metrics = &distribution.utxo_cohorts.all.metrics; - let realized_cap_cents = &all_metrics.realized.cap_cents.height; + let realized_cap_cents = &all_metrics.realized.cap.cents.height; let circulating_supply = &all_metrics.supply.total.btc.height; self.thermo_cap.cents.height.compute_transform( diff --git a/crates/brk_computer/src/cointime/value/compute.rs b/crates/brk_computer/src/cointime/value/compute.rs index 4e8a00257..eb3810a55 100644 --- a/crates/brk_computer/src/cointime/value/compute.rs +++ b/crates/brk_computer/src/cointime/value/compute.rs @@ -28,7 +28,7 @@ impl Vecs { vec.compute_multiply( starting_indexes.height, &prices.price.usd.height, - &coinblocks_destroyed.height, + &coinblocks_destroyed.raw.height, exit, )?; Ok(()) @@ -64,7 +64,7 @@ impl Vecs { vec.compute_transform3( starting_indexes.height, &prices.price.usd.height, - &coindays_destroyed.height, + &coindays_destroyed.raw.height, circulating_supply, |(i, price, cdd, supply, _): (_, Dollars, StoredF64, Bitcoin, _)| { let supply_f64 = f64::from(supply); diff --git a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs index b93a21150..ca1fce87d 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs @@ -157,7 +157,6 @@ impl DynCohortVecs for AddressCohortVecs { self.addr_count .height .validate_computed_version_or_reset(base_version)?; - self.metrics.validate_computed_versions(base_version)?; Ok(()) } @@ -170,18 +169,9 @@ impl DynCohortVecs for AddressCohortVecs { self.addr_count .height .truncate_push(height, state.addr_count.into())?; - self.metrics - .supply - .truncate_push(height, state.inner.supply.value)?; - self.metrics - .outputs - .truncate_push(height, state.inner.supply.utxo_count)?; - self.metrics - .activity - .truncate_push(height, state.inner.sent)?; - self.metrics - .realized - .truncate_push(height, &state.inner.realized)?; + self.metrics.supply.truncate_push(height, &state.inner)?; + self.metrics.outputs.truncate_push(height, &state.inner)?; + self.metrics.realized.truncate_push(height, &state.inner)?; } Ok(()) @@ -189,17 +179,10 @@ impl DynCohortVecs for AddressCohortVecs { fn compute_then_truncate_push_unrealized_states( &mut self, - height: Height, - height_price: Cents, + _height: Height, + _height_price: Cents, _is_day_boundary: bool, ) -> Result<()> { - if let Some(state) = self.state.as_mut() { - state.inner.apply_pending(); - let unrealized_state = state.inner.compute_unrealized_state(height_price); - self.metrics - .unrealized - .truncate_push(height, &unrealized_state)?; - } Ok(()) } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs b/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs index 6bdc0ad32..857aec36e 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs @@ -17,9 +17,10 @@ use crate::{ distribution::{ DynCohortVecs, metrics::{ - AllCohortMetrics, BasicCohortMetrics, CohortMetricsBase, CoreCohortMetrics, - ExtendedAdjustedCohortMetrics, ExtendedCohortMetrics, ImportConfig, - MinimalCohortMetrics, ProfitabilityMetrics, RealizedFullAccum, SupplyMetrics, + AllCohortMetrics, BasicCohortMetrics, CohortMetricsBase, + CoreCohortMetrics, ExtendedAdjustedCohortMetrics, ExtendedCohortMetrics, ImportConfig, + MinimalCohortMetrics, ProfitabilityMetrics, RealizedFullAccum, SupplyFull, + TypeCohortMetrics, }, state::UTXOCohortState, }, @@ -47,7 +48,7 @@ pub struct UTXOCohorts { pub amount_range: ByAmountRange>>, pub lt_amount: ByLowerThanAmount>>, #[traversable(rename = "type")] - pub type_: BySpendableType>>, + pub type_: BySpendableType>>, pub profitability: ProfitabilityMetrics, pub matured: ByAgeRange>, #[traversable(skip)] @@ -81,7 +82,7 @@ impl UTXOCohorts { version: v + Version::ONE, indexes, }; - let all_supply = SupplyMetrics::forced_import(&all_cfg)?; + let all_supply = SupplyFull::forced_import(&all_cfg)?; // Phase 2: Import separate (stateful) cohorts. @@ -144,7 +145,25 @@ impl UTXOCohorts { }; let amount_range = ByAmountRange::try_new(&minimal_separate)?; - let type_ = BySpendableType::try_new(&minimal_separate)?; + + let type_separate = + |f: Filter, name: &'static str| -> Result> { + let full_name = CohortContext::Utxo.full_name(&f, name); + let cfg = ImportConfig { + db, + filter: &f, + full_name: &full_name, + version: v, + indexes, + }; + let state = Some(Box::new(UTXOCohortState::new(states_path, &full_name))); + Ok(UTXOCohortVecs::new( + state, + TypeCohortMetrics::forced_import(&cfg)?, + )) + }; + + let type_ = BySpendableType::try_new(&type_separate)?; // Phase 3: Import "all" cohort with pre-imported supply. let all = UTXOCohortVecs::new( @@ -208,7 +227,6 @@ impl UTXOCohorts { // min_age: CoreCohortMetrics (no state, aggregates from age_range) let min_age = ByMinAge::try_new(&core_no_state)?; - // MinimalCohortMetrics without state (for aggregate amount cohorts) let minimal_no_state = |f: Filter, name: &'static str| -> Result> { let full_name = CohortContext::Utxo.full_name(&f, name); @@ -424,7 +442,8 @@ impl UTXOCohorts { .try_for_each(|vecs| { let sources = filter_minimal_sources_from(amr.iter(), Some(&vecs.metrics.filter)); - vecs.metrics.compute_from_sources(si, &sources, exit) + vecs.metrics + .compute_from_sources(si, &sources, exit) }) }), ]; @@ -507,7 +526,10 @@ impl UTXOCohorts { .up_to_1h .metrics .realized + .minimal + .sopr .value_created + .raw .height .read_only_clone(); let up_to_1h_value_destroyed = self @@ -515,7 +537,10 @@ impl UTXOCohorts { .up_to_1h .metrics .realized + .minimal + .sopr .value_destroyed + .raw .height .read_only_clone(); @@ -746,12 +771,6 @@ impl UTXOCohorts { for v in self.max_age.iter_mut() { v.metrics.validate_computed_versions(base_version)?; } - for v in self.ge_amount.iter_mut() { - v.metrics.validate_computed_versions(base_version)?; - } - for v in self.lt_amount.iter_mut() { - v.metrics.validate_computed_versions(base_version)?; - } Ok(()) } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs new file mode 100644 index 000000000..0d7441b23 --- /dev/null +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs @@ -0,0 +1,84 @@ +use brk_cohort::{Filter, Filtered}; +use brk_error::Result; +use brk_types::{Cents, Height, Indexes, Version}; +use vecdb::{Exit, ReadableVec}; + +use crate::{blocks, distribution::{cohorts::traits::DynCohortVecs, metrics::CoreCohortMetrics}, prices}; + +use super::UTXOCohortVecs; + +impl Filtered for UTXOCohortVecs { + fn filter(&self) -> &Filter { + &self.metrics.filter + } +} + +impl DynCohortVecs for UTXOCohortVecs { + fn min_stateful_height_len(&self) -> usize { + self.metrics.min_stateful_height_len() + } + + fn reset_state_starting_height(&mut self) { + self.reset_state_impl(); + } + + impl_import_state!(); + + fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { + self.metrics.validate_computed_versions(base_version) + } + + fn truncate_push(&mut self, height: Height) -> Result<()> { + if self.state_starting_height.is_some_and(|h| h > height) { + return Ok(()); + } + + if let Some(state) = self.state.as_ref() { + self.metrics.supply.truncate_push(height, state)?; + self.metrics.outputs.truncate_push(height, state)?; + self.metrics.activity.truncate_push(height, state)?; + self.metrics.realized.truncate_push(height, state)?; + } + + Ok(()) + } + + fn compute_then_truncate_push_unrealized_states( + &mut self, + height: Height, + height_price: Cents, + _is_day_boundary: bool, + ) -> Result<()> { + if let Some(state) = self.state.as_mut() { + state.apply_pending(); + let unrealized_state = state.compute_unrealized_state(height_price); + self.metrics + .unrealized + .truncate_push(height, &unrealized_state)?; + } + Ok(()) + } + + fn compute_rest_part1( + &mut self, + blocks: &blocks::Vecs, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.metrics + .compute_rest_part1(blocks, prices, starting_indexes, exit) + } + + fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { + self.write_state_impl(height, cleanup) + } + + fn reset_cost_basis_data_if_needed(&mut self) -> Result<()> { + self.reset_cost_basis_impl() + } + + fn reset_single_iteration_values(&mut self) { + self.reset_iteration_impl(); + } +} diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs new file mode 100644 index 000000000..b223ebae3 --- /dev/null +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs @@ -0,0 +1,80 @@ +use brk_cohort::{Filter, Filtered}; +use brk_error::Result; +use brk_types::{Cents, Height, Indexes, Version}; +use vecdb::{Exit, ReadableVec}; + +use crate::{ + blocks, + distribution::{cohorts::traits::DynCohortVecs, metrics::MinimalCohortMetrics}, + prices, +}; + +use super::UTXOCohortVecs; + +impl Filtered for UTXOCohortVecs { + fn filter(&self) -> &Filter { + &self.metrics.filter + } +} + +impl DynCohortVecs for UTXOCohortVecs { + fn min_stateful_height_len(&self) -> usize { + self.metrics.min_stateful_height_len() + } + + fn reset_state_starting_height(&mut self) { + self.reset_state_impl(); + } + + impl_import_state!(); + + fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { + Ok(()) + } + + fn truncate_push(&mut self, height: Height) -> Result<()> { + if self.state_starting_height.is_some_and(|h| h > height) { + return Ok(()); + } + + if let Some(state) = self.state.as_ref() { + self.metrics.supply.truncate_push(height, state)?; + self.metrics.outputs.truncate_push(height, state)?; + self.metrics.realized.truncate_push(height, state)?; + } + + Ok(()) + } + + fn compute_then_truncate_push_unrealized_states( + &mut self, + _height: Height, + _height_price: Cents, + _is_day_boundary: bool, + ) -> Result<()> { + Ok(()) + } + + fn compute_rest_part1( + &mut self, + blocks: &blocks::Vecs, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.metrics + .compute_rest_part1(blocks, prices, starting_indexes, exit) + } + + fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { + self.write_state_impl(height, cleanup) + } + + fn reset_cost_basis_data_if_needed(&mut self) -> Result<()> { + self.reset_cost_basis_impl() + } + + fn reset_single_iteration_values(&mut self) { + self.reset_iteration_impl(); + } +} diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs similarity index 54% rename from crates/brk_computer/src/distribution/cohorts/utxo/vecs.rs rename to crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs index 85e2a28dc..c7c805874 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs @@ -1,17 +1,63 @@ +macro_rules! impl_import_state { + () => { + fn import_state(&mut self, starting_height: Height) -> Result { + if let Some(state) = self.state.as_mut() { + if let Some(mut prev_height) = starting_height.decremented() { + prev_height = state.import_at_or_before(prev_height)?; + + state.supply.value = self + .metrics + .supply + .total + .sats + .height + .collect_one(prev_height) + .unwrap(); + state.supply.utxo_count = *self + .metrics + .outputs + .utxo_count + .height + .collect_one(prev_height) + .unwrap(); + + state.restore_realized_cap(); + + let result = prev_height.incremented(); + self.state_starting_height = Some(result); + Ok(result) + } else { + self.state_starting_height = Some(Height::ZERO); + Ok(Height::ZERO) + } + } else { + self.state_starting_height = Some(starting_height); + Ok(starting_height) + } + } + }; +} + +mod core; +mod minimal; +mod r#type; + use brk_cohort::{Filter, Filtered}; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Cents, Height, Indexes, Version}; use vecdb::{Exit, ReadableVec}; -use crate::{blocks, distribution::state::UTXOCohortState, prices}; - -use crate::distribution::metrics::{ - CohortMetricsBase, CohortMetricsState, CoreCohortMetrics, MinimalCohortMetrics, +use crate::{ + blocks, + distribution::{ + cohorts::traits::DynCohortVecs, + metrics::{CohortMetricsBase, CohortMetricsState}, + state::UTXOCohortState, + }, + prices, }; -use super::super::traits::DynCohortVecs; - #[derive(Traversable)] pub struct UTXOCohortVecs { #[traversable(skip)] @@ -24,8 +70,6 @@ pub struct UTXOCohortVecs { pub metrics: M, } -// --- Shared state helpers (identical across all DynCohortVecs impls) --- - impl UTXOCohortVecs { pub(crate) fn new(state: Option>>, metrics: M) -> Self { Self { @@ -172,213 +216,3 @@ impl DynCohortVecs for UTXOCohortVecs { self.reset_iteration_impl(); } } - -// --- Shared import_state for non-blanket impls (direct field access) --- - -macro_rules! impl_import_state { - () => { - fn import_state(&mut self, starting_height: Height) -> Result { - if let Some(state) = self.state.as_mut() { - if let Some(mut prev_height) = starting_height.decremented() { - prev_height = state.import_at_or_before(prev_height)?; - - state.supply.value = self - .metrics - .supply - .total - .sats - .height - .collect_one(prev_height) - .unwrap(); - state.supply.utxo_count = *self - .metrics - .outputs - .utxo_count - .height - .collect_one(prev_height) - .unwrap(); - - state.restore_realized_cap(); - - let result = prev_height.incremented(); - self.state_starting_height = Some(result); - Ok(result) - } else { - self.state_starting_height = Some(Height::ZERO); - Ok(Height::ZERO) - } - } else { - self.state_starting_height = Some(starting_height); - Ok(starting_height) - } - } - }; -} - -// --- MinimalCohortMetrics: uses MinimalRealizedState --- - -impl Filtered for UTXOCohortVecs { - fn filter(&self) -> &Filter { - &self.metrics.filter - } -} - -impl DynCohortVecs for UTXOCohortVecs { - fn min_stateful_height_len(&self) -> usize { - self.metrics.min_stateful_height_len() - } - - fn reset_state_starting_height(&mut self) { - self.reset_state_impl(); - } - - impl_import_state!(); - - fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { - self.metrics.validate_computed_versions(base_version) - } - - fn truncate_push(&mut self, height: Height) -> Result<()> { - if self.state_starting_height.is_some_and(|h| h > height) { - return Ok(()); - } - - if let Some(state) = self.state.as_ref() { - self.metrics - .supply - .truncate_push(height, state.supply.value)?; - self.metrics - .outputs - .truncate_push(height, state.supply.utxo_count)?; - self.metrics.activity.truncate_push(height, state.sent)?; - self.metrics - .realized - .truncate_push(height, &state.realized)?; - } - - Ok(()) - } - - fn compute_then_truncate_push_unrealized_states( - &mut self, - height: Height, - height_price: Cents, - _is_day_boundary: bool, - ) -> Result<()> { - if let Some(state) = self.state.as_mut() { - state.apply_pending(); - let unrealized_state = state.compute_unrealized_state(height_price); - self.metrics - .unrealized - .truncate_push(height, &unrealized_state)?; - } - Ok(()) - } - - fn compute_rest_part1( - &mut self, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.metrics - .compute_rest_part1(blocks, prices, starting_indexes, exit) - } - - fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { - self.write_state_impl(height, cleanup) - } - - fn reset_cost_basis_data_if_needed(&mut self) -> Result<()> { - self.reset_cost_basis_impl() - } - - fn reset_single_iteration_values(&mut self) { - self.reset_iteration_impl(); - } -} - -// --- CoreCohortMetrics: uses CoreRealizedState --- - -impl Filtered for UTXOCohortVecs { - fn filter(&self) -> &Filter { - &self.metrics.filter - } -} - -impl DynCohortVecs for UTXOCohortVecs { - fn min_stateful_height_len(&self) -> usize { - self.metrics.min_stateful_height_len() - } - - fn reset_state_starting_height(&mut self) { - self.reset_state_impl(); - } - - impl_import_state!(); - - fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { - self.metrics.validate_computed_versions(base_version) - } - - fn truncate_push(&mut self, height: Height) -> Result<()> { - if self.state_starting_height.is_some_and(|h| h > height) { - return Ok(()); - } - - if let Some(state) = self.state.as_ref() { - self.metrics - .supply - .truncate_push(height, state.supply.value)?; - self.metrics - .outputs - .truncate_push(height, state.supply.utxo_count)?; - self.metrics.activity.truncate_push(height, state.sent)?; - self.metrics - .realized - .truncate_push(height, &state.realized)?; - } - - Ok(()) - } - - fn compute_then_truncate_push_unrealized_states( - &mut self, - height: Height, - height_price: Cents, - _is_day_boundary: bool, - ) -> Result<()> { - if let Some(state) = self.state.as_mut() { - state.apply_pending(); - let unrealized_state = state.compute_unrealized_state(height_price); - self.metrics - .unrealized - .truncate_push(height, &unrealized_state)?; - } - Ok(()) - } - - fn compute_rest_part1( - &mut self, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.metrics - .compute_rest_part1(blocks, prices, starting_indexes, exit) - } - - fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { - self.write_state_impl(height, cleanup) - } - - fn reset_cost_basis_data_if_needed(&mut self) -> Result<()> { - self.reset_cost_basis_impl() - } - - fn reset_single_iteration_values(&mut self) { - self.reset_iteration_impl(); - } -} diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs new file mode 100644 index 000000000..9efe65111 --- /dev/null +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs @@ -0,0 +1,83 @@ +use brk_cohort::{Filter, Filtered}; +use brk_error::Result; +use brk_types::{Cents, Height, Indexes, Version}; +use vecdb::{Exit, ReadableVec}; + +use crate::{blocks, distribution::cohorts::traits::DynCohortVecs, distribution::metrics::TypeCohortMetrics, prices}; + +use super::UTXOCohortVecs; + +impl Filtered for UTXOCohortVecs { + fn filter(&self) -> &Filter { + &self.metrics.filter + } +} + +impl DynCohortVecs for UTXOCohortVecs { + fn min_stateful_height_len(&self) -> usize { + self.metrics.min_stateful_height_len() + } + + fn reset_state_starting_height(&mut self) { + self.reset_state_impl(); + } + + impl_import_state!(); + + fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { + Ok(()) + } + + fn truncate_push(&mut self, height: Height) -> Result<()> { + if self.state_starting_height.is_some_and(|h| h > height) { + return Ok(()); + } + + if let Some(state) = self.state.as_ref() { + self.metrics.supply.truncate_push(height, state)?; + self.metrics.outputs.truncate_push(height, state)?; + self.metrics.realized.truncate_push(height, state)?; + } + + Ok(()) + } + + fn compute_then_truncate_push_unrealized_states( + &mut self, + height: Height, + height_price: Cents, + _is_day_boundary: bool, + ) -> Result<()> { + if let Some(state) = self.state.as_mut() { + state.apply_pending(); + let unrealized_state = state.compute_unrealized_state(height_price); + self.metrics + .unrealized + .truncate_push(height, &unrealized_state)?; + } + Ok(()) + } + + fn compute_rest_part1( + &mut self, + blocks: &blocks::Vecs, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.metrics + .compute_rest_part1(blocks, prices, starting_indexes, exit) + } + + fn write_state(&mut self, height: Height, cleanup: bool) -> Result<()> { + self.write_state_impl(height, cleanup) + } + + fn reset_cost_basis_data_if_needed(&mut self) -> Result<()> { + self.reset_cost_basis_impl() + } + + fn reset_single_iteration_values(&mut self) { + self.reset_iteration_impl(); + } +} diff --git a/crates/brk_computer/src/distribution/metrics/activity/base.rs b/crates/brk_computer/src/distribution/metrics/activity/base.rs deleted file mode 100644 index ab5056738..000000000 --- a/crates/brk_computer/src/distribution/metrics/activity/base.rs +++ /dev/null @@ -1,97 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF64, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; - -use crate::internal::ComputedPerBlock; - -use crate::{blocks, distribution::metrics::ImportConfig}; - -use super::ActivityCore; - -#[derive(Deref, DerefMut, Traversable)] -pub struct ActivityBase { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub core: ActivityCore, - - pub coinblocks_destroyed: ComputedPerBlock, - pub coindays_destroyed: ComputedPerBlock, -} - -impl ActivityBase { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v1 = Version::ONE; - Ok(Self { - core: ActivityCore::forced_import(cfg)?, - coinblocks_destroyed: cfg.import("coinblocks_destroyed", v1)?, - coindays_destroyed: cfg.import("coindays_destroyed", v1)?, - }) - } - - pub(crate) fn min_len(&self) -> usize { - self.core - .min_len() - .min(self.coinblocks_destroyed.height.len()) - .min(self.coindays_destroyed.height.len()) - } - - pub(crate) fn truncate_push( - &mut self, - height: Height, - sent: Sats, - satblocks_destroyed: Sats, - satdays_destroyed: Sats, - ) -> Result<()> { - self.core.truncate_push(height, sent)?; - self.coinblocks_destroyed.height.truncate_push( - height, - StoredF64::from(Bitcoin::from(satblocks_destroyed)), - )?; - self.coindays_destroyed.height.truncate_push( - height, - StoredF64::from(Bitcoin::from(satdays_destroyed)), - )?; - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![ - &mut self.core.sent.height as &mut dyn AnyStoredVec, - &mut self.coinblocks_destroyed.height as &mut dyn AnyStoredVec, - &mut self.coindays_destroyed.height as &mut dyn AnyStoredVec, - ] - } - - pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { - Ok(()) - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - let core_refs: Vec<&ActivityCore> = others.iter().map(|o| &o.core).collect(); - self.core - .compute_from_stateful(starting_indexes, &core_refs, exit)?; - - sum_others!(self, starting_indexes, others, exit; coinblocks_destroyed.height); - sum_others!(self, starting_indexes, others, exit; coindays_destroyed.height); - Ok(()) - } - - pub(crate) fn compute_rest_part1( - &mut self, - blocks: &blocks::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.core - .compute_rest_part1(blocks, starting_indexes, exit)?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/activity/core.rs b/crates/brk_computer/src/distribution/metrics/activity/core.rs index ea9c7c48e..eb824598e 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/core.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/core.rs @@ -1,16 +1,18 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Height, Indexes, Sats, Version}; +use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF64, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; -use crate::internal::{ComputedPerBlock, RollingWindow24h}; - -use crate::{blocks, distribution::metrics::ImportConfig}; +use crate::{ + blocks, + distribution::{metrics::ImportConfig, state::{CohortState, RealizedOps}}, + internal::PerBlockWithSum24h, +}; #[derive(Traversable)] pub struct ActivityCore { - pub sent: ComputedPerBlock, - pub sent_sum: RollingWindow24h, + pub sent: PerBlockWithSum24h, + pub coindays_destroyed: PerBlockWithSum24h, } impl ActivityCore { @@ -18,21 +20,36 @@ impl ActivityCore { let v1 = Version::ONE; Ok(Self { sent: cfg.import("sent", v1)?, - sent_sum: cfg.import("sent", v1)?, + coindays_destroyed: cfg.import("coindays_destroyed", v1)?, }) } pub(crate) fn min_len(&self) -> usize { - self.sent.height.len() + self.sent + .raw + .height + .len() + .min(self.coindays_destroyed.raw.height.len()) } - pub(crate) fn truncate_push(&mut self, height: Height, sent: Sats) -> Result<()> { - self.sent.height.truncate_push(height, sent)?; + pub(crate) fn truncate_push( + &mut self, + height: Height, + state: &CohortState, + ) -> Result<()> { + self.sent.raw.height.truncate_push(height, state.sent)?; + self.coindays_destroyed.raw.height.truncate_push( + height, + StoredF64::from(Bitcoin::from(state.satdays_destroyed)), + )?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![&mut self.sent.height as &mut dyn AnyStoredVec] + vec![ + &mut self.sent.raw.height as &mut dyn AnyStoredVec, + &mut self.coindays_destroyed.raw.height, + ] } pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { @@ -45,14 +62,17 @@ impl ActivityCore { others: &[&Self], exit: &Exit, ) -> Result<()> { - self.sent.height.compute_sum_of_others( + self.sent.raw.height.compute_sum_of_others( starting_indexes.height, &others .iter() - .map(|v| &v.sent.height) + .map(|v| &v.sent.raw.height) .collect::>(), exit, )?; + + sum_others!(self, starting_indexes, others, exit; coindays_destroyed.raw.height); + Ok(()) } @@ -62,10 +82,16 @@ impl ActivityCore { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.sent_sum.compute_rolling_sum( + self.sent.sum.compute_rolling_sum( starting_indexes.height, &blocks.lookback.height_24h_ago, - &self.sent.height, + &self.sent.raw.height, + exit, + )?; + self.coindays_destroyed.sum.compute_rolling_sum( + starting_indexes.height, + &blocks.lookback.height_24h_ago, + &self.coindays_destroyed.raw.height, exit, )?; Ok(()) diff --git a/crates/brk_computer/src/distribution/metrics/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index 4f39ae9b4..68610ac40 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -1,47 +1,90 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Indexes, Sats, StoredF64, Version}; +use brk_types::{Bitcoin, Height, Indexes, Sats, StoredF32, StoredF64, Version}; use derive_more::{Deref, DerefMut}; -use vecdb::{Exit, Rw, StorageMode}; +use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; -use crate::internal::{ComputedPerBlock, RollingWindows, RollingWindowsFrom1w}; +use crate::internal::{ComputedPerBlock, RollingWindowsFrom1w}; -use crate::{blocks, distribution::metrics::ImportConfig}; +use crate::{blocks, distribution::{metrics::ImportConfig, state::{CohortState, RealizedOps}}}; -use super::ActivityBase; +use super::ActivityCore; + +#[derive(Traversable)] +pub struct ActivityCoinblocks { + pub raw: ComputedPerBlock, + pub cumulative: ComputedPerBlock, +} #[derive(Deref, DerefMut, Traversable)] pub struct ActivityFull { #[deref] #[deref_mut] #[traversable(flatten)] - pub inner: ActivityBase, + pub inner: ActivityCore, - pub coinblocks_destroyed_cumulative: ComputedPerBlock, + pub coinblocks_destroyed: ActivityCoinblocks, + + #[traversable(wrap = "coindays_destroyed", rename = "cumulative")] pub coindays_destroyed_cumulative: ComputedPerBlock, - pub coindays_destroyed_sum: RollingWindows, + #[traversable(wrap = "coindays_destroyed", rename = "sum")] + pub coindays_destroyed_sum: RollingWindowsFrom1w, - #[traversable(rename = "sent_sum")] + #[traversable(wrap = "sent", rename = "sum")] pub sent_sum_extended: RollingWindowsFrom1w, + + pub dormancy: ComputedPerBlock, + pub velocity: ComputedPerBlock, } impl ActivityFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v1 = Version::ONE; Ok(Self { - inner: ActivityBase::forced_import(cfg)?, - coinblocks_destroyed_cumulative: cfg - .import("coinblocks_destroyed_cumulative", v1)?, + inner: ActivityCore::forced_import(cfg)?, + coinblocks_destroyed: ActivityCoinblocks { + raw: cfg.import("coinblocks_destroyed", v1)?, + cumulative: cfg.import("coinblocks_destroyed_cumulative", v1)?, + }, coindays_destroyed_cumulative: cfg.import("coindays_destroyed_cumulative", v1)?, coindays_destroyed_sum: cfg.import("coindays_destroyed", v1)?, sent_sum_extended: cfg.import("sent", v1)?, + dormancy: cfg.import("dormancy", v1)?, + velocity: cfg.import("velocity", v1)?, }) } + pub(crate) fn full_min_len(&self) -> usize { + self.inner + .min_len() + .min(self.coinblocks_destroyed.raw.height.len()) + } + + pub(crate) fn full_truncate_push( + &mut self, + height: Height, + state: &CohortState, + ) -> Result<()> { + self.inner.truncate_push(height, state)?; + self.coinblocks_destroyed.raw.height.truncate_push( + height, + StoredF64::from(Bitcoin::from(state.satblocks_destroyed)), + )?; + Ok(()) + } + + pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + let mut vecs = self.inner.collect_vecs_mut(); + vecs.push(&mut self.coinblocks_destroyed.raw.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.dormancy.height); + vecs.push(&mut self.velocity.height); + vecs + } + pub(crate) fn compute_from_stateful( &mut self, starting_indexes: &Indexes, - others: &[&ActivityBase], + others: &[&ActivityCore], exit: &Exit, ) -> Result<()> { self.inner @@ -57,11 +100,12 @@ impl ActivityFull { self.inner .compute_rest_part1(blocks, starting_indexes, exit)?; - self.coinblocks_destroyed_cumulative + self.coinblocks_destroyed + .cumulative .height .compute_cumulative( starting_indexes.height, - &self.inner.coinblocks_destroyed.height, + &self.coinblocks_destroyed.raw.height, exit, )?; @@ -69,7 +113,7 @@ impl ActivityFull { .height .compute_cumulative( starting_indexes.height, - &self.inner.coindays_destroyed.height, + &self.inner.coindays_destroyed.raw.height, exit, )?; @@ -77,14 +121,53 @@ impl ActivityFull { self.coindays_destroyed_sum.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.inner.coindays_destroyed.height, + &self.inner.coindays_destroyed.raw.height, exit, )?; self.sent_sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.inner.core.sent.height, + &self.inner.sent.raw.height, + exit, + )?; + + Ok(()) + } + + pub(crate) fn compute_rest_part2( + &mut self, + starting_indexes: &Indexes, + supply_total_sats: &impl ReadableVec, + exit: &Exit, + ) -> Result<()> { + self.dormancy.height.compute_transform2( + starting_indexes.height, + &self.inner.coindays_destroyed.raw.height, + &self.inner.sent.raw.height, + |(i, cdd, sent_sats, ..)| { + let sent_btc = f64::from(Bitcoin::from(sent_sats)); + if sent_btc == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + (i, StoredF32::from((f64::from(cdd) / sent_btc) as f32)) + } + }, + exit, + )?; + + self.velocity.height.compute_transform2( + starting_indexes.height, + &self.inner.sent.raw.height, + supply_total_sats, + |(i, sent_sats, supply_sats, ..)| { + let supply = supply_sats.as_u128() as f64; + if supply == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + (i, StoredF32::from((sent_sats.as_u128() as f64 / supply) as f32)) + } + }, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/activity/mod.rs b/crates/brk_computer/src/distribution/metrics/activity/mod.rs index 541f8c3ad..e86af7873 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/mod.rs @@ -1,33 +1,29 @@ -mod base; mod core; mod full; -pub use base::ActivityBase; pub use self::core::ActivityCore; pub use full::ActivityFull; use brk_error::Result; -use brk_types::{Height, Indexes, Sats, Version}; +use brk_types::{Height, Indexes, Version}; use vecdb::Exit; -use crate::blocks; +use crate::{blocks, distribution::state::{CohortState, RealizedOps}}; pub trait ActivityLike: Send + Sync { - fn as_base(&self) -> &ActivityBase; - fn as_base_mut(&mut self) -> &mut ActivityBase; + fn as_core(&self) -> &ActivityCore; + fn as_core_mut(&mut self) -> &mut ActivityCore; fn min_len(&self) -> usize; - fn truncate_push( + fn truncate_push( &mut self, height: Height, - sent: Sats, - satblocks_destroyed: Sats, - satdays_destroyed: Sats, + state: &CohortState, ) -> Result<()>; fn validate_computed_versions(&mut self, base_version: Version) -> Result<()>; fn compute_from_stateful( &mut self, starting_indexes: &Indexes, - others: &[&ActivityBase], + others: &[&ActivityCore], exit: &Exit, ) -> Result<()>; fn compute_rest_part1( @@ -38,17 +34,17 @@ pub trait ActivityLike: Send + Sync { ) -> Result<()>; } -impl ActivityLike for ActivityBase { - fn as_base(&self) -> &ActivityBase { self } - fn as_base_mut(&mut self) -> &mut ActivityBase { self } +impl ActivityLike for ActivityCore { + fn as_core(&self) -> &ActivityCore { self } + fn as_core_mut(&mut self) -> &mut ActivityCore { self } fn min_len(&self) -> usize { self.min_len() } - fn truncate_push(&mut self, height: Height, sent: Sats, satblocks_destroyed: Sats, satdays_destroyed: Sats) -> Result<()> { - self.truncate_push(height, sent, satblocks_destroyed, satdays_destroyed) + fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { + self.truncate_push(height, state) } fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { self.validate_computed_versions(base_version) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityBase], exit: &Exit) -> Result<()> { + fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityCore], exit: &Exit) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { @@ -57,16 +53,16 @@ impl ActivityLike for ActivityBase { } impl ActivityLike for ActivityFull { - fn as_base(&self) -> &ActivityBase { &self.inner } - fn as_base_mut(&mut self) -> &mut ActivityBase { &mut self.inner } - fn min_len(&self) -> usize { self.inner.min_len() } - fn truncate_push(&mut self, height: Height, sent: Sats, satblocks_destroyed: Sats, satdays_destroyed: Sats) -> Result<()> { - self.inner.truncate_push(height, sent, satblocks_destroyed, satdays_destroyed) + fn as_core(&self) -> &ActivityCore { &self.inner } + fn as_core_mut(&mut self) -> &mut ActivityCore { &mut self.inner } + fn min_len(&self) -> usize { self.full_min_len() } + fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { + self.full_truncate_push(height, state) } fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { self.inner.validate_computed_versions(base_version) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityBase], exit: &Exit) -> Result<()> { + fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&ActivityCore], exit: &Exit) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index e5fd2d998..ccf3776c5 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -2,7 +2,7 @@ use brk_cohort::Filter; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - Bitcoin, Cents, Dollars, Height, Indexes, Sats, SatsSigned, StoredF32, StoredI64, StoredU64, + Cents, Dollars, Height, Indexes, Sats, SatsSigned, StoredI64, StoredU64, Version, }; use vecdb::AnyStoredVec; @@ -10,11 +10,11 @@ use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; -use crate::internal::{ComputedPerBlock, RollingDeltaExcept1m}; +use crate::internal::RollingDeltaExcept1m; use crate::distribution::metrics::{ - ActivityFull, CohortMetricsBase, CostBasis, ImportConfig, OutputsMetrics, - RealizedAdjusted, RealizedFull, RelativeForAll, SupplyMetrics, UnrealizedFull, + ActivityFull, CohortMetricsBase, CostBasis, ImportConfig, OutputsFull, + AdjustedSopr, RealizedFull, RelativeForAll, SupplyFull, UnrealizedFull, }; /// All-cohort metrics: extended realized + adjusted (as composable add-on), @@ -24,16 +24,15 @@ use crate::distribution::metrics::{ pub struct AllCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, + pub supply: Box>, + pub outputs: Box>, pub activity: Box>, pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, - pub adjusted: Box>, + #[traversable(wrap = "realized/sopr", rename = "adjusted")] + pub asopr: Box>, pub relative: Box>, - pub dormancy: ComputedPerBlock, - pub velocity: ComputedPerBlock, #[traversable(wrap = "supply", rename = "delta")] pub supply_delta_extended: RollingDeltaExcept1m, @@ -73,8 +72,6 @@ impl CohortMetricsBase for AllCohortMetrics { vecs.extend(self.realized.collect_vecs_mut()); vecs.extend(self.cost_basis.collect_vecs_mut()); vecs.extend(self.unrealized.collect_vecs_mut()); - vecs.push(&mut self.dormancy.height); - vecs.push(&mut self.velocity.height); vecs } } @@ -86,26 +83,24 @@ impl AllCohortMetrics { /// reference for relative metric lazy vecs in other cohorts. pub(crate) fn forced_import_with_supply( cfg: &ImportConfig, - supply: SupplyMetrics, + supply: SupplyFull, ) -> Result { let unrealized = UnrealizedFull::forced_import(cfg)?; let realized = RealizedFull::forced_import(cfg)?; - let adjusted = RealizedAdjusted::forced_import(cfg)?; + let asopr = AdjustedSopr::forced_import(cfg)?; let relative = RelativeForAll::forced_import(cfg)?; Ok(Self { filter: cfg.filter.clone(), supply: Box::new(supply), - outputs: Box::new(OutputsMetrics::forced_import(cfg)?), + outputs: Box::new(OutputsFull::forced_import(cfg)?), activity: Box::new(ActivityFull::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasis::forced_import(cfg)?), unrealized: Box::new(unrealized), - adjusted: Box::new(adjusted), + asopr: Box::new(asopr), relative: Box::new(relative), - dormancy: cfg.import("dormancy", Version::ONE)?, - velocity: cfg.import("velocity", Version::ONE)?, supply_delta_extended: cfg.import("supply_delta", Version::ONE)?, utxo_count_delta_extended: cfg.import("utxo_count_delta", Version::ONE)?, }) @@ -131,11 +126,11 @@ impl AllCohortMetrics { exit, )?; - self.adjusted.compute_rest_part2( + self.asopr.compute_rest_part2( blocks, starting_indexes, - &self.realized.value_created.height, - &self.realized.value_destroyed.height, + &self.realized.minimal.sopr.value_created.raw.height, + &self.realized.minimal.sopr.value_destroyed.raw.height, up_to_1h_value_created, up_to_1h_value_destroyed, exit, @@ -163,33 +158,9 @@ impl AllCohortMetrics { exit, )?; - self.dormancy.height.compute_transform2( - starting_indexes.height, - &self.activity.coindays_destroyed.height, - &self.activity.sent.height, - |(i, cdd, sent_sats, ..)| { - let sent_btc = f64::from(Bitcoin::from(sent_sats)); - if sent_btc == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((f64::from(cdd) / sent_btc) as f32)) - } - }, - exit, - )?; - - self.velocity.height.compute_transform2( - starting_indexes.height, - &self.activity.sent.height, + self.activity.compute_rest_part2( + starting_indexes, &self.supply.total.sats.height, - |(i, sent_sats, supply_sats, ..)| { - let supply = supply_sats.as_u128() as f64; - if supply == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((sent_sats.as_u128() as f64 / supply) as f32)) - } - }, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs index c9c6fe67d..c15725d7c 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/basic.rs @@ -7,8 +7,8 @@ use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityBase, CohortMetricsBase, ImportConfig, OutputsMetrics, RealizedBase, - RelativeToAll, SupplyMetrics, UnrealizedBase, + ActivityCore, CohortMetricsBase, ImportConfig, OutputsFull, RealizedCore, + RelativeToAll, SupplyFull, UnrealizedBase, }; /// Basic cohort metrics: no extensions, with relative (rel_to_all). @@ -17,17 +17,17 @@ use crate::distribution::metrics::{ pub struct BasicCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, - pub activity: Box>, - pub realized: Box>, + pub supply: Box>, + pub outputs: Box>, + pub activity: Box>, + pub realized: Box>, pub unrealized: Box>, pub relative: Box>, } impl CohortMetricsBase for BasicCohortMetrics { - type ActivityVecs = ActivityBase; - type RealizedVecs = RealizedBase; + type ActivityVecs = ActivityCore; + type RealizedVecs = RealizedCore; type UnrealizedVecs = UnrealizedBase; impl_cohort_accessors!(); @@ -45,17 +45,17 @@ impl CohortMetricsBase for BasicCohortMetrics { impl BasicCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let supply = SupplyMetrics::forced_import(cfg)?; + let supply = SupplyFull::forced_import(cfg)?; let unrealized = UnrealizedBase::forced_import(cfg)?; - let realized = RealizedBase::forced_import(cfg)?; + let realized = RealizedCore::forced_import(cfg)?; let relative = RelativeToAll::forced_import(cfg)?; Ok(Self { filter: cfg.filter.clone(), supply: Box::new(supply), - outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityBase::forced_import(cfg)?), + outputs: Box::new(OutputsFull::forced_import(cfg)?), + activity: Box::new(ActivityCore::forced_import(cfg)?), realized: Box::new(realized), unrealized: Box::new(unrealized), relative: Box::new(relative), diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index 861666a7b..334fa3111 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -7,16 +7,16 @@ use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityCore, CohortMetricsBase, RealizedCore, ImportConfig, OutputsMetrics, - RelativeToAll, SupplyMetrics, UnrealizedCore, + ActivityCore, CohortMetricsBase, RealizedCore, ImportConfig, OutputsFull, + RelativeToAll, SupplyFull, UnrealizedCore, }; #[derive(Traversable)] pub struct CoreCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, + pub supply: Box>, + pub outputs: Box>, pub activity: Box>, pub realized: Box>, pub unrealized: Box>, @@ -27,8 +27,8 @@ impl CoreCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { filter: cfg.filter.clone(), - supply: Box::new(SupplyMetrics::forced_import(cfg)?), - outputs: Box::new(OutputsMetrics::forced_import(cfg)?), + supply: Box::new(SupplyFull::forced_import(cfg)?), + outputs: Box::new(OutputsFull::forced_import(cfg)?), activity: Box::new(ActivityCore::forced_import(cfg)?), realized: Box::new(RealizedCore::forced_import(cfg)?), unrealized: Box::new(UnrealizedCore::forced_import(cfg)?), @@ -80,12 +80,12 @@ impl CoreCohortMetrics { )?; self.activity.compute_from_stateful( starting_indexes, - &others.iter().map(|v| &v.activity_base().core).collect::>(), + &others.iter().map(|v| v.activity_core()).collect::>(), exit, )?; self.realized.compute_from_stateful( starting_indexes, - &others.iter().map(|v| &v.realized_base().core).collect::>(), + &others.iter().map(|v| v.realized_core()).collect::>(), exit, )?; self.unrealized.compute_from_stateful( @@ -117,7 +117,7 @@ impl CoreCohortMetrics { self.realized .compute_rest_part1(blocks, starting_indexes, exit)?; - self.unrealized.compute_rest(prices, starting_indexes, exit)?; + self.unrealized.compute_rest(blocks, prices, starting_indexes, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index 09290840f..f76c75244 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -2,18 +2,18 @@ use brk_cohort::Filter; use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - Bitcoin, Dollars, Height, Indexes, Sats, SatsSigned, StoredF32, StoredI64, StoredU64, Version, + Dollars, Height, Indexes, Sats, SatsSigned, StoredI64, StoredU64, Version, }; use vecdb::AnyStoredVec; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; -use crate::internal::{ComputedPerBlock, RollingDeltaExcept1m}; +use crate::internal::RollingDeltaExcept1m; use crate::distribution::metrics::{ - ActivityFull, CohortMetricsBase, CostBasis, ImportConfig, OutputsMetrics, - RealizedFull, RelativeWithExtended, SupplyMetrics, UnrealizedFull, + ActivityFull, CohortMetricsBase, CostBasis, ImportConfig, OutputsFull, + RealizedFull, RelativeWithExtended, SupplyFull, UnrealizedFull, }; /// Cohort metrics with extended realized + extended cost basis (no adjusted). @@ -22,15 +22,13 @@ use crate::distribution::metrics::{ pub struct ExtendedCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, + pub supply: Box>, + pub outputs: Box>, pub activity: Box>, pub realized: Box>, pub cost_basis: Box>, pub unrealized: Box>, pub relative: Box>, - pub dormancy: ComputedPerBlock, - pub velocity: ComputedPerBlock, #[traversable(wrap = "supply", rename = "delta")] pub supply_delta_extended: RollingDeltaExcept1m, @@ -70,15 +68,13 @@ impl CohortMetricsBase for ExtendedCohortMetrics { vecs.extend(self.realized.collect_vecs_mut()); vecs.extend(self.cost_basis.collect_vecs_mut()); vecs.extend(self.unrealized.collect_vecs_mut()); - vecs.push(&mut self.dormancy.height); - vecs.push(&mut self.velocity.height); vecs } } impl ExtendedCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let supply = SupplyMetrics::forced_import(cfg)?; + let supply = SupplyFull::forced_import(cfg)?; let unrealized = UnrealizedFull::forced_import(cfg)?; let realized = RealizedFull::forced_import(cfg)?; @@ -87,14 +83,12 @@ impl ExtendedCohortMetrics { Ok(Self { filter: cfg.filter.clone(), supply: Box::new(supply), - outputs: Box::new(OutputsMetrics::forced_import(cfg)?), + outputs: Box::new(OutputsFull::forced_import(cfg)?), activity: Box::new(ActivityFull::forced_import(cfg)?), realized: Box::new(realized), cost_basis: Box::new(CostBasis::forced_import(cfg)?), unrealized: Box::new(unrealized), relative: Box::new(relative), - dormancy: cfg.import("dormancy", Version::ONE)?, - velocity: cfg.import("velocity", Version::ONE)?, supply_delta_extended: cfg.import("supply_delta", Version::ONE)?, utxo_count_delta_extended: cfg.import("utxo_count_delta", Version::ONE)?, }) @@ -142,33 +136,9 @@ impl ExtendedCohortMetrics { exit, )?; - self.dormancy.height.compute_transform2( - starting_indexes.height, - &self.activity.coindays_destroyed.height, - &self.activity.sent.height, - |(i, cdd, sent_sats, ..)| { - let sent_btc = f64::from(Bitcoin::from(sent_sats)); - if sent_btc == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((f64::from(cdd) / sent_btc) as f32)) - } - }, - exit, - )?; - - self.velocity.height.compute_transform2( - starting_indexes.height, - &self.activity.sent.height, + self.activity.compute_rest_part2( + starting_indexes, &self.supply.total.sats.height, - |(i, sent_sats, supply_sats, ..)| { - let supply = supply_sats.as_u128() as f64; - if supply == 0.0 { - (i, StoredF32::from(0.0f32)) - } else { - (i, StoredF32::from((sent_sats.as_u128() as f64 / supply) as f32)) - } - }, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs index ac2d07815..244ec8e8e 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs @@ -7,7 +7,7 @@ use vecdb::{AnyStoredVec, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityFull, CohortMetricsBase, ImportConfig, RealizedAdjusted, + ActivityFull, CohortMetricsBase, ImportConfig, AdjustedSopr, RealizedFull, UnrealizedFull, }; @@ -22,7 +22,8 @@ pub struct ExtendedAdjustedCohortMetrics { #[deref_mut] #[traversable(flatten)] pub inner: ExtendedCohortMetrics, - pub adjusted: Box>, + #[traversable(wrap = "realized/sopr", rename = "adjusted")] + pub asopr: Box>, } impl CohortMetricsBase for ExtendedAdjustedCohortMetrics { @@ -48,10 +49,10 @@ impl CohortMetricsBase for ExtendedAdjustedCohortMetrics { impl ExtendedAdjustedCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let inner = ExtendedCohortMetrics::forced_import(cfg)?; - let adjusted = RealizedAdjusted::forced_import(cfg)?; + let asopr = AdjustedSopr::forced_import(cfg)?; Ok(Self { inner, - adjusted: Box::new(adjusted), + asopr: Box::new(asopr), }) } @@ -76,11 +77,11 @@ impl ExtendedAdjustedCohortMetrics { exit, )?; - self.adjusted.compute_rest_part2( + self.asopr.compute_rest_part2( blocks, starting_indexes, - &self.inner.realized.value_created.height, - &self.inner.realized.value_destroyed.height, + &self.inner.realized.minimal.sopr.value_created.raw.height, + &self.inner.realized.minimal.sopr.value_destroyed.raw.height, up_to_1h_value_created, up_to_1h_value_destroyed, exit, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs index 438c5f605..f2f924a59 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs @@ -1,41 +1,35 @@ use brk_cohort::Filter; use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Indexes, Version}; +use brk_types::Indexes; use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; -use crate::distribution::metrics::unrealized::UnrealizedMinimal; use crate::{blocks, prices}; use crate::distribution::metrics::{ - ActivityCore, ImportConfig, OutputsMetrics, RealizedMinimal, SupplyMetrics, + ImportConfig, OutputsBase, RealizedMinimal, SupplyBase, }; -/// MinimalCohortMetrics: supply, outputs, sent+ema, realized cap/price/mvrv/profit/loss, -/// supply in profit/loss. +/// MinimalCohortMetrics: supply, outputs, realized cap/price/mvrv/profit/loss + value_created/destroyed. /// -/// Used for type_, amount, and address cohorts. +/// Used for amount_range cohorts. /// Does NOT implement CohortMetricsBase — standalone, not aggregatable via trait. #[derive(Traversable)] pub struct MinimalCohortMetrics { #[traversable(skip)] pub filter: Filter, - pub supply: Box>, - pub outputs: Box>, - pub activity: Box>, + pub supply: Box>, + pub outputs: Box>, pub realized: Box>, - pub unrealized: Box>, } impl MinimalCohortMetrics { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { Ok(Self { filter: cfg.filter.clone(), - supply: Box::new(SupplyMetrics::forced_import(cfg)?), - outputs: Box::new(OutputsMetrics::forced_import(cfg)?), - activity: Box::new(ActivityCore::forced_import(cfg)?), + supply: Box::new(SupplyBase::forced_import(cfg)?), + outputs: Box::new(OutputsBase::forced_import(cfg)?), realized: Box::new(RealizedMinimal::forced_import(cfg)?), - unrealized: Box::new(UnrealizedMinimal::forced_import(cfg)?), }) } @@ -43,23 +37,14 @@ impl MinimalCohortMetrics { self.supply .min_len() .min(self.outputs.min_len()) - .min(self.activity.min_len()) .min(self.realized.min_stateful_height_len()) - .min(self.unrealized.min_stateful_height_len()) - } - - pub(crate) fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { - self.supply.validate_computed_versions(base_version)?; - Ok(()) } pub(crate) fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { let mut vecs: Vec<&mut dyn AnyStoredVec> = Vec::new(); vecs.extend(self.supply.collect_vecs_mut()); vecs.extend(self.outputs.collect_vecs_mut()); - vecs.extend(self.activity.collect_vecs_mut()); vecs.extend(self.realized.collect_vecs_mut()); - vecs.extend(self.unrealized.collect_vecs_mut()); vecs } @@ -83,14 +68,6 @@ impl MinimalCohortMetrics { .collect::>(), exit, )?; - self.activity.compute_from_stateful( - starting_indexes, - &others - .iter() - .map(|v| v.activity.as_ref()) - .collect::>(), - exit, - )?; self.realized.compute_from_stateful( starting_indexes, &others @@ -99,14 +76,6 @@ impl MinimalCohortMetrics { .collect::>(), exit, )?; - self.unrealized.compute_from_sources( - starting_indexes, - &others - .iter() - .map(|v| v.unrealized.as_ref()) - .collect::>(), - exit, - )?; Ok(()) } @@ -118,15 +87,8 @@ impl MinimalCohortMetrics { exit: &Exit, ) -> Result<()> { self.supply.compute(prices, starting_indexes.height, exit)?; - self.supply - .compute_rest_part1(blocks, starting_indexes, exit)?; - self.outputs.compute_rest(blocks, starting_indexes, exit)?; - self.activity - .compute_rest_part1(blocks, starting_indexes, exit)?; self.realized .compute_rest_part1(blocks, starting_indexes, exit)?; - self.unrealized - .compute_rest(prices, starting_indexes.height, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/mod.rs b/crates/brk_computer/src/distribution/metrics/cohort/mod.rs index 55c950bc6..25f31a548 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/mod.rs @@ -4,6 +4,7 @@ mod core; mod extended; mod extended_adjusted; mod minimal; +mod r#type; pub use all::AllCohortMetrics; pub use basic::BasicCohortMetrics; @@ -11,3 +12,4 @@ pub use core::CoreCohortMetrics; pub use extended::ExtendedCohortMetrics; pub use extended_adjusted::ExtendedAdjustedCohortMetrics; pub use minimal::MinimalCohortMetrics; +pub use r#type::TypeCohortMetrics; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/type.rs b/crates/brk_computer/src/distribution/metrics/cohort/type.rs new file mode 100644 index 000000000..b4a441a22 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/cohort/type.rs @@ -0,0 +1,83 @@ +use brk_cohort::Filter; +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::Indexes; +use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; + +use crate::{blocks, prices}; + +use crate::distribution::metrics::{ + ImportConfig, OutputsBase, RealizedMinimal, SupplyBase, UnrealizedBasic, +}; + +/// TypeCohortMetrics: supply(base), 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 outputs: Box>, + pub realized: Box>, + pub unrealized: Box>, +} + +impl TypeCohortMetrics { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + Ok(Self { + filter: cfg.filter.clone(), + supply: Box::new(SupplyBase::forced_import(cfg)?), + outputs: Box::new(OutputsBase::forced_import(cfg)?), + realized: Box::new(RealizedMinimal::forced_import(cfg)?), + unrealized: Box::new(UnrealizedBasic::forced_import(cfg)?), + }) + } + + pub(crate) fn min_stateful_height_len(&self) -> usize { + self.supply + .min_len() + .min(self.outputs.min_len()) + .min(self.realized.min_stateful_height_len()) + .min(self.unrealized.min_stateful_height_len()) + } + + pub(crate) fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + let mut vecs: Vec<&mut dyn AnyStoredVec> = Vec::new(); + vecs.extend(self.supply.collect_vecs_mut()); + vecs.extend(self.outputs.collect_vecs_mut()); + vecs.extend(self.realized.collect_vecs_mut()); + vecs.extend(self.unrealized.collect_vecs_mut()); + vecs + } + + pub(crate) fn compute_rest_part1( + &mut self, + blocks: &blocks::Vecs, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.supply.compute(prices, starting_indexes.height, exit)?; + self.realized + .compute_rest_part1(blocks, starting_indexes, exit)?; + self.unrealized + .compute_rest(blocks, prices, starting_indexes.height, exit)?; + Ok(()) + } + + pub(crate) fn compute_rest_part2( + &mut self, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.realized.compute_rest_part2( + prices, + starting_indexes, + &self.supply.total.btc.height, + exit, + )?; + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/config.rs b/crates/brk_computer/src/distribution/metrics/config.rs index e6051dc39..3353bcade 100644 --- a/crates/brk_computer/src/distribution/metrics/config.rs +++ b/crates/brk_computer/src/distribution/metrics/config.rs @@ -7,11 +7,13 @@ use vecdb::{BytesVec, BytesVecValue, Database, ImportableVec}; use crate::{ indexes, internal::{ - AmountPerBlock, AmountPerBlockCumulative, CentsType, ComputedPerBlock, - ComputedPerBlockCumulative, ComputedPerBlockCumulativeSum, RatioPerBlock, + AmountPerBlock, AmountPerBlockCumulative, AmountPerBlockWithSum24h, CentsType, ComputedPerBlock, + ComputedPerBlockCumulative, ComputedPerBlockCumulativeSum, FiatPerBlockWithSum24h, + PerBlockWithSum24h, RatioPerBlock, RollingWindow24hAmountPerBlock, + RollingWindow24hFiatPerBlock, RollingWindow24hPerBlock, FiatPerBlock, FiatRollingDelta1m, FiatRollingDeltaExcept1m, NumericValue, PercentPerBlock, PercentRollingWindows, Price, RollingDelta1m, RollingDeltaExcept1m, - RollingWindow24h, RollingWindows, RollingWindowsFrom1w, + RollingWindows, RollingWindowsFrom1w, }, }; @@ -37,7 +39,9 @@ macro_rules! impl_config_import { impl_config_import!( AmountPerBlock, AmountPerBlockCumulative, - RatioPerBlock, + RollingWindow24hAmountPerBlock, + RatioPerBlock, + RatioPerBlock, PercentPerBlock, PercentPerBlock, PercentPerBlock, @@ -66,11 +70,40 @@ impl ConfigImport for RollingWindows { Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) } } -impl ConfigImport for RollingWindow24h { +impl ConfigImport for RollingWindow24hPerBlock { fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) } } +impl ConfigImport for PerBlockWithSum24h { + fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { + Ok(Self { + raw: ComputedPerBlock::config_import(cfg, suffix, offset)?, + sum: RollingWindow24hPerBlock::config_import(cfg, suffix, offset)?, + }) + } +} +impl ConfigImport for AmountPerBlockWithSum24h { + fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { + Ok(Self { + raw: AmountPerBlock::config_import(cfg, suffix, offset)?, + sum: RollingWindow24hAmountPerBlock::config_import(cfg, suffix, offset)?, + }) + } +} +impl ConfigImport for RollingWindow24hFiatPerBlock { + fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { + Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) + } +} +impl ConfigImport for FiatPerBlockWithSum24h { + fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { + Ok(Self { + raw: FiatPerBlock::config_import(cfg, suffix, offset)?, + sum: RollingWindow24hFiatPerBlock::config_import(cfg, suffix, offset)?, + }) + } +} impl ConfigImport for RollingWindowsFrom1w { fn config_import(cfg: &ImportConfig, suffix: &str, offset: Version) -> Result { Self::forced_import(cfg.db, &cfg.name(suffix), cfg.version + offset, cfg.indexes) diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index d3c08e25c..c541f0245 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -19,10 +19,10 @@ mod activity; macro_rules! impl_cohort_accessors { () => { fn filter(&self) -> &brk_cohort::Filter { &self.filter } - fn supply(&self) -> &$crate::distribution::metrics::SupplyMetrics { &self.supply } - fn supply_mut(&mut self) -> &mut $crate::distribution::metrics::SupplyMetrics { &mut self.supply } - fn outputs(&self) -> &$crate::distribution::metrics::OutputsMetrics { &self.outputs } - fn outputs_mut(&mut self) -> &mut $crate::distribution::metrics::OutputsMetrics { &mut self.outputs } + fn supply(&self) -> &$crate::distribution::metrics::SupplyFull { &self.supply } + fn supply_mut(&mut self) -> &mut $crate::distribution::metrics::SupplyFull { &mut self.supply } + fn outputs(&self) -> &$crate::distribution::metrics::OutputsFull { &self.outputs } + fn outputs_mut(&mut self) -> &mut $crate::distribution::metrics::OutputsFull { &mut self.outputs } fn activity(&self) -> &Self::ActivityVecs { &self.activity } fn activity_mut(&mut self) -> &mut Self::ActivityVecs { &mut self.activity } fn realized(&self) -> &Self::RealizedVecs { &self.realized } @@ -42,24 +42,24 @@ mod relative; mod supply; mod unrealized; -pub use activity::{ActivityBase, ActivityCore, ActivityFull, ActivityLike}; +pub use activity::{ActivityCore, ActivityFull, ActivityLike}; pub use cohort::{ - AllCohortMetrics, BasicCohortMetrics, CoreCohortMetrics, ExtendedAdjustedCohortMetrics, - ExtendedCohortMetrics, MinimalCohortMetrics, + AllCohortMetrics, BasicCohortMetrics, CoreCohortMetrics, + ExtendedAdjustedCohortMetrics, ExtendedCohortMetrics, MinimalCohortMetrics, TypeCohortMetrics, }; pub use config::ImportConfig; pub use cost_basis::CostBasis; pub use profitability::ProfitabilityMetrics; -pub use outputs::OutputsMetrics; +pub use outputs::{OutputsBase, OutputsFull}; pub use realized::{ - RealizedAdjusted, RealizedBase, RealizedCore, RealizedFull, RealizedFullAccum, RealizedLike, + AdjustedSopr, RealizedCore, RealizedFull, RealizedFullAccum, RealizedLike, RealizedMinimal, }; pub use relative::{ RelativeForAll, RelativeToAll, RelativeWithExtended, }; -pub use supply::SupplyMetrics; -pub use unrealized::{UnrealizedBase, UnrealizedCore, UnrealizedFull, UnrealizedLike}; +pub use supply::{SupplyBase, SupplyFull}; +pub use unrealized::{UnrealizedBase, UnrealizedBasic, UnrealizedCore, UnrealizedFull, UnrealizedLike}; use brk_cohort::Filter; use brk_error::Result; @@ -72,6 +72,9 @@ pub trait CohortMetricsState { type Realized: RealizedOps; } +impl CohortMetricsState for TypeCohortMetrics { + type Realized = MinimalRealizedState; +} impl CohortMetricsState for MinimalCohortMetrics { type Realized = MinimalRealizedState; } @@ -97,10 +100,10 @@ pub trait CohortMetricsBase: CohortMetricsState + Send type UnrealizedVecs: UnrealizedLike; fn filter(&self) -> &Filter; - fn supply(&self) -> &SupplyMetrics; - fn supply_mut(&mut self) -> &mut SupplyMetrics; - fn outputs(&self) -> &OutputsMetrics; - fn outputs_mut(&mut self) -> &mut OutputsMetrics; + fn supply(&self) -> &SupplyFull; + fn supply_mut(&mut self) -> &mut SupplyFull; + fn outputs(&self) -> &OutputsFull; + fn outputs_mut(&mut self) -> &mut OutputsFull; fn activity(&self) -> &Self::ActivityVecs; fn activity_mut(&mut self) -> &mut Self::ActivityVecs; fn realized(&self) -> &Self::RealizedVecs; @@ -108,13 +111,13 @@ pub trait CohortMetricsBase: CohortMetricsState + Send fn unrealized(&self) -> &Self::UnrealizedVecs; fn unrealized_mut(&mut self) -> &mut Self::UnrealizedVecs; - /// Convenience: access activity as `&ActivityBase` (via `ActivityLike::as_base`). - fn activity_base(&self) -> &ActivityBase { self.activity().as_base() } - fn activity_base_mut(&mut self) -> &mut ActivityBase { self.activity_mut().as_base_mut() } + /// Convenience: access activity as `&ActivityCore` (via `ActivityLike::as_core`). + fn activity_core(&self) -> &ActivityCore { self.activity().as_core() } + fn activity_core_mut(&mut self) -> &mut ActivityCore { self.activity_mut().as_core_mut() } - /// Convenience: access realized as `&RealizedBase` (via `RealizedLike::as_base`). - fn realized_base(&self) -> &RealizedBase { self.realized().as_base() } - fn realized_base_mut(&mut self) -> &mut RealizedBase { self.realized_mut().as_base_mut() } + /// Convenience: access realized as `&RealizedCore` (via `RealizedLike::as_core`). + fn realized_core(&self) -> &RealizedCore { self.realized().as_core() } + fn realized_core_mut(&mut self) -> &mut RealizedCore { self.realized_mut().as_core_mut() } /// Convenience: access unrealized as `&UnrealizedBase` (via `UnrealizedLike::as_base`). fn unrealized_base(&self) -> &UnrealizedBase { self.unrealized().as_base() } @@ -152,18 +155,10 @@ pub trait CohortMetricsBase: CohortMetricsState + Send } fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { - self.supply_mut() - .truncate_push(height, state.supply.value)?; - self.outputs_mut() - .truncate_push(height, state.supply.utxo_count)?; - self.activity_mut().truncate_push( - height, - state.sent, - state.satblocks_destroyed, - state.satdays_destroyed, - )?; - self.realized_mut() - .truncate_push(height, &state.realized)?; + self.supply_mut().truncate_push(height, state)?; + self.outputs_mut().truncate_push(height, state)?; + self.activity_mut().truncate_push(height, state)?; + self.realized_mut().truncate_push(height, state)?; Ok(()) } @@ -188,7 +183,7 @@ pub trait CohortMetricsBase: CohortMetricsState + Send .compute_rest_part1(blocks, starting_indexes, exit)?; self.unrealized_mut() - .compute_rest(prices, starting_indexes, exit)?; + .compute_rest(blocks, prices, starting_indexes, exit)?; self.unrealized_mut() .compute_net_sentiment_height(starting_indexes, exit)?; @@ -215,12 +210,12 @@ pub trait CohortMetricsBase: CohortMetricsState + Send )?; self.activity_mut().compute_from_stateful( starting_indexes, - &others.iter().map(|v| v.activity_base()).collect::>(), + &others.iter().map(|v| v.activity_core()).collect::>(), exit, )?; self.realized_mut().compute_from_stateful( starting_indexes, - &others.iter().map(|v| v.realized_base()).collect::>(), + &others.iter().map(|v| v.realized_core()).collect::>(), exit, )?; self.unrealized_base_mut().compute_from_stateful( diff --git a/crates/brk_computer/src/distribution/metrics/outputs.rs b/crates/brk_computer/src/distribution/metrics/outputs.rs deleted file mode 100644 index 6dacc7130..000000000 --- a/crates/brk_computer/src/distribution/metrics/outputs.rs +++ /dev/null @@ -1,77 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Indexes, StoredI64, StoredU64, Version}; -use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; - -use crate::{blocks, internal::{ComputedPerBlock, RollingDelta1m}}; - -use super::ImportConfig; - -/// Output metrics for a cohort. -#[derive(Traversable)] -pub struct OutputsMetrics { - pub utxo_count: ComputedPerBlock, - pub utxo_count_delta: RollingDelta1m, -} - -impl OutputsMetrics { - /// Import output metrics from database. - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - Ok(Self { - utxo_count: cfg.import("utxo_count", Version::ZERO)?, - utxo_count_delta: cfg.import("utxo_count_delta", Version::ONE)?, - }) - } - - /// Get minimum length across height-indexed vectors. - pub(crate) fn min_len(&self) -> usize { - self.utxo_count.height.len() - } - - /// Push utxo count to height-indexed vector. - pub(crate) fn truncate_push(&mut self, height: Height, utxo_count: u64) -> Result<()> { - self.utxo_count - .height - .truncate_push(height, StoredU64::from(utxo_count))?; - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - vec![&mut self.utxo_count.height as &mut dyn AnyStoredVec] - } - - /// Compute aggregate values from separate cohorts. - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - self.utxo_count.height.compute_sum_of_others( - starting_indexes.height, - &others - .iter() - .map(|v| &v.utxo_count.height) - .collect::>(), - exit, - )?; - Ok(()) - } - - /// Compute derived metrics. - pub(crate) fn compute_rest( - &mut self, - blocks: &blocks::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.utxo_count_delta.compute( - starting_indexes.height, - &blocks.lookback.height_1m_ago, - &self.utxo_count.height, - exit, - )?; - - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/outputs/base.rs b/crates/brk_computer/src/distribution/metrics/outputs/base.rs new file mode 100644 index 000000000..2d927fe93 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/outputs/base.rs @@ -0,0 +1,54 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{Height, Indexes, StoredU64, Version}; +use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; + +use crate::{distribution::state::{CohortState, RealizedOps}, internal::ComputedPerBlock}; + +use crate::distribution::metrics::ImportConfig; + +/// Base output metrics: utxo_count only (1 stored vec). +#[derive(Traversable)] +pub struct OutputsBase { + pub utxo_count: ComputedPerBlock, +} + +impl OutputsBase { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + Ok(Self { + utxo_count: cfg.import("utxo_count", Version::ZERO)?, + }) + } + + pub(crate) fn min_len(&self) -> usize { + self.utxo_count.height.len() + } + + pub(crate) fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { + self.utxo_count + .height + .truncate_push(height, StoredU64::from(state.supply.utxo_count))?; + Ok(()) + } + + pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + vec![&mut self.utxo_count.height as &mut dyn AnyStoredVec] + } + + pub(crate) fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&Self], + exit: &Exit, + ) -> Result<()> { + self.utxo_count.height.compute_sum_of_others( + starting_indexes.height, + &others + .iter() + .map(|v| &v.utxo_count.height) + .collect::>(), + exit, + )?; + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/outputs/full.rs b/crates/brk_computer/src/distribution/metrics/outputs/full.rs new file mode 100644 index 000000000..1399f0295 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/outputs/full.rs @@ -0,0 +1,64 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{Indexes, StoredI64, StoredU64, Version}; +use derive_more::{Deref, DerefMut}; +use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; + +use crate::{blocks, internal::RollingDelta1m}; + +use crate::distribution::metrics::ImportConfig; + +use super::OutputsBase; + +/// Full output metrics: utxo_count + delta (3 stored vecs). +#[derive(Deref, DerefMut, Traversable)] +pub struct OutputsFull { + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub base: OutputsBase, + + pub utxo_count_delta: RollingDelta1m, +} + +impl OutputsFull { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let base = OutputsBase::forced_import(cfg)?; + let utxo_count_delta = cfg.import("utxo_count_delta", Version::ONE)?; + + Ok(Self { + base, + utxo_count_delta, + }) + } + + pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + self.base.collect_vecs_mut() + } + + pub(crate) fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&Self], + exit: &Exit, + ) -> Result<()> { + let base_refs: Vec<&OutputsBase> = others.iter().map(|o| &o.base).collect(); + self.base.compute_from_stateful(starting_indexes, &base_refs, exit) + } + + pub(crate) fn compute_rest( + &mut self, + blocks: &blocks::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.utxo_count_delta.compute( + starting_indexes.height, + &blocks.lookback.height_1m_ago, + &self.base.utxo_count.height, + exit, + )?; + + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/outputs/mod.rs b/crates/brk_computer/src/distribution/metrics/outputs/mod.rs new file mode 100644 index 000000000..73441acb9 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/outputs/mod.rs @@ -0,0 +1,5 @@ +mod base; +mod full; + +pub use base::OutputsBase; +pub use full::OutputsFull; diff --git a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs index a17377706..ae36c2ad1 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/adjusted.rs @@ -11,22 +11,22 @@ use crate::{ use crate::distribution::metrics::ImportConfig; #[derive(Traversable)] -pub struct RealizedAdjusted { +pub struct AdjustedSopr { pub value_created: ComputedPerBlock, pub value_destroyed: ComputedPerBlock, pub value_created_sum: RollingWindows, pub value_destroyed_sum: RollingWindows, - pub sopr: RollingWindows, + pub ratio: RollingWindows, } -impl RealizedAdjusted { +impl AdjustedSopr { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - Ok(RealizedAdjusted { + Ok(Self { value_created: cfg.import("adjusted_value_created", Version::ZERO)?, value_destroyed: cfg.import("adjusted_value_destroyed", Version::ZERO)?, value_created_sum: cfg.import("adjusted_value_created", Version::ONE)?, value_destroyed_sum: cfg.import("adjusted_value_destroyed", Version::ONE)?, - sopr: cfg.import("adjusted_sopr", Version::ONE)?, + ratio: cfg.import("adjusted_sopr", Version::ONE)?, }) } @@ -72,7 +72,7 @@ impl RealizedAdjusted { // SOPR ratios from rolling sums for ((sopr, vc), vd) in self - .sopr + .ratio .as_mut_array() .into_iter() .zip(self.value_created_sum.as_array()) diff --git a/crates/brk_computer/src/distribution/metrics/realized/base.rs b/crates/brk_computer/src/distribution/metrics/realized/base.rs deleted file mode 100644 index f76960c18..000000000 --- a/crates/brk_computer/src/distribution/metrics/realized/base.rs +++ /dev/null @@ -1,106 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{Height, Indexes, Sats, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; - -use crate::{ - blocks, - distribution::state::RealizedOps, - internal::{ComputedPerBlock, RollingWindow24h}, -}; - -use crate::distribution::metrics::ImportConfig; - -use super::RealizedCore; - -#[derive(Deref, DerefMut, Traversable)] -pub struct RealizedBase { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub core: RealizedCore, - - pub sent_in_profit: ComputedPerBlock, - pub sent_in_loss: ComputedPerBlock, - - pub sent_in_profit_sum: RollingWindow24h, - pub sent_in_loss_sum: RollingWindow24h, -} - -impl RealizedBase { - pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v1 = Version::ONE; - - Ok(Self { - core: RealizedCore::forced_import(cfg)?, - sent_in_profit: cfg.import("sent_in_profit", v1)?, - sent_in_loss: cfg.import("sent_in_loss", v1)?, - sent_in_profit_sum: cfg.import("sent_in_profit", v1)?, - sent_in_loss_sum: cfg.import("sent_in_loss", v1)?, - }) - } - - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.core - .min_stateful_height_len() - .min(self.sent_in_profit.height.len()) - .min(self.sent_in_loss.height.len()) - } - - pub(crate) fn truncate_push(&mut self, height: Height, state: &impl RealizedOps) -> Result<()> { - self.core.truncate_push(height, state)?; - self.sent_in_profit - .height - .truncate_push(height, state.sent_in_profit())?; - self.sent_in_loss - .height - .truncate_push(height, state.sent_in_loss())?; - Ok(()) - } - - pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - let mut vecs = self.core.collect_vecs_mut(); - vecs.push(&mut self.sent_in_profit.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.sent_in_loss.height); - vecs - } - - pub(crate) fn compute_from_stateful( - &mut self, - starting_indexes: &Indexes, - others: &[&Self], - exit: &Exit, - ) -> Result<()> { - let core_refs: Vec<&RealizedCore> = others.iter().map(|o| &o.core).collect(); - self.core - .compute_from_stateful(starting_indexes, &core_refs, exit)?; - - sum_others!(self, starting_indexes, others, exit; sent_in_profit.height); - sum_others!(self, starting_indexes, others, exit; sent_in_loss.height); - - Ok(()) - } - - pub(crate) fn compute_rest_part1( - &mut self, - blocks: &blocks::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.core.compute_rest_part1(blocks, starting_indexes, exit)?; - self.sent_in_profit_sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback.height_24h_ago, - &self.sent_in_profit.height, - exit, - )?; - self.sent_in_loss_sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback.height_24h_ago, - &self.sent_in_loss.height, - exit, - )?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/distribution/metrics/realized/core.rs b/crates/brk_computer/src/distribution/metrics/realized/core.rs index 6f72821dc..d87e964ff 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/core.rs @@ -8,10 +8,11 @@ use vecdb::{ use crate::{ blocks, - distribution::state::RealizedOps, + distribution::state::{CohortState, RealizedOps}, internal::{ - ComputedPerBlock, FiatRollingDelta1m, LazyPerBlock, NegCentsUnsignedToDollars, - RatioCents64, RollingWindow24h, + AmountPerBlockWithSum24h, ComputedPerBlock, FiatRollingDelta1m, LazyPerBlock, + NegCentsUnsignedToDollars, PerBlockWithSum24h, RatioCents64, + RollingWindow24hPerBlock, }, prices, }; @@ -20,6 +21,17 @@ use crate::distribution::metrics::ImportConfig; use super::RealizedMinimal; +#[derive(Traversable)] +pub struct RealizedSoprCore { + pub ratio: RollingWindow24hPerBlock, +} + +#[derive(Traversable)] +pub struct RealizedSentCore { + pub in_profit: AmountPerBlockWithSum24h, + pub in_loss: AmountPerBlockWithSum24h, +} + #[derive(Deref, DerefMut, Traversable)] pub struct RealizedCore { #[deref] @@ -27,17 +39,19 @@ pub struct RealizedCore { #[traversable(flatten)] pub minimal: RealizedMinimal, + #[traversable(wrap = "profit", rename = "cumulative")] + pub profit_cumulative: ComputedPerBlock, + #[traversable(wrap = "loss", rename = "cumulative")] + pub loss_cumulative: ComputedPerBlock, + + #[traversable(wrap = "cap", rename = "delta")] pub cap_delta: FiatRollingDelta1m, + #[traversable(wrap = "loss", rename = "neg")] pub neg_loss: LazyPerBlock, - pub net_pnl: ComputedPerBlock, - pub net_pnl_sum: RollingWindow24h, - - pub value_created: ComputedPerBlock, - pub value_destroyed: ComputedPerBlock, - pub value_created_sum: RollingWindow24h, - pub value_destroyed_sum: RollingWindow24h, - pub sopr: RollingWindow24h, + pub net_pnl: PerBlockWithSum24h, + pub sopr: RealizedSoprCore, + pub sent: RealizedSentCore, } impl RealizedCore { @@ -50,55 +64,57 @@ impl RealizedCore { let neg_realized_loss = LazyPerBlock::from_height_source::( &cfg.name("neg_realized_loss"), cfg.version + Version::ONE, - minimal.loss.height.read_only_boxed_clone(), + minimal.loss.raw.cents.height.read_only_boxed_clone(), cfg.indexes, ); - let net_realized_pnl = cfg.import("net_realized_pnl", v1)?; - let net_realized_pnl_sum = cfg.import("net_realized_pnl", v1)?; - - let value_created = cfg.import("value_created", v0)?; - let value_destroyed = cfg.import("value_destroyed", v0)?; - let value_created_sum = cfg.import("value_created", v1)?; - let value_destroyed_sum = cfg.import("value_destroyed", v1)?; - let sopr = cfg.import("sopr", v1)?; - Ok(Self { minimal, + profit_cumulative: cfg.import("realized_profit_cumulative", v0)?, + loss_cumulative: cfg.import("realized_loss_cumulative", v0)?, cap_delta: cfg.import("realized_cap_delta", v1)?, neg_loss: neg_realized_loss, - net_pnl: net_realized_pnl, - net_pnl_sum: net_realized_pnl_sum, - value_created, - value_destroyed, - value_created_sum, - value_destroyed_sum, - sopr, + net_pnl: cfg.import("net_realized_pnl", v1)?, + sopr: RealizedSoprCore { + ratio: cfg.import("sopr", v1)?, + }, + sent: RealizedSentCore { + in_profit: cfg.import("sent_in_profit", v1)?, + in_loss: cfg.import("sent_in_loss", v1)?, + }, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { self.minimal .min_stateful_height_len() - .min(self.value_created.height.len()) - .min(self.value_destroyed.height.len()) + .min(self.sent.in_profit.raw.sats.height.len()) + .min(self.sent.in_loss.raw.sats.height.len()) } - pub(crate) fn truncate_push(&mut self, height: Height, state: &impl RealizedOps) -> Result<()> { + pub(crate) fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { self.minimal.truncate_push(height, state)?; - self.value_created + self.sent + .in_profit + .raw + .sats .height - .truncate_push(height, state.value_created())?; - self.value_destroyed + .truncate_push(height, state.realized.sent_in_profit())?; + self.sent + .in_loss + .raw + .sats .height - .truncate_push(height, state.value_destroyed())?; + .truncate_push(height, state.realized.sent_in_loss())?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { let mut vecs = self.minimal.collect_vecs_mut(); - vecs.push(&mut self.value_created.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.value_destroyed.height); + vecs.push(&mut self.sent.in_profit.raw.sats.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.sent.in_profit.raw.cents.height); + vecs.push(&mut self.sent.in_loss.raw.sats.height); + vecs.push(&mut self.sent.in_loss.raw.cents.height); vecs } @@ -112,8 +128,10 @@ impl RealizedCore { self.minimal .compute_from_stateful(starting_indexes, &minimal_refs, exit)?; - sum_others!(self, starting_indexes, others, exit; value_created.height); - sum_others!(self, starting_indexes, others, exit; value_destroyed.height); + sum_others!(self, starting_indexes, others, exit; sent.in_profit.raw.sats.height); + sum_others!(self, starting_indexes, others, exit; sent.in_profit.raw.cents.height); + sum_others!(self, starting_indexes, others, exit; sent.in_loss.raw.sats.height); + sum_others!(self, starting_indexes, others, exit; sent.in_loss.raw.cents.height); Ok(()) } @@ -127,10 +145,21 @@ impl RealizedCore { self.minimal .compute_rest_part1(blocks, starting_indexes, exit)?; - self.net_pnl.height.compute_transform2( + self.profit_cumulative.height.compute_cumulative( starting_indexes.height, - &self.minimal.profit.height, - &self.minimal.loss.height, + &self.minimal.profit.raw.cents.height, + exit, + )?; + self.loss_cumulative.height.compute_cumulative( + starting_indexes.height, + &self.minimal.loss.raw.cents.height, + exit, + )?; + + self.net_pnl.raw.height.compute_transform2( + starting_indexes.height, + &self.minimal.profit.raw.cents.height, + &self.minimal.loss.raw.cents.height, |(i, profit, loss, ..)| { ( i, @@ -157,39 +186,51 @@ impl RealizedCore { self.cap_delta.compute( starting_indexes.height, &blocks.lookback.height_1m_ago, - &self.minimal.cap_cents.height, + &self.minimal.cap.cents.height, exit, )?; - self.net_pnl_sum.compute_rolling_sum( + self.net_pnl.sum.compute_rolling_sum( starting_indexes.height, &blocks.lookback.height_24h_ago, - &self.net_pnl.height, - exit, - )?; - - self.value_created_sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback.height_24h_ago, - &self.value_created.height, - exit, - )?; - self.value_destroyed_sum.compute_rolling_sum( - starting_indexes.height, - &blocks.lookback.height_24h_ago, - &self.value_destroyed.height, + &self.net_pnl.raw.height, exit, )?; self.sopr + .ratio ._24h .compute_binary::( starting_indexes.height, - &self.value_created_sum._24h.height, - &self.value_destroyed_sum._24h.height, + &self.minimal.sopr.value_created.sum._24h.height, + &self.minimal.sopr.value_destroyed.sum._24h.height, exit, )?; + self.sent + .in_profit + .raw + .compute(prices, starting_indexes.height, exit)?; + self.sent + .in_loss + .raw + .compute(prices, starting_indexes.height, exit)?; + + self.sent.in_profit.sum.compute_rolling_sum( + starting_indexes.height, + &blocks.lookback.height_24h_ago, + &self.sent.in_profit.raw.sats.height, + &self.sent.in_profit.raw.cents.height, + exit, + )?; + self.sent.in_loss.sum.compute_rolling_sum( + starting_indexes.height, + &blocks.lookback.height_24h_ago, + &self.sent.in_loss.raw.sats.height, + &self.sent.in_loss.raw.cents.height, + exit, + )?; + Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/realized/full.rs b/crates/brk_computer/src/distribution/metrics/realized/full.rs index 1468d7e57..f8333c932 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -12,7 +12,7 @@ use vecdb::{ use crate::{ blocks, - distribution::state::RealizedState, + distribution::state::{CohortState, RealizedState}, internal::{ CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative, FiatPerBlock, FiatRollingDelta1m, FiatRollingDeltaExcept1m, LazyPerBlock, PercentPerBlock, @@ -25,86 +25,118 @@ use crate::{ use crate::distribution::metrics::ImportConfig; -use super::RealizedBase; +use super::RealizedCore; + +#[derive(Traversable)] +pub struct RealizedProfit { + pub rel_to_rcap: PercentPerBlock, + pub value_created: ComputedPerBlock, + pub value_destroyed: ComputedPerBlock, + pub value_created_sum: RollingWindows, + pub value_destroyed_sum: RollingWindows, + pub flow: LazyPerBlock, + #[traversable(rename = "sum")] + pub sum_extended: RollingWindowsFrom1w, +} + +#[derive(Traversable)] +pub struct RealizedLoss { + pub rel_to_rcap: PercentPerBlock, + pub value_created: ComputedPerBlock, + pub value_destroyed: ComputedPerBlock, + pub value_created_sum: RollingWindows, + pub value_destroyed_sum: RollingWindows, + pub capitulation_flow: LazyPerBlock, + #[traversable(rename = "sum")] + pub sum_extended: RollingWindowsFrom1w, +} + +#[derive(Traversable)] +pub struct RealizedGrossPnl { + #[traversable(flatten)] + pub value: FiatPerBlock, + pub sum: RollingWindows, + pub sell_side_risk_ratio: PercentRollingWindows, +} + +#[derive(Traversable)] +pub struct RealizedNetPnl { + pub rel_to_rcap: PercentPerBlock, + pub cumulative: ComputedPerBlock, + #[traversable(rename = "sum")] + pub sum_extended: RollingWindowsFrom1w, + pub delta: FiatRollingDelta1m, + #[traversable(rename = "delta")] + pub delta_extended: FiatRollingDeltaExcept1m, + pub change_1m_rel_to_rcap: PercentPerBlock, + pub change_1m_rel_to_mcap: PercentPerBlock, +} + +#[derive(Traversable)] +pub struct RealizedSopr { + #[traversable(rename = "value_created_sum")] + pub value_created_sum_extended: RollingWindowsFrom1w, + #[traversable(rename = "value_destroyed_sum")] + pub value_destroyed_sum_extended: RollingWindowsFrom1w, + #[traversable(rename = "ratio")] + pub ratio_extended: RollingWindowsFrom1w, +} + +#[derive(Traversable)] +pub struct RealizedSentFull { + #[traversable(wrap = "in_profit", rename = "sum")] + pub in_profit_sum_extended: RollingWindowsFrom1w, + #[traversable(wrap = "in_loss", rename = "sum")] + pub in_loss_sum_extended: RollingWindowsFrom1w, +} + +#[derive(Traversable)] +pub struct RealizedPeakRegret { + #[traversable(flatten)] + pub value: ComputedPerBlockCumulative, + pub rel_to_rcap: PercentPerBlock, +} + +#[derive(Traversable)] +pub struct RealizedInvestor { + pub price: Price>, + pub price_ratio: RatioPerBlock, + pub lower_price_band: Price>, + pub upper_price_band: Price>, + pub cap_raw: M::Stored>, + pub price_ratio_percentiles: RatioPerBlockPercentiles, +} #[derive(Deref, DerefMut, Traversable)] pub struct RealizedFull { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: RealizedBase, + pub core: RealizedCore, - pub gross_pnl: FiatPerBlock, + pub profit: RealizedProfit, + pub loss: RealizedLoss, + pub gross_pnl: RealizedGrossPnl, + pub net_pnl: RealizedNetPnl, + pub sopr: RealizedSopr, + pub sent: RealizedSentFull, + pub peak_regret: RealizedPeakRegret, + pub investor: RealizedInvestor, - pub profit_rel_to_rcap: PercentPerBlock, - pub loss_rel_to_rcap: PercentPerBlock, - pub net_pnl_rel_to_rcap: PercentPerBlock, - - pub profit_value_created: ComputedPerBlock, - pub profit_value_destroyed: ComputedPerBlock, - pub loss_value_created: ComputedPerBlock, - pub loss_value_destroyed: ComputedPerBlock, - - pub profit_value_created_sum: RollingWindows, - pub profit_value_destroyed_sum: RollingWindows, - pub loss_value_created_sum: RollingWindows, - pub loss_value_destroyed_sum: RollingWindows, - - pub capitulation_flow: LazyPerBlock, - pub profit_flow: LazyPerBlock, - - pub gross_pnl_sum: RollingWindows, - - pub net_pnl_cumulative: ComputedPerBlock, - #[traversable(rename = "net_pnl_sum")] - pub net_pnl_sum_extended: RollingWindowsFrom1w, - - pub net_pnl_delta: FiatRollingDelta1m, - #[traversable(rename = "net_pnl_delta")] - pub net_pnl_delta_extended: FiatRollingDeltaExcept1m, - pub net_pnl_change_1m_rel_to_rcap: PercentPerBlock, - pub net_pnl_change_1m_rel_to_mcap: PercentPerBlock, - - #[traversable(rename = "cap_delta")] - pub cap_delta_extended: FiatRollingDeltaExcept1m, - - pub investor_price: Price>, - pub investor_price_ratio: RatioPerBlock, - - pub lower_price_band: Price>, - pub upper_price_band: Price>, - - pub cap_raw: M::Stored>, - pub investor_cap_raw: M::Stored>, - - pub sell_side_risk_ratio: PercentRollingWindows, - - pub peak_regret: ComputedPerBlockCumulative, - pub peak_regret_rel_to_rcap: PercentPerBlock, - - pub cap_rel_to_own_mcap: PercentPerBlock, - - #[traversable(rename = "profit_sum")] - pub profit_sum_extended: RollingWindowsFrom1w, - #[traversable(rename = "loss_sum")] - pub loss_sum_extended: RollingWindowsFrom1w, pub profit_to_loss_ratio: RollingWindows, - #[traversable(rename = "value_created_sum")] - pub value_created_sum_extended: RollingWindowsFrom1w, - #[traversable(rename = "value_destroyed_sum")] - pub value_destroyed_sum_extended: RollingWindowsFrom1w, - #[traversable(rename = "sopr")] - pub sopr_extended: RollingWindowsFrom1w, + #[traversable(wrap = "cap", rename = "delta")] + pub cap_delta_extended: FiatRollingDeltaExcept1m, - #[traversable(rename = "sent_in_profit_sum")] - pub sent_in_profit_sum_extended: RollingWindowsFrom1w, - #[traversable(rename = "sent_in_loss_sum")] - pub sent_in_loss_sum_extended: RollingWindowsFrom1w, + #[traversable(wrap = "cap", rename = "raw")] + pub cap_raw: M::Stored>, + #[traversable(wrap = "cap", rename = "rel_to_own_mcap")] + pub cap_rel_to_own_mcap: PercentPerBlock, + #[traversable(wrap = "price_ratio", rename = "percentiles")] pub price_ratio_percentiles: RatioPerBlockPercentiles, + #[traversable(wrap = "price_ratio", rename = "std_dev")] pub price_ratio_std_dev: RatioPerBlockStdDevBands, - pub investor_price_ratio_percentiles: RatioPerBlockPercentiles, } impl RealizedFull { @@ -112,111 +144,120 @@ impl RealizedFull { let v0 = Version::ZERO; let v1 = Version::ONE; - let base = RealizedBase::forced_import(cfg)?; + let core = RealizedCore::forced_import(cfg)?; - let gross_pnl = cfg.import("realized_gross_pnl", v0)?; - - let profit_value_created = cfg.import("profit_value_created", v0)?; + // Profit let profit_value_destroyed: ComputedPerBlock = cfg.import("profit_value_destroyed", v0)?; - let loss_value_created = cfg.import("loss_value_created", v0)?; - let loss_value_destroyed: ComputedPerBlock = - cfg.import("loss_value_destroyed", v0)?; - - let profit_value_created_sum = cfg.import("profit_value_created", v1)?; - let profit_value_destroyed_sum = cfg.import("profit_value_destroyed", v1)?; - let loss_value_created_sum = cfg.import("loss_value_created", v1)?; - let loss_value_destroyed_sum = cfg.import("loss_value_destroyed", v1)?; - - let capitulation_flow = LazyPerBlock::from_computed::( - &cfg.name("capitulation_flow"), - cfg.version, - loss_value_destroyed.height.read_only_boxed_clone(), - &loss_value_destroyed, - ); let profit_flow = LazyPerBlock::from_computed::( &cfg.name("profit_flow"), cfg.version, profit_value_destroyed.height.read_only_boxed_clone(), &profit_value_destroyed, ); + let profit = RealizedProfit { + rel_to_rcap: cfg.import("realized_profit_rel_to_realized_cap", Version::new(2))?, + value_created: cfg.import("profit_value_created", v0)?, + value_destroyed: profit_value_destroyed, + value_created_sum: cfg.import("profit_value_created", v1)?, + value_destroyed_sum: cfg.import("profit_value_destroyed", v1)?, + flow: profit_flow, + sum_extended: cfg.import("realized_profit", v1)?, + }; - let gross_pnl_sum = cfg.import("gross_pnl_sum", Version::ONE)?; + // Loss + let loss_value_destroyed: ComputedPerBlock = + cfg.import("loss_value_destroyed", v0)?; + let capitulation_flow = LazyPerBlock::from_computed::( + &cfg.name("capitulation_flow"), + cfg.version, + loss_value_destroyed.height.read_only_boxed_clone(), + &loss_value_destroyed, + ); + let loss = RealizedLoss { + rel_to_rcap: cfg.import("realized_loss_rel_to_realized_cap", Version::new(2))?, + value_created: cfg.import("loss_value_created", v0)?, + value_destroyed: loss_value_destroyed, + value_created_sum: cfg.import("loss_value_created", v1)?, + value_destroyed_sum: cfg.import("loss_value_destroyed", v1)?, + capitulation_flow, + sum_extended: cfg.import("realized_loss", v1)?, + }; - let investor_price = cfg.import("investor_price", v0)?; - let investor_price_ratio = cfg.import("investor_price", v0)?; - let lower_price_band = cfg.import("lower_price_band", v0)?; - let upper_price_band = cfg.import("upper_price_band", v0)?; + // Gross PnL + let gross_pnl = RealizedGrossPnl { + value: cfg.import("realized_gross_pnl", v0)?, + sum: cfg.import("gross_pnl_sum", v1)?, + sell_side_risk_ratio: cfg.import("sell_side_risk_ratio", Version::new(2))?, + }; - let cap_raw = cfg.import("cap_raw", v0)?; - let investor_cap_raw = cfg.import("investor_cap_raw", v0)?; + // Net PnL + let net_pnl = RealizedNetPnl { + rel_to_rcap: cfg + .import("net_realized_pnl_rel_to_realized_cap", Version::new(2))?, + cumulative: cfg.import("net_realized_pnl_cumulative", v1)?, + sum_extended: cfg.import("net_realized_pnl", v1)?, + delta: cfg.import("net_pnl_delta", Version::new(5))?, + delta_extended: cfg.import("net_pnl_delta", Version::new(5))?, + change_1m_rel_to_rcap: cfg + .import("net_pnl_change_1m_rel_to_realized_cap", Version::new(4))?, + change_1m_rel_to_mcap: cfg + .import("net_pnl_change_1m_rel_to_market_cap", Version::new(4))?, + }; - let sell_side_risk_ratio = cfg.import("sell_side_risk_ratio", Version::new(2))?; + // SOPR + let sopr = RealizedSopr { + value_created_sum_extended: cfg.import("value_created", v1)?, + value_destroyed_sum_extended: cfg.import("value_destroyed", v1)?, + ratio_extended: cfg.import("sopr", v1)?, + }; - let peak_regret = cfg.import("realized_peak_regret", Version::new(2))?; - let peak_regret_rel_to_realized_cap = - cfg.import("realized_peak_regret_rel_to_realized_cap", Version::new(2))?; + // Sent + let sent = RealizedSentFull { + in_profit_sum_extended: cfg.import("sent_in_profit", v1)?, + in_loss_sum_extended: cfg.import("sent_in_loss", v1)?, + }; + // Peak regret + let peak_regret = RealizedPeakRegret { + value: cfg.import("realized_peak_regret", Version::new(2))?, + rel_to_rcap: cfg + .import("realized_peak_regret_rel_to_realized_cap", Version::new(2))?, + }; + + // Investor + let investor = RealizedInvestor { + price: cfg.import("investor_price", v0)?, + price_ratio: cfg.import("investor_price", v0)?, + lower_price_band: cfg.import("lower_price_band", v0)?, + upper_price_band: cfg.import("upper_price_band", v0)?, + cap_raw: cfg.import("investor_cap_raw", v0)?, + price_ratio_percentiles: RatioPerBlockPercentiles::forced_import( + cfg.db, + &cfg.name("investor_price"), + cfg.version, + cfg.indexes, + )?, + }; + + // Price ratio stats let realized_price_name = cfg.name("realized_price"); let realized_price_version = cfg.version + v1; - let investor_price_name = cfg.name("investor_price"); - let investor_price_version = cfg.version; - - let realized_profit_rel_to_realized_cap = - cfg.import("realized_profit_rel_to_realized_cap", Version::new(2))?; - let realized_loss_rel_to_realized_cap = - cfg.import("realized_loss_rel_to_realized_cap", Version::new(2))?; - let net_realized_pnl_rel_to_realized_cap = - cfg.import("net_realized_pnl_rel_to_realized_cap", Version::new(2))?; - - let value_created_sum_extended = cfg.import("value_created", v1)?; - let value_destroyed_sum_extended = cfg.import("value_destroyed", v1)?; - let sopr_extended = cfg.import("sopr", v1)?; Ok(Self { - base, + core, + profit, + loss, gross_pnl, - profit_rel_to_rcap: realized_profit_rel_to_realized_cap, - loss_rel_to_rcap: realized_loss_rel_to_realized_cap, - net_pnl_rel_to_rcap: net_realized_pnl_rel_to_realized_cap, - profit_value_created, - profit_value_destroyed, - loss_value_created, - loss_value_destroyed, - profit_value_created_sum, - profit_value_destroyed_sum, - loss_value_created_sum, - loss_value_destroyed_sum, - capitulation_flow, - profit_flow, - gross_pnl_sum, - net_pnl_cumulative: cfg.import("net_realized_pnl_cumulative", Version::ONE)?, - net_pnl_sum_extended: cfg.import("net_realized_pnl", Version::ONE)?, - net_pnl_delta: cfg.import("net_pnl_delta", Version::new(5))?, - net_pnl_delta_extended: cfg.import("net_pnl_delta", Version::new(5))?, - net_pnl_change_1m_rel_to_rcap: cfg - .import("net_pnl_change_1m_rel_to_realized_cap", Version::new(4))?, - net_pnl_change_1m_rel_to_mcap: cfg - .import("net_pnl_change_1m_rel_to_market_cap", Version::new(4))?, - cap_delta_extended: cfg.import("realized_cap_delta", Version::new(5))?, - investor_price, - investor_price_ratio, - lower_price_band, - upper_price_band, - cap_raw, - investor_cap_raw, - sell_side_risk_ratio, + net_pnl, + sopr, + sent, peak_regret, - peak_regret_rel_to_rcap: peak_regret_rel_to_realized_cap, - cap_rel_to_own_mcap: cfg.import("realized_cap_rel_to_own_market_cap", v1)?, - profit_sum_extended: cfg.import("realized_profit", v1)?, - loss_sum_extended: cfg.import("realized_loss", v1)?, + investor, profit_to_loss_ratio: cfg.import("realized_profit_to_loss_ratio", v1)?, - value_created_sum_extended, - value_destroyed_sum_extended, - sopr_extended, - sent_in_profit_sum_extended: cfg.import("sent_in_profit", v1)?, - sent_in_loss_sum_extended: cfg.import("sent_in_loss", v1)?, + cap_delta_extended: cfg.import("realized_cap_delta", Version::new(5))?, + cap_raw: cfg.import("cap_raw", v0)?, + cap_rel_to_own_mcap: cfg.import("realized_cap_rel_to_own_market_cap", v1)?, price_ratio_percentiles: RatioPerBlockPercentiles::forced_import( cfg.db, &realized_price_name, @@ -229,76 +270,82 @@ impl RealizedFull { realized_price_version, cfg.indexes, )?, - investor_price_ratio_percentiles: RatioPerBlockPercentiles::forced_import( - cfg.db, - &investor_price_name, - investor_price_version, - cfg.indexes, - )?, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { - self.base + self.core .min_stateful_height_len() - .min(self.profit_value_created.height.len()) - .min(self.profit_value_destroyed.height.len()) - .min(self.loss_value_created.height.len()) - .min(self.loss_value_destroyed.height.len()) - .min(self.investor_price.cents.height.len()) + .min(self.profit.value_created.height.len()) + .min(self.profit.value_destroyed.height.len()) + .min(self.loss.value_created.height.len()) + .min(self.loss.value_destroyed.height.len()) + .min(self.investor.price.cents.height.len()) .min(self.cap_raw.len()) - .min(self.investor_cap_raw.len()) - .min(self.peak_regret.height.len()) + .min(self.investor.cap_raw.len()) + .min(self.peak_regret.value.height.len()) } - pub(crate) fn truncate_push(&mut self, height: Height, state: &RealizedState) -> Result<()> { - self.base.truncate_push(height, state)?; - self.profit_value_created + pub(crate) fn truncate_push( + &mut self, + height: Height, + state: &CohortState, + ) -> Result<()> { + self.core.truncate_push(height, state)?; + self.profit + .value_created .height - .truncate_push(height, state.profit_value_created())?; - self.profit_value_destroyed + .truncate_push(height, state.realized.profit_value_created())?; + self.profit + .value_destroyed .height - .truncate_push(height, state.profit_value_destroyed())?; - self.loss_value_created + .truncate_push(height, state.realized.profit_value_destroyed())?; + self.loss + .value_created .height - .truncate_push(height, state.loss_value_created())?; - self.loss_value_destroyed + .truncate_push(height, state.realized.loss_value_created())?; + self.loss + .value_destroyed .height - .truncate_push(height, state.loss_value_destroyed())?; - self.investor_price + .truncate_push(height, state.realized.loss_value_destroyed())?; + self.investor + .price .cents .height - .truncate_push(height, state.investor_price())?; - self.cap_raw.truncate_push(height, state.cap_raw())?; - self.investor_cap_raw - .truncate_push(height, state.investor_cap_raw())?; + .truncate_push(height, state.realized.investor_price())?; + self.cap_raw + .truncate_push(height, state.realized.cap_raw())?; + self.investor + .cap_raw + .truncate_push(height, state.realized.investor_cap_raw())?; self.peak_regret + .value .height - .truncate_push(height, state.peak_regret())?; + .truncate_push(height, state.realized.peak_regret())?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { - let mut vecs = self.base.collect_vecs_mut(); - vecs.push(&mut self.profit_value_created.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.profit_value_destroyed.height); - vecs.push(&mut self.loss_value_created.height); - vecs.push(&mut self.loss_value_destroyed.height); - vecs.push(&mut self.investor_price.cents.height); + let mut vecs = self.core.collect_vecs_mut(); + vecs.push(&mut self.profit.value_created.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.profit.value_destroyed.height); + vecs.push(&mut self.loss.value_created.height); + vecs.push(&mut self.loss.value_destroyed.height); + vecs.push(&mut self.investor.price.cents.height); vecs.push(&mut self.cap_raw as &mut dyn AnyStoredVec); - vecs.push(&mut self.investor_cap_raw as &mut dyn AnyStoredVec); - vecs.push(&mut self.peak_regret.height); + vecs.push(&mut self.investor.cap_raw as &mut dyn AnyStoredVec); + vecs.push(&mut self.peak_regret.value.height); vecs } pub(crate) fn compute_from_stateful( &mut self, starting_indexes: &Indexes, - others: &[&RealizedBase], + others: &[&RealizedCore], exit: &Exit, ) -> Result<()> { - self.base + self.core .compute_from_stateful(starting_indexes, others, exit)?; Ok(()) @@ -309,20 +356,26 @@ impl RealizedFull { accum: &RealizedFullAccum, height: Height, ) -> Result<()> { - self.profit_value_created + self.profit + .value_created .height .truncate_push(height, accum.profit_value_created)?; - self.profit_value_destroyed + self.profit + .value_destroyed .height .truncate_push(height, accum.profit_value_destroyed)?; - self.loss_value_created + self.loss + .value_created .height .truncate_push(height, accum.loss_value_created)?; - self.loss_value_destroyed + self.loss + .value_destroyed .height .truncate_push(height, accum.loss_value_destroyed)?; - self.cap_raw.truncate_push(height, accum.cap_raw)?; - self.investor_cap_raw + self.cap_raw + .truncate_push(height, accum.cap_raw)?; + self.investor + .cap_raw .truncate_push(height, accum.investor_cap_raw)?; let investor_price = { @@ -333,12 +386,14 @@ impl RealizedFull { Cents::new((accum.investor_cap_raw / cap) as u64) } }; - self.investor_price + self.investor + .price .cents .height .truncate_push(height, investor_price)?; self.peak_regret + .value .height .truncate_push(height, accum.peak_regret)?; @@ -351,16 +406,17 @@ impl RealizedFull { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.base + self.core .compute_rest_part1(blocks, starting_indexes, exit)?; - self.net_pnl_cumulative.height.compute_cumulative( + self.net_pnl.cumulative.height.compute_cumulative( starting_indexes.height, - &self.base.core.net_pnl.height, + &self.core.net_pnl.raw.height, exit, )?; self.peak_regret + .value .compute_rest(starting_indexes.height, exit)?; Ok(()) } @@ -374,7 +430,7 @@ impl RealizedFull { height_to_market_cap: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.base.core.compute_rest_part2( + self.core.compute_rest_part2( blocks, prices, starting_indexes, @@ -384,33 +440,36 @@ impl RealizedFull { let window_starts = blocks.lookback.window_starts(); - // Extended rolling sum (1w, 1m, 1y) for net_realized_pnl - self.net_pnl_sum_extended.compute_rolling_sum( + // Net PnL rolling sums (1w, 1m, 1y) + self.net_pnl.sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.base.core.net_pnl.height, + &self.core.net_pnl.raw.height, exit, )?; - // Extended rolling windows (1w, 1m, 1y) for value_created/destroyed/sopr - self.value_created_sum_extended.compute_rolling_sum( + // SOPR: value created/destroyed rolling sums and ratios + self.sopr.value_created_sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.base.core.value_created.height, - exit, - )?; - self.value_destroyed_sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.base.core.value_destroyed.height, + &self.core.minimal.sopr.value_created.raw.height, exit, )?; + self.sopr + .value_destroyed_sum_extended + .compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.core.minimal.sopr.value_destroyed.raw.height, + exit, + )?; for ((sopr, vc), vd) in self - .sopr_extended + .sopr + .ratio_extended .as_mut_array() .into_iter() - .zip(self.value_created_sum_extended.as_array()) - .zip(self.value_destroyed_sum_extended.as_array()) + .zip(self.sopr.value_created_sum_extended.as_array()) + .zip(self.sopr.value_destroyed_sum_extended.as_array()) { sopr.compute_binary::( starting_indexes.height, @@ -420,108 +479,113 @@ impl RealizedFull { )?; } - // Realized P/L rel to realized cap - self.profit_rel_to_rcap + // Profit/loss/net_pnl rel to realized cap + self.profit + .rel_to_rcap .compute_binary::( starting_indexes.height, - &self.base.core.minimal.profit.height, - &self.base.core.minimal.cap_cents.height, + &self.core.minimal.profit.raw.cents.height, + &self.core.minimal.cap.cents.height, exit, )?; - self.loss_rel_to_rcap + self.loss + .rel_to_rcap .compute_binary::( starting_indexes.height, - &self.base.core.minimal.loss.height, - &self.base.core.minimal.cap_cents.height, + &self.core.minimal.loss.raw.cents.height, + &self.core.minimal.cap.cents.height, exit, )?; - self.net_pnl_rel_to_rcap + self.net_pnl + .rel_to_rcap .compute_binary::( starting_indexes.height, - &self.base.core.net_pnl.height, - &self.base.core.minimal.cap_cents.height, + &self.core.net_pnl.raw.height, + &self.core.minimal.cap.cents.height, exit, )?; - // Sent in profit/loss extended rolling sums (1w, 1m, 1y) - self.sent_in_profit_sum_extended.compute_rolling_sum( + // Sent rolling sums (1w, 1m, 1y) + self.sent.in_profit_sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.base.sent_in_profit.height, + &self.core.sent.in_profit.raw.sats.height, exit, )?; - self.sent_in_loss_sum_extended.compute_rolling_sum( + self.sent.in_loss_sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.base.sent_in_loss.height, + &self.core.sent.in_loss.raw.sats.height, exit, )?; // Profit/loss value created/destroyed rolling sums - self.profit_value_created_sum.compute_rolling_sum( + self.profit.value_created_sum.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.profit_value_created.height, + &self.profit.value_created.height, exit, )?; - self.profit_value_destroyed_sum.compute_rolling_sum( + self.profit.value_destroyed_sum.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.profit_value_destroyed.height, + &self.profit.value_destroyed.height, exit, )?; - self.loss_value_created_sum.compute_rolling_sum( + self.loss.value_created_sum.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.loss_value_created.height, + &self.loss.value_created.height, exit, )?; - self.loss_value_destroyed_sum.compute_rolling_sum( + self.loss.value_destroyed_sum.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.loss_value_destroyed.height, + &self.loss.value_destroyed.height, exit, )?; // Gross PnL - self.gross_pnl.cents.height.compute_add( + self.gross_pnl.value.cents.height.compute_add( starting_indexes.height, - &self.base.core.minimal.profit.height, - &self.base.core.minimal.loss.height, + &self.core.minimal.profit.raw.cents.height, + &self.core.minimal.loss.raw.cents.height, exit, )?; - self.gross_pnl_sum.compute_rolling_sum( + self.gross_pnl.sum.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.gross_pnl.cents.height, + &self.gross_pnl.value.cents.height, exit, )?; // Net PnL delta (1m base + 24h/1w/1y extended) - self.net_pnl_delta.compute( + self.net_pnl.delta.compute( starting_indexes.height, &blocks.lookback.height_1m_ago, - &self.net_pnl_cumulative.height, + &self.net_pnl.cumulative.height, exit, )?; - self.net_pnl_delta_extended.compute( + self.net_pnl.delta_extended.compute( starting_indexes.height, &window_starts, - &self.net_pnl_cumulative.height, + &self.net_pnl.cumulative.height, exit, )?; - self.net_pnl_change_1m_rel_to_rcap + self.net_pnl + .change_1m_rel_to_rcap .compute_binary::( starting_indexes.height, - &self.net_pnl_delta.change_1m.cents.height, - &self.base.core.minimal.cap_cents.height, + &self.net_pnl.delta.change_1m.cents.height, + &self.core.minimal.cap.cents.height, exit, )?; - self.net_pnl_change_1m_rel_to_mcap + self.net_pnl + .change_1m_rel_to_mcap .compute_binary::( starting_indexes.height, - &self.net_pnl_delta.change_1m.cents.height, + &self.net_pnl.delta.change_1m.cents.height, height_to_market_cap, exit, )?; @@ -530,85 +594,95 @@ impl RealizedFull { self.cap_delta_extended.compute( starting_indexes.height, &window_starts, - &self.base.core.minimal.cap_cents.height, + &self.core.minimal.cap.cents.height, exit, )?; - // Peak regret - self.peak_regret_rel_to_rcap + // Peak regret rel to rcap + self.peak_regret + .rel_to_rcap .compute_binary::( starting_indexes.height, - &self.peak_regret.height, - &self.base.core.minimal.cap_cents.height, + &self.peak_regret.value.height, + &self.core.minimal.cap.cents.height, exit, )?; - // Investor price ratio and price bands - self.investor_price_ratio.compute_ratio( + // Investor price ratio and bands + self.investor.price_ratio.compute_ratio( starting_indexes, &prices.price.cents.height, - &self.investor_price.cents.height, + &self.investor.price.cents.height, exit, )?; - self.lower_price_band.cents.height.compute_transform2( - starting_indexes.height, - &self.base.core.minimal.price.cents.height, - &self.investor_price.cents.height, - |(i, rp, ip, ..)| { - let rp = rp.as_u128(); - let ip = ip.as_u128(); - if ip == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(rp * rp / ip)) - } - }, - exit, - )?; + self.investor + .lower_price_band + .cents + .height + .compute_transform2( + starting_indexes.height, + &self.core.minimal.price.cents.height, + &self.investor.price.cents.height, + |(i, rp, ip, ..)| { + let rp = rp.as_u128(); + let ip = ip.as_u128(); + if ip == 0 { + (i, Cents::ZERO) + } else { + (i, Cents::from(rp * rp / ip)) + } + }, + exit, + )?; - self.upper_price_band.cents.height.compute_transform2( - starting_indexes.height, - &self.investor_price.cents.height, - &self.base.core.minimal.price.cents.height, - |(i, ip, rp, ..)| { - let ip = ip.as_u128(); - let rp = rp.as_u128(); - if rp == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(ip * ip / rp)) - } - }, - exit, - )?; + self.investor + .upper_price_band + .cents + .height + .compute_transform2( + starting_indexes.height, + &self.investor.price.cents.height, + &self.core.minimal.price.cents.height, + |(i, ip, rp, ..)| { + let ip = ip.as_u128(); + let rp = rp.as_u128(); + if rp == 0 { + (i, Cents::ZERO) + } else { + (i, Cents::from(ip * ip / rp)) + } + }, + exit, + )?; // Sell-side risk ratios for (ssrr, rv) in self + .gross_pnl .sell_side_risk_ratio .as_mut_array() .into_iter() - .zip(self.gross_pnl_sum.as_array()) + .zip(self.gross_pnl.sum.as_array()) { ssrr.compute_binary::( starting_indexes.height, &rv.height, - &self.base.core.minimal.cap_cents.height, + &self.core.minimal.cap.cents.height, exit, )?; } - // Extended: realized profit/loss rolling sums (1w, 1m, 1y) - self.profit_sum_extended.compute_rolling_sum( + // Profit/loss sum extended (1w, 1m, 1y) + self.profit.sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.base.core.minimal.profit.height, + &self.core.minimal.profit.raw.cents.height, exit, )?; - self.loss_sum_extended.compute_rolling_sum( + self.loss.sum_extended.compute_rolling_sum( starting_indexes.height, &window_starts, - &self.base.core.minimal.loss.height, + &self.core.minimal.loss.raw.cents.height, exit, )?; @@ -616,7 +690,7 @@ impl RealizedFull { self.cap_rel_to_own_mcap .compute_binary::( starting_indexes.height, - &self.base.core.minimal.cap.height, + &self.core.minimal.cap.usd.height, height_to_market_cap, exit, )?; @@ -626,16 +700,16 @@ impl RealizedFull { ._24h .compute_binary::( starting_indexes.height, - &self.base.core.minimal.profit_sum._24h.height, - &self.base.core.minimal.loss_sum._24h.height, + &self.core.minimal.profit.sum._24h.cents.height, + &self.core.minimal.loss.sum._24h.cents.height, exit, )?; for ((ratio, profit), loss) in self .profit_to_loss_ratio .as_mut_array_from_1w() .into_iter() - .zip(self.profit_sum_extended.as_array()) - .zip(self.loss_sum_extended.as_array()) + .zip(self.profit.sum_extended.as_array()) + .zip(self.loss.sum_extended.as_array()) { ratio.compute_binary::( starting_indexes.height, @@ -645,29 +719,30 @@ impl RealizedFull { )?; } + // Price ratio: percentiles and std dev bands self.price_ratio_percentiles.compute( blocks, starting_indexes, exit, - &self.base.core.minimal.price_ratio.ratio.height, - &self.base.core.minimal.price.cents.height, + &self.core.minimal.price_ratio.ratio.height, + &self.core.minimal.price.cents.height, )?; self.price_ratio_std_dev.compute( blocks, starting_indexes, exit, - &self.base.core.minimal.price_ratio.ratio.height, - &self.base.core.minimal.price.cents.height, + &self.core.minimal.price_ratio.ratio.height, + &self.core.minimal.price.cents.height, )?; - // Investor price: percentiles - let investor_price = &self.investor_price.cents.height; - self.investor_price_ratio_percentiles.compute( + // Investor price ratio: percentiles + let investor_price = &self.investor.price.cents.height; + self.investor.price_ratio_percentiles.compute( blocks, starting_indexes, exit, - &self.investor_price_ratio.ratio.height, + &self.investor.price_ratio.ratio.height, investor_price, )?; diff --git a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs index 36af08818..e6366a8e9 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs @@ -1,18 +1,19 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ - BasisPoints32, Bitcoin, Cents, Dollars, Height, Indexes, Sats, StoredF32, Version, + BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, Height, Indexes, Sats, StoredF32, + Version, }; use vecdb::{ - AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec, + AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec, }; use crate::{ blocks, - distribution::state::RealizedOps, + distribution::state::{CohortState, RealizedOps}, internal::{ - CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative, Identity, - LazyPerBlock, Price, RatioPerBlock, RollingWindow24h, + ComputedPerBlock, FiatPerBlock, FiatPerBlockWithSum24h, Identity, LazyPerBlock, + PerBlockWithSum24h, Price, RatioPerBlock, }, prices, }; @@ -20,77 +21,92 @@ use crate::{ use crate::distribution::metrics::ImportConfig; #[derive(Traversable)] -pub struct RealizedMinimal { - pub cap_cents: ComputedPerBlock, - pub profit: ComputedPerBlockCumulative, - pub loss: ComputedPerBlockCumulative, - pub cap: LazyPerBlock, - pub price: Price>, - pub price_ratio: RatioPerBlock, - pub mvrv: LazyPerBlock, +pub struct RealizedSoprMinimal { + pub value_created: PerBlockWithSum24h, + pub value_destroyed: PerBlockWithSum24h, +} - pub profit_sum: RollingWindow24h, - pub loss_sum: RollingWindow24h, +/// Minimal realized metrics: cap (fiat), profit/loss (fiat + 24h sum), +/// price, mvrv, nupl, sopr (value_created/destroyed with 24h sums). +#[derive(Traversable)] +pub struct RealizedMinimal { + pub cap: FiatPerBlock, + pub profit: FiatPerBlockWithSum24h, + pub loss: FiatPerBlockWithSum24h, + pub price: Price>, + pub price_ratio: RatioPerBlock, + pub mvrv: LazyPerBlock, + pub nupl: RatioPerBlock, + + pub sopr: RealizedSoprMinimal, } impl RealizedMinimal { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let realized_cap_cents: ComputedPerBlock = - cfg.import("realized_cap_cents", Version::ZERO)?; - let realized_cap = LazyPerBlock::from_computed::( - &cfg.name("realized_cap"), - cfg.version, - realized_cap_cents.height.read_only_boxed_clone(), - &realized_cap_cents, - ); + let v1 = Version::ONE; - let realized_profit = cfg.import("realized_profit", Version::ZERO)?; - let realized_loss = cfg.import("realized_loss", Version::ZERO)?; + let cap: FiatPerBlock = cfg.import("realized_cap", Version::ZERO)?; - let realized_price = cfg.import("realized_price", Version::ONE)?; - let realized_price_ratio: RatioPerBlock = cfg.import("realized_price", Version::ONE)?; + let realized_price = cfg.import("realized_price", v1)?; + let realized_price_ratio: RatioPerBlock = cfg.import("realized_price", v1)?; let mvrv = LazyPerBlock::from_lazy::, BasisPoints32>( &cfg.name("mvrv"), cfg.version, &realized_price_ratio.ratio, ); - let realized_profit_sum = cfg.import("realized_profit", Version::ONE)?; - let realized_loss_sum = cfg.import("realized_loss", Version::ONE)?; + let nupl = cfg.import("nupl", v1)?; Ok(Self { - cap_cents: realized_cap_cents, - profit: realized_profit, - loss: realized_loss, - cap: realized_cap, + cap, + profit: cfg.import("realized_profit", v1)?, + loss: cfg.import("realized_loss", v1)?, price: realized_price, price_ratio: realized_price_ratio, mvrv, - profit_sum: realized_profit_sum, - loss_sum: realized_loss_sum, + nupl, + sopr: RealizedSoprMinimal { + value_created: cfg.import("value_created", v1)?, + value_destroyed: cfg.import("value_destroyed", v1)?, + }, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { - self.cap_cents + self.cap + .cents .height .len() - .min(self.profit.height.len()) - .min(self.loss.height.len()) + .min(self.profit.raw.cents.height.len()) + .min(self.loss.raw.cents.height.len()) + .min(self.sopr.value_created.raw.height.len()) + .min(self.sopr.value_destroyed.raw.height.len()) } - pub(crate) fn truncate_push(&mut self, height: Height, state: &impl RealizedOps) -> Result<()> { - self.cap_cents.height.truncate_push(height, state.cap())?; - self.profit.height.truncate_push(height, state.profit())?; - self.loss.height.truncate_push(height, state.loss())?; + pub(crate) fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { + self.cap.cents.height.truncate_push(height, state.realized.cap())?; + self.profit.raw.cents.height.truncate_push(height, state.realized.profit())?; + self.loss.raw.cents.height.truncate_push(height, state.realized.loss())?; + self.sopr + .value_created + .raw + .height + .truncate_push(height, state.realized.value_created())?; + self.sopr + .value_destroyed + .raw + .height + .truncate_push(height, state.realized.value_destroyed())?; Ok(()) } pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { vec![ - &mut self.cap_cents.height as &mut dyn AnyStoredVec, - &mut self.profit.height, - &mut self.loss.height, + &mut self.cap.cents.height as &mut dyn AnyStoredVec, + &mut self.profit.raw.cents.height, + &mut self.loss.raw.cents.height, + &mut self.sopr.value_created.raw.height, + &mut self.sopr.value_destroyed.raw.height, ] } @@ -100,9 +116,11 @@ impl RealizedMinimal { others: &[&Self], exit: &Exit, ) -> Result<()> { - sum_others!(self, starting_indexes, others, exit; cap_cents.height); - sum_others!(self, starting_indexes, others, exit; profit.height); - sum_others!(self, starting_indexes, others, exit; loss.height); + sum_others!(self, starting_indexes, others, exit; cap.cents.height); + sum_others!(self, starting_indexes, others, exit; profit.raw.cents.height); + sum_others!(self, starting_indexes, others, exit; loss.raw.cents.height); + sum_others!(self, starting_indexes, others, exit; sopr.value_created.raw.height); + sum_others!(self, starting_indexes, others, exit; sopr.value_destroyed.raw.height); Ok(()) } @@ -112,18 +130,28 @@ impl RealizedMinimal { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.profit.compute_rest(starting_indexes.height, exit)?; - self.loss.compute_rest(starting_indexes.height, exit)?; - self.profit_sum.compute_rolling_sum( + self.profit.sum.compute_rolling_sum( starting_indexes.height, &blocks.lookback.height_24h_ago, - &self.profit.height, + &self.profit.raw.cents.height, exit, )?; - self.loss_sum.compute_rolling_sum( + self.loss.sum.compute_rolling_sum( starting_indexes.height, &blocks.lookback.height_24h_ago, - &self.loss.height, + &self.loss.raw.cents.height, + exit, + )?; + self.sopr.value_created.sum.compute_rolling_sum( + starting_indexes.height, + &blocks.lookback.height_24h_ago, + &self.sopr.value_created.raw.height, + exit, + )?; + self.sopr.value_destroyed.sum.compute_rolling_sum( + starting_indexes.height, + &blocks.lookback.height_24h_ago, + &self.sopr.value_destroyed.raw.height, exit, )?; Ok(()) @@ -138,7 +166,7 @@ impl RealizedMinimal { ) -> Result<()> { self.price.cents.height.compute_transform2( starting_indexes.height, - &self.cap_cents.height, + &self.cap.cents.height, height_to_supply, |(i, cap_cents, supply, ..)| { let cap = cap_cents.as_u128(); @@ -159,6 +187,23 @@ impl RealizedMinimal { exit, )?; + self.nupl.bps.height.compute_transform2( + starting_indexes.height, + &prices.price.cents.height, + &self.price.cents.height, + |(i, price, realized_price, ..)| { + let p = price.as_u128(); + if p == 0 { + (i, BasisPointsSigned32::ZERO) + } else { + let rp = realized_price.as_u128(); + let nupl_bps = ((p as i128 - rp as i128) * 10000) / p as i128; + (i, BasisPointsSigned32::from(nupl_bps as i32)) + } + }, + exit, + )?; + Ok(()) } } diff --git a/crates/brk_computer/src/distribution/metrics/realized/mod.rs b/crates/brk_computer/src/distribution/metrics/realized/mod.rs index 2d4d1af69..a8b76a128 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/mod.rs @@ -1,11 +1,9 @@ mod adjusted; -mod base; mod core; mod full; mod minimal; -pub use adjusted::RealizedAdjusted; -pub use base::RealizedBase; +pub use adjusted::AdjustedSopr; pub use self::core::RealizedCore; pub use full::{RealizedFull, RealizedFullAccum}; pub use minimal::RealizedMinimal; @@ -14,53 +12,53 @@ use brk_error::Result; use brk_types::{Height, Indexes}; use vecdb::Exit; -use crate::{blocks, distribution::state::RealizedState}; +use crate::{blocks, distribution::state::{CohortState, RealizedState}}; /// Polymorphic dispatch for realized metric types. /// -/// Both `RealizedBase` and `RealizedFull` have the same inherent methods +/// Both `RealizedCore` and `RealizedFull` have the same inherent methods /// but with different behavior (Full checks/pushes more fields). /// This trait enables `CohortMetricsBase` to dispatch correctly via associated type. pub trait RealizedLike: Send + Sync { - fn as_base(&self) -> &RealizedBase; - fn as_base_mut(&mut self) -> &mut RealizedBase; + fn as_core(&self) -> &RealizedCore; + fn as_core_mut(&mut self) -> &mut RealizedCore; fn min_stateful_height_len(&self) -> usize; - fn truncate_push(&mut self, height: Height, state: &RealizedState) -> Result<()>; + fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()>; fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()>; fn compute_from_stateful( &mut self, starting_indexes: &Indexes, - others: &[&RealizedBase], + others: &[&RealizedCore], exit: &Exit, ) -> Result<()>; } -impl RealizedLike for RealizedBase { - fn as_base(&self) -> &RealizedBase { self } - fn as_base_mut(&mut self) -> &mut RealizedBase { self } +impl RealizedLike for RealizedCore { + fn as_core(&self) -> &RealizedCore { self } + fn as_core_mut(&mut self) -> &mut RealizedCore { self } fn min_stateful_height_len(&self) -> usize { self.min_stateful_height_len() } - fn truncate_push(&mut self, height: Height, state: &RealizedState) -> Result<()> { + fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { self.truncate_push(height, state) } fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { self.compute_rest_part1(blocks, starting_indexes, exit) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&RealizedBase], exit: &Exit) -> Result<()> { + fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&RealizedCore], exit: &Exit) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } } impl RealizedLike for RealizedFull { - fn as_base(&self) -> &RealizedBase { &self.base } - fn as_base_mut(&mut self) -> &mut RealizedBase { &mut self.base } + fn as_core(&self) -> &RealizedCore { &self.core } + fn as_core_mut(&mut self) -> &mut RealizedCore { &mut self.core } fn min_stateful_height_len(&self) -> usize { self.min_stateful_height_len() } - fn truncate_push(&mut self, height: Height, state: &RealizedState) -> Result<()> { + fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { self.truncate_push(height, state) } fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()> { self.compute_rest_part1(blocks, starting_indexes, exit) } - fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&RealizedBase], exit: &Exit) -> Result<()> { + fn compute_from_stateful(&mut self, starting_indexes: &Indexes, others: &[&RealizedCore], exit: &Exit) -> Result<()> { self.compute_from_stateful(starting_indexes, others, exit) } } diff --git a/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs b/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs index 4cb4516ed..1884f03eb 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs @@ -10,8 +10,11 @@ use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; /// Extended relative metrics for own market cap (extended && rel_to_all). #[derive(Traversable)] pub struct RelativeExtendedOwnMarketCap { + #[traversable(wrap = "unrealized/profit", rename = "rel_to_own_market_cap")] pub unrealized_profit_rel_to_own_market_cap: PercentPerBlock, + #[traversable(wrap = "unrealized/loss", rename = "rel_to_own_market_cap")] pub unrealized_loss_rel_to_own_market_cap: PercentPerBlock, + #[traversable(wrap = "unrealized/net_pnl", rename = "rel_to_own_market_cap")] pub net_unrealized_pnl_rel_to_own_market_cap: PercentPerBlock, } @@ -39,14 +42,14 @@ impl RelativeExtendedOwnMarketCap { self.unrealized_profit_rel_to_own_market_cap .compute_binary::( max_from, - &unrealized.profit.usd.height, + &unrealized.profit.raw.usd.height, own_market_cap, exit, )?; self.unrealized_loss_rel_to_own_market_cap .compute_binary::( max_from, - &unrealized.loss.usd.height, + &unrealized.loss.raw.usd.height, own_market_cap, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs b/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs index aac7677be..5d4c75867 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs @@ -10,8 +10,11 @@ use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; /// Extended relative metrics for own total unrealized PnL (extended only). #[derive(Traversable)] pub struct RelativeExtendedOwnPnl { + #[traversable(wrap = "unrealized/profit", rename = "rel_to_own_gross_pnl")] pub unrealized_profit_rel_to_own_gross_pnl: PercentPerBlock, + #[traversable(wrap = "unrealized/loss", rename = "rel_to_own_gross_pnl")] pub unrealized_loss_rel_to_own_gross_pnl: PercentPerBlock, + #[traversable(wrap = "unrealized/net_pnl", rename = "rel_to_own_gross_pnl")] pub net_unrealized_pnl_rel_to_own_gross_pnl: PercentPerBlock, } @@ -39,14 +42,14 @@ impl RelativeExtendedOwnPnl { self.unrealized_profit_rel_to_own_gross_pnl .compute_binary::( max_from, - &unrealized.profit.usd.height, + &unrealized.profit.raw.usd.height, gross_pnl_usd, exit, )?; self.unrealized_loss_rel_to_own_gross_pnl .compute_binary::( max_from, - &unrealized.loss.usd.height, + &unrealized.loss.raw.usd.height, gross_pnl_usd, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/relative/full.rs b/crates/brk_computer/src/distribution/metrics/relative/full.rs index 1afd6c306..b52253fc0 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/full.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/full.rs @@ -1,44 +1,31 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, StoredF32, Version}; -use vecdb::{Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; +use brk_types::{BasisPoints16, Dollars, Height, Sats, Version}; +use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::internal::{ - Bps32ToFloat, LazyPerBlock, PercentPerBlock, RatioDollarsBp16, RatioDollarsBps32, RatioSatsBp16, +use crate::{ + distribution::metrics::{ImportConfig, UnrealizedCore}, + internal::{PercentPerBlock, RatioDollarsBp16, RatioSatsBp16}, }; -use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; - /// Full relative metrics (sth/lth/all tier). #[derive(Traversable)] pub struct RelativeFull { + #[traversable(wrap = "supply/in_profit", rename = "rel_to_own_supply")] pub supply_in_profit_rel_to_own_supply: PercentPerBlock, + #[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")] pub unrealized_profit_rel_to_market_cap: PercentPerBlock, + #[traversable(wrap = "unrealized/loss", rename = "rel_to_market_cap")] pub unrealized_loss_rel_to_market_cap: PercentPerBlock, - pub net_unrealized_pnl_rel_to_market_cap: PercentPerBlock, - pub nupl: LazyPerBlock, } impl RelativeFull { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let v1 = Version::ONE; let v2 = Version::new(2); - let v3 = Version::new(3); - - let net_unrealized_pnl_rel_to_market_cap: PercentPerBlock = - cfg.import("net_unrealized_pnl_rel_to_market_cap", v3)?; - - let nupl = LazyPerBlock::from_computed::( - &cfg.name("nupl"), - cfg.version + v3, - net_unrealized_pnl_rel_to_market_cap - .bps - .height - .read_only_boxed_clone(), - &net_unrealized_pnl_rel_to_market_cap.bps, - ); Ok(Self { supply_in_profit_rel_to_own_supply: cfg @@ -48,8 +35,6 @@ impl RelativeFull { .import("unrealized_profit_rel_to_market_cap", v2)?, unrealized_loss_rel_to_market_cap: cfg .import("unrealized_loss_rel_to_market_cap", v2)?, - net_unrealized_pnl_rel_to_market_cap, - nupl, }) } @@ -79,21 +64,14 @@ impl RelativeFull { self.unrealized_profit_rel_to_market_cap .compute_binary::( max_from, - &unrealized.profit.usd.height, + &unrealized.profit.raw.usd.height, market_cap, exit, )?; self.unrealized_loss_rel_to_market_cap .compute_binary::( max_from, - &unrealized.loss.usd.height, - market_cap, - exit, - )?; - self.net_unrealized_pnl_rel_to_market_cap - .compute_binary::( - max_from, - &unrealized.net_pnl.usd.height, + &unrealized.loss.raw.usd.height, market_cap, 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 e9a4ea96f..423860f65 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/to_all.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/to_all.rs @@ -10,8 +10,11 @@ use crate::distribution::metrics::ImportConfig; /// 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 = "supply/in_profit", rename = "rel_to_circulating_supply")] pub supply_in_profit_rel_to_circulating_supply: PercentPerBlock, + #[traversable(wrap = "supply/in_loss", rename = "rel_to_circulating_supply")] pub supply_in_loss_rel_to_circulating_supply: PercentPerBlock, } diff --git a/crates/brk_computer/src/distribution/metrics/supply.rs b/crates/brk_computer/src/distribution/metrics/supply/base.rs similarity index 55% rename from crates/brk_computer/src/distribution/metrics/supply.rs rename to crates/brk_computer/src/distribution/metrics/supply/base.rs index 0637b1685..c6b23e8a7 100644 --- a/crates/brk_computer/src/distribution/metrics/supply.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/base.rs @@ -1,27 +1,25 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Height, Indexes, Sats, SatsSigned, Version}; - -use crate::{blocks, prices}; +use brk_types::{Height, Indexes, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; +use crate::{distribution::state::{CohortState, RealizedOps}, prices}; + use crate::internal::{ AmountPerBlock, HalveCents, HalveDollars, HalveSats, HalveSatsToBitcoin, - LazyAmountPerBlock, RollingDelta1m, + LazyAmountPerBlock, }; -use super::ImportConfig; +use crate::distribution::metrics::ImportConfig; -/// Supply metrics for a cohort. +/// Base supply metrics: total supply only (2 stored vecs). #[derive(Traversable)] -pub struct SupplyMetrics { +pub struct SupplyBase { pub total: AmountPerBlock, pub halved: LazyAmountPerBlock, - pub delta: RollingDelta1m, } -impl SupplyMetrics { - /// Import supply metrics from database. +impl SupplyBase { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { let supply = cfg.import("supply", Version::ZERO)?; @@ -32,23 +30,18 @@ impl SupplyMetrics { HalveDollars, >(&cfg.name("supply_halved"), &supply, cfg.version); - let delta = cfg.import("supply_delta", Version::ONE)?; - Ok(Self { total: supply, halved: supply_halved, - delta, }) } - /// Get minimum length across height-indexed vectors. pub(crate) fn min_len(&self) -> usize { self.total.sats.height.len() } - /// Push supply state values to height-indexed vectors. - pub(crate) fn truncate_push(&mut self, height: Height, supply: Sats) -> Result<()> { - self.total.sats.height.truncate_push(height, supply)?; + pub(crate) fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { + self.total.sats.height.truncate_push(height, state.supply.value)?; Ok(()) } @@ -59,7 +52,6 @@ impl SupplyMetrics { ] } - /// Eagerly compute USD height values from sats × price. pub(crate) fn compute( &mut self, prices: &prices::Vecs, @@ -69,13 +61,6 @@ impl SupplyMetrics { self.total.compute(prices, max_from, exit) } - /// Validate computed versions against base version. - pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { - // Validation logic for computed vecs - Ok(()) - } - - /// Compute aggregate values from separate cohorts. pub(crate) fn compute_from_stateful( &mut self, starting_indexes: &Indexes, @@ -92,19 +77,4 @@ impl SupplyMetrics { )?; Ok(()) } - - /// Compute derived vecs from existing height data. - pub(crate) fn compute_rest_part1( - &mut self, - blocks: &blocks::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - ) -> Result<()> { - self.delta.compute( - starting_indexes.height, - &blocks.lookback.height_1m_ago, - &self.total.sats.height, - exit, - ) - } } diff --git a/crates/brk_computer/src/distribution/metrics/supply/full.rs b/crates/brk_computer/src/distribution/metrics/supply/full.rs new file mode 100644 index 000000000..dd929f34a --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/supply/full.rs @@ -0,0 +1,63 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{Indexes, Sats, SatsSigned, Version}; +use derive_more::{Deref, DerefMut}; +use vecdb::{AnyStoredVec, Exit, Rw, StorageMode}; + +use crate::{blocks, internal::RollingDelta1m}; + +use crate::distribution::metrics::ImportConfig; + +use super::SupplyBase; + +/// Full supply metrics: total + delta (4 stored vecs). +#[derive(Deref, DerefMut, Traversable)] +pub struct SupplyFull { + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub base: SupplyBase, + + pub delta: RollingDelta1m, +} + +impl SupplyFull { + pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { + let base = SupplyBase::forced_import(cfg)?; + let delta = cfg.import("supply_delta", Version::ONE)?; + + Ok(Self { base, delta }) + } + + pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { + self.base.collect_vecs_mut() + } + + pub(crate) fn validate_computed_versions(&mut self, _base_version: Version) -> Result<()> { + Ok(()) + } + + pub(crate) fn compute_from_stateful( + &mut self, + starting_indexes: &Indexes, + others: &[&Self], + exit: &Exit, + ) -> Result<()> { + let base_refs: Vec<&SupplyBase> = others.iter().map(|o| &o.base).collect(); + self.base.compute_from_stateful(starting_indexes, &base_refs, exit) + } + + pub(crate) fn compute_rest_part1( + &mut self, + blocks: &blocks::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + self.delta.compute( + starting_indexes.height, + &blocks.lookback.height_1m_ago, + &self.base.total.sats.height, + exit, + ) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/supply/mod.rs b/crates/brk_computer/src/distribution/metrics/supply/mod.rs new file mode 100644 index 000000000..e8855dfb2 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/supply/mod.rs @@ -0,0 +1,5 @@ +mod base; +mod full; + +pub use base::SupplyBase; +pub use full::SupplyFull; diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs index aadb8ae83..6c3447627 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::{distribution::{metrics::ImportConfig, state::UnrealizedState}, prices}; +use crate::{blocks, distribution::{metrics::ImportConfig, state::UnrealizedState}, prices}; use super::UnrealizedCore; @@ -15,9 +15,13 @@ pub struct UnrealizedBase { #[traversable(flatten)] pub core: UnrealizedCore, + #[traversable(wrap = "invested_capital/in_profit", rename = "raw")] pub invested_capital_in_profit_raw: M::Stored>, + #[traversable(wrap = "invested_capital/in_loss", rename = "raw")] pub invested_capital_in_loss_raw: M::Stored>, + #[traversable(wrap = "investor_cap/in_profit", rename = "raw")] pub investor_cap_in_profit_raw: M::Stored>, + #[traversable(wrap = "investor_cap/in_loss", rename = "raw")] pub investor_cap_in_loss_raw: M::Stored>, } @@ -161,11 +165,12 @@ 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(prices, starting_indexes, exit)?; + self.core.compute_rest(blocks, prices, 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 new file mode 100644 index 000000000..3a065da05 --- /dev/null +++ b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs @@ -0,0 +1,107 @@ +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)] +pub struct UnrealizedBasic { + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub minimal: UnrealizedMinimal, + + pub profit: FiatPerBlockWithSum24h, + pub loss: FiatPerBlockWithSum24h, +} + +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()) + .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 + .height + .truncate_push(height, state.unrealized_profit)?; + self.loss + .raw + .cents + .height + .truncate_push(height, state.unrealized_loss)?; + Ok(()) + } + + 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 + } + + pub(crate) fn compute_from_sources( + &mut self, + starting_indexes: &Indexes, + 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(()) + } + + 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, + &self.profit.raw.cents.height, + exit, + )?; + self.loss.sum.compute_rolling_sum( + max_from, + &blocks.lookback.height_24h_ago, + &self.loss.raw.cents.height, + exit, + )?; + + Ok(()) + } +} diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs index 94296ea62..d7a380e34 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs @@ -2,11 +2,12 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Cents, CentsSigned, Height, Indexes, Version}; use derive_more::{Deref, DerefMut}; -use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, Rw, StorageMode, WritableVec}; +use vecdb::{AnyStoredVec, Exit, ReadableCloneableVec, Rw, StorageMode}; use crate::{ + blocks, distribution::{ - metrics::{ImportConfig, unrealized::UnrealizedMinimal}, + metrics::ImportConfig, state::UnrealizedState, }, internal::{CentsSubtractToCentsSigned, FiatPerBlock, LazyPerBlock, NegCentsUnsignedToDollars}, @@ -15,51 +16,42 @@ use crate::{ use brk_types::Dollars; +use super::UnrealizedBasic; + #[derive(Deref, DerefMut, Traversable)] pub struct UnrealizedCore { #[deref] #[deref_mut] #[traversable(flatten)] - pub minimal: UnrealizedMinimal, + pub basic: UnrealizedBasic, - pub profit: FiatPerBlock, - pub loss: FiatPerBlock, + #[traversable(wrap = "loss", rename = "neg")] pub neg_loss: LazyPerBlock, pub net_pnl: FiatPerBlock, } impl UnrealizedCore { pub(crate) fn forced_import(cfg: &ImportConfig) -> Result { - let v0 = Version::ZERO; - - let minimal = UnrealizedMinimal::forced_import(cfg)?; - - let unrealized_profit = cfg.import("unrealized_profit", v0)?; - let unrealized_loss: FiatPerBlock = cfg.import("unrealized_loss", v0)?; + let basic = UnrealizedBasic::forced_import(cfg)?; let neg_unrealized_loss = LazyPerBlock::from_computed::( &cfg.name("neg_unrealized_loss"), cfg.version, - unrealized_loss.cents.height.read_only_boxed_clone(), - &unrealized_loss.cents, + basic.loss.raw.cents.height.read_only_boxed_clone(), + &basic.loss.raw.cents, ); - let net_unrealized_pnl = cfg.import("net_unrealized_pnl", v0)?; + let net_unrealized_pnl = cfg.import("net_unrealized_pnl", Version::ZERO)?; Ok(Self { - minimal, - profit: unrealized_profit, - loss: unrealized_loss, + basic, neg_loss: neg_unrealized_loss, net_pnl: net_unrealized_pnl, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { - self.minimal - .min_stateful_height_len() - .min(self.profit.cents.height.len()) - .min(self.loss.cents.height.len()) + self.basic.min_stateful_height_len() } pub(crate) fn truncate_push( @@ -67,24 +59,12 @@ impl UnrealizedCore { height: Height, height_state: &UnrealizedState, ) -> Result<()> { - self.minimal.truncate_push(height, height_state)?; - self.profit - .cents - .height - .truncate_push(height, height_state.unrealized_profit)?; - self.loss - .cents - .height - .truncate_push(height, height_state.unrealized_loss)?; - + self.basic.truncate_push(height, height_state)?; Ok(()) } 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.cents.height); - vecs.push(&mut self.loss.cents.height); - vecs + self.basic.collect_vecs_mut() } pub(crate) fn compute_from_stateful( @@ -93,33 +73,30 @@ impl UnrealizedCore { 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.cents.height); - sum_others!(self, starting_indexes, others, exit; loss.cents.height); - + let basic_refs: Vec<&UnrealizedBasic> = others.iter().map(|o| &o.basic).collect(); + self.basic + .compute_from_sources(starting_indexes, &basic_refs, exit)?; Ok(()) } /// Compute derived metrics from stored values. pub(crate) fn compute_rest( &mut self, + blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.minimal - .compute_rest(prices, starting_indexes.height, exit)?; + self.basic + .compute_rest(blocks, prices, starting_indexes.height, exit)?; self.net_pnl .cents .height .compute_binary::( starting_indexes.height, - &self.profit.cents.height, - &self.loss.cents.height, + &self.basic.profit.raw.cents.height, + &self.basic.loss.raw.cents.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/full.rs b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs index c410c48e7..ea4b4e7e0 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/full.rs @@ -6,10 +6,17 @@ use vecdb::{AnyStoredVec, Exit, Rw, StorageMode, WritableVec}; use crate::distribution::state::UnrealizedState; use crate::internal::{CentsSubtractToCentsSigned, FiatPerBlock}; -use crate::{distribution::metrics::ImportConfig, prices}; +use crate::{blocks, distribution::metrics::ImportConfig, prices}; use super::UnrealizedBase; +#[derive(Traversable)] +pub struct UnrealizedSentiment { + pub pain_index: FiatPerBlock, + pub greed_index: FiatPerBlock, + pub net: FiatPerBlock, +} + #[derive(Deref, DerefMut, Traversable)] pub struct UnrealizedFull { #[deref] @@ -18,12 +25,13 @@ pub struct UnrealizedFull { pub inner: UnrealizedBase, pub gross_pnl: FiatPerBlock, + + #[traversable(wrap = "invested_capital", rename = "in_profit")] pub invested_capital_in_profit: FiatPerBlock, + #[traversable(wrap = "invested_capital", rename = "in_loss")] pub invested_capital_in_loss: FiatPerBlock, - pub pain_index: FiatPerBlock, - pub greed_index: FiatPerBlock, - pub net_sentiment: FiatPerBlock, + pub sentiment: UnrealizedSentiment, } impl UnrealizedFull { @@ -35,18 +43,18 @@ impl UnrealizedFull { let invested_capital_in_profit = cfg.import("invested_capital_in_profit", v0)?; let invested_capital_in_loss = cfg.import("invested_capital_in_loss", v0)?; - let pain_index = cfg.import("pain_index", v0)?; - let greed_index = cfg.import("greed_index", v0)?; - let net_sentiment = cfg.import("net_sentiment", Version::ONE)?; + let sentiment = UnrealizedSentiment { + pain_index: cfg.import("pain_index", v0)?, + greed_index: cfg.import("greed_index", v0)?, + net: cfg.import("net_sentiment", Version::ONE)?, + }; Ok(Self { inner, gross_pnl, invested_capital_in_profit, invested_capital_in_loss, - pain_index, - greed_index, - net_sentiment, + sentiment, }) } @@ -72,24 +80,25 @@ impl UnrealizedFull { vecs.push(&mut self.gross_pnl.cents.height as &mut dyn AnyStoredVec); vecs.push(&mut self.invested_capital_in_profit.cents.height as &mut dyn AnyStoredVec); vecs.push(&mut self.invested_capital_in_loss.cents.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.pain_index.cents.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.greed_index.cents.height as &mut dyn AnyStoredVec); - vecs.push(&mut self.net_sentiment.cents.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.sentiment.pain_index.cents.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.sentiment.greed_index.cents.height as &mut dyn AnyStoredVec); + vecs.push(&mut self.sentiment.net.cents.height as &mut dyn AnyStoredVec); vecs } pub(crate) fn compute_rest_all( &mut self, + blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.inner.compute_rest(prices, starting_indexes, exit)?; + self.inner.compute_rest(blocks, prices, starting_indexes, exit)?; self.gross_pnl.cents.height.compute_add( starting_indexes.height, - &self.inner.core.profit.cents.height, - &self.inner.core.loss.cents.height, + &self.inner.core.basic.profit.raw.cents.height, + &self.inner.core.basic.loss.raw.cents.height, exit, )?; @@ -123,7 +132,7 @@ impl UnrealizedFull { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.pain_index.cents.height.compute_transform3( + self.sentiment.pain_index.cents.height.compute_transform3( starting_indexes.height, &self.inner.investor_cap_in_loss_raw, &self.inner.invested_capital_in_loss_raw, @@ -139,7 +148,7 @@ impl UnrealizedFull { exit, )?; - self.greed_index.cents.height.compute_transform3( + self.sentiment.greed_index.cents.height.compute_transform3( starting_indexes.height, &self.inner.investor_cap_in_profit_raw, &self.inner.invested_capital_in_profit_raw, @@ -163,13 +172,14 @@ impl UnrealizedFull { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.net_sentiment + self.sentiment + .net .cents .height .compute_binary::( starting_indexes.height, - &self.greed_index.cents.height, - &self.pain_index.cents.height, + &self.sentiment.greed_index.cents.height, + &self.sentiment.pain_index.cents.height, exit, )?; Ok(()) diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs b/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs index 68f27e99b..087f07be5 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs @@ -12,15 +12,18 @@ 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", Version::ZERO)?, - supply_in_loss: cfg.import("supply_in_loss", Version::ZERO)?, + supply_in_profit: cfg.import("supply_in_profit", v0)?, + supply_in_loss: cfg.import("supply_in_loss", v0)?, }) } @@ -47,9 +50,9 @@ impl UnrealizedMinimal { 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 as &mut dyn AnyStoredVec, - &mut self.supply_in_loss.sats.height as &mut dyn AnyStoredVec, - &mut self.supply_in_loss.cents.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, ] } diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs index 5cd91f3b3..57bb5fc6c 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs @@ -1,10 +1,12 @@ 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; @@ -12,7 +14,7 @@ use brk_error::Result; use brk_types::{Height, Indexes}; use vecdb::Exit; -use crate::{distribution::state::UnrealizedState, prices}; +use crate::{blocks, distribution::state::UnrealizedState, prices}; pub trait UnrealizedLike: Send + Sync { fn as_base(&self) -> &UnrealizedBase; @@ -21,6 +23,7 @@ pub trait UnrealizedLike: Send + Sync { fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()>; fn compute_rest( &mut self, + blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, @@ -47,11 +50,12 @@ impl UnrealizedLike for UnrealizedBase { } fn compute_rest( &mut self, + blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.compute_rest(prices, starting_indexes, exit) + self.compute_rest(blocks, prices, starting_indexes, exit) } fn compute_net_sentiment_height( &mut self, @@ -77,11 +81,12 @@ impl UnrealizedLike for UnrealizedFull { } fn compute_rest( &mut self, + blocks: &blocks::Vecs, prices: &prices::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.compute_rest_all(prices, starting_indexes, exit) + self.compute_rest_all(blocks, prices, starting_indexes, exit) } fn compute_net_sentiment_height( &mut self, diff --git a/crates/brk_computer/src/distribution/state/cost_basis/realized.rs b/crates/brk_computer/src/distribution/state/cost_basis/realized.rs index c0ae49a42..4c0a93882 100644 --- a/crates/brk_computer/src/distribution/state/cost_basis/realized.rs +++ b/crates/brk_computer/src/distribution/state/cost_basis/realized.rs @@ -38,13 +38,15 @@ pub trait RealizedOps: Default + Clone + Send + Sync + 'static { ); } -/// Minimal realized state: only cap, profit, loss. +/// Minimal realized state: cap, profit, loss, value_created/destroyed. /// Used by MinimalCohortMetrics cohorts (amount_range, type_, address — ~135 separate cohorts). #[derive(Debug, Default, Clone)] pub struct MinimalRealizedState { cap_raw: u128, profit_raw: u128, loss_raw: u128, + value_created_raw: u128, + value_destroyed_raw: u128, } impl RealizedOps for MinimalRealizedState { @@ -72,6 +74,22 @@ impl RealizedOps for MinimalRealizedState { Cents::new((self.loss_raw / Sats::ONE_BTC_U128) as u64) } + #[inline] + fn value_created(&self) -> Cents { + if self.value_created_raw == 0 { + return Cents::ZERO; + } + Cents::new((self.value_created_raw / Sats::ONE_BTC_U128) as u64) + } + + #[inline] + fn value_destroyed(&self) -> Cents { + if self.value_destroyed_raw == 0 { + return Cents::ZERO; + } + Cents::new((self.value_destroyed_raw / Sats::ONE_BTC_U128) as u64) + } + #[inline] fn set_cap_raw(&mut self, cap_raw: CentsSats) { self.cap_raw = cap_raw.inner(); @@ -84,6 +102,8 @@ impl RealizedOps for MinimalRealizedState { fn reset_single_iteration_values(&mut self) { self.profit_raw = 0; self.loss_raw = 0; + self.value_created_raw = 0; + self.value_destroyed_raw = 0; } #[inline] @@ -124,16 +144,16 @@ impl RealizedOps for MinimalRealizedState { Ordering::Equal => {} } self.cap_raw -= prev_ps.as_u128(); + self.value_created_raw += current_ps.as_u128(); + self.value_destroyed_raw += prev_ps.as_u128(); } } -/// Core realized state: cap, profit, loss + value_created/destroyed for SOPR + sent tracking. +/// Core realized state: extends Minimal with sent_in_profit/loss tracking. /// Used by CoreCohortMetrics cohorts (epoch, class, max_age, min_age — ~59 separate cohorts). #[derive(Debug, Default, Clone)] pub struct CoreRealizedState { minimal: MinimalRealizedState, - value_created_raw: u128, - value_destroyed_raw: u128, sent_in_profit: Sats, sent_in_loss: Sats, } @@ -156,18 +176,12 @@ impl RealizedOps for CoreRealizedState { #[inline] fn value_created(&self) -> Cents { - if self.value_created_raw == 0 { - return Cents::ZERO; - } - Cents::new((self.value_created_raw / Sats::ONE_BTC_U128) as u64) + self.minimal.value_created() } #[inline] fn value_destroyed(&self) -> Cents { - if self.value_destroyed_raw == 0 { - return Cents::ZERO; - } - Cents::new((self.value_destroyed_raw / Sats::ONE_BTC_U128) as u64) + self.minimal.value_destroyed() } #[inline] @@ -191,8 +205,6 @@ impl RealizedOps for CoreRealizedState { #[inline] fn reset_single_iteration_values(&mut self) { self.minimal.reset_single_iteration_values(); - self.value_created_raw = 0; - self.value_destroyed_raw = 0; self.sent_in_profit = Sats::ZERO; self.sent_in_loss = Sats::ZERO; } @@ -223,8 +235,6 @@ impl RealizedOps for CoreRealizedState { ) { self.minimal .send(sats, current_ps, prev_ps, ath_ps, prev_investor_cap); - self.value_created_raw += current_ps.as_u128(); - self.value_destroyed_raw += prev_ps.as_u128(); match current_ps.cmp(&prev_ps) { Ordering::Greater | Ordering::Equal => { self.sent_in_profit += sats; diff --git a/crates/brk_computer/src/distribution/vecs.rs b/crates/brk_computer/src/distribution/vecs.rs index 6f21ac949..39009a71b 100644 --- a/crates/brk_computer/src/distribution/vecs.rs +++ b/crates/brk_computer/src/distribution/vecs.rs @@ -60,9 +60,9 @@ pub struct Vecs { /// Windowed change + growth rate for addr_count, global + per-type pub delta: DeltaVecs, - pub fundedaddressindex: + pub funded_address_index: LazyVecFrom1, - pub emptyaddressindex: + pub empty_address_index: LazyVecFrom1, /// In-memory block state for UTXO processing. Persisted via supply_state. @@ -115,14 +115,14 @@ impl Vecs { )?; // Identity mappings for traversable - let fundedaddressindex = LazyVecFrom1::init( - "fundedaddressindex", + let funded_address_index = LazyVecFrom1::init( + "funded_address_index", version, fundedaddressindex_to_fundedaddressdata.read_only_boxed_clone(), |index, _| index, ); - let emptyaddressindex = LazyVecFrom1::init( - "emptyaddressindex", + let empty_address_index = LazyVecFrom1::init( + "empty_address_index", version, emptyaddressindex_to_emptyaddressdata.read_only_boxed_clone(), |index, _| index, @@ -164,8 +164,8 @@ impl Vecs { funded: fundedaddressindex_to_fundedaddressdata, empty: emptyaddressindex_to_emptyaddressdata, }, - fundedaddressindex, - emptyaddressindex, + funded_address_index, + empty_address_index, chain_state: Vec::new(), txindex_to_height: RangeMap::default(), diff --git a/crates/brk_computer/src/indexes/epoch.rs b/crates/brk_computer/src/indexes/epoch.rs index 62c6e16d8..ffa3fc330 100644 --- a/crates/brk_computer/src/indexes/epoch.rs +++ b/crates/brk_computer/src/indexes/epoch.rs @@ -14,7 +14,7 @@ pub struct Vecs { impl Vecs { pub(crate) fn forced_import(db: &Database, version: Version) -> Result { Ok(Self { - identity: EagerVec::forced_import(db, "difficultyepoch", version)?, + identity: EagerVec::forced_import(db, "epoch", version)?, first_height: EagerVec::forced_import(db, "first_height", version)?, height_count: EagerVec::forced_import(db, "height_count", version)?, }) diff --git a/crates/brk_computer/src/indexes/halving.rs b/crates/brk_computer/src/indexes/halving.rs index 183e91774..12e2d515d 100644 --- a/crates/brk_computer/src/indexes/halving.rs +++ b/crates/brk_computer/src/indexes/halving.rs @@ -13,7 +13,7 @@ pub struct Vecs { impl Vecs { pub(crate) fn forced_import(db: &Database, version: Version) -> Result { Ok(Self { - identity: EagerVec::forced_import(db, "halvingepoch", version)?, + identity: EagerVec::forced_import(db, "halving", version)?, first_height: EagerVec::forced_import(db, "first_height", version)?, }) } diff --git a/crates/brk_computer/src/indexes/height.rs b/crates/brk_computer/src/indexes/height.rs index d8a80c811..55d07f438 100644 --- a/crates/brk_computer/src/indexes/height.rs +++ b/crates/brk_computer/src/indexes/height.rs @@ -39,7 +39,7 @@ impl Vecs { hour12: EagerVec::forced_import(db, "hour12", version)?, day1: EagerVec::forced_import(db, "day1", version)?, day3: EagerVec::forced_import(db, "day3", version)?, - epoch: EagerVec::forced_import(db, "difficulty", version)?, + epoch: EagerVec::forced_import(db, "epoch", version)?, halving: EagerVec::forced_import(db, "halving", version)?, week1: EagerVec::forced_import(db, "week1", version)?, month1: EagerVec::forced_import(db, "month1", version)?, diff --git a/crates/brk_computer/src/internal/algo/sliding_distribution.rs b/crates/brk_computer/src/internal/algo/sliding_distribution.rs index e7155a347..3a7c67ef3 100644 --- a/crates/brk_computer/src/internal/algo/sliding_distribution.rs +++ b/crates/brk_computer/src/internal/algo/sliding_distribution.rs @@ -106,19 +106,19 @@ where &mut *p75_out, &mut *p90_out, ] { - v.checked_push_at(i, zero)?; + v.truncate_push_at(i, zero)?; } } else { - average_out.checked_push_at(i, T::from(window.average()))?; - min_out.checked_push_at(i, T::from(window.min()))?; - max_out.checked_push_at(i, T::from(window.max()))?; + average_out.truncate_push_at(i, T::from(window.average()))?; + min_out.truncate_push_at(i, T::from(window.min()))?; + max_out.truncate_push_at(i, T::from(window.max()))?; let [p10, p25, p50, p75, p90] = window.percentiles(&[0.10, 0.25, 0.50, 0.75, 0.90]); - p10_out.checked_push_at(i, T::from(p10))?; - p25_out.checked_push_at(i, T::from(p25))?; - median_out.checked_push_at(i, T::from(p50))?; - p75_out.checked_push_at(i, T::from(p75))?; - p90_out.checked_push_at(i, T::from(p90))?; + p10_out.truncate_push_at(i, T::from(p10))?; + p25_out.truncate_push_at(i, T::from(p25))?; + median_out.truncate_push_at(i, T::from(p50))?; + p75_out.truncate_push_at(i, T::from(p75))?; + p90_out.truncate_push_at(i, T::from(p90))?; } if average_out.batch_limit_reached() { diff --git a/crates/brk_computer/src/internal/containers/mod.rs b/crates/brk_computer/src/internal/containers/mod.rs index fb9deb2d8..908e4d47e 100644 --- a/crates/brk_computer/src/internal/containers/mod.rs +++ b/crates/brk_computer/src/internal/containers/mod.rs @@ -1,7 +1,13 @@ mod distribution_stats; mod per_resolution; +mod window_24h; mod windows; +mod windows_except_1m; +mod windows_from_1w; pub use distribution_stats::*; pub use per_resolution::*; +pub use window_24h::*; pub use windows::*; +pub use windows_except_1m::*; +pub use windows_from_1w::*; diff --git a/crates/brk_computer/src/internal/containers/window_24h.rs b/crates/brk_computer/src/internal/containers/window_24h.rs new file mode 100644 index 000000000..5f6069997 --- /dev/null +++ b/crates/brk_computer/src/internal/containers/window_24h.rs @@ -0,0 +1,7 @@ +use brk_traversable::Traversable; + +/// Generic single-24h-window container. +#[derive(Traversable)] +pub struct RollingWindow24h { + pub _24h: Inner, +} diff --git a/crates/brk_computer/src/internal/containers/windows_except_1m.rs b/crates/brk_computer/src/internal/containers/windows_except_1m.rs new file mode 100644 index 000000000..8e8549624 --- /dev/null +++ b/crates/brk_computer/src/internal/containers/windows_except_1m.rs @@ -0,0 +1,30 @@ +use brk_traversable::Traversable; + +#[derive(Clone, Traversable)] +pub struct WindowsExcept1m { + pub _24h: A, + pub _1w: A, + pub _1y: A, +} + +impl WindowsExcept1m { + pub const SUFFIXES: [&'static str; 3] = ["24h", "1w", "1y"]; + + pub fn try_from_fn( + mut f: impl FnMut(&str) -> std::result::Result, + ) -> std::result::Result { + Ok(Self { + _24h: f(Self::SUFFIXES[0])?, + _1w: f(Self::SUFFIXES[1])?, + _1y: f(Self::SUFFIXES[2])?, + }) + } + + pub fn as_array(&self) -> [&A; 3] { + [&self._24h, &self._1w, &self._1y] + } + + pub fn as_mut_array(&mut self) -> [&mut A; 3] { + [&mut self._24h, &mut self._1w, &mut self._1y] + } +} diff --git a/crates/brk_computer/src/internal/containers/windows_from_1w.rs b/crates/brk_computer/src/internal/containers/windows_from_1w.rs new file mode 100644 index 000000000..f2a1cba70 --- /dev/null +++ b/crates/brk_computer/src/internal/containers/windows_from_1w.rs @@ -0,0 +1,30 @@ +use brk_traversable::Traversable; + +#[derive(Clone, Traversable)] +pub struct WindowsFrom1w { + pub _1w: A, + pub _1m: A, + pub _1y: A, +} + +impl WindowsFrom1w { + pub const SUFFIXES: [&'static str; 3] = ["1w", "1m", "1y"]; + + pub fn try_from_fn( + mut f: impl FnMut(&str) -> std::result::Result, + ) -> std::result::Result { + Ok(Self { + _1w: f(Self::SUFFIXES[0])?, + _1m: f(Self::SUFFIXES[1])?, + _1y: f(Self::SUFFIXES[2])?, + }) + } + + pub fn as_array(&self) -> [&A; 3] { + [&self._1w, &self._1m, &self._1y] + } + + pub fn as_mut_array(&mut self) -> [&mut A; 3] { + [&mut self._1w, &mut self._1m, &mut self._1y] + } +} diff --git a/crates/brk_computer/src/internal/per_block/amount/mod.rs b/crates/brk_computer/src/internal/per_block/amount/mod.rs index c89f89a44..9198a4aa4 100644 --- a/crates/brk_computer/src/internal/per_block/amount/mod.rs +++ b/crates/brk_computer/src/internal/per_block/amount/mod.rs @@ -8,6 +8,7 @@ mod rolling; mod rolling_full; mod rolling_sum; mod windows; +mod with_sum_24h; pub use base::*; pub use cumulative::*; @@ -19,3 +20,4 @@ pub use rolling::*; pub use rolling_full::*; pub use rolling_sum::*; pub use windows::*; +pub use with_sum_24h::*; diff --git a/crates/brk_computer/src/internal/per_block/amount/rolling_sum.rs b/crates/brk_computer/src/internal/per_block/amount/rolling_sum.rs index abf5a210d..3d333f84a 100644 --- a/crates/brk_computer/src/internal/per_block/amount/rolling_sum.rs +++ b/crates/brk_computer/src/internal/per_block/amount/rolling_sum.rs @@ -6,9 +6,43 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{AmountPerBlock, WindowStarts, Windows}, + internal::{AmountPerBlock, RollingWindow24h, WindowStarts, Windows}, }; +/// Single 24h rolling sum as amount (sats + btc + cents + usd). +/// +/// Tree: `_24h.sats.height`, `_24h.btc.height`, etc. +#[derive(Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct RollingWindow24hAmountPerBlock( + pub RollingWindow24h>, +); + +impl RollingWindow24hAmountPerBlock { + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + indexes: &indexes::Vecs, + ) -> Result { + Ok(Self(RollingWindow24h { + _24h: AmountPerBlock::forced_import(db, &format!("{name}_24h"), version, indexes)?, + })) + } + + pub(crate) fn compute_rolling_sum( + &mut self, + max_from: Height, + height_24h_ago: &impl ReadableVec, + sats_source: &impl ReadableVec, + cents_source: &impl ReadableVec, + exit: &Exit, + ) -> Result<()> { + self._24h + .compute_rolling_sum(max_from, height_24h_ago, sats_source, cents_source, exit) + } +} + /// Rolling sum only, window-first then unit. /// /// Tree: `_24h.sats.height`, `_24h.btc.height`, etc. diff --git a/crates/brk_computer/src/internal/per_block/amount/with_sum_24h.rs b/crates/brk_computer/src/internal/per_block/amount/with_sum_24h.rs new file mode 100644 index 000000000..9dab07f06 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/amount/with_sum_24h.rs @@ -0,0 +1,14 @@ +//! AmountPerBlockWithSum24h - AmountPerBlock raw + RollingWindow24hAmountPerBlock sum. + +use brk_traversable::Traversable; +use vecdb::{Rw, StorageMode}; + +use crate::internal::{AmountPerBlock, RollingWindow24hAmountPerBlock}; + +/// Amount per-block value (sats + cents) with 24h rolling sum (also amount). +#[derive(Traversable)] +pub struct AmountPerBlockWithSum24h { + #[traversable(flatten)] + pub raw: AmountPerBlock, + pub sum: RollingWindow24hAmountPerBlock, +} diff --git a/crates/brk_computer/src/internal/per_block/computed/delta.rs b/crates/brk_computer/src/internal/per_block/computed/delta.rs index 43fc27639..ceb159afd 100644 --- a/crates/brk_computer/src/internal/per_block/computed/delta.rs +++ b/crates/brk_computer/src/internal/per_block/computed/delta.rs @@ -19,7 +19,7 @@ use crate::{ indexes, internal::{ ComputedPerBlock, NumericValue, PercentPerBlock, PercentRollingWindows, - RollingWindows, WindowStarts, + RollingWindows, WindowStarts, WindowsExcept1m, }, }; @@ -168,7 +168,9 @@ where S: NumericValue + JsonSchema, C: NumericValue + JsonSchema, { + #[traversable(wrap = "change", rename = "1m")] pub change_1m: ComputedPerBlock, + #[traversable(wrap = "rate", rename = "1m")] pub rate_1m: PercentPerBlock, _phantom: std::marker::PhantomData, } @@ -227,14 +229,8 @@ where S: NumericValue + JsonSchema, C: NumericValue + JsonSchema, { - #[traversable(rename = "24h")] - pub change_24h: ComputedPerBlock, - pub change_1w: ComputedPerBlock, - pub change_1y: ComputedPerBlock, - #[traversable(rename = "24h")] - pub rate_24h: PercentPerBlock, - pub rate_1w: PercentPerBlock, - pub rate_1y: PercentPerBlock, + pub change: WindowsExcept1m>, + pub rate: WindowsExcept1m>, _phantom: std::marker::PhantomData, } @@ -250,42 +246,22 @@ where indexes: &indexes::Vecs, ) -> Result { Ok(Self { - change_24h: ComputedPerBlock::forced_import( - db, - &format!("{name}_change_24h"), - version, - indexes, - )?, - change_1w: ComputedPerBlock::forced_import( - db, - &format!("{name}_change_1w"), - version, - indexes, - )?, - change_1y: ComputedPerBlock::forced_import( - db, - &format!("{name}_change_1y"), - version, - indexes, - )?, - rate_24h: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_24h"), - version, - indexes, - )?, - rate_1w: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_1w"), - version, - indexes, - )?, - rate_1y: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_1y"), - version, - indexes, - )?, + change: WindowsExcept1m::try_from_fn(|suffix| { + ComputedPerBlock::forced_import( + db, + &format!("{name}_change_{suffix}"), + version, + indexes, + ) + })?, + rate: WindowsExcept1m::try_from_fn(|suffix| { + PercentPerBlock::forced_import( + db, + &format!("{name}_rate_{suffix}"), + version, + indexes, + ) + })?, _phantom: std::marker::PhantomData, }) } @@ -297,8 +273,8 @@ where source: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - let changes = [&mut self.change_24h, &mut self.change_1w, &mut self.change_1y]; - let rates = [&mut self.rate_24h, &mut self.rate_1w, &mut self.rate_1y]; + let changes = self.change.as_mut_array(); + let rates = self.rate.as_mut_array(); let starts = [windows._24h, windows._1w, windows._1y]; for ((change_w, rate_w), starts) in changes.into_iter().zip(rates).zip(starts) { diff --git a/crates/brk_computer/src/internal/per_block/computed/fiat_delta.rs b/crates/brk_computer/src/internal/per_block/computed/fiat_delta.rs index e31b7a1bd..5f58e1118 100644 --- a/crates/brk_computer/src/internal/per_block/computed/fiat_delta.rs +++ b/crates/brk_computer/src/internal/per_block/computed/fiat_delta.rs @@ -11,7 +11,7 @@ use crate::{ indexes, internal::{ CentsType, FiatPerBlock, NumericValue, PercentPerBlock, PercentRollingWindows, - WindowStarts, + Windows, WindowStarts, WindowsExcept1m, }, }; @@ -24,7 +24,9 @@ where S: NumericValue + JsonSchema, C: CentsType, { + #[traversable(wrap = "change", rename = "1m")] pub change_1m: FiatPerBlock, + #[traversable(wrap = "rate", rename = "1m")] pub rate_1m: PercentPerBlock, _phantom: std::marker::PhantomData, } @@ -82,14 +84,8 @@ where S: NumericValue + JsonSchema, C: CentsType, { - #[traversable(rename = "24h")] - pub change_24h: FiatPerBlock, - pub change_1w: FiatPerBlock, - pub change_1y: FiatPerBlock, - #[traversable(rename = "24h")] - pub rate_24h: PercentPerBlock, - pub rate_1w: PercentPerBlock, - pub rate_1y: PercentPerBlock, + pub change: WindowsExcept1m>, + pub rate: WindowsExcept1m>, _phantom: std::marker::PhantomData, } @@ -105,42 +101,22 @@ where indexes: &indexes::Vecs, ) -> Result { Ok(Self { - change_24h: FiatPerBlock::forced_import( - db, - &format!("{name}_change_24h"), - version, - indexes, - )?, - change_1w: FiatPerBlock::forced_import( - db, - &format!("{name}_change_1w"), - version, - indexes, - )?, - change_1y: FiatPerBlock::forced_import( - db, - &format!("{name}_change_1y"), - version, - indexes, - )?, - rate_24h: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_24h"), - version, - indexes, - )?, - rate_1w: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_1w"), - version, - indexes, - )?, - rate_1y: PercentPerBlock::forced_import( - db, - &format!("{name}_rate_1y"), - version, - indexes, - )?, + change: WindowsExcept1m::try_from_fn(|suffix| { + FiatPerBlock::forced_import( + db, + &format!("{name}_change_{suffix}"), + version, + indexes, + ) + })?, + rate: WindowsExcept1m::try_from_fn(|suffix| { + PercentPerBlock::forced_import( + db, + &format!("{name}_rate_{suffix}"), + version, + indexes, + ) + })?, _phantom: std::marker::PhantomData, }) } @@ -152,12 +128,8 @@ where source: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - let changes: [&mut FiatPerBlock; 3] = [ - &mut self.change_24h, - &mut self.change_1w, - &mut self.change_1y, - ]; - let rates = [&mut self.rate_24h, &mut self.rate_1w, &mut self.rate_1y]; + let changes = self.change.as_mut_array(); + let rates = self.rate.as_mut_array(); let starts = [windows._24h, windows._1w, windows._1y]; for ((change_w, rate_w), starts) in changes.into_iter().zip(rates).zip(starts) { @@ -181,10 +153,7 @@ where S: NumericValue + JsonSchema, C: CentsType, { - pub change_24h: FiatPerBlock, - pub change_1w: FiatPerBlock, - pub change_1m: FiatPerBlock, - pub change_1y: FiatPerBlock, + pub change: Windows>, pub rate: PercentRollingWindows, _phantom: std::marker::PhantomData, } @@ -201,30 +170,14 @@ where indexes: &indexes::Vecs, ) -> Result { Ok(Self { - change_24h: FiatPerBlock::forced_import( - db, - &format!("{name}_change_24h"), - version, - indexes, - )?, - change_1w: FiatPerBlock::forced_import( - db, - &format!("{name}_change_1w"), - version, - indexes, - )?, - change_1m: FiatPerBlock::forced_import( - db, - &format!("{name}_change_1m"), - version, - indexes, - )?, - change_1y: FiatPerBlock::forced_import( - db, - &format!("{name}_change_1y"), - version, - indexes, - )?, + change: Windows::try_from_fn(|suffix| { + FiatPerBlock::forced_import( + db, + &format!("{name}_change_{suffix}"), + version, + indexes, + ) + })?, rate: PercentRollingWindows::forced_import( db, &format!("{name}_rate"), @@ -242,12 +195,7 @@ where source: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - let changes: [&mut FiatPerBlock; 4] = [ - &mut self.change_24h, - &mut self.change_1w, - &mut self.change_1m, - &mut self.change_1y, - ]; + let changes = self.change.as_mut_array(); let rates = self.rate.0.as_mut_array(); let starts = windows.as_array(); diff --git a/crates/brk_computer/src/internal/per_block/computed/mod.rs b/crates/brk_computer/src/internal/per_block/computed/mod.rs index 314a444c0..6e1f16fad 100644 --- a/crates/brk_computer/src/internal/per_block/computed/mod.rs +++ b/crates/brk_computer/src/internal/per_block/computed/mod.rs @@ -10,6 +10,7 @@ mod fiat_delta; mod full; mod rolling_average; mod sum; +mod with_sum_24h; pub use aggregated::*; pub use base::*; @@ -23,3 +24,4 @@ pub use fiat_delta::*; pub use full::*; pub use rolling_average::*; pub use sum::*; +pub use with_sum_24h::*; diff --git a/crates/brk_computer/src/internal/per_block/computed/resolutions.rs b/crates/brk_computer/src/internal/per_block/computed/resolutions.rs index f0bbf9411..39ce599e8 100644 --- a/crates/brk_computer/src/internal/per_block/computed/resolutions.rs +++ b/crates/brk_computer/src/internal/per_block/computed/resolutions.rs @@ -90,12 +90,7 @@ where break; } let target = S1I::max_from(I::from(i), source_len); - if cursor.position() <= target { - cursor.advance(target - cursor.position()); - if let Some(v) = cursor.next() { - f(v); - } - } else if let Some(v) = source.collect_one_at(target) { + if let Some(v) = cursor.get(target) { f(v); } } diff --git a/crates/brk_computer/src/internal/per_block/computed/with_sum_24h.rs b/crates/brk_computer/src/internal/per_block/computed/with_sum_24h.rs new file mode 100644 index 000000000..6c1ee5355 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/computed/with_sum_24h.rs @@ -0,0 +1,19 @@ +//! PerBlockWithSum24h - ComputedPerBlock + RollingWindow24hPerBlock rolling sum. +//! +//! Generic building block for metrics that store a per-block value +//! plus its 24h rolling sum. Used across activity and realized metrics. + +use brk_traversable::Traversable; +use schemars::JsonSchema; +use vecdb::{Rw, StorageMode}; + +use crate::internal::{ComputedPerBlock, ComputedVecValue, RollingWindow24hPerBlock}; + +#[derive(Traversable)] +pub struct PerBlockWithSum24h +where + T: ComputedVecValue + PartialOrd + JsonSchema, +{ + pub raw: ComputedPerBlock, + pub sum: RollingWindow24hPerBlock, +} diff --git a/crates/brk_computer/src/internal/per_block/fiat/mod.rs b/crates/brk_computer/src/internal/per_block/fiat/mod.rs index 230d73479..2a53f64e9 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/mod.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/mod.rs @@ -1,5 +1,7 @@ mod base; mod lazy; +mod with_sum_24h; pub use base::*; pub use lazy::*; +pub use with_sum_24h::*; diff --git a/crates/brk_computer/src/internal/per_block/fiat/with_sum_24h.rs b/crates/brk_computer/src/internal/per_block/fiat/with_sum_24h.rs new file mode 100644 index 000000000..6c356ac71 --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/fiat/with_sum_24h.rs @@ -0,0 +1,59 @@ +//! FiatPerBlockWithSum24h - FiatPerBlock raw + RollingWindow24hFiatPerBlock sum. + +use std::ops::SubAssign; + +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{Height, Version}; +use derive_more::{Deref, DerefMut}; +use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; + +use crate::{ + indexes, + internal::{CentsType, FiatPerBlock, RollingWindow24h}, +}; + +/// Single 24h rolling window backed by FiatPerBlock (cents + lazy usd). +#[derive(Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct RollingWindow24hFiatPerBlock( + pub RollingWindow24h>, +); + +impl RollingWindow24hFiatPerBlock { + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + indexes: &indexes::Vecs, + ) -> Result { + Ok(Self(RollingWindow24h { + _24h: FiatPerBlock::forced_import(db, &format!("{name}_24h"), version, indexes)?, + })) + } + + pub(crate) fn compute_rolling_sum( + &mut self, + max_from: Height, + height_24h_ago: &impl ReadableVec, + source: &impl ReadableVec, + exit: &Exit, + ) -> Result<()> + where + C: Default + SubAssign, + { + self._24h + .cents + .height + .compute_rolling_sum(max_from, height_24h_ago, source, exit)?; + Ok(()) + } +} + +/// Fiat per-block value (cents + usd) with 24h rolling sum (also fiat). +#[derive(Traversable)] +pub struct FiatPerBlockWithSum24h { + #[traversable(flatten)] + pub raw: FiatPerBlock, + pub sum: RollingWindow24hFiatPerBlock, +} diff --git a/crates/brk_computer/src/internal/per_block/ratio/base.rs b/crates/brk_computer/src/internal/per_block/ratio/base.rs index 0bd400c4f..7b211807e 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/base.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/base.rs @@ -5,18 +5,18 @@ use vecdb::{Database, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{Bp32ToFloat, ComputedPerBlock, LazyPerBlock}, + internal::{BpsType, ComputedPerBlock, LazyPerBlock}, }; #[derive(Traversable)] -pub struct RatioPerBlock { - pub bps: ComputedPerBlock, - pub ratio: LazyPerBlock, +pub struct RatioPerBlock { + pub bps: ComputedPerBlock, + pub ratio: LazyPerBlock, } const VERSION: Version = Version::TWO; -impl RatioPerBlock { +impl RatioPerBlock { pub(crate) fn forced_import( db: &Database, name: &str, @@ -36,7 +36,7 @@ impl RatioPerBlock { let bps = ComputedPerBlock::forced_import(db, &format!("{name}_bps"), v, indexes)?; - let ratio = LazyPerBlock::from_computed::( + let ratio = LazyPerBlock::from_computed::( name, v, bps.height.read_only_boxed_clone(), @@ -45,7 +45,9 @@ impl RatioPerBlock { Ok(Self { bps, ratio }) } +} +impl RatioPerBlock { pub(crate) fn compute_ratio( &mut self, starting_indexes: &Indexes, diff --git a/crates/brk_computer/src/internal/per_block/ratio/extended.rs b/crates/brk_computer/src/internal/per_block/ratio/extended.rs index c3262639d..3f63f8622 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/extended.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/extended.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Cents, Height, Indexes, Version}; +use brk_types::{BasisPoints32, Cents, Height, Indexes, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; @@ -13,7 +13,7 @@ pub struct RatioPerBlockExtended { #[deref] #[deref_mut] #[traversable(flatten)] - pub base: RatioPerBlock, + pub base: RatioPerBlock, #[traversable(flatten)] pub percentiles: RatioPerBlockPercentiles, } diff --git a/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs b/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs index 6f1a093a1..47edd812f 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs @@ -13,22 +13,23 @@ use crate::{ use super::{super::ComputedPerBlock, RatioPerBlock}; +#[derive(Traversable)] +pub struct RatioBand { + #[traversable(flatten)] + pub ratio: RatioPerBlock, + pub price: Price>, +} + #[derive(Traversable)] pub struct RatioPerBlockPercentiles { - pub ratio_sma_1w: RatioPerBlock, - pub ratio_sma_1m: RatioPerBlock, - pub ratio_pct99: RatioPerBlock, - pub ratio_pct98: RatioPerBlock, - pub ratio_pct95: RatioPerBlock, - pub ratio_pct5: RatioPerBlock, - pub ratio_pct2: RatioPerBlock, - pub ratio_pct1: RatioPerBlock, - pub ratio_pct99_price: Price>, - pub ratio_pct98_price: Price>, - pub ratio_pct95_price: Price>, - pub ratio_pct5_price: Price>, - pub ratio_pct2_price: Price>, - pub ratio_pct1_price: Price>, + pub sma_1w: RatioPerBlock, + pub sma_1m: RatioPerBlock, + pub pct99: RatioBand, + pub pct98: RatioBand, + pub pct95: RatioBand, + pub pct5: RatioBand, + pub pct2: RatioBand, + pub pct1: RatioBand, #[traversable(skip)] expanding_pct: ExpandingPercentiles, @@ -62,21 +63,24 @@ impl RatioPerBlockPercentiles { }; } + macro_rules! import_band { + ($suffix:expr) => { + RatioBand { + ratio: import_ratio!($suffix), + price: import_price!($suffix), + } + }; + } + Ok(Self { - ratio_sma_1w: import_ratio!("ratio_sma_1w"), - ratio_sma_1m: import_ratio!("ratio_sma_1m"), - ratio_pct99: import_ratio!("ratio_pct99"), - ratio_pct98: import_ratio!("ratio_pct98"), - ratio_pct95: import_ratio!("ratio_pct95"), - ratio_pct5: import_ratio!("ratio_pct5"), - ratio_pct2: import_ratio!("ratio_pct2"), - ratio_pct1: import_ratio!("ratio_pct1"), - ratio_pct99_price: import_price!("ratio_pct99"), - ratio_pct98_price: import_price!("ratio_pct98"), - ratio_pct95_price: import_price!("ratio_pct95"), - ratio_pct5_price: import_price!("ratio_pct5"), - ratio_pct2_price: import_price!("ratio_pct2"), - ratio_pct1_price: import_price!("ratio_pct1"), + sma_1w: import_ratio!("ratio_sma_1w"), + sma_1m: import_ratio!("ratio_sma_1m"), + pct99: import_band!("ratio_pct99"), + pct98: import_band!("ratio_pct98"), + pct95: import_band!("ratio_pct95"), + pct5: import_band!("ratio_pct5"), + pct2: import_band!("ratio_pct2"), + pct1: import_band!("ratio_pct1"), expanding_pct: ExpandingPercentiles::default(), }) } @@ -89,14 +93,14 @@ impl RatioPerBlockPercentiles { ratio_source: &impl ReadableVec, metric_price: &impl ReadableVec, ) -> Result<()> { - self.ratio_sma_1w.bps.height.compute_rolling_average( + self.sma_1w.bps.height.compute_rolling_average( starting_indexes.height, &blocks.lookback.height_1w_ago, ratio_source, exit, )?; - self.ratio_sma_1m.bps.height.compute_rolling_average( + self.sma_1m.bps.height.compute_rolling_average( starting_indexes.height, &blocks.lookback.height_1m_ago, ratio_source, @@ -131,12 +135,12 @@ impl RatioPerBlockPercentiles { let new_ratios = ratio_source.collect_range_at(start, ratio_len); let mut pct_vecs: [&mut EagerVec>; 6] = [ - &mut self.ratio_pct1.bps.height, - &mut self.ratio_pct2.bps.height, - &mut self.ratio_pct5.bps.height, - &mut self.ratio_pct95.bps.height, - &mut self.ratio_pct98.bps.height, - &mut self.ratio_pct99.bps.height, + &mut self.pct1.ratio.bps.height, + &mut self.pct2.ratio.bps.height, + &mut self.pct5.ratio.bps.height, + &mut self.pct95.ratio.bps.height, + &mut self.pct98.ratio.bps.height, + &mut self.pct99.ratio.bps.height, ]; const PCTS: [f64; 6] = [0.01, 0.02, 0.05, 0.95, 0.98, 0.99]; let mut out = [0u32; 6]; @@ -158,24 +162,25 @@ impl RatioPerBlockPercentiles { // Cents bands macro_rules! compute_band { - ($usd_field:ident, $band_source:expr) => { - self.$usd_field + ($band:ident) => { + self.$band + .price .cents .compute_binary::( starting_indexes.height, metric_price, - $band_source, + &self.$band.ratio.bps.height, exit, )?; }; } - compute_band!(ratio_pct99_price, &self.ratio_pct99.bps.height); - compute_band!(ratio_pct98_price, &self.ratio_pct98.bps.height); - compute_band!(ratio_pct95_price, &self.ratio_pct95.bps.height); - compute_band!(ratio_pct5_price, &self.ratio_pct5.bps.height); - compute_band!(ratio_pct2_price, &self.ratio_pct2.bps.height); - compute_band!(ratio_pct1_price, &self.ratio_pct1.bps.height); + compute_band!(pct99); + compute_band!(pct98); + compute_band!(pct95); + compute_band!(pct5); + compute_band!(pct2); + compute_band!(pct1); Ok(()) } @@ -184,12 +189,12 @@ impl RatioPerBlockPercentiles { &mut self, ) -> impl Iterator>> { [ - &mut self.ratio_pct1.bps.height, - &mut self.ratio_pct2.bps.height, - &mut self.ratio_pct5.bps.height, - &mut self.ratio_pct95.bps.height, - &mut self.ratio_pct98.bps.height, - &mut self.ratio_pct99.bps.height, + &mut self.pct1.ratio.bps.height, + &mut self.pct2.ratio.bps.height, + &mut self.pct5.ratio.bps.height, + &mut self.pct95.ratio.bps.height, + &mut self.pct98.ratio.bps.height, + &mut self.pct99.ratio.bps.height, ] .into_iter() } diff --git a/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs b/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs index 4aa14e805..219d85b28 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Cents, Height, Indexes, Version}; +use brk_types::{BasisPoints32, Cents, Height, Indexes, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; @@ -14,7 +14,7 @@ pub struct PriceWithRatioPerBlock { #[deref] #[deref_mut] #[traversable(flatten)] - pub inner: RatioPerBlock, + pub inner: RatioPerBlock, pub price: Price>, } diff --git a/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs b/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs index c57471c9a..3d664e1a5 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/std_dev_bands.rs @@ -7,10 +7,10 @@ use crate::{blocks, indexes, internal::StdDevPerBlockExtended}; #[derive(Traversable)] pub struct RatioPerBlockStdDevBands { - pub ratio_sd: StdDevPerBlockExtended, - pub ratio_sd_4y: StdDevPerBlockExtended, - pub ratio_sd_2y: StdDevPerBlockExtended, - pub ratio_sd_1y: StdDevPerBlockExtended, + pub all: StdDevPerBlockExtended, + pub _4y: StdDevPerBlockExtended, + pub _2y: StdDevPerBlockExtended, + pub _1y: StdDevPerBlockExtended, } const VERSION: Version = Version::new(4); @@ -38,10 +38,10 @@ impl RatioPerBlockStdDevBands { } Ok(Self { - ratio_sd: import_sd!("ratio", "", usize::MAX), - ratio_sd_1y: import_sd!("ratio", "1y", 365), - ratio_sd_2y: import_sd!("ratio", "2y", 2 * 365), - ratio_sd_4y: import_sd!("ratio", "4y", 4 * 365), + all: import_sd!("ratio", "", usize::MAX), + _1y: import_sd!("ratio", "1y", 365), + _2y: import_sd!("ratio", "2y", 2 * 365), + _4y: import_sd!("ratio", "4y", 4 * 365), }) } @@ -54,10 +54,10 @@ impl RatioPerBlockStdDevBands { metric_price: &impl ReadableVec, ) -> Result<()> { for sd in [ - &mut self.ratio_sd, - &mut self.ratio_sd_4y, - &mut self.ratio_sd_2y, - &mut self.ratio_sd_1y, + &mut self.all, + &mut self._4y, + &mut self._2y, + &mut self._1y, ] { sd.compute_all(blocks, starting_indexes, exit, ratio_source)?; sd.compute_cents_bands(starting_indexes, metric_price, exit)?; diff --git a/crates/brk_computer/src/internal/per_block/rolling/windows.rs b/crates/brk_computer/src/internal/per_block/rolling/windows.rs index 69528cd36..f24139ff2 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/windows.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/windows.rs @@ -15,7 +15,7 @@ use vecdb::{Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{ComputedPerBlock, ComputedVecValue, NumericValue, Windows}, + internal::{ComputedPerBlock, ComputedVecValue, NumericValue, RollingWindow24h, Windows, WindowsFrom1w}, }; /// Rolling window start heights — the 4 height-ago vecs (24h, 1w, 1m, 1y). @@ -61,16 +61,16 @@ where } } -/// Single 24h rolling window (1 stored vec). -#[derive(Traversable)] -pub struct RollingWindow24h +/// Single 24h rolling window backed by ComputedPerBlock (1 stored vec). +#[derive(Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct RollingWindow24hPerBlock( + pub RollingWindow24h>, +) where - T: ComputedVecValue + PartialOrd + JsonSchema, -{ - pub _24h: ComputedPerBlock, -} + T: ComputedVecValue + PartialOrd + JsonSchema; -impl RollingWindow24h +impl RollingWindow24hPerBlock where T: NumericValue + JsonSchema, { @@ -80,14 +80,14 @@ where version: Version, indexes: &indexes::Vecs, ) -> Result { - Ok(Self { + Ok(Self(RollingWindow24h { _24h: ComputedPerBlock::forced_import( db, &format!("{name}_24h"), version, indexes, )?, - }) + })) } pub(crate) fn compute_rolling_sum( @@ -108,15 +108,11 @@ where } /// Extended rolling windows: 1w + 1m + 1y (3 stored vecs). -#[derive(Traversable)] -pub struct RollingWindowsFrom1w +#[derive(Deref, DerefMut, Traversable)] +#[traversable(transparent)] +pub struct RollingWindowsFrom1w(pub WindowsFrom1w>) where - T: ComputedVecValue + PartialOrd + JsonSchema, -{ - pub _1w: ComputedPerBlock, - pub _1m: ComputedPerBlock, - pub _1y: ComputedPerBlock, -} + T: ComputedVecValue + PartialOrd + JsonSchema; impl RollingWindowsFrom1w where @@ -128,34 +124,9 @@ where version: Version, indexes: &indexes::Vecs, ) -> Result { - Ok(Self { - _1w: ComputedPerBlock::forced_import( - db, - &format!("{name}_1w"), - version, - indexes, - )?, - _1m: ComputedPerBlock::forced_import( - db, - &format!("{name}_1m"), - version, - indexes, - )?, - _1y: ComputedPerBlock::forced_import( - db, - &format!("{name}_1y"), - version, - indexes, - )?, - }) - } - - pub fn as_array(&self) -> [&ComputedPerBlock; 3] { - [&self._1w, &self._1m, &self._1y] - } - - pub fn as_mut_array(&mut self) -> [&mut ComputedPerBlock; 3] { - [&mut self._1w, &mut self._1m, &mut self._1y] + Ok(Self(WindowsFrom1w::try_from_fn(|suffix| { + ComputedPerBlock::forced_import(db, &format!("{name}_{suffix}"), version, indexes) + })?)) } pub(crate) fn compute_rolling_sum( @@ -168,15 +139,11 @@ where where T: Default + SubAssign, { - self._1w - .height - .compute_rolling_sum(max_from, windows._1w, source, exit)?; - self._1m - .height - .compute_rolling_sum(max_from, windows._1m, source, exit)?; - self._1y - .height - .compute_rolling_sum(max_from, windows._1y, source, exit)?; + let starts = [windows._1w, windows._1m, windows._1y]; + for (w, starts) in self.0.as_mut_array().into_iter().zip(starts) { + w.height + .compute_rolling_sum(max_from, starts, source, exit)?; + } Ok(()) } } diff --git a/crates/brk_computer/src/internal/per_block/stddev/extended.rs b/crates/brk_computer/src/internal/per_block/stddev/extended.rs index 86df1f4a7..678d8edc2 100644 --- a/crates/brk_computer/src/internal/per_block/stddev/extended.rs +++ b/crates/brk_computer/src/internal/per_block/stddev/extended.rs @@ -2,17 +2,31 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Cents, Height, Indexes, StoredF32, Version}; use vecdb::{ - AnyStoredVec, AnyVec, Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode, VecIndex, - WritableVec, + AnyStoredVec, AnyVec, Database, EagerVec, Exit, Ident, PcoVec, ReadableCloneableVec, + ReadableVec, Rw, StorageMode, VecIndex, WritableVec, }; use crate::{ blocks, indexes, - internal::{ComputedPerBlock, Price, PriceTimesRatioCents}, + internal::{ComputedPerBlock, LazyPerBlock, Price, PriceTimesRatioCents}, }; use super::StdDevPerBlock; +#[derive(Traversable)] +pub struct StdDevBand { + #[traversable(flatten)] + pub value: ComputedPerBlock, + pub price: Price>, +} + +#[derive(Traversable)] +pub struct LazyStdDevBand { + #[traversable(flatten)] + pub value: LazyPerBlock, + pub price: Price>, +} + #[derive(Traversable)] pub struct StdDevPerBlockExtended { #[traversable(flatten)] @@ -20,32 +34,19 @@ pub struct StdDevPerBlockExtended { pub zscore: ComputedPerBlock, - pub p0_5sd: ComputedPerBlock, - pub p1sd: ComputedPerBlock, - pub p1_5sd: ComputedPerBlock, - pub p2sd: ComputedPerBlock, - pub p2_5sd: ComputedPerBlock, - pub p3sd: ComputedPerBlock, - pub m0_5sd: ComputedPerBlock, - pub m1sd: ComputedPerBlock, - pub m1_5sd: ComputedPerBlock, - pub m2sd: ComputedPerBlock, - pub m2_5sd: ComputedPerBlock, - pub m3sd: ComputedPerBlock, - - pub _0sd_price: Price>, - pub p0_5sd_price: Price>, - pub p1sd_price: Price>, - pub p1_5sd_price: Price>, - pub p2sd_price: Price>, - pub p2_5sd_price: Price>, - pub p3sd_price: Price>, - pub m0_5sd_price: Price>, - pub m1sd_price: Price>, - pub m1_5sd_price: Price>, - pub m2sd_price: Price>, - pub m2_5sd_price: Price>, - pub m3sd_price: Price>, + pub _0sd: LazyStdDevBand, + pub p0_5sd: StdDevBand, + pub p1sd: StdDevBand, + pub p1_5sd: StdDevBand, + pub p2sd: StdDevBand, + pub p2_5sd: StdDevBand, + pub p3sd: StdDevBand, + pub m0_5sd: StdDevBand, + pub m1sd: StdDevBand, + pub m1_5sd: StdDevBand, + pub m2sd: StdDevBand, + pub m2_5sd: StdDevBand, + pub m3sd: StdDevBand, } impl StdDevPerBlockExtended { @@ -77,41 +78,50 @@ impl StdDevPerBlockExtended { }; } + macro_rules! import_band { + ($suffix:expr) => { + StdDevBand { + value: import!($suffix), + price: import_price!($suffix), + } + }; + } + + let base = StdDevPerBlock::forced_import( + db, + name, + period, + days, + parent_version, + indexes, + )?; + + let _0sd = LazyStdDevBand { + value: LazyPerBlock::from_computed::( + &format!("{name}_0sd{p}"), + version, + base.sma.height.read_only_boxed_clone(), + &base.sma, + ), + price: import_price!("0sd"), + }; + Ok(Self { - base: StdDevPerBlock::forced_import( - db, - name, - period, - days, - parent_version, - indexes, - )?, + base, zscore: import!("zscore"), - p0_5sd: import!("p0_5sd"), - p1sd: import!("p1sd"), - p1_5sd: import!("p1_5sd"), - p2sd: import!("p2sd"), - p2_5sd: import!("p2_5sd"), - p3sd: import!("p3sd"), - m0_5sd: import!("m0_5sd"), - m1sd: import!("m1sd"), - m1_5sd: import!("m1_5sd"), - m2sd: import!("m2sd"), - m2_5sd: import!("m2_5sd"), - m3sd: import!("m3sd"), - _0sd_price: import_price!("0sd"), - p0_5sd_price: import_price!("p0_5sd"), - p1sd_price: import_price!("p1sd"), - p1_5sd_price: import_price!("p1_5sd"), - p2sd_price: import_price!("p2sd"), - p2_5sd_price: import_price!("p2_5sd"), - p3sd_price: import_price!("p3sd"), - m0_5sd_price: import_price!("m0_5sd"), - m1sd_price: import_price!("m1sd"), - m1_5sd_price: import_price!("m1_5sd"), - m2sd_price: import_price!("m2sd"), - m2_5sd_price: import_price!("m2_5sd"), - m3sd_price: import_price!("m3sd"), + _0sd, + p0_5sd: import_band!("p0_5sd"), + p1sd: import_band!("p1sd"), + p1_5sd: import_band!("p1_5sd"), + p2sd: import_band!("p2sd"), + p2_5sd: import_band!("p2_5sd"), + p3sd: import_band!("p3sd"), + m0_5sd: import_band!("m0_5sd"), + m1sd: import_band!("m1sd"), + m1_5sd: import_band!("m1_5sd"), + m2sd: import_band!("m2sd"), + m2_5sd: import_band!("m2_5sd"), + m3sd: import_band!("m3sd"), }) } @@ -214,9 +224,9 @@ impl StdDevPerBlockExtended { metric_price: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - macro_rules! compute_band { - ($usd_field:ident, $band_source:expr) => { - self.$usd_field + macro_rules! compute_band_price { + ($price:expr, $band_source:expr) => { + $price .cents .compute_binary::( starting_indexes.height, @@ -227,19 +237,19 @@ impl StdDevPerBlockExtended { }; } - compute_band!(_0sd_price, &self.base.sma.height); - compute_band!(p0_5sd_price, &self.p0_5sd.height); - compute_band!(p1sd_price, &self.p1sd.height); - compute_band!(p1_5sd_price, &self.p1_5sd.height); - compute_band!(p2sd_price, &self.p2sd.height); - compute_band!(p2_5sd_price, &self.p2_5sd.height); - compute_band!(p3sd_price, &self.p3sd.height); - compute_band!(m0_5sd_price, &self.m0_5sd.height); - compute_band!(m1sd_price, &self.m1sd.height); - compute_band!(m1_5sd_price, &self.m1_5sd.height); - compute_band!(m2sd_price, &self.m2sd.height); - compute_band!(m2_5sd_price, &self.m2_5sd.height); - compute_band!(m3sd_price, &self.m3sd.height); + compute_band_price!(&mut self._0sd.price, &self.base.sma.height); + compute_band_price!(&mut self.p0_5sd.price, &self.p0_5sd.value.height); + compute_band_price!(&mut self.p1sd.price, &self.p1sd.value.height); + compute_band_price!(&mut self.p1_5sd.price, &self.p1_5sd.value.height); + compute_band_price!(&mut self.p2sd.price, &self.p2sd.value.height); + compute_band_price!(&mut self.p2_5sd.price, &self.p2_5sd.value.height); + compute_band_price!(&mut self.p3sd.price, &self.p3sd.value.height); + compute_band_price!(&mut self.m0_5sd.price, &self.m0_5sd.value.height); + compute_band_price!(&mut self.m1sd.price, &self.m1sd.value.height); + compute_band_price!(&mut self.m1_5sd.price, &self.m1_5sd.value.height); + compute_band_price!(&mut self.m2sd.price, &self.m2sd.value.height); + compute_band_price!(&mut self.m2_5sd.price, &self.m2_5sd.value.height); + compute_band_price!(&mut self.m3sd.price, &self.m3sd.value.height); Ok(()) } @@ -248,18 +258,18 @@ impl StdDevPerBlockExtended { &mut self, ) -> impl Iterator>> { [ - &mut self.p0_5sd.height, - &mut self.p1sd.height, - &mut self.p1_5sd.height, - &mut self.p2sd.height, - &mut self.p2_5sd.height, - &mut self.p3sd.height, - &mut self.m0_5sd.height, - &mut self.m1sd.height, - &mut self.m1_5sd.height, - &mut self.m2sd.height, - &mut self.m2_5sd.height, - &mut self.m3sd.height, + &mut self.p0_5sd.value.height, + &mut self.p1sd.value.height, + &mut self.p1_5sd.value.height, + &mut self.p2sd.value.height, + &mut self.p2_5sd.value.height, + &mut self.p3sd.value.height, + &mut self.m0_5sd.value.height, + &mut self.m1sd.value.height, + &mut self.m1_5sd.value.height, + &mut self.m2sd.value.height, + &mut self.m2_5sd.value.height, + &mut self.m3sd.value.height, ] .into_iter() } diff --git a/crates/brk_computer/src/market/ath/compute.rs b/crates/brk_computer/src/market/ath/compute.rs index 5f321532a..38aecb7ed 100644 --- a/crates/brk_computer/src/market/ath/compute.rs +++ b/crates/brk_computer/src/market/ath/compute.rs @@ -13,16 +13,16 @@ impl Vecs { starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { - self.price_ath.cents.height.compute_all_time_high( + self.price.cents.height.compute_all_time_high( starting_indexes.height, &prices.price.cents.height, exit, )?; let mut ath_ts: Option = None; - self.days_since_price_ath.height.compute_transform3( + self.days_since.height.compute_transform3( starting_indexes.height, - &self.price_ath.cents.height, + &self.price.cents.height, &prices.price.cents.height, &blocks.time.timestamp_monotonic, |(i, ath, price, ts, slf)| { @@ -47,9 +47,9 @@ impl Vecs { )?; let mut prev = None; - self.max_days_between_price_ath.height.compute_transform( + self.max_days_between.height.compute_transform( starting_indexes.height, - &self.days_since_price_ath.height, + &self.days_since.height, |(i, days, slf)| { if prev.is_none() { let i = i.to_usize(); @@ -66,10 +66,10 @@ impl Vecs { exit, )?; - self.price_drawdown.compute_drawdown( + self.drawdown.compute_drawdown( starting_indexes.height, &prices.price.cents.height, - &self.price_ath.cents.height, + &self.price.cents.height, exit, )?; diff --git a/crates/brk_computer/src/market/ath/import.rs b/crates/brk_computer/src/market/ath/import.rs index 85cc7116c..ea5c98709 100644 --- a/crates/brk_computer/src/market/ath/import.rs +++ b/crates/brk_computer/src/market/ath/import.rs @@ -18,35 +18,35 @@ impl Vecs { ) -> Result { let v = version + VERSION; - let price_ath = Price::forced_import(db, "price_ath", v, indexes)?; + let price = Price::forced_import(db, "price_ath", v, indexes)?; - let max_days_between_price_ath = + let max_days_between = ComputedPerBlock::forced_import(db, "max_days_between_price_ath", v, indexes)?; - let max_years_between_price_ath = DerivedResolutions::from_computed::( + let max_years_between = DerivedResolutions::from_computed::( "max_years_between_price_ath", v, - &max_days_between_price_ath, + &max_days_between, ); - let days_since_price_ath = + let days_since = ComputedPerBlock::forced_import(db, "days_since_price_ath", v, indexes)?; - let years_since_price_ath = DerivedResolutions::from_computed::( + let years_since = DerivedResolutions::from_computed::( "years_since_price_ath", v, - &days_since_price_ath, + &days_since, ); - let price_drawdown = PercentPerBlock::forced_import(db, "price_drawdown", v, indexes)?; + let drawdown = PercentPerBlock::forced_import(db, "price_drawdown", v, indexes)?; Ok(Self { - price_ath, - price_drawdown, - days_since_price_ath, - years_since_price_ath, - max_days_between_price_ath, - max_years_between_price_ath, + price, + drawdown, + days_since, + years_since, + max_days_between, + max_years_between, }) } } diff --git a/crates/brk_computer/src/market/ath/vecs.rs b/crates/brk_computer/src/market/ath/vecs.rs index 1c5e44399..ce35e21f3 100644 --- a/crates/brk_computer/src/market/ath/vecs.rs +++ b/crates/brk_computer/src/market/ath/vecs.rs @@ -6,10 +6,10 @@ use crate::internal::{ComputedPerBlock, DerivedResolutions, PercentPerBlock, Pri #[derive(Traversable)] pub struct Vecs { - pub price_ath: Price>, - pub price_drawdown: PercentPerBlock, - pub days_since_price_ath: ComputedPerBlock, - pub years_since_price_ath: DerivedResolutions, - pub max_days_between_price_ath: ComputedPerBlock, - pub max_years_between_price_ath: DerivedResolutions, + pub price: Price>, + pub drawdown: PercentPerBlock, + pub days_since: ComputedPerBlock, + pub years_since: DerivedResolutions, + pub max_days_between: ComputedPerBlock, + pub max_years_between: DerivedResolutions, } diff --git a/crates/brk_computer/src/market/indicators/compute.rs b/crates/brk_computer/src/market/indicators/compute.rs index 239178bd9..584a88968 100644 --- a/crates/brk_computer/src/market/indicators/compute.rs +++ b/crates/brk_computer/src/market/indicators/compute.rs @@ -40,8 +40,8 @@ impl Vecs { self.stoch_k.bps.height.compute_transform3( starting_indexes.height, price, - &range.price_min_2w.usd.height, - &range.price_max_2w.usd.height, + &range.min._2w.usd.height, + &range.max._2w.usd.height, |(h, close, low, high, ..)| { let range = *high - *low; let stoch = if range == 0.0 { @@ -127,8 +127,8 @@ impl Vecs { .bps .compute_binary::( starting_indexes.height, - &moving_average.price_sma_111d.price.usd.height, - &moving_average.price_sma_350d_x2.usd.height, + &moving_average.sma._111d.price.usd.height, + &moving_average.sma._350d_x2.usd.height, exit, )?; diff --git a/crates/brk_computer/src/market/indicators/vecs.rs b/crates/brk_computer/src/market/indicators/vecs.rs index 177026f64..a0a5726a1 100644 --- a/crates/brk_computer/src/market/indicators/vecs.rs +++ b/crates/brk_computer/src/market/indicators/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints16, StoredF32}; +use brk_types::{BasisPoints16, BasisPoints32, StoredF32}; use vecdb::{Rw, StorageMode}; use crate::internal::{ComputedPerBlock, RatioPerBlock, PercentPerBlock, Windows}; @@ -29,15 +29,15 @@ pub struct MacdChain { #[derive(Traversable)] pub struct Vecs { - pub puell_multiple: RatioPerBlock, - pub nvt: RatioPerBlock, + pub puell_multiple: RatioPerBlock, + pub nvt: RatioPerBlock, pub rsi: Windows>, pub stoch_k: PercentPerBlock, pub stoch_d: PercentPerBlock, - pub pi_cycle: RatioPerBlock, + pub pi_cycle: RatioPerBlock, pub macd: Windows>, diff --git a/crates/brk_computer/src/market/moving_average/compute.rs b/crates/brk_computer/src/market/moving_average/compute.rs index bb38a974e..c5b9a9608 100644 --- a/crates/brk_computer/src/market/moving_average/compute.rs +++ b/crates/brk_computer/src/market/moving_average/compute.rs @@ -16,22 +16,22 @@ impl Vecs { let close = &prices.price.cents.height; for (sma, period) in [ - (&mut self.price_sma_1w, 7), - (&mut self.price_sma_8d, 8), - (&mut self.price_sma_13d, 13), - (&mut self.price_sma_21d, 21), - (&mut self.price_sma_1m, 30), - (&mut self.price_sma_34d, 34), - (&mut self.price_sma_55d, 55), - (&mut self.price_sma_89d, 89), - (&mut self.price_sma_111d, 111), - (&mut self.price_sma_144d, 144), - (&mut self.price_sma_200d, 200), - (&mut self.price_sma_350d, 350), - (&mut self.price_sma_1y, 365), - (&mut self.price_sma_2y, 2 * 365), - (&mut self.price_sma_200w, 200 * 7), - (&mut self.price_sma_4y, 4 * 365), + (&mut self.sma._1w, 7), + (&mut self.sma._8d, 8), + (&mut self.sma._13d, 13), + (&mut self.sma._21d, 21), + (&mut self.sma._1m, 30), + (&mut self.sma._34d, 34), + (&mut self.sma._55d, 55), + (&mut self.sma._89d, 89), + (&mut self.sma._111d, 111), + (&mut self.sma._144d, 144), + (&mut self.sma._200d, 200), + (&mut self.sma._350d, 350), + (&mut self.sma._1y, 365), + (&mut self.sma._2y, 2 * 365), + (&mut self.sma._200w, 200 * 7), + (&mut self.sma._4y, 4 * 365), ] { let window_starts = blocks.lookback.start_vec(period); sma.compute_all(prices, starting_indexes, exit, |v| { @@ -41,22 +41,22 @@ impl Vecs { } for (ema, period) in [ - (&mut self.price_ema_1w, 7), - (&mut self.price_ema_8d, 8), - (&mut self.price_ema_12d, 12), - (&mut self.price_ema_13d, 13), - (&mut self.price_ema_21d, 21), - (&mut self.price_ema_26d, 26), - (&mut self.price_ema_1m, 30), - (&mut self.price_ema_34d, 34), - (&mut self.price_ema_55d, 55), - (&mut self.price_ema_89d, 89), - (&mut self.price_ema_144d, 144), - (&mut self.price_ema_200d, 200), - (&mut self.price_ema_1y, 365), - (&mut self.price_ema_2y, 2 * 365), - (&mut self.price_ema_200w, 200 * 7), - (&mut self.price_ema_4y, 4 * 365), + (&mut self.ema._1w, 7), + (&mut self.ema._8d, 8), + (&mut self.ema._12d, 12), + (&mut self.ema._13d, 13), + (&mut self.ema._21d, 21), + (&mut self.ema._26d, 26), + (&mut self.ema._1m, 30), + (&mut self.ema._34d, 34), + (&mut self.ema._55d, 55), + (&mut self.ema._89d, 89), + (&mut self.ema._144d, 144), + (&mut self.ema._200d, 200), + (&mut self.ema._1y, 365), + (&mut self.ema._2y, 2 * 365), + (&mut self.ema._200w, 200 * 7), + (&mut self.ema._4y, 4 * 365), ] { let window_starts = blocks.lookback.start_vec(period); ema.compute_all(prices, starting_indexes, exit, |v| { diff --git a/crates/brk_computer/src/market/moving_average/import.rs b/crates/brk_computer/src/market/moving_average/import.rs index 40e72b4c3..1a4ea1600 100644 --- a/crates/brk_computer/src/market/moving_average/import.rs +++ b/crates/brk_computer/src/market/moving_average/import.rs @@ -2,10 +2,13 @@ use brk_error::Result; use brk_types::Version; use vecdb::Database; -use super::Vecs; +use super::{ + vecs::{EmaVecs, SmaVecs}, + Vecs, +}; use crate::{ indexes, - internal::{CentsTimesTenths, PriceWithRatioPerBlock, Price}, + internal::{CentsTimesTenths, Price, PriceWithRatioPerBlock}, }; impl Vecs { @@ -16,72 +19,73 @@ impl Vecs { ) -> Result { macro_rules! import { ($name:expr) => { - PriceWithRatioPerBlock::forced_import( - db, $name, version, indexes, - )? + PriceWithRatioPerBlock::forced_import(db, $name, version, indexes)? }; } - let price_sma_200d = import!("price_sma_200d"); - let price_sma_350d = import!("price_sma_350d"); + let sma_200d = import!("price_sma_200d"); + let sma_350d = import!("price_sma_350d"); - let price_sma_200d_source = &price_sma_200d.price.cents; - let price_sma_200d_x2_4 = Price::from_cents_source::>( + let price_sma_200d_source = &sma_200d.price.cents; + let _200d_x2_4 = Price::from_cents_source::>( "price_sma_200d_x2_4", version, price_sma_200d_source, ); - let price_sma_200d_x0_8 = Price::from_cents_source::>( + let _200d_x0_8 = Price::from_cents_source::>( "price_sma_200d_x0_8", version, price_sma_200d_source, ); - let price_sma_350d_source = &price_sma_350d.price.cents; - let price_sma_350d_x2 = Price::from_cents_source::>( + let price_sma_350d_source = &sma_350d.price.cents; + let _350d_x2 = Price::from_cents_source::>( "price_sma_350d_x2", version, price_sma_350d_source, ); - Ok(Self { - price_sma_1w: import!("price_sma_1w"), - price_sma_8d: import!("price_sma_8d"), - price_sma_13d: import!("price_sma_13d"), - price_sma_21d: import!("price_sma_21d"), - price_sma_1m: import!("price_sma_1m"), - price_sma_34d: import!("price_sma_34d"), - price_sma_55d: import!("price_sma_55d"), - price_sma_89d: import!("price_sma_89d"), - price_sma_111d: import!("price_sma_111d"), - price_sma_144d: import!("price_sma_144d"), - price_sma_200d, - price_sma_350d, - price_sma_1y: import!("price_sma_1y"), - price_sma_2y: import!("price_sma_2y"), - price_sma_200w: import!("price_sma_200w"), - price_sma_4y: import!("price_sma_4y"), + let sma = SmaVecs { + _1w: import!("price_sma_1w"), + _8d: import!("price_sma_8d"), + _13d: import!("price_sma_13d"), + _21d: import!("price_sma_21d"), + _1m: import!("price_sma_1m"), + _34d: import!("price_sma_34d"), + _55d: import!("price_sma_55d"), + _89d: import!("price_sma_89d"), + _111d: import!("price_sma_111d"), + _144d: import!("price_sma_144d"), + _200d: sma_200d, + _350d: sma_350d, + _1y: import!("price_sma_1y"), + _2y: import!("price_sma_2y"), + _200w: import!("price_sma_200w"), + _4y: import!("price_sma_4y"), + _200d_x2_4, + _200d_x0_8, + _350d_x2, + }; - price_ema_1w: import!("price_ema_1w"), - price_ema_8d: import!("price_ema_8d"), - price_ema_12d: import!("price_ema_12d"), - price_ema_13d: import!("price_ema_13d"), - price_ema_21d: import!("price_ema_21d"), - price_ema_26d: import!("price_ema_26d"), - price_ema_1m: import!("price_ema_1m"), - price_ema_34d: import!("price_ema_34d"), - price_ema_55d: import!("price_ema_55d"), - price_ema_89d: import!("price_ema_89d"), - price_ema_144d: import!("price_ema_144d"), - price_ema_200d: import!("price_ema_200d"), - price_ema_1y: import!("price_ema_1y"), - price_ema_2y: import!("price_ema_2y"), - price_ema_200w: import!("price_ema_200w"), - price_ema_4y: import!("price_ema_4y"), + let ema = EmaVecs { + _1w: import!("price_ema_1w"), + _8d: import!("price_ema_8d"), + _12d: import!("price_ema_12d"), + _13d: import!("price_ema_13d"), + _21d: import!("price_ema_21d"), + _26d: import!("price_ema_26d"), + _1m: import!("price_ema_1m"), + _34d: import!("price_ema_34d"), + _55d: import!("price_ema_55d"), + _89d: import!("price_ema_89d"), + _144d: import!("price_ema_144d"), + _200d: import!("price_ema_200d"), + _1y: import!("price_ema_1y"), + _2y: import!("price_ema_2y"), + _200w: import!("price_ema_200w"), + _4y: import!("price_ema_4y"), + }; - price_sma_200d_x2_4, - price_sma_200d_x0_8, - price_sma_350d_x2, - }) + Ok(Self { sma, ema }) } } diff --git a/crates/brk_computer/src/market/moving_average/vecs.rs b/crates/brk_computer/src/market/moving_average/vecs.rs index b11ab043b..a3930cb7f 100644 --- a/crates/brk_computer/src/market/moving_average/vecs.rs +++ b/crates/brk_computer/src/market/moving_average/vecs.rs @@ -2,44 +2,53 @@ use brk_traversable::Traversable; use brk_types::Cents; use vecdb::{Rw, StorageMode}; -use crate::internal::{PriceWithRatioPerBlock, LazyPerBlock, Price}; +use crate::internal::{LazyPerBlock, Price, PriceWithRatioPerBlock}; + +#[derive(Traversable)] +pub struct SmaVecs { + pub _1w: PriceWithRatioPerBlock, + pub _8d: PriceWithRatioPerBlock, + pub _13d: PriceWithRatioPerBlock, + pub _21d: PriceWithRatioPerBlock, + pub _1m: PriceWithRatioPerBlock, + pub _34d: PriceWithRatioPerBlock, + pub _55d: PriceWithRatioPerBlock, + pub _89d: PriceWithRatioPerBlock, + pub _111d: PriceWithRatioPerBlock, + pub _144d: PriceWithRatioPerBlock, + pub _200d: PriceWithRatioPerBlock, + pub _350d: PriceWithRatioPerBlock, + pub _1y: PriceWithRatioPerBlock, + pub _2y: PriceWithRatioPerBlock, + pub _200w: PriceWithRatioPerBlock, + pub _4y: PriceWithRatioPerBlock, + pub _200d_x2_4: Price>, + pub _200d_x0_8: Price>, + pub _350d_x2: Price>, +} + +#[derive(Traversable)] +pub struct EmaVecs { + pub _1w: PriceWithRatioPerBlock, + pub _8d: PriceWithRatioPerBlock, + pub _12d: PriceWithRatioPerBlock, + pub _13d: PriceWithRatioPerBlock, + pub _21d: PriceWithRatioPerBlock, + pub _26d: PriceWithRatioPerBlock, + pub _1m: PriceWithRatioPerBlock, + pub _34d: PriceWithRatioPerBlock, + pub _55d: PriceWithRatioPerBlock, + pub _89d: PriceWithRatioPerBlock, + pub _144d: PriceWithRatioPerBlock, + pub _200d: PriceWithRatioPerBlock, + pub _1y: PriceWithRatioPerBlock, + pub _2y: PriceWithRatioPerBlock, + pub _200w: PriceWithRatioPerBlock, + pub _4y: PriceWithRatioPerBlock, +} + #[derive(Traversable)] pub struct Vecs { - pub price_sma_1w: PriceWithRatioPerBlock, - pub price_sma_8d: PriceWithRatioPerBlock, - pub price_sma_13d: PriceWithRatioPerBlock, - pub price_sma_21d: PriceWithRatioPerBlock, - pub price_sma_1m: PriceWithRatioPerBlock, - pub price_sma_34d: PriceWithRatioPerBlock, - pub price_sma_55d: PriceWithRatioPerBlock, - pub price_sma_89d: PriceWithRatioPerBlock, - pub price_sma_111d: PriceWithRatioPerBlock, - pub price_sma_144d: PriceWithRatioPerBlock, - pub price_sma_200d: PriceWithRatioPerBlock, - pub price_sma_350d: PriceWithRatioPerBlock, - pub price_sma_1y: PriceWithRatioPerBlock, - pub price_sma_2y: PriceWithRatioPerBlock, - pub price_sma_200w: PriceWithRatioPerBlock, - pub price_sma_4y: PriceWithRatioPerBlock, - - pub price_ema_1w: PriceWithRatioPerBlock, - pub price_ema_8d: PriceWithRatioPerBlock, - pub price_ema_12d: PriceWithRatioPerBlock, - pub price_ema_13d: PriceWithRatioPerBlock, - pub price_ema_21d: PriceWithRatioPerBlock, - pub price_ema_26d: PriceWithRatioPerBlock, - pub price_ema_1m: PriceWithRatioPerBlock, - pub price_ema_34d: PriceWithRatioPerBlock, - pub price_ema_55d: PriceWithRatioPerBlock, - pub price_ema_89d: PriceWithRatioPerBlock, - pub price_ema_144d: PriceWithRatioPerBlock, - pub price_ema_200d: PriceWithRatioPerBlock, - pub price_ema_1y: PriceWithRatioPerBlock, - pub price_ema_2y: PriceWithRatioPerBlock, - pub price_ema_200w: PriceWithRatioPerBlock, - pub price_ema_4y: PriceWithRatioPerBlock, - - pub price_sma_200d_x2_4: Price>, - pub price_sma_200d_x0_8: Price>, - pub price_sma_350d_x2: Price>, + pub sma: SmaVecs, + pub ema: EmaVecs, } diff --git a/crates/brk_computer/src/market/range/compute.rs b/crates/brk_computer/src/market/range/compute.rs index 307812f65..0625c48f7 100644 --- a/crates/brk_computer/src/market/range/compute.rs +++ b/crates/brk_computer/src/market/range/compute.rs @@ -17,23 +17,23 @@ impl Vecs { for (min_vec, max_vec, starts) in [ ( - &mut self.price_min_1w.cents.height, - &mut self.price_max_1w.cents.height, + &mut self.min._1w.cents.height, + &mut self.max._1w.cents.height, &blocks.lookback.height_1w_ago, ), ( - &mut self.price_min_2w.cents.height, - &mut self.price_max_2w.cents.height, + &mut self.min._2w.cents.height, + &mut self.max._2w.cents.height, &blocks.lookback.height_2w_ago, ), ( - &mut self.price_min_1m.cents.height, - &mut self.price_max_1m.cents.height, + &mut self.min._1m.cents.height, + &mut self.max._1m.cents.height, &blocks.lookback.height_1m_ago, ), ( - &mut self.price_min_1y.cents.height, - &mut self.price_max_1y.cents.height, + &mut self.min._1y.cents.height, + &mut self.max._1y.cents.height, &blocks.lookback.height_1y_ago, ), ] { @@ -53,7 +53,7 @@ impl Vecs { // True range at block level: |price[h] - price[h-1]| let mut prev_price = None; - self.price_true_range.height.compute_transform( + self.true_range.height.compute_transform( starting_indexes.height, price, |(h, current, ..)| { @@ -73,21 +73,21 @@ impl Vecs { )?; // 2w rolling sum of true range - self.price_true_range_sum_2w.height.compute_rolling_sum( + self.true_range_sum_2w.height.compute_rolling_sum( starting_indexes.height, &blocks.lookback.height_2w_ago, - &self.price_true_range.height, + &self.true_range.height, exit, )?; - self.price_choppiness_index_2w + self.choppiness_index_2w .bps .height .compute_transform4( starting_indexes.height, - &self.price_true_range_sum_2w.height, - &self.price_max_2w.cents.height, - &self.price_min_2w.cents.height, + &self.true_range_sum_2w.height, + &self.max._2w.cents.height, + &self.min._2w.cents.height, &blocks.lookback.height_2w_ago, |(h, tr_sum, max, min, window_start, ..)| { let range = f64::from(max) - f64::from(min); diff --git a/crates/brk_computer/src/market/range/import.rs b/crates/brk_computer/src/market/range/import.rs index 40d2a6794..0827c1322 100644 --- a/crates/brk_computer/src/market/range/import.rs +++ b/crates/brk_computer/src/market/range/import.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_types::Version; use vecdb::Database; -use super::Vecs; +use super::{vecs::PriceMinMaxVecs, Vecs}; use crate::{ indexes, internal::{ComputedPerBlock, PercentPerBlock, Price}, @@ -17,27 +17,31 @@ impl Vecs { let v1 = Version::ONE; Ok(Self { - price_min_1w: Price::forced_import(db, "price_min_1w", version + v1, indexes)?, - price_max_1w: Price::forced_import(db, "price_max_1w", version + v1, indexes)?, - price_min_2w: Price::forced_import(db, "price_min_2w", version + v1, indexes)?, - price_max_2w: Price::forced_import(db, "price_max_2w", version + v1, indexes)?, - price_min_1m: Price::forced_import(db, "price_min_1m", version + v1, indexes)?, - price_max_1m: Price::forced_import(db, "price_max_1m", version + v1, indexes)?, - price_min_1y: Price::forced_import(db, "price_min_1y", version + v1, indexes)?, - price_max_1y: Price::forced_import(db, "price_max_1y", version + v1, indexes)?, - price_true_range: ComputedPerBlock::forced_import( + min: PriceMinMaxVecs { + _1w: Price::forced_import(db, "price_min_1w", version + v1, indexes)?, + _2w: Price::forced_import(db, "price_min_2w", version + v1, indexes)?, + _1m: Price::forced_import(db, "price_min_1m", version + v1, indexes)?, + _1y: Price::forced_import(db, "price_min_1y", version + v1, indexes)?, + }, + max: PriceMinMaxVecs { + _1w: Price::forced_import(db, "price_max_1w", version + v1, indexes)?, + _2w: Price::forced_import(db, "price_max_2w", version + v1, indexes)?, + _1m: Price::forced_import(db, "price_max_1m", version + v1, indexes)?, + _1y: Price::forced_import(db, "price_max_1y", version + v1, indexes)?, + }, + true_range: ComputedPerBlock::forced_import( db, "price_true_range", version + v1, indexes, )?, - price_true_range_sum_2w: ComputedPerBlock::forced_import( + true_range_sum_2w: ComputedPerBlock::forced_import( db, "price_true_range_sum_2w", version + v1, indexes, )?, - price_choppiness_index_2w: PercentPerBlock::forced_import( + choppiness_index_2w: PercentPerBlock::forced_import( db, "price_choppiness_index_2w", version + v1, diff --git a/crates/brk_computer/src/market/range/vecs.rs b/crates/brk_computer/src/market/range/vecs.rs index 1a02a7bfb..08abd71f9 100644 --- a/crates/brk_computer/src/market/range/vecs.rs +++ b/crates/brk_computer/src/market/range/vecs.rs @@ -3,17 +3,20 @@ use brk_types::{BasisPoints16, Cents, StoredF32}; use vecdb::{Rw, StorageMode}; use crate::internal::{ComputedPerBlock, PercentPerBlock, Price}; + +#[derive(Traversable)] +pub struct PriceMinMaxVecs { + pub _1w: Price>, + pub _2w: Price>, + pub _1m: Price>, + pub _1y: Price>, +} + #[derive(Traversable)] pub struct Vecs { - pub price_min_1w: Price>, - pub price_max_1w: Price>, - pub price_min_2w: Price>, - pub price_max_2w: Price>, - pub price_min_1m: Price>, - pub price_max_1m: Price>, - pub price_min_1y: Price>, - pub price_max_1y: Price>, - pub price_true_range: ComputedPerBlock, - pub price_true_range_sum_2w: ComputedPerBlock, - pub price_choppiness_index_2w: PercentPerBlock, + pub min: PriceMinMaxVecs, + pub max: PriceMinMaxVecs, + pub true_range: ComputedPerBlock, + pub true_range_sum_2w: ComputedPerBlock, + pub choppiness_index_2w: PercentPerBlock, } diff --git a/crates/brk_computer/src/market/returns/compute.rs b/crates/brk_computer/src/market/returns/compute.rs index c371be217..36d60a1b7 100644 --- a/crates/brk_computer/src/market/returns/compute.rs +++ b/crates/brk_computer/src/market/returns/compute.rs @@ -47,9 +47,9 @@ impl Vecs { let _24h_price_return_ratio = &self.price_return._24h.ratio.height; for sd in [ - &mut self.price_return_24h_sd_1w, - &mut self.price_return_24h_sd_1m, - &mut self.price_return_24h_sd_1y, + &mut self.price_return_24h_sd._1w, + &mut self.price_return_24h_sd._1m, + &mut self.price_return_24h_sd._1y, ] { sd.compute_all(blocks, starting_indexes, exit, _24h_price_return_ratio)?; } diff --git a/crates/brk_computer/src/market/returns/import.rs b/crates/brk_computer/src/market/returns/import.rs index cecbe44d7..08657936e 100644 --- a/crates/brk_computer/src/market/returns/import.rs +++ b/crates/brk_computer/src/market/returns/import.rs @@ -3,7 +3,7 @@ use brk_types::Version; use vecdb::Database; use super::super::lookback::ByLookbackPeriod; -use super::Vecs; +use super::{vecs::PriceReturn24hSdVecs, Vecs}; use crate::{ indexes, internal::{StdDevPerBlock, PercentPerBlock}, @@ -27,37 +27,37 @@ impl Vecs { PercentPerBlock::forced_import(db, &format!("price_cagr_{name}"), version, indexes) })?; - let price_return_24h_sd_1w = StdDevPerBlock::forced_import( - db, - "price_return_24h", - "1w", - 7, - version + v1, - indexes, - )?; - let price_return_24h_sd_1m = StdDevPerBlock::forced_import( - db, - "price_return_24h", - "1m", - 30, - version + v1, - indexes, - )?; - let price_return_24h_sd_1y = StdDevPerBlock::forced_import( - db, - "price_return_24h", - "1y", - 365, - version + v1, - indexes, - )?; + let price_return_24h_sd = PriceReturn24hSdVecs { + _1w: StdDevPerBlock::forced_import( + db, + "price_return_24h", + "1w", + 7, + version + v1, + indexes, + )?, + _1m: StdDevPerBlock::forced_import( + db, + "price_return_24h", + "1m", + 30, + version + v1, + indexes, + )?, + _1y: StdDevPerBlock::forced_import( + db, + "price_return_24h", + "1y", + 365, + version + v1, + indexes, + )?, + }; Ok(Self { price_return, price_cagr, - price_return_24h_sd_1w, - price_return_24h_sd_1m, - price_return_24h_sd_1y, + price_return_24h_sd, }) } } diff --git a/crates/brk_computer/src/market/returns/vecs.rs b/crates/brk_computer/src/market/returns/vecs.rs index 0a7e69408..880d0f290 100644 --- a/crates/brk_computer/src/market/returns/vecs.rs +++ b/crates/brk_computer/src/market/returns/vecs.rs @@ -3,19 +3,20 @@ use brk_types::BasisPointsSigned32; use vecdb::{Rw, StorageMode}; use crate::{ - internal::{StdDevPerBlock, PercentPerBlock}, + internal::{PercentPerBlock, StdDevPerBlock}, market::{dca::ByDcaCagr, lookback::ByLookbackPeriod}, }; + +#[derive(Traversable)] +pub struct PriceReturn24hSdVecs { + pub _1w: StdDevPerBlock, + pub _1m: StdDevPerBlock, + pub _1y: StdDevPerBlock, +} + #[derive(Traversable)] pub struct Vecs { pub price_return: ByLookbackPeriod>, - - // CAGR (computed from returns, 2y+ only) pub price_cagr: ByDcaCagr>, - - // Returns standard deviation (computed from 24h returns) - pub price_return_24h_sd_1w: StdDevPerBlock, - pub price_return_24h_sd_1m: StdDevPerBlock, - pub price_return_24h_sd_1y: StdDevPerBlock, - + pub price_return_24h_sd: PriceReturn24hSdVecs, } diff --git a/crates/brk_computer/src/market/volatility/import.rs b/crates/brk_computer/src/market/volatility/import.rs index 1bd764287..3455c0281 100644 --- a/crates/brk_computer/src/market/volatility/import.rs +++ b/crates/brk_computer/src/market/volatility/import.rs @@ -10,43 +10,42 @@ impl Vecs { pub(crate) fn forced_import(version: Version, returns: &returns::Vecs) -> Result { let v2 = Version::TWO; - let price_volatility_1w = LazyPerBlock::from_computed::>( + let _1w = LazyPerBlock::from_computed::>( "price_volatility_1w", version + v2, returns - .price_return_24h_sd_1w + .price_return_24h_sd + ._1w .sd .height .read_only_boxed_clone(), - &returns.price_return_24h_sd_1w.sd, + &returns.price_return_24h_sd._1w.sd, ); - let price_volatility_1m = LazyPerBlock::from_computed::>( + let _1m = LazyPerBlock::from_computed::>( "price_volatility_1m", version + v2, returns - .price_return_24h_sd_1m + .price_return_24h_sd + ._1m .sd .height .read_only_boxed_clone(), - &returns.price_return_24h_sd_1m.sd, + &returns.price_return_24h_sd._1m.sd, ); - let price_volatility_1y = LazyPerBlock::from_computed::>( + let _1y = LazyPerBlock::from_computed::>( "price_volatility_1y", version + v2, returns - .price_return_24h_sd_1y + .price_return_24h_sd + ._1y .sd .height .read_only_boxed_clone(), - &returns.price_return_24h_sd_1y.sd, + &returns.price_return_24h_sd._1y.sd, ); - Ok(Self { - price_volatility_1w, - price_volatility_1m, - price_volatility_1y, - }) + Ok(Self { _1w, _1m, _1y }) } } diff --git a/crates/brk_computer/src/market/volatility/vecs.rs b/crates/brk_computer/src/market/volatility/vecs.rs index 4d5716bca..ce7ab59b3 100644 --- a/crates/brk_computer/src/market/volatility/vecs.rs +++ b/crates/brk_computer/src/market/volatility/vecs.rs @@ -5,7 +5,7 @@ use crate::internal::LazyPerBlock; use brk_types::StoredF32; #[derive(Clone, Traversable)] pub struct Vecs { - pub price_volatility_1w: LazyPerBlock, - pub price_volatility_1m: LazyPerBlock, - pub price_volatility_1y: LazyPerBlock, + pub _1w: LazyPerBlock, + pub _1m: LazyPerBlock, + pub _1y: LazyPerBlock, } diff --git a/crates/brk_computer/src/mining/hashrate/compute.rs b/crates/brk_computer/src/mining/hashrate/compute.rs index 8091f213e..ebbc0668d 100644 --- a/crates/brk_computer/src/mining/hashrate/compute.rs +++ b/crates/brk_computer/src/mining/hashrate/compute.rs @@ -38,10 +38,10 @@ impl Vecs { let hash_rate = &self.hash_rate.height; for (sma, window) in [ - (&mut self.hash_rate_sma_1w.height, &lookback.height_1w_ago), - (&mut self.hash_rate_sma_1m.height, &lookback.height_1m_ago), - (&mut self.hash_rate_sma_2m.height, &lookback.height_2m_ago), - (&mut self.hash_rate_sma_1y.height, &lookback.height_1y_ago), + (&mut self.hash_rate_sma._1w.height, &lookback.height_1w_ago), + (&mut self.hash_rate_sma._1m.height, &lookback.height_1m_ago), + (&mut self.hash_rate_sma._2m.height, &lookback.height_2m_ago), + (&mut self.hash_rate_sma._1y.height, &lookback.height_1y_ago), ] { sma.compute_rolling_average(starting_indexes.height, window, hash_rate, exit)?; } @@ -59,7 +59,7 @@ impl Vecs { exit, )?; - self.hash_price_ths.height.compute_transform2( + self.hash_price.ths.height.compute_transform2( starting_indexes.height, coinbase_usd_24h_sum, &self.hash_rate.height, @@ -75,14 +75,14 @@ impl Vecs { exit, )?; - self.hash_price_phs.height.compute_transform( + self.hash_price.phs.height.compute_transform( starting_indexes.height, - &self.hash_price_ths.height, + &self.hash_price.ths.height, |(i, price, ..)| (i, (*price * 1000.0).into()), exit, )?; - self.hash_value_ths.height.compute_transform2( + self.hash_value.ths.height.compute_transform2( starting_indexes.height, coinbase_sats_24h_sum, &self.hash_rate.height, @@ -98,47 +98,49 @@ impl Vecs { exit, )?; - self.hash_value_phs.height.compute_transform( + self.hash_value.phs.height.compute_transform( starting_indexes.height, - &self.hash_value_ths.height, + &self.hash_value.ths.height, |(i, value, ..)| (i, (*value * 1000.0).into()), exit, )?; for (min_vec, src_vec) in [ ( - &mut self.hash_price_ths_min.height, - &self.hash_price_ths.height, + &mut self.hash_price.ths_min.height, + &self.hash_price.ths.height, ), ( - &mut self.hash_price_phs_min.height, - &self.hash_price_phs.height, + &mut self.hash_price.phs_min.height, + &self.hash_price.phs.height, ), ( - &mut self.hash_value_ths_min.height, - &self.hash_value_ths.height, + &mut self.hash_value.ths_min.height, + &self.hash_value.ths.height, ), ( - &mut self.hash_value_phs_min.height, - &self.hash_value_phs.height, + &mut self.hash_value.phs_min.height, + &self.hash_value.phs.height, ), ] { min_vec.compute_all_time_low_(starting_indexes.height, src_vec, exit, true)?; } - self.hash_price_rebound + self.hash_price + .rebound .compute_binary::( starting_indexes.height, - &self.hash_price_phs.height, - &self.hash_price_phs_min.height, + &self.hash_price.phs.height, + &self.hash_price.phs_min.height, exit, )?; - self.hash_value_rebound + self.hash_value + .rebound .compute_binary::( starting_indexes.height, - &self.hash_value_phs.height, - &self.hash_value_phs_min.height, + &self.hash_value.phs.height, + &self.hash_value.phs_min.height, exit, )?; diff --git a/crates/brk_computer/src/mining/hashrate/import.rs b/crates/brk_computer/src/mining/hashrate/import.rs index a529f8b00..47d0fe036 100644 --- a/crates/brk_computer/src/mining/hashrate/import.rs +++ b/crates/brk_computer/src/mining/hashrate/import.rs @@ -2,7 +2,10 @@ use brk_error::Result; use brk_types::Version; use vecdb::Database; -use super::Vecs; +use super::{ + vecs::{HashPriceValueVecs, HashRateSmaVecs}, + Vecs, +}; use crate::{ indexes, internal::{ComputedPerBlock, PercentPerBlock}, @@ -19,30 +22,32 @@ impl Vecs { Ok(Self { hash_rate: ComputedPerBlock::forced_import(db, "hash_rate", version + v5, indexes)?, - hash_rate_sma_1w: ComputedPerBlock::forced_import( - db, - "hash_rate_sma_1w", - version, - indexes, - )?, - hash_rate_sma_1m: ComputedPerBlock::forced_import( - db, - "hash_rate_sma_1m", - version, - indexes, - )?, - hash_rate_sma_2m: ComputedPerBlock::forced_import( - db, - "hash_rate_sma_2m", - version, - indexes, - )?, - hash_rate_sma_1y: ComputedPerBlock::forced_import( - db, - "hash_rate_sma_1y", - version, - indexes, - )?, + hash_rate_sma: HashRateSmaVecs { + _1w: ComputedPerBlock::forced_import( + db, + "hash_rate_sma_1w", + version, + indexes, + )?, + _1m: ComputedPerBlock::forced_import( + db, + "hash_rate_sma_1m", + version, + indexes, + )?, + _2m: ComputedPerBlock::forced_import( + db, + "hash_rate_sma_2m", + version, + indexes, + )?, + _1y: ComputedPerBlock::forced_import( + db, + "hash_rate_sma_1y", + version, + indexes, + )?, + }, hash_rate_ath: ComputedPerBlock::forced_import( db, "hash_rate_ath", @@ -55,66 +60,70 @@ impl Vecs { version, indexes, )?, - hash_price_ths: ComputedPerBlock::forced_import( - db, - "hash_price_ths", - version + v4, - indexes, - )?, - hash_price_ths_min: ComputedPerBlock::forced_import( - db, - "hash_price_ths_min", - version + v4, - indexes, - )?, - hash_price_phs: ComputedPerBlock::forced_import( - db, - "hash_price_phs", - version + v4, - indexes, - )?, - hash_price_phs_min: ComputedPerBlock::forced_import( - db, - "hash_price_phs_min", - version + v4, - indexes, - )?, - hash_price_rebound: PercentPerBlock::forced_import( - db, - "hash_price_rebound", - version + v4, - indexes, - )?, - hash_value_ths: ComputedPerBlock::forced_import( - db, - "hash_value_ths", - version + v4, - indexes, - )?, - hash_value_ths_min: ComputedPerBlock::forced_import( - db, - "hash_value_ths_min", - version + v4, - indexes, - )?, - hash_value_phs: ComputedPerBlock::forced_import( - db, - "hash_value_phs", - version + v4, - indexes, - )?, - hash_value_phs_min: ComputedPerBlock::forced_import( - db, - "hash_value_phs_min", - version + v4, - indexes, - )?, - hash_value_rebound: PercentPerBlock::forced_import( - db, - "hash_value_rebound", - version + v4, - indexes, - )?, + hash_price: HashPriceValueVecs { + ths: ComputedPerBlock::forced_import( + db, + "hash_price_ths", + version + v4, + indexes, + )?, + ths_min: ComputedPerBlock::forced_import( + db, + "hash_price_ths_min", + version + v4, + indexes, + )?, + phs: ComputedPerBlock::forced_import( + db, + "hash_price_phs", + version + v4, + indexes, + )?, + phs_min: ComputedPerBlock::forced_import( + db, + "hash_price_phs_min", + version + v4, + indexes, + )?, + rebound: PercentPerBlock::forced_import( + db, + "hash_price_rebound", + version + v4, + indexes, + )?, + }, + hash_value: HashPriceValueVecs { + ths: ComputedPerBlock::forced_import( + db, + "hash_value_ths", + version + v4, + indexes, + )?, + ths_min: ComputedPerBlock::forced_import( + db, + "hash_value_ths_min", + version + v4, + indexes, + )?, + phs: ComputedPerBlock::forced_import( + db, + "hash_value_phs", + version + v4, + indexes, + )?, + phs_min: ComputedPerBlock::forced_import( + db, + "hash_value_phs_min", + version + v4, + indexes, + )?, + rebound: PercentPerBlock::forced_import( + db, + "hash_value_rebound", + version + v4, + indexes, + )?, + }, }) } } diff --git a/crates/brk_computer/src/mining/hashrate/vecs.rs b/crates/brk_computer/src/mining/hashrate/vecs.rs index 445d00554..3950ef6c1 100644 --- a/crates/brk_computer/src/mining/hashrate/vecs.rs +++ b/crates/brk_computer/src/mining/hashrate/vecs.rs @@ -4,23 +4,29 @@ use vecdb::{Rw, StorageMode}; use crate::internal::{ComputedPerBlock, PercentPerBlock}; +#[derive(Traversable)] +pub struct HashRateSmaVecs { + pub _1w: ComputedPerBlock, + pub _1m: ComputedPerBlock, + pub _2m: ComputedPerBlock, + pub _1y: ComputedPerBlock, +} + +#[derive(Traversable)] +pub struct HashPriceValueVecs { + pub ths: ComputedPerBlock, + pub ths_min: ComputedPerBlock, + pub phs: ComputedPerBlock, + pub phs_min: ComputedPerBlock, + pub rebound: PercentPerBlock, +} + #[derive(Traversable)] pub struct Vecs { pub hash_rate: ComputedPerBlock, - pub hash_rate_sma_1w: ComputedPerBlock, - pub hash_rate_sma_1m: ComputedPerBlock, - pub hash_rate_sma_2m: ComputedPerBlock, - pub hash_rate_sma_1y: ComputedPerBlock, + pub hash_rate_sma: HashRateSmaVecs, pub hash_rate_ath: ComputedPerBlock, pub hash_rate_drawdown: PercentPerBlock, - pub hash_price_ths: ComputedPerBlock, - pub hash_price_ths_min: ComputedPerBlock, - pub hash_price_phs: ComputedPerBlock, - pub hash_price_phs_min: ComputedPerBlock, - pub hash_price_rebound: PercentPerBlock, - pub hash_value_ths: ComputedPerBlock, - pub hash_value_ths_min: ComputedPerBlock, - pub hash_value_phs: ComputedPerBlock, - pub hash_value_phs_min: ComputedPerBlock, - pub hash_value_rebound: PercentPerBlock, + pub hash_price: HashPriceValueVecs, + pub hash_value: HashPriceValueVecs, } diff --git a/crates/brk_computer/src/supply/compute.rs b/crates/brk_computer/src/supply/compute.rs index 86476214b..b0cbee183 100644 --- a/crates/brk_computer/src/supply/compute.rs +++ b/crates/brk_computer/src/supply/compute.rs @@ -61,10 +61,10 @@ impl Vecs { // 24h, 1w, 1y from extended; 1m from core delta let rcr_rates = [ - &all_realized.cap_delta_extended.rate_24h.bps.height, - &all_realized.cap_delta_extended.rate_1w.bps.height, + &all_realized.cap_delta_extended.rate._24h.bps.height, + &all_realized.cap_delta_extended.rate._1w.bps.height, &all_realized.cap_delta.rate_1m.bps.height, - &all_realized.cap_delta_extended.rate_1y.bps.height, + &all_realized.cap_delta_extended.rate._1y.bps.height, ]; for i in 0..4 { diff --git a/crates/brk_error/src/lib.rs b/crates/brk_error/src/lib.rs index 786403c14..33c303bc4 100644 --- a/crates/brk_error/src/lib.rs +++ b/crates/brk_error/src/lib.rs @@ -1,6 +1,6 @@ #![doc = include_str!("../README.md")] -use std::{io, path::PathBuf, result, time}; +use std::{fmt, io, path::PathBuf, result, time}; use thiserror::Error; @@ -127,13 +127,10 @@ pub enum Error { AuthFailed, // Metric-specific errors - #[error("'{metric}' not found{}", suggestion.as_ref().map(|s| format!(", did you mean '{s}'?")).unwrap_or_default())] - MetricNotFound { - metric: String, - suggestion: Option, - }, + #[error("{0}")] + MetricNotFound(MetricNotFound), - #[error("'{metric}' doesn't support the requested index. Supported indexes: {supported}")] + #[error("'{metric}' doesn't support the requested index. Try: {supported}")] MetricUnsupportedIndex { metric: String, supported: String }, #[error("No metrics specified")] @@ -226,3 +223,46 @@ fn is_io_error_permanent(e: &std::io::Error) -> bool { } } } + +#[derive(Debug)] +pub struct MetricNotFound { + pub metric: String, + pub suggestions: Vec, + pub total_matches: usize, +} + +impl MetricNotFound { + pub fn new(metric: String, all_matches: Vec) -> Self { + let total_matches = all_matches.len(); + let suggestions = all_matches.into_iter().take(3).collect(); + Self { + metric, + suggestions, + total_matches, + } + } +} + +impl fmt::Display for MetricNotFound { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + write!(f, "'{}' not found", self.metric)?; + + if self.suggestions.is_empty() { + return Ok(()); + } + + let quoted: Vec<_> = self.suggestions.iter().map(|s| format!("'{s}'")).collect(); + write!(f, ", did you mean {}?", quoted.join(", "))?; + + let remaining = self.total_matches.saturating_sub(self.suggestions.len()); + if remaining > 0 { + write!( + f, + " ({remaining} more — /api/metrics/search/{} for all)", + self.metric + )?; + } + + Ok(()) + } +} diff --git a/crates/brk_query/src/impl/block/info.rs b/crates/brk_query/src/impl/block/info.rs index 3463db3a0..aef4aecb8 100644 --- a/crates/brk_query/src/impl/block/info.rs +++ b/crates/brk_query/src/impl/block/info.rs @@ -39,7 +39,7 @@ impl Query { } pub fn blocks(&self, start_height: Option) -> Result> { - let max_height = self.height(); + let max_height = self.indexed_height(); let start = start_height.unwrap_or(max_height); let start = start.min(max_height); diff --git a/crates/brk_query/src/impl/block/timestamp.rs b/crates/brk_query/src/impl/block/timestamp.rs index e82410a87..048de3ab2 100644 --- a/crates/brk_query/src/impl/block/timestamp.rs +++ b/crates/brk_query/src/impl/block/timestamp.rs @@ -10,7 +10,7 @@ impl Query { let indexer = self.indexer(); let computer = self.computer(); - let max_height = self.height(); + let max_height = self.indexed_height(); let max_height_usize: usize = max_height.into(); if max_height_usize == 0 { diff --git a/crates/brk_query/src/impl/block/txs.rs b/crates/brk_query/src/impl/block/txs.rs index 64884428b..ec99e4704 100644 --- a/crates/brk_query/src/impl/block/txs.rs +++ b/crates/brk_query/src/impl/block/txs.rs @@ -26,7 +26,7 @@ impl Query { fn block_txids_by_height(&self, height: Height) -> Result> { let indexer = self.indexer(); - let max_height = self.height(); + let max_height = self.indexed_height(); if height > max_height { return Err(Error::OutOfRange("Block height out of range".into())); } @@ -55,7 +55,7 @@ impl Query { fn block_txs_by_height(&self, height: Height, start_index: usize) -> Result> { let indexer = self.indexer(); - let max_height = self.height(); + let max_height = self.indexed_height(); if height > max_height { return Err(Error::OutOfRange("Block height out of range".into())); } @@ -97,7 +97,7 @@ impl Query { fn block_txid_at_index_by_height(&self, height: Height, index: usize) -> Result { let indexer = self.indexer(); - let max_height = self.height(); + let max_height = self.indexed_height(); if height > max_height { return Err(Error::OutOfRange("Block height out of range".into())); } diff --git a/crates/brk_query/src/impl/cost_basis.rs b/crates/brk_query/src/impl/cost_basis.rs index c2411e059..a05ab0f12 100644 --- a/crates/brk_query/src/impl/cost_basis.rs +++ b/crates/brk_query/src/impl/cost_basis.rs @@ -37,7 +37,10 @@ impl Query { .join(format!("utxo_{cohort}_cost_basis/by_date")); if !dir.exists() { - return Err(Error::NotFound(format!("Unknown cohort '{cohort}'"))); + let valid = self.cost_basis_cohorts().unwrap_or_default().join(", "); + return Err(Error::NotFound(format!( + "Unknown cohort '{cohort}'. Available: {valid}" + ))); } Ok(dir) diff --git a/crates/brk_query/src/impl/metrics.rs b/crates/brk_query/src/impl/metrics.rs index a2ee28ddf..1ee3e5459 100644 --- a/crates/brk_query/src/impl/metrics.rs +++ b/crates/brk_query/src/impl/metrics.rs @@ -27,21 +27,24 @@ impl Query { pub fn metric_not_found_error(&self, metric: &Metric) -> Error { // Check if metric exists but with different indexes if let Some(indexes) = self.vecs().metric_to_indexes(metric.clone()) { - let index_list: Vec<_> = indexes.iter().map(|i| i.to_string()).collect(); + let supported = indexes + .iter() + .map(|i| format!("/api/metric/{metric}/{i}")) + .collect::>() + .join(", "); return Error::MetricUnsupportedIndex { metric: metric.to_string(), - supported: index_list.join(", "), + supported, }; } // Metric doesn't exist, suggest alternatives - Error::MetricNotFound { - metric: metric.to_string(), - suggestion: self - .match_metric(metric, Limit::MIN) - .first() - .map(|s| s.to_string()), - } + let matches = self + .match_metric(metric, Limit::DEFAULT) + .into_iter() + .map(|s| s.to_string()) + .collect(); + Error::MetricNotFound(brk_error::MetricNotFound::new(metric.to_string(), matches)) } pub(crate) fn columns_to_csv( @@ -334,4 +337,9 @@ impl ResolvedQuery { pub fn format(&self) -> Format { self.format } + + pub fn csv_filename(&self) -> String { + let names: Vec<_> = self.vecs.iter().map(|v| v.name()).collect(); + format!("{}-{}.csv", names.join("_"), self.index) + } } diff --git a/crates/brk_query/src/lib.rs b/crates/brk_query/src/lib.rs index 10b3e25f9..d9f04ed80 100644 --- a/crates/brk_query/src/lib.rs +++ b/crates/brk_query/src/lib.rs @@ -8,8 +8,8 @@ use brk_indexer::Indexer; use brk_mempool::Mempool; use brk_reader::Reader; use brk_rpc::Client; -use brk_types::Height; -use vecdb::{ReadOnlyClone, Ro}; +use brk_types::{Height, SyncStatus}; +use vecdb::{AnyVec, ReadOnlyClone, ReadableVec, Ro}; #[cfg(feature = "tokio")] mod r#async; @@ -57,10 +57,43 @@ impl Query { } /// Current indexed height - pub fn height(&self) -> Height { + pub fn indexed_height(&self) -> Height { Height::from(self.indexer().vecs.blocks.blockhash.stamp()) } + /// Current computed height (metrics) + pub fn computed_height(&self) -> Height { + Height::from(self.computer().distribution.supply_state.len()) + } + + /// Minimum of indexed and computed heights + pub fn height(&self) -> Height { + self.indexed_height().min(self.computed_height()) + } + + /// Build sync status with the given tip height + pub fn sync_status(&self, tip_height: Height) -> SyncStatus { + let indexed_height = self.indexed_height(); + let computed_height = self.computed_height(); + let blocks_behind = Height::from(tip_height.saturating_sub(*indexed_height)); + let last_indexed_at_unix = self + .indexer() + .vecs + .blocks + .timestamp + .collect_one(indexed_height) + .unwrap(); + + SyncStatus { + indexed_height, + computed_height, + tip_height, + blocks_behind, + last_indexed_at: last_indexed_at_unix.to_iso8601(), + last_indexed_at_unix, + } + } + #[inline] pub fn reader(&self) -> &Reader { &self.0.reader diff --git a/crates/brk_server/src/api/metrics/bulk.rs b/crates/brk_server/src/api/metrics/bulk.rs index 62dc39fa8..151ca9720 100644 --- a/crates/brk_server/src/api/metrics/bulk.rs +++ b/crates/brk_server/src/api/metrics/bulk.rs @@ -31,6 +31,7 @@ pub async fn handler( let format = resolved.format(); let etag = resolved.etag(); + let csv_filename = resolved.csv_filename(); if headers.has_etag(etag.as_str()) { return Ok((StatusCode::NOT_MODIFIED, "").into_response()); @@ -55,8 +56,8 @@ pub async fn handler( h.insert_cache_control(CACHE_CONTROL); match format { Format::CSV => { - h.insert_content_disposition_attachment(); - h.insert_content_type_text_csv() + h.insert_content_disposition_attachment(&csv_filename); + h.insert_content_type_text_csv(); } Format::JSON => h.insert_content_type_application_json(), } diff --git a/crates/brk_server/src/api/metrics/data.rs b/crates/brk_server/src/api/metrics/data.rs index db1b3a569..9f1a6cb48 100644 --- a/crates/brk_server/src/api/metrics/data.rs +++ b/crates/brk_server/src/api/metrics/data.rs @@ -31,6 +31,7 @@ pub async fn handler( let format = resolved.format(); let etag = resolved.etag(); + let csv_filename = resolved.csv_filename(); if headers.has_etag(etag.as_str()) { return Ok((StatusCode::NOT_MODIFIED, "").into_response()); @@ -55,8 +56,8 @@ pub async fn handler( h.insert_cache_control(CACHE_CONTROL); match format { Format::CSV => { - h.insert_content_disposition_attachment(); - h.insert_content_type_text_csv() + h.insert_content_disposition_attachment(&csv_filename); + h.insert_content_type_text_csv(); } Format::JSON => h.insert_content_type_application_json(), } diff --git a/crates/brk_server/src/api/metrics/legacy.rs b/crates/brk_server/src/api/metrics/legacy.rs index e8c397414..1b43b465d 100644 --- a/crates/brk_server/src/api/metrics/legacy.rs +++ b/crates/brk_server/src/api/metrics/legacy.rs @@ -15,6 +15,8 @@ use crate::{ extended::HeaderMapExtended, }; +const SUNSET: &str = "2027-01-01T00:00:00Z"; + use super::AppState; pub async fn handler( @@ -31,6 +33,7 @@ pub async fn handler( let format = resolved.format(); let etag = resolved.etag(); + let csv_filename = resolved.csv_filename(); if headers.has_etag(etag.as_str()) { return Ok((StatusCode::NOT_MODIFIED, "").into_response()); @@ -55,11 +58,12 @@ pub async fn handler( h.insert_cache_control(CACHE_CONTROL); match format { Format::CSV => { - h.insert_content_disposition_attachment(); - h.insert_content_type_text_csv() + h.insert_content_disposition_attachment(&csv_filename); + h.insert_content_type_text_csv(); } Format::JSON => h.insert_content_type_application_json(), } + h.insert_deprecation(SUNSET); Ok(response) } diff --git a/crates/brk_server/src/api/metrics/mod.rs b/crates/brk_server/src/api/metrics/mod.rs index f81e544a3..5426f7262 100644 --- a/crates/brk_server/src/api/metrics/mod.rs +++ b/crates/brk_server/src/api/metrics/mod.rs @@ -14,7 +14,7 @@ use brk_types::{ MetricSelection, MetricSelectionLegacy, MetricWithIndex, Metrics, PaginatedMetrics, Pagination, }; -use crate::{CacheStrategy, extended::TransformResponseExtended}; +use crate::{CacheStrategy, Error, extended::TransformResponseExtended}; use super::AppState; @@ -244,7 +244,9 @@ impl ApiMetricsRoutes for ApiRouter { let ser_index = split.next().unwrap(); let Ok(index) = Index::try_from(ser_index) else { - return format!("Index {ser_index} doesn't exist").into_response(); + return Error::not_found( + format!("Index '{ser_index}' doesn't exist") + ).into_response(); }; let params = MetricSelection::from(( diff --git a/crates/brk_server/src/api/openapi/mod.rs b/crates/brk_server/src/api/openapi/mod.rs index 0228760ab..bf3325110 100644 --- a/crates/brk_server/src/api/openapi/mod.rs +++ b/crates/brk_server/src/api/openapi/mod.rs @@ -14,7 +14,7 @@ mod compact; pub use compact::ApiJson; -use aide::openapi::{Contact, Info, License, OpenApi, Tag}; +use aide::openapi::{Contact, Info, License, OpenApi, Server, ServerVariable, Tag}; use crate::VERSION; @@ -31,6 +31,34 @@ pub fn create_openapi() -> OpenApi { - **Multiple formats**: JSON and CSV output - **LLM-optimized**: [`/llms.txt`](/llms.txt) for discovery, [`/api.json`](/api.json) compact OpenAPI spec for tool use (full spec at [`/openapi.json`](/openapi.json)) +### Quick start + +```bash +curl -s https://bitview.space/api/block-height/0 +curl -s https://bitview.space/api/metrics/search/price +curl -s https://bitview.space/api/metric/price/day1 +``` + +### Errors + +All errors return structured JSON with a consistent format: + +```json +{ + "error": { + "type": "not_found", + "code": "metric_not_found", + "message": "'foo' not found, did you mean 'bar'?", + "doc_url": "https://bitcoinresearchkit.org/api" + } +} +``` + +- **`type`**: Error category — `invalid_request` (400), `forbidden` (403), `not_found` (404), `unavailable` (503), or `internal` (500) +- **`code`**: Machine-readable error code (e.g. `invalid_address`, `metric_not_found`, `weight_exceeded`) +- **`message`**: Human-readable description +- **`doc_url`**: Link to API documentation + ### Client Libraries - [JavaScript](https://www.npmjs.com/package/brk-client) @@ -130,9 +158,38 @@ pub fn create_openapi() -> OpenApi { }, ]; + let servers = vec![Server { + url: "{scheme}://{host}".into(), + description: Some("BRK server".into()), + variables: [ + ( + "scheme".into(), + ServerVariable { + enumeration: vec!["https".into(), "http".into()], + default: "https".into(), + description: Some("Protocol".into()), + ..Default::default() + }, + ), + ( + "host".into(), + ServerVariable { + default: "bitview.space".into(), + description: Some( + "Server address (e.g. bitview.space or localhost:3110)".into(), + ), + ..Default::default() + }, + ), + ] + .into(), + ..Default::default() + }]; + OpenApi { info, tags, + servers, ..OpenApi::default() } } diff --git a/crates/brk_server/src/api/server/mod.rs b/crates/brk_server/src/api/server/mod.rs index 9ac3dac81..efa8f0195 100644 --- a/crates/brk_server/src/api/server/mod.rs +++ b/crates/brk_server/src/api/server/mod.rs @@ -5,10 +5,9 @@ use axum::{ extract::State, http::{HeaderMap, Uri}, }; -use brk_types::{DiskUsage, Health, Height, SyncStatus}; -use vecdb::ReadableVec; +use brk_types::{DiskUsage, Health, SyncStatus}; -use crate::{CacheStrategy, extended::TransformResponseExtended}; +use crate::{CacheStrategy, VERSION, extended::TransformResponseExtended}; use super::AppState; @@ -26,23 +25,7 @@ impl ServerRoutes for ApiRouter { state .cached_json(&headers, CacheStrategy::Height, &uri, move |q| { - let indexed_height = q.height(); - let tip_height = tip_height?; - let blocks_behind = Height::from(tip_height.saturating_sub(*indexed_height)); - let last_indexed_at_unix = q - .indexer() - .vecs - .blocks - .timestamp - .collect_one(indexed_height).unwrap(); - - Ok(SyncStatus { - indexed_height, - tip_height, - blocks_behind, - last_indexed_at: last_indexed_at_unix.to_iso8601(), - last_indexed_at_unix, - }) + Ok(q.sync_status(tip_height?)) }) .await }, @@ -89,12 +72,19 @@ impl ServerRoutes for ApiRouter { get_with( async |State(state): State| -> axum::Json { let uptime = state.started_instant.elapsed(); + let tip_height = state.client.get_last_height(); + let sync = state.sync(|q| { + let tip_height = tip_height.unwrap_or(q.indexed_height()); + q.sync_status(tip_height) + }); axum::Json(Health { status: Cow::Borrowed("healthy"), service: Cow::Borrowed("brk"), + version: Cow::Borrowed(VERSION), timestamp: jiff::Timestamp::now().to_string(), started_at: state.started_at.to_string(), uptime_seconds: uptime.as_secs(), + sync, }) }, |op| { diff --git a/crates/brk_server/src/error.rs b/crates/brk_server/src/error.rs index 3a25e8923..91aa30993 100644 --- a/crates/brk_server/src/error.rs +++ b/crates/brk_server/src/error.rs @@ -1,58 +1,162 @@ use axum::{ - http::StatusCode, + http::{StatusCode, header}, response::{IntoResponse, Response}, }; use brk_error::Error as BrkError; +use schemars::JsonSchema; +use serde::Serialize; + +use crate::extended::HeaderMapExtended; /// Server result type with Error that implements IntoResponse. pub type Result = std::result::Result; -/// Server error type that maps to HTTP status codes. -pub struct Error(StatusCode, String); +const DOC_URL: &str = "/api"; + +#[derive(Serialize, JsonSchema)] +pub(crate) struct ErrorBody { + error: ErrorDetail, +} + +#[derive(Serialize, JsonSchema)] +struct ErrorDetail { + /// Error category: "invalid_request", "forbidden", "not_found", "unavailable", or "internal" + #[schemars(with = "String")] + r#type: &'static str, + /// Machine-readable error code (e.g. "invalid_address", "metric_not_found") + #[schemars(with = "String")] + code: &'static str, + /// Human-readable description + message: String, + /// Link to API documentation + #[schemars(with = "String")] + doc_url: &'static str, +} + +fn error_type(status: StatusCode) -> &'static str { + match status { + StatusCode::BAD_REQUEST => "invalid_request", + StatusCode::FORBIDDEN => "forbidden", + StatusCode::NOT_FOUND => "not_found", + StatusCode::SERVICE_UNAVAILABLE => "unavailable", + _ => "internal", + } +} + +fn error_status(e: &BrkError) -> StatusCode { + match e { + BrkError::InvalidTxid + | BrkError::InvalidNetwork + | BrkError::InvalidAddress + | BrkError::UnsupportedType(_) + | BrkError::Parse(_) + | BrkError::NoMetrics + | BrkError::MetricUnsupportedIndex { .. } + | BrkError::WeightExceeded { .. } => StatusCode::BAD_REQUEST, + + BrkError::UnknownAddress + | BrkError::UnknownTxid + | BrkError::NotFound(_) + | BrkError::MetricNotFound(_) => StatusCode::NOT_FOUND, + + BrkError::AuthFailed => StatusCode::FORBIDDEN, + BrkError::MempoolNotAvailable => StatusCode::SERVICE_UNAVAILABLE, + + _ => StatusCode::INTERNAL_SERVER_ERROR, + } +} + +fn error_code(e: &BrkError) -> &'static str { + match e { + BrkError::InvalidAddress => "invalid_address", + BrkError::InvalidTxid => "invalid_txid", + BrkError::InvalidNetwork => "invalid_network", + BrkError::UnsupportedType(_) => "unsupported_type", + BrkError::Parse(_) => "parse_error", + BrkError::NoMetrics => "no_metrics", + BrkError::MetricUnsupportedIndex { .. } => "metric_unsupported_index", + BrkError::WeightExceeded { .. } => "weight_exceeded", + BrkError::UnknownAddress => "unknown_address", + BrkError::UnknownTxid => "unknown_txid", + BrkError::NotFound(_) => "not_found", + BrkError::MetricNotFound(_) => "metric_not_found", + BrkError::MempoolNotAvailable => "mempool_not_available", + BrkError::AuthFailed => "auth_failed", + _ => "internal_error", + } +} + +fn build_error_body(status: StatusCode, code: &'static str, message: String) -> Vec { + serde_json::to_vec(&ErrorBody { + error: ErrorDetail { + r#type: error_type(status), + code, + message, + doc_url: DOC_URL, + }, + }) + .unwrap() +} + +/// Server error type that maps to HTTP status codes and structured JSON. +pub struct Error { + status: StatusCode, + code: &'static str, + message: String, +} impl Error { + pub(crate) fn new(status: StatusCode, code: &'static str, msg: impl Into) -> Self { + Self { + status, + code, + message: msg.into(), + } + } + pub fn bad_request(msg: impl Into) -> Self { - Self(StatusCode::BAD_REQUEST, msg.into()) + Self::new(StatusCode::BAD_REQUEST, "bad_request", msg) } pub fn forbidden(msg: impl Into) -> Self { - Self(StatusCode::FORBIDDEN, msg.into()) + Self::new(StatusCode::FORBIDDEN, "forbidden", msg) } pub fn not_found(msg: impl Into) -> Self { - Self(StatusCode::NOT_FOUND, msg.into()) + Self::new(StatusCode::NOT_FOUND, "not_found", msg) } pub fn internal(msg: impl Into) -> Self { - Self(StatusCode::INTERNAL_SERVER_ERROR, msg.into()) + Self::new(StatusCode::INTERNAL_SERVER_ERROR, "internal_error", msg) + } + + pub(crate) fn into_response_with_etag(self, etag: &str) -> Response { + let mut response = self.into_response(); + let headers = response.headers_mut(); + headers.insert_etag(etag); + headers.insert_cache_control_must_revalidate(); + response } } impl From for Error { fn from(e: BrkError) -> Self { - let status = match &e { - BrkError::InvalidTxid - | BrkError::InvalidNetwork - | BrkError::InvalidAddress - | BrkError::UnsupportedType(_) - | BrkError::Parse(_) - | BrkError::NoMetrics - | BrkError::MetricUnsupportedIndex { .. } - | BrkError::WeightExceeded { .. } => StatusCode::BAD_REQUEST, - - BrkError::UnknownAddress - | BrkError::UnknownTxid - | BrkError::NotFound(_) - | BrkError::MetricNotFound { .. } => StatusCode::NOT_FOUND, - - _ => StatusCode::INTERNAL_SERVER_ERROR, - }; - Self(status, e.to_string()) + Self { + status: error_status(&e), + code: error_code(&e), + message: e.to_string(), + } } } impl IntoResponse for Error { fn into_response(self) -> Response { - (self.0, self.1).into_response() + let body = build_error_body(self.status, self.code, self.message); + ( + self.status, + [(header::CONTENT_TYPE, "application/json")], + body, + ) + .into_response() } } diff --git a/crates/brk_server/src/extended/header_map.rs b/crates/brk_server/src/extended/header_map.rs index 0f535ccce..df1afcdec 100644 --- a/crates/brk_server/src/extended/header_map.rs +++ b/crates/brk_server/src/extended/header_map.rs @@ -10,12 +10,14 @@ pub trait HeaderMapExtended { fn insert_cache_control(&mut self, value: &str); fn insert_cache_control_must_revalidate(&mut self); - fn insert_content_disposition_attachment(&mut self); + fn insert_content_disposition_attachment(&mut self, filename: &str); fn insert_content_type_application_json(&mut self); fn insert_content_type_text_csv(&mut self); fn insert_content_type_text_plain(&mut self); fn insert_content_type_octet_stream(&mut self); + + fn insert_deprecation(&mut self, sunset: &'static str); } impl HeaderMapExtended for HeaderMap { @@ -36,8 +38,11 @@ impl HeaderMapExtended for HeaderMap { self.insert_cache_control("public, max-age=1, must-revalidate"); } - fn insert_content_disposition_attachment(&mut self) { - self.insert(header::CONTENT_DISPOSITION, "attachment".parse().unwrap()); + fn insert_content_disposition_attachment(&mut self, filename: &str) { + self.insert( + header::CONTENT_DISPOSITION, + format!("attachment; filename=\"{filename}\"").parse().unwrap(), + ); } fn insert_content_type_application_json(&mut self) { @@ -58,4 +63,9 @@ impl HeaderMapExtended for HeaderMap { "application/octet-stream".parse().unwrap(), ); } + + fn insert_deprecation(&mut self, sunset: &'static str) { + self.insert("Deprecation", "true".parse().unwrap()); + self.insert("Sunset", sunset.parse().unwrap()); + } } diff --git a/crates/brk_server/src/extended/result.rs b/crates/brk_server/src/extended/result.rs index 0406c9e34..b6c6a8881 100644 --- a/crates/brk_server/src/extended/result.rs +++ b/crates/brk_server/src/extended/result.rs @@ -1,11 +1,10 @@ -use axum::{http::StatusCode, response::Response}; -use brk_error::{Error, Result}; +use axum::response::Response; +use brk_error::Result; use serde::Serialize; -use crate::extended::ResponseExtended; +use crate::{Error, extended::ResponseExtended}; pub trait ResultExtended { - fn with_status(self) -> Result; fn to_json_response(self, etag: &str) -> Response where T: Serialize; @@ -18,29 +17,13 @@ pub trait ResultExtended { } impl ResultExtended for Result { - fn with_status(self) -> Result { - self.map_err(|e| { - ( - match e { - Error::InvalidTxid - | Error::InvalidNetwork - | Error::InvalidAddress - | Error::UnsupportedType(_) => StatusCode::BAD_REQUEST, - Error::UnknownAddress | Error::UnknownTxid => StatusCode::NOT_FOUND, - _ => StatusCode::INTERNAL_SERVER_ERROR, - }, - e.to_string(), - ) - }) - } - fn to_json_response(self, etag: &str) -> Response where T: Serialize, { - match self.with_status() { + match self { Ok(value) => Response::new_json(&value, etag), - Err((status, message)) => Response::new_json_with(status, &message, etag), + Err(e) => Error::from(e).into_response_with_etag(etag), } } @@ -48,9 +31,9 @@ impl ResultExtended for Result { where T: AsRef, { - match self.with_status() { + match self { Ok(value) => Response::new_text(value.as_ref(), etag), - Err((status, message)) => Response::new_text_with(status, &message, etag), + Err(e) => Error::from(e).into_response_with_etag(etag), } } @@ -58,9 +41,9 @@ impl ResultExtended for Result { where T: Into>, { - match self.with_status() { + match self { Ok(value) => Response::new_bytes(value.into(), etag), - Err((status, message)) => Response::new_bytes_with(status, message.into_bytes(), etag), + Err(e) => Error::from(e).into_response_with_etag(etag), } } } diff --git a/crates/brk_server/src/extended/transform_operation.rs b/crates/brk_server/src/extended/transform_operation.rs index 1d168c52e..085196305 100644 --- a/crates/brk_server/src/extended/transform_operation.rs +++ b/crates/brk_server/src/extended/transform_operation.rs @@ -3,6 +3,8 @@ use aide::transform::{TransformOperation, TransformResponse}; use axum::Json; use schemars::JsonSchema; +use crate::error::ErrorBody; + pub trait TransformResponseExtended<'t> { fn addresses_tag(self) -> Self; fn blocks_tag(self) -> Self; @@ -99,13 +101,13 @@ impl<'t> TransformResponseExtended<'t> for TransformOperation<'t> { } fn bad_request(self) -> Self { - self.response_with::<400, Json, _>(|res| { + self.response_with::<400, Json, _>(|res| { res.description("Invalid request parameters") }) } fn not_found(self) -> Self { - self.response_with::<404, Json, _>(|res| res.description("Resource not found")) + self.response_with::<404, Json, _>(|res| res.description("Resource not found")) } fn not_modified(self) -> Self { @@ -115,6 +117,8 @@ impl<'t> TransformResponseExtended<'t> for TransformOperation<'t> { } fn server_error(self) -> Self { - self.response_with::<500, Json, _>(|res| res.description("Internal server error")) + self.response_with::<500, Json, _>(|res| { + res.description("Internal server error") + }) } } diff --git a/crates/brk_server/src/lib.rs b/crates/brk_server/src/lib.rs index 69ae70005..55d6c9b67 100644 --- a/crates/brk_server/src/lib.rs +++ b/crates/brk_server/src/lib.rs @@ -85,11 +85,50 @@ impl Server { }, ); - let response_uri_layer = axum::middleware::from_fn( + let response_time_layer = axum::middleware::from_fn( async |request: Request, next: Next| -> Response { let uri = request.uri().clone(); + let start = Instant::now(); let mut response = next.run(request).await; response.extensions_mut().insert(uri); + response.headers_mut().insert( + "X-Response-Time", + format!("{}us", start.elapsed().as_micros()) + .parse() + .unwrap(), + ); + response + }, + ); + + // Wrap non-JSON client errors (e.g. axum extraction rejections) in structured JSON + let json_error_layer = axum::middleware::from_fn( + async |request: Request, next: Next| -> Response { + use axum::http::header::CONTENT_TYPE; + use axum::response::IntoResponse; + + let response = next.run(request).await; + if !response.status().is_client_error() + || response + .headers() + .get(CONTENT_TYPE) + .is_some_and(|v| v.as_bytes().starts_with(b"application/json")) + { + return response; + } + + let (parts, body) = response.into_parts(); + let bytes = axum::body::to_bytes(body, 4096) + .await + .unwrap_or_default(); + let msg = String::from_utf8_lossy(&bytes).to_string(); + let code = if parts.status == StatusCode::NOT_FOUND { + "not_found" + } else { + "bad_request" + }; + let mut response = Error::new(parts.status, code, msg).into_response(); + response.extensions_mut().extend(parts.extensions); response }, ); @@ -99,7 +138,8 @@ impl Server { .on_response( |response: &Response, latency: Duration, _: &tracing::Span| { let status = response.status().as_u16(); - let uri = response.extensions().get::().unwrap(); + let unknown = Uri::from_static("/unknown"); + let uri = response.extensions().get::().unwrap_or(&unknown); match response.status() { StatusCode::OK => info!(status, %uri, ?latency), StatusCode::NOT_MODIFIED @@ -125,10 +165,11 @@ impl Server { let router = router .with_state(state) .merge(website_router) - .layer(CatchPanicLayer::new()) + .layer(json_error_layer) .layer(compression_layer) - .layer(response_uri_layer) + .layer(response_time_layer) .layer(trace_layer) + .layer(CatchPanicLayer::new()) .layer(TimeoutLayer::with_status_code( StatusCode::GATEWAY_TIMEOUT, Duration::from_secs(5), diff --git a/crates/brk_traversable_derive/src/lib.rs b/crates/brk_traversable_derive/src/lib.rs index eb2f973a2..5f59ef4ff 100644 --- a/crates/brk_traversable_derive/src/lib.rs +++ b/crates/brk_traversable_derive/src/lib.rs @@ -398,30 +398,44 @@ fn generate_field_traversals(infos: &[FieldInfo], merge: bool) -> proc_macro2::T s.strip_prefix('_').map(String::from).unwrap_or(s) }; - let (outer_key, inner_wrap): (&str, Option<&str>) = + // Determine the tree key and optional wrapping path. + // wrap = "a/b" means: outer_key = "a", wrap the node under "b" then under the rename/field name. + // wrap = "a" means: outer_key = "a", wrap under rename or field name. + // No wrap: outer_key = rename or field name, no wrapping. + let (outer_key, wrap_path): (String, Vec<&str>) = match (info.wrap.as_deref(), info.rename.as_deref()) { - (Some(wrap), Some(rename)) => (wrap, Some(rename)), - (Some(wrap), None) => (wrap, Some(&field_name_str)), - (None, Some(rename)) => (rename, None), - (None, None) => (&field_name_str, None), + (Some(wrap), Some(rename)) => { + let parts: Vec<&str> = wrap.split('/').collect(); + let outer = parts[0].to_string(); + let mut path: Vec<&str> = parts[1..].to_vec(); + path.push(rename); + (outer, path) + } + (Some(wrap), None) => { + let parts: Vec<&str> = wrap.split('/').collect(); + let outer = parts[0].to_string(); + let mut path: Vec<&str> = parts[1..].to_vec(); + path.push(&field_name_str); + (outer, path) + } + (None, Some(rename)) => (rename.to_string(), vec![]), + (None, None) => (field_name_str.clone(), vec![]), }; - let node_expr = if let Some(inner_key) = inner_wrap { - quote! { brk_traversable::TreeNode::wrap(#inner_key, nested.to_tree_node()) } - } else { - quote! { nested.to_tree_node() } + // Build nested wrapping: wrap(path[last], wrap(path[last-1], ... node)) + let build_wrapped = |base: proc_macro2::TokenStream| -> proc_macro2::TokenStream { + wrap_path.iter().rev().fold(base, |inner, key| { + quote! { brk_traversable::TreeNode::wrap(#key, #inner) } + }) }; if info.is_option { + let node_expr = build_wrapped(quote! { nested.to_tree_node() }); quote! { self.#field_name.as_ref().map(|nested| (String::from(#outer_key), #node_expr)) } } else { - let node_expr_self = if let Some(inner_key) = inner_wrap { - quote! { brk_traversable::TreeNode::wrap(#inner_key, self.#field_name.to_tree_node()) } - } else { - quote! { self.#field_name.to_tree_node() } - }; + let node_expr_self = build_wrapped(quote! { self.#field_name.to_tree_node() }); quote! { Some((String::from(#outer_key), #node_expr_self)) } diff --git a/crates/brk_types/src/epoch.rs b/crates/brk_types/src/epoch.rs index 876cc7077..16d981321 100644 --- a/crates/brk_types/src/epoch.rs +++ b/crates/brk_types/src/epoch.rs @@ -92,7 +92,7 @@ impl CheckedSub for Epoch { impl PrintableIndex for Epoch { fn to_string() -> &'static str { - "difficultyepoch" + "epoch" } fn to_possible_strings() -> &'static [&'static str] { diff --git a/crates/brk_types/src/halving.rs b/crates/brk_types/src/halving.rs index ea1e20362..c62d58670 100644 --- a/crates/brk_types/src/halving.rs +++ b/crates/brk_types/src/halving.rs @@ -98,7 +98,7 @@ impl Div for Halving { impl PrintableIndex for Halving { fn to_string() -> &'static str { - "halvingepoch" + "halving" } fn to_possible_strings() -> &'static [&'static str] { diff --git a/crates/brk_types/src/health.rs b/crates/brk_types/src/health.rs index 0e7bc4d79..6187dd4bc 100644 --- a/crates/brk_types/src/health.rs +++ b/crates/brk_types/src/health.rs @@ -3,14 +3,19 @@ use std::borrow::Cow; use schemars::JsonSchema; use serde::{Deserialize, Serialize}; +use crate::SyncStatus; + /// Server health status #[derive(Debug, Serialize, Deserialize, JsonSchema)] pub struct Health { pub status: Cow<'static, str>, pub service: Cow<'static, str>, + pub version: Cow<'static, str>, pub timestamp: String, /// Server start time (ISO 8601) pub started_at: String, /// Uptime in seconds pub uptime_seconds: u64, + #[serde(flatten)] + pub sync: SyncStatus, } diff --git a/crates/brk_types/src/metricdata.rs b/crates/brk_types/src/metricdata.rs index 7e7ce3afc..f26dfd724 100644 --- a/crates/brk_types/src/metricdata.rs +++ b/crates/brk_types/src/metricdata.rs @@ -1,4 +1,4 @@ -use std::{io::Write, ops::Deref}; +use std::ops::Deref; use schemars::JsonSchema; use serde::{Deserialize, de::DeserializeOwned}; @@ -38,17 +38,26 @@ impl MetricData { end: usize, buf: &mut Vec, ) -> vecdb::Result<()> { - let version = u32::from(vec.version()); - let index_str = index.name(); let total = vec.len(); let end = end.min(total); let start = start.min(end); - let stamp = Timestamp::now().to_iso8601(); - write!( - buf, - r#"{{"version":{version},"index":"{index_str}","total":{total},"start":{start},"end":{end},"stamp":"{stamp}","data":"#, - )?; + let mut itoa_buf = itoa::Buffer::new(); + + buf.extend_from_slice(b"{\"version\":"); + buf.extend_from_slice(itoa_buf.format(u32::from(vec.version())).as_bytes()); + buf.extend_from_slice(b",\"index\":\""); + buf.extend_from_slice(index.name().as_bytes()); + buf.extend_from_slice(b"\",\"total\":"); + buf.extend_from_slice(itoa_buf.format(total).as_bytes()); + buf.extend_from_slice(b",\"start\":"); + buf.extend_from_slice(itoa_buf.format(start).as_bytes()); + buf.extend_from_slice(b",\"end\":"); + buf.extend_from_slice(itoa_buf.format(end).as_bytes()); + buf.extend_from_slice(b",\"stamp\":\""); + buf.extend_from_slice(Timestamp::now().to_iso8601().as_bytes()); + buf.extend_from_slice(b"\",\"data\":"); + vec.write_json(Some(start), Some(end), buf)?; buf.push(b'}'); Ok(()) diff --git a/crates/brk_types/src/syncstatus.rs b/crates/brk_types/src/syncstatus.rs index b40e7ec9d..392f2aa16 100644 --- a/crates/brk_types/src/syncstatus.rs +++ b/crates/brk_types/src/syncstatus.rs @@ -8,6 +8,8 @@ use crate::{Height, Timestamp}; pub struct SyncStatus { /// Height of the last indexed block pub indexed_height: Height, + /// Height of the last computed block (metrics) + pub computed_height: Height, /// Height of the chain tip (from Bitcoin node) pub tip_height: Height, /// Number of blocks behind the tip diff --git a/crates/brk_types/src/treenode.rs b/crates/brk_types/src/treenode.rs index 9491cf8fb..d74473480 100644 --- a/crates/brk_types/src/treenode.rs +++ b/crates/brk_types/src/treenode.rs @@ -466,7 +466,7 @@ mod tests { // - height_cumulative (renamed to "cumulative") → direct leaf at Height // - day1 → branch with sum/cumulative at Day1 // - week1 (flattened from dates) → branch with sum/cumulative at Week1 - // - difficultyepoch → branch with sum/cumulative at Epoch + // - epoch → branch with sum/cumulative at Epoch let tree = branch(vec![ ("cumulative", leaf("metric_cumulative", Index::Height)), ( @@ -484,7 +484,7 @@ mod tests { ]), ), ( - "difficultyepoch", + "epoch", branch(vec![ ("sum", leaf("metric_sum", Index::Epoch)), ( diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 4465c9c82..d559e794b 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -312,7 +312,6 @@ * @property {number} difficulty - Difficulty value. * @property {Height} height - Block height of the adjustment. */ -/** @typedef {number} Epoch */ /** * Disk usage of the indexed data * @@ -338,6 +337,18 @@ */ /** @typedef {TypeIndex} EmptyAddressIndex */ /** @typedef {TypeIndex} EmptyOutputIndex */ +/** @typedef {number} Epoch */ +/** + * @typedef {Object} ErrorBody + * @property {ErrorDetail} error + */ +/** + * @typedef {Object} ErrorDetail + * @property {string} type - Error category: "invalid_request", "forbidden", "not_found", "unavailable", or "internal" + * @property {string} code - Machine-readable error code (e.g. "invalid_address", "metric_not_found") + * @property {string} message - Human-readable description + * @property {string} docUrl - Link to API documentation + */ /** * Fee rate in sats/vB * @@ -384,9 +395,16 @@ * @typedef {Object} Health * @property {string} status * @property {string} service + * @property {string} version * @property {string} timestamp * @property {string} startedAt - Server start time (ISO 8601) * @property {number} uptimeSeconds - Uptime in seconds + * @property {Height} indexedHeight - Height of the last indexed block + * @property {Height} computedHeight - Height of the last computed block (metrics) + * @property {Height} tipHeight - Height of the chain tip (from Bitcoin node) + * @property {Height} blocksBehind - Number of blocks behind the tip + * @property {string} lastIndexedAt - Human-readable timestamp of the last indexed block (ISO 8601) + * @property {Timestamp} lastIndexedAtUnix - Unix timestamp of the last indexed block */ /** * Block height @@ -414,7 +432,7 @@ * Aggregation dimension for querying metrics. Includes time-based (date, week, month, year), * block-based (height, txindex), and address/output type indexes. * - * @typedef {("minute10"|"minute30"|"hour1"|"hour4"|"hour12"|"day1"|"day3"|"week1"|"month1"|"month3"|"month6"|"year1"|"year10"|"halvingepoch"|"difficultyepoch"|"height"|"txindex"|"txinindex"|"txoutindex"|"emptyoutputindex"|"opreturnindex"|"p2aaddressindex"|"p2msoutputindex"|"p2pk33addressindex"|"p2pk65addressindex"|"p2pkhaddressindex"|"p2shaddressindex"|"p2traddressindex"|"p2wpkhaddressindex"|"p2wshaddressindex"|"unknownoutputindex"|"fundedaddressindex"|"emptyaddressindex"|"pairoutputindex")} Index + * @typedef {("minute10"|"minute30"|"hour1"|"hour4"|"hour12"|"day1"|"day3"|"week1"|"month1"|"month3"|"month6"|"year1"|"year10"|"halving"|"epoch"|"height"|"txindex"|"txinindex"|"txoutindex"|"emptyoutputindex"|"opreturnindex"|"p2aaddressindex"|"p2msoutputindex"|"p2pk33addressindex"|"p2pk65addressindex"|"p2pkhaddressindex"|"p2shaddressindex"|"p2traddressindex"|"p2wpkhaddressindex"|"p2wshaddressindex"|"unknownoutputindex"|"fundedaddressindex"|"emptyaddressindex"|"pairoutputindex")} Index */ /** * Information about an available index and its query aliases @@ -753,6 +771,7 @@ * * @typedef {Object} SyncStatus * @property {Height} indexedHeight - Height of the last indexed block + * @property {Height} computedHeight - Height of the last computed block (metrics) * @property {Height} tipHeight - Height of the chain tip (from Bitcoin node) * @property {Height} blocksBehind - Number of blocks behind the tip * @property {string} lastIndexedAt - Human-readable timestamp of the last indexed block (ISO 8601) @@ -1404,8 +1423,8 @@ const _p = (prefix, acc) => acc ? `${prefix}_${acc}` : prefix; // Index group constants and factory -const _i1 = /** @type {const} */ (["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halvingepoch", "difficultyepoch", "height"]); -const _i2 = /** @type {const} */ (["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halvingepoch", "difficultyepoch"]); +const _i1 = /** @type {const} */ (["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halving", "epoch", "height"]); +const _i2 = /** @type {const} */ (["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halving", "epoch"]); const _i3 = /** @type {const} */ (["minute10"]); const _i4 = /** @type {const} */ (["minute30"]); const _i5 = /** @type {const} */ (["hour1"]); @@ -1419,8 +1438,8 @@ const _i12 = /** @type {const} */ (["month3"]); const _i13 = /** @type {const} */ (["month6"]); const _i14 = /** @type {const} */ (["year1"]); const _i15 = /** @type {const} */ (["year10"]); -const _i16 = /** @type {const} */ (["halvingepoch"]); -const _i17 = /** @type {const} */ (["difficultyepoch"]); +const _i16 = /** @type {const} */ (["halving"]); +const _i17 = /** @type {const} */ (["epoch"]); const _i18 = /** @type {const} */ (["height"]); const _i19 = /** @type {const} */ (["txindex"]); const _i20 = /** @type {const} */ (["txinindex"]); @@ -1466,10 +1485,10 @@ function _mp(client, name, indexes) { }; } -/** @template T @typedef {{ name: string, by: { readonly minute10: DateMetricEndpointBuilder, readonly minute30: DateMetricEndpointBuilder, readonly hour1: DateMetricEndpointBuilder, readonly hour4: DateMetricEndpointBuilder, readonly hour12: DateMetricEndpointBuilder, readonly day1: DateMetricEndpointBuilder, readonly day3: DateMetricEndpointBuilder, readonly week1: DateMetricEndpointBuilder, readonly month1: DateMetricEndpointBuilder, readonly month3: DateMetricEndpointBuilder, readonly month6: DateMetricEndpointBuilder, readonly year1: DateMetricEndpointBuilder, readonly year10: DateMetricEndpointBuilder, readonly halvingepoch: MetricEndpointBuilder, readonly difficultyepoch: MetricEndpointBuilder, readonly height: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern1 */ +/** @template T @typedef {{ name: string, by: { readonly minute10: DateMetricEndpointBuilder, readonly minute30: DateMetricEndpointBuilder, readonly hour1: DateMetricEndpointBuilder, readonly hour4: DateMetricEndpointBuilder, readonly hour12: DateMetricEndpointBuilder, readonly day1: DateMetricEndpointBuilder, readonly day3: DateMetricEndpointBuilder, readonly week1: DateMetricEndpointBuilder, readonly month1: DateMetricEndpointBuilder, readonly month3: DateMetricEndpointBuilder, readonly month6: DateMetricEndpointBuilder, readonly year1: DateMetricEndpointBuilder, readonly year10: DateMetricEndpointBuilder, readonly halving: MetricEndpointBuilder, readonly epoch: MetricEndpointBuilder, readonly height: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern1 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {MetricPattern1} */ function createMetricPattern1(client, name) { return /** @type {MetricPattern1} */ (_mp(client, name, _i1)); } -/** @template T @typedef {{ name: string, by: { readonly minute10: DateMetricEndpointBuilder, readonly minute30: DateMetricEndpointBuilder, readonly hour1: DateMetricEndpointBuilder, readonly hour4: DateMetricEndpointBuilder, readonly hour12: DateMetricEndpointBuilder, readonly day1: DateMetricEndpointBuilder, readonly day3: DateMetricEndpointBuilder, readonly week1: DateMetricEndpointBuilder, readonly month1: DateMetricEndpointBuilder, readonly month3: DateMetricEndpointBuilder, readonly month6: DateMetricEndpointBuilder, readonly year1: DateMetricEndpointBuilder, readonly year10: DateMetricEndpointBuilder, readonly halvingepoch: MetricEndpointBuilder, readonly difficultyepoch: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern2 */ +/** @template T @typedef {{ name: string, by: { readonly minute10: DateMetricEndpointBuilder, readonly minute30: DateMetricEndpointBuilder, readonly hour1: DateMetricEndpointBuilder, readonly hour4: DateMetricEndpointBuilder, readonly hour12: DateMetricEndpointBuilder, readonly day1: DateMetricEndpointBuilder, readonly day3: DateMetricEndpointBuilder, readonly week1: DateMetricEndpointBuilder, readonly month1: DateMetricEndpointBuilder, readonly month3: DateMetricEndpointBuilder, readonly month6: DateMetricEndpointBuilder, readonly year1: DateMetricEndpointBuilder, readonly year10: DateMetricEndpointBuilder, readonly halving: MetricEndpointBuilder, readonly epoch: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern2 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {MetricPattern2} */ function createMetricPattern2(client, name) { return /** @type {MetricPattern2} */ (_mp(client, name, _i2)); } /** @template T @typedef {{ name: string, by: { readonly minute10: DateMetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern3 */ @@ -1511,10 +1530,10 @@ function createMetricPattern14(client, name) { return /** @type {MetricPattern14 /** @template T @typedef {{ name: string, by: { readonly year10: DateMetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern15 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {MetricPattern15} */ function createMetricPattern15(client, name) { return /** @type {MetricPattern15} */ (_mp(client, name, _i15)); } -/** @template T @typedef {{ name: string, by: { readonly halvingepoch: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern16 */ +/** @template T @typedef {{ name: string, by: { readonly halving: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern16 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {MetricPattern16} */ function createMetricPattern16(client, name) { return /** @type {MetricPattern16} */ (_mp(client, name, _i16)); } -/** @template T @typedef {{ name: string, by: { readonly difficultyepoch: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern17 */ +/** @template T @typedef {{ name: string, by: { readonly epoch: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern17 */ /** @template T @param {BrkClientBase} client @param {string} name @returns {MetricPattern17} */ function createMetricPattern17(client, name) { return /** @type {MetricPattern17} */ (_mp(client, name, _i17)); } /** @template T @typedef {{ name: string, by: { readonly height: MetricEndpointBuilder }, indexes: () => readonly Index[], get: (index: Index) => MetricEndpointBuilder|undefined }} MetricPattern18 */ @@ -1574,281 +1593,6 @@ function createMetricPattern35(client, name) { return /** @type {MetricPattern35 // Reusable structural pattern factories -/** - * @typedef {Object} CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern - * @property {MetricPattern18} capRaw - * @property {MetricPattern1} capitulationFlow - * @property {CentsUsdPattern} grossPnl - * @property {_1m1w1y24hPattern} grossPnlSum - * @property {MetricPattern18} investorCapRaw - * @property {CentsSatsUsdPattern} investorPrice - * @property {BpsRatioPattern} investorPriceRatio - * @property {RatioPattern} investorPriceRatioPercentiles - * @property {MetricPattern1} lossValueCreated - * @property {_1m1w1y24hPattern} lossValueCreatedSum - * @property {MetricPattern1} lossValueDestroyed - * @property {_1m1w1y24hPattern} lossValueDestroyedSum - * @property {CentsSatsUsdPattern} lowerPriceBand - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} negRealizedLoss - * @property {BpsPercentRatioPattern} netPnlChange1mRelToMarketCap - * @property {BpsPercentRatioPattern} netPnlChange1mRelToRealizedCap - * @property {ChangeRatePattern3} netPnlDelta - * @property {_24hChangeRatePattern} netPnlDeltaExtended - * @property {MetricPattern1} netRealizedPnl - * @property {MetricPattern1} netRealizedPnlCumulative - * @property {BpsPercentRatioPattern} netRealizedPnlRelToRealizedCap - * @property {_24hPattern} netRealizedPnlSum - * @property {_1m1w1yPattern} netRealizedPnlSumExtended - * @property {CumulativeHeightPattern} peakRegret - * @property {BpsPercentRatioPattern} peakRegretRelToRealizedCap - * @property {MetricPattern1} profitFlow - * @property {MetricPattern1} profitValueCreated - * @property {_1m1w1y24hPattern} profitValueCreatedSum - * @property {MetricPattern1} profitValueDestroyed - * @property {_1m1w1y24hPattern} profitValueDestroyedSum - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {ChangeRatePattern3} realizedCapDelta - * @property {_24hChangeRatePattern} realizedCapDeltaExtended - * @property {BpsPercentRatioPattern} realizedCapRelToOwnMarketCap - * @property {CumulativeHeightPattern} realizedLoss - * @property {BpsPercentRatioPattern} realizedLossRelToRealizedCap - * @property {_24hPattern} realizedLossSum - * @property {_1m1w1yPattern} realizedLossSumExtended - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {RatioPattern} realizedPriceRatioPercentiles - * @property {RatioPattern2} realizedPriceRatioStdDev - * @property {CumulativeHeightPattern} realizedProfit - * @property {BpsPercentRatioPattern} realizedProfitRelToRealizedCap - * @property {_24hPattern} realizedProfitSum - * @property {_1m1w1yPattern} realizedProfitSumExtended - * @property {_1m1w1y24hPattern} realizedProfitToLossRatio - * @property {_1m1w1y24hPattern2} sellSideRiskRatio - * @property {MetricPattern1} sentInLoss - * @property {_24hPattern} sentInLossSum - * @property {_1m1w1yPattern} sentInLossSumExtended - * @property {MetricPattern1} sentInProfit - * @property {_24hPattern} sentInProfitSum - * @property {_1m1w1yPattern} sentInProfitSumExtended - * @property {_24hPattern} sopr - * @property {_1m1w1yPattern} soprExtended - * @property {CentsSatsUsdPattern} upperPriceBand - * @property {MetricPattern1} valueCreated - * @property {_24hPattern} valueCreatedSum - * @property {_1m1w1yPattern} valueCreatedSumExtended - * @property {MetricPattern1} valueDestroyed - * @property {_24hPattern} valueDestroyedSum - * @property {_1m1w1yPattern} valueDestroyedSumExtended - */ - -/** - * Create a CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} - */ -function createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, acc) { - return { - capRaw: createMetricPattern18(client, _m(acc, 'cap_raw')), - capitulationFlow: createMetricPattern1(client, _m(acc, 'capitulation_flow')), - grossPnl: createCentsUsdPattern(client, _m(acc, 'realized_gross_pnl')), - grossPnlSum: create_1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')), - investorCapRaw: createMetricPattern18(client, _m(acc, 'investor_cap_raw')), - investorPrice: createCentsSatsUsdPattern(client, _m(acc, 'investor_price')), - investorPriceRatio: createBpsRatioPattern(client, _m(acc, 'investor_price_ratio')), - investorPriceRatioPercentiles: createRatioPattern(client, _m(acc, 'investor_price_ratio')), - lossValueCreated: createMetricPattern1(client, _m(acc, 'loss_value_created')), - lossValueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'loss_value_created')), - lossValueDestroyed: createMetricPattern1(client, _m(acc, 'loss_value_destroyed')), - lossValueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'loss_value_destroyed')), - lowerPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'lower_price_band')), - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - negRealizedLoss: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), - netPnlChange1mRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_market_cap')), - netPnlChange1mRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_realized_cap')), - netPnlDelta: createChangeRatePattern3(client, _m(acc, 'net_pnl_delta')), - netPnlDeltaExtended: create_24hChangeRatePattern(client, _m(acc, 'net_pnl_delta')), - netRealizedPnl: createMetricPattern1(client, _m(acc, 'net_realized_pnl')), - netRealizedPnlCumulative: createMetricPattern1(client, _m(acc, 'net_realized_pnl_cumulative')), - netRealizedPnlRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')), - netRealizedPnlSum: create_24hPattern(client, _m(acc, 'net_realized_pnl_24h')), - netRealizedPnlSumExtended: create_1m1w1yPattern(client, _m(acc, 'net_realized_pnl')), - peakRegret: createCumulativeHeightPattern(client, _m(acc, 'realized_peak_regret')), - peakRegretRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_peak_regret_rel_to_realized_cap')), - profitFlow: createMetricPattern1(client, _m(acc, 'profit_flow')), - profitValueCreated: createMetricPattern1(client, _m(acc, 'profit_value_created')), - profitValueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'profit_value_created')), - profitValueDestroyed: createMetricPattern1(client, _m(acc, 'profit_value_destroyed')), - profitValueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'profit_value_destroyed')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedCapDelta: createChangeRatePattern3(client, _m(acc, 'realized_cap_delta')), - realizedCapDeltaExtended: create_24hChangeRatePattern(client, _m(acc, 'realized_cap_delta')), - realizedCapRelToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_cap_rel_to_own_market_cap')), - realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), - realizedLossRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')), - realizedLossSum: create_24hPattern(client, _m(acc, 'realized_loss_24h')), - realizedLossSumExtended: create_1m1w1yPattern(client, _m(acc, 'realized_loss')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedPriceRatioPercentiles: createRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedPriceRatioStdDev: createRatioPattern2(client, _m(acc, 'realized_price_ratio')), - realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), - realizedProfitRelToRealizedCap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')), - realizedProfitSum: create_24hPattern(client, _m(acc, 'realized_profit_24h')), - realizedProfitSumExtended: create_1m1w1yPattern(client, _m(acc, 'realized_profit')), - realizedProfitToLossRatio: create_1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')), - sellSideRiskRatio: create_1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')), - sentInLoss: createMetricPattern1(client, _m(acc, 'sent_in_loss')), - sentInLossSum: create_24hPattern(client, _m(acc, 'sent_in_loss_24h')), - sentInLossSumExtended: create_1m1w1yPattern(client, _m(acc, 'sent_in_loss')), - sentInProfit: createMetricPattern1(client, _m(acc, 'sent_in_profit')), - sentInProfitSum: create_24hPattern(client, _m(acc, 'sent_in_profit_24h')), - sentInProfitSumExtended: create_1m1w1yPattern(client, _m(acc, 'sent_in_profit')), - sopr: create_24hPattern(client, _m(acc, 'sopr_24h')), - soprExtended: create_1m1w1yPattern(client, _m(acc, 'sopr')), - upperPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'upper_price_band')), - valueCreated: createMetricPattern1(client, _m(acc, 'value_created')), - valueCreatedSum: create_24hPattern(client, _m(acc, 'value_created_24h')), - valueCreatedSumExtended: create_1m1w1yPattern(client, _m(acc, 'value_created')), - valueDestroyed: createMetricPattern1(client, _m(acc, 'value_destroyed')), - valueDestroyedSum: create_24hPattern(client, _m(acc, 'value_destroyed_24h')), - valueDestroyedSumExtended: create_1m1w1yPattern(client, _m(acc, 'value_destroyed')), - }; -} - -/** - * @typedef {Object} _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern - * @property {CentsSatsUsdPattern} _0sdPrice - * @property {MetricPattern1} m05sd - * @property {CentsSatsUsdPattern} m05sdPrice - * @property {MetricPattern1} m15sd - * @property {CentsSatsUsdPattern} m15sdPrice - * @property {MetricPattern1} m1sd - * @property {CentsSatsUsdPattern} m1sdPrice - * @property {MetricPattern1} m25sd - * @property {CentsSatsUsdPattern} m25sdPrice - * @property {MetricPattern1} m2sd - * @property {CentsSatsUsdPattern} m2sdPrice - * @property {MetricPattern1} m3sd - * @property {CentsSatsUsdPattern} m3sdPrice - * @property {MetricPattern1} p05sd - * @property {CentsSatsUsdPattern} p05sdPrice - * @property {MetricPattern1} p15sd - * @property {CentsSatsUsdPattern} p15sdPrice - * @property {MetricPattern1} p1sd - * @property {CentsSatsUsdPattern} p1sdPrice - * @property {MetricPattern1} p25sd - * @property {CentsSatsUsdPattern} p25sdPrice - * @property {MetricPattern1} p2sd - * @property {CentsSatsUsdPattern} p2sdPrice - * @property {MetricPattern1} p3sd - * @property {CentsSatsUsdPattern} p3sdPrice - * @property {MetricPattern1} sd - * @property {MetricPattern1} sma - * @property {MetricPattern1} zscore - */ - -/** - * Create a _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} - */ -function create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) { - return { - _0sdPrice: createCentsSatsUsdPattern(client, _m(acc, '0sd_4y')), - m05sd: createMetricPattern1(client, _m(acc, 'm0_5sd_4y')), - m05sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'm0_5sd_4y')), - m15sd: createMetricPattern1(client, _m(acc, 'm1_5sd_4y')), - m15sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'm1_5sd_4y')), - m1sd: createMetricPattern1(client, _m(acc, 'm1sd_4y')), - m1sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'm1sd_4y')), - m25sd: createMetricPattern1(client, _m(acc, 'm2_5sd_4y')), - m25sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'm2_5sd_4y')), - m2sd: createMetricPattern1(client, _m(acc, 'm2sd_4y')), - m2sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'm2sd_4y')), - m3sd: createMetricPattern1(client, _m(acc, 'm3sd_4y')), - m3sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'm3sd_4y')), - p05sd: createMetricPattern1(client, _m(acc, 'p0_5sd_4y')), - p05sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'p0_5sd_4y')), - p15sd: createMetricPattern1(client, _m(acc, 'p1_5sd_4y')), - p15sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'p1_5sd_4y')), - p1sd: createMetricPattern1(client, _m(acc, 'p1sd_4y')), - p1sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'p1sd_4y')), - p25sd: createMetricPattern1(client, _m(acc, 'p2_5sd_4y')), - p25sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'p2_5sd_4y')), - p2sd: createMetricPattern1(client, _m(acc, 'p2sd_4y')), - p2sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'p2sd_4y')), - p3sd: createMetricPattern1(client, _m(acc, 'p3sd_4y')), - p3sdPrice: createCentsSatsUsdPattern(client, _m(acc, 'p3sd_4y')), - sd: createMetricPattern1(client, _m(acc, 'sd_4y')), - sma: createMetricPattern1(client, _m(acc, 'sma_4y')), - zscore: createMetricPattern1(client, _m(acc, 'zscore_4y')), - }; -} - -/** - * @typedef {Object} MvrvNegNetRealizedSentSoprValuePattern - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} negRealizedLoss - * @property {MetricPattern1} netRealizedPnl - * @property {_24hPattern} netRealizedPnlSum - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {ChangeRatePattern3} realizedCapDelta - * @property {CumulativeHeightPattern} realizedLoss - * @property {_24hPattern} realizedLossSum - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {CumulativeHeightPattern} realizedProfit - * @property {_24hPattern} realizedProfitSum - * @property {MetricPattern1} sentInLoss - * @property {_24hPattern} sentInLossSum - * @property {MetricPattern1} sentInProfit - * @property {_24hPattern} sentInProfitSum - * @property {_24hPattern} sopr - * @property {MetricPattern1} valueCreated - * @property {_24hPattern} valueCreatedSum - * @property {MetricPattern1} valueDestroyed - * @property {_24hPattern} valueDestroyedSum - */ - -/** - * Create a MvrvNegNetRealizedSentSoprValuePattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {MvrvNegNetRealizedSentSoprValuePattern} - */ -function createMvrvNegNetRealizedSentSoprValuePattern(client, acc) { - return { - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - negRealizedLoss: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), - netRealizedPnl: createMetricPattern1(client, _m(acc, 'net_realized_pnl')), - netRealizedPnlSum: create_24hPattern(client, _m(acc, 'net_realized_pnl_24h')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedCapDelta: createChangeRatePattern3(client, _m(acc, 'realized_cap_delta')), - realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), - realizedLossSum: create_24hPattern(client, _m(acc, 'realized_loss_24h')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), - realizedProfitSum: create_24hPattern(client, _m(acc, 'realized_profit_24h')), - sentInLoss: createMetricPattern1(client, _m(acc, 'sent_in_loss')), - sentInLossSum: create_24hPattern(client, _m(acc, 'sent_in_loss_24h')), - sentInProfit: createMetricPattern1(client, _m(acc, 'sent_in_profit')), - sentInProfitSum: create_24hPattern(client, _m(acc, 'sent_in_profit_24h')), - sopr: create_24hPattern(client, _m(acc, 'sopr_24h')), - valueCreated: createMetricPattern1(client, _m(acc, 'value_created')), - valueCreatedSum: create_24hPattern(client, _m(acc, 'value_created_24h')), - valueDestroyed: createMetricPattern1(client, _m(acc, 'value_destroyed')), - valueDestroyedSum: create_24hPattern(client, _m(acc, 'value_destroyed_24h')), - }; -} - /** * @typedef {Object} Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern * @property {CentsSatsUsdPattern} pct05 @@ -1903,235 +1647,92 @@ function createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65 } /** - * @typedef {Object} MvrvNegNetRealizedSoprValuePattern + * @typedef {Object} _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern + * @property {PriceValuePattern} _0sd + * @property {PriceValuePattern} m05sd + * @property {PriceValuePattern} m15sd + * @property {PriceValuePattern} m1sd + * @property {PriceValuePattern} m25sd + * @property {PriceValuePattern} m2sd + * @property {PriceValuePattern} m3sd + * @property {PriceValuePattern} p05sd + * @property {PriceValuePattern} p15sd + * @property {PriceValuePattern} p1sd + * @property {PriceValuePattern} p25sd + * @property {PriceValuePattern} p2sd + * @property {PriceValuePattern} p3sd + * @property {MetricPattern1} sd + * @property {MetricPattern1} sma + * @property {MetricPattern1} zscore + */ + +/** + * Create a _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} + */ +function create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) { + return { + _0sd: createPriceValuePattern(client, _m(acc, '0sd_4y')), + m05sd: createPriceValuePattern(client, _m(acc, 'm0_5sd_4y')), + m15sd: createPriceValuePattern(client, _m(acc, 'm1_5sd_4y')), + m1sd: createPriceValuePattern(client, _m(acc, 'm1sd_4y')), + m25sd: createPriceValuePattern(client, _m(acc, 'm2_5sd_4y')), + m2sd: createPriceValuePattern(client, _m(acc, 'm2sd_4y')), + m3sd: createPriceValuePattern(client, _m(acc, 'm3sd_4y')), + p05sd: createPriceValuePattern(client, _m(acc, 'p0_5sd_4y')), + p15sd: createPriceValuePattern(client, _m(acc, 'p1_5sd_4y')), + p1sd: createPriceValuePattern(client, _m(acc, 'p1sd_4y')), + p25sd: createPriceValuePattern(client, _m(acc, 'p2_5sd_4y')), + p2sd: createPriceValuePattern(client, _m(acc, 'p2sd_4y')), + p3sd: createPriceValuePattern(client, _m(acc, 'p3sd_4y')), + sd: createMetricPattern1(client, _m(acc, 'sd_4y')), + sma: createMetricPattern1(client, _m(acc, 'sma_4y')), + zscore: createMetricPattern1(client, _m(acc, 'zscore_4y')), + }; +} + +/** + * @typedef {Object} CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern + * @property {CentsDeltaRawRelUsdPattern} cap + * @property {CentsSellSumUsdPattern} grossPnl + * @property {CapLowerPriceUpperPattern} investor + * @property {CapitulationCentsCumulativeNegRelSumUsdValuePattern} loss * @property {MetricPattern1} mvrv - * @property {MetricPattern1} negRealizedLoss - * @property {MetricPattern1} netRealizedPnl - * @property {_24hPattern} netRealizedPnlSum - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {ChangeRatePattern3} realizedCapDelta - * @property {CumulativeHeightPattern} realizedLoss - * @property {_24hPattern} realizedLossSum - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {CumulativeHeightPattern} realizedProfit - * @property {_24hPattern} realizedProfitSum - * @property {_24hPattern} sopr - * @property {MetricPattern1} valueCreated - * @property {_24hPattern} valueCreatedSum - * @property {MetricPattern1} valueDestroyed - * @property {_24hPattern} valueDestroyedSum + * @property {ChangeCumulativeDeltaRawRelSumPattern} netPnl + * @property {BpsRatioPattern} nupl + * @property {CumulativeHeightRelPattern} peakRegret + * @property {CentsSatsUsdPattern} price + * @property {BpsPercentilesRatioStdPattern} priceRatio + * @property {CentsCumulativeFlowRelSumUsdValuePattern} profit + * @property {_1m1w1y24hPattern} profitToLossRatio + * @property {InPattern3} sent + * @property {AdjustedRatioValuePattern} sopr */ /** - * Create a MvrvNegNetRealizedSoprValuePattern pattern node + * Create a CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {MvrvNegNetRealizedSoprValuePattern} + * @returns {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern} */ -function createMvrvNegNetRealizedSoprValuePattern(client, acc) { +function createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(client, acc) { return { + cap: createCentsDeltaRawRelUsdPattern(client, acc), + grossPnl: createCentsSellSumUsdPattern(client, acc), + investor: createCapLowerPriceUpperPattern(client, acc), + loss: createCapitulationCentsCumulativeNegRelSumUsdValuePattern(client, acc), mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - negRealizedLoss: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), - netRealizedPnl: createMetricPattern1(client, _m(acc, 'net_realized_pnl')), - netRealizedPnlSum: create_24hPattern(client, _m(acc, 'net_realized_pnl_24h')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedCapDelta: createChangeRatePattern3(client, _m(acc, 'realized_cap_delta')), - realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), - realizedLossSum: create_24hPattern(client, _m(acc, 'realized_loss_24h')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), - realizedProfitSum: create_24hPattern(client, _m(acc, 'realized_profit_24h')), - sopr: create_24hPattern(client, _m(acc, 'sopr_24h')), - valueCreated: createMetricPattern1(client, _m(acc, 'value_created')), - valueCreatedSum: create_24hPattern(client, _m(acc, 'value_created_24h')), - valueDestroyed: createMetricPattern1(client, _m(acc, 'value_destroyed')), - valueDestroyedSum: create_24hPattern(client, _m(acc, 'value_destroyed_24h')), - }; -} - -/** - * @typedef {Object} BpsRatioPattern2 - * @property {MetricPattern1} bps - * @property {MetricPattern1} ratio - * @property {BpsRatioPattern} ratioPct1 - * @property {CentsSatsUsdPattern} ratioPct1Price - * @property {BpsRatioPattern} ratioPct2 - * @property {CentsSatsUsdPattern} ratioPct2Price - * @property {BpsRatioPattern} ratioPct5 - * @property {CentsSatsUsdPattern} ratioPct5Price - * @property {BpsRatioPattern} ratioPct95 - * @property {CentsSatsUsdPattern} ratioPct95Price - * @property {BpsRatioPattern} ratioPct98 - * @property {CentsSatsUsdPattern} ratioPct98Price - * @property {BpsRatioPattern} ratioPct99 - * @property {CentsSatsUsdPattern} ratioPct99Price - * @property {BpsRatioPattern} ratioSma1m - * @property {BpsRatioPattern} ratioSma1w - */ - -/** - * Create a BpsRatioPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {BpsRatioPattern2} - */ -function createBpsRatioPattern2(client, acc) { - return { - bps: createMetricPattern1(client, _m(acc, 'bps')), - ratio: createMetricPattern1(client, acc), - ratioPct1: createBpsRatioPattern(client, _m(acc, 'pct1')), - ratioPct1Price: createCentsSatsUsdPattern(client, _m(acc, 'pct1')), - ratioPct2: createBpsRatioPattern(client, _m(acc, 'pct2')), - ratioPct2Price: createCentsSatsUsdPattern(client, _m(acc, 'pct2')), - ratioPct5: createBpsRatioPattern(client, _m(acc, 'pct5')), - ratioPct5Price: createCentsSatsUsdPattern(client, _m(acc, 'pct5')), - ratioPct95: createBpsRatioPattern(client, _m(acc, 'pct95')), - ratioPct95Price: createCentsSatsUsdPattern(client, _m(acc, 'pct95')), - ratioPct98: createBpsRatioPattern(client, _m(acc, 'pct98')), - ratioPct98Price: createCentsSatsUsdPattern(client, _m(acc, 'pct98')), - ratioPct99: createBpsRatioPattern(client, _m(acc, 'pct99')), - ratioPct99Price: createCentsSatsUsdPattern(client, _m(acc, 'pct99')), - ratioSma1m: createBpsRatioPattern(client, _m(acc, 'sma_1m')), - ratioSma1w: createBpsRatioPattern(client, _m(acc, 'sma_1w')), - }; -} - -/** - * @typedef {Object} GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern - * @property {CentsUsdPattern} greedIndex - * @property {CentsUsdPattern} grossPnl - * @property {CentsUsdPattern} investedCapitalInLoss - * @property {MetricPattern18} investedCapitalInLossRaw - * @property {CentsUsdPattern} investedCapitalInProfit - * @property {MetricPattern18} investedCapitalInProfitRaw - * @property {MetricPattern18} investorCapInLossRaw - * @property {MetricPattern18} investorCapInProfitRaw - * @property {MetricPattern1} negUnrealizedLoss - * @property {CentsUsdPattern} netSentiment - * @property {CentsUsdPattern} netUnrealizedPnl - * @property {CentsUsdPattern} painIndex - * @property {BtcCentsSatsUsdPattern} supplyInLoss - * @property {BtcCentsSatsUsdPattern} supplyInProfit - * @property {CentsUsdPattern} unrealizedLoss - * @property {CentsUsdPattern} unrealizedProfit - */ - -/** - * Create a GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} - */ -function createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, acc) { - return { - greedIndex: createCentsUsdPattern(client, _m(acc, 'greed_index')), - grossPnl: createCentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')), - investedCapitalInLoss: createCentsUsdPattern(client, _m(acc, 'invested_capital_in_loss')), - investedCapitalInLossRaw: createMetricPattern18(client, _m(acc, 'invested_capital_in_loss_raw')), - investedCapitalInProfit: createCentsUsdPattern(client, _m(acc, 'invested_capital_in_profit')), - investedCapitalInProfitRaw: createMetricPattern18(client, _m(acc, 'invested_capital_in_profit_raw')), - investorCapInLossRaw: createMetricPattern18(client, _m(acc, 'investor_cap_in_loss_raw')), - investorCapInProfitRaw: createMetricPattern18(client, _m(acc, 'investor_cap_in_profit_raw')), - negUnrealizedLoss: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - netSentiment: createCentsUsdPattern(client, _m(acc, 'net_sentiment')), - netUnrealizedPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - painIndex: createCentsUsdPattern(client, _m(acc, 'pain_index')), - supplyInLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')), - supplyInProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')), - unrealizedLoss: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - unrealizedProfit: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), - }; -} - -/** - * @typedef {Object} NetNuplSupplyUnrealizedPattern2 - * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToMarketCap - * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToOwnGrossPnl - * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToOwnMarketCap - * @property {MetricPattern1} nupl - * @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply - * @property {BpsPercentRatioPattern} unrealizedLossRelToMarketCap - * @property {BpsPercentRatioPattern} unrealizedLossRelToOwnGrossPnl - * @property {BpsPercentRatioPattern} unrealizedLossRelToOwnMarketCap - * @property {BpsPercentRatioPattern} unrealizedProfitRelToMarketCap - * @property {BpsPercentRatioPattern} unrealizedProfitRelToOwnGrossPnl - * @property {BpsPercentRatioPattern} unrealizedProfitRelToOwnMarketCap - */ - -/** - * Create a NetNuplSupplyUnrealizedPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {NetNuplSupplyUnrealizedPattern2} - */ -function createNetNuplSupplyUnrealizedPattern2(client, acc) { - return { - netUnrealizedPnlRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_market_cap')), - netUnrealizedPnlRelToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_own_gross_pnl')), - netUnrealizedPnlRelToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_own_market_cap')), - nupl: createMetricPattern1(client, _m(acc, 'nupl')), - supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_circulating_supply')), - supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_own_supply')), - supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_circulating_supply')), - supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_own_supply')), - supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'supply_rel_to_circulating_supply')), - unrealizedLossRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')), - unrealizedLossRelToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')), - unrealizedLossRelToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')), - unrealizedProfitRelToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')), - unrealizedProfitRelToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_gross_pnl')), - unrealizedProfitRelToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_market_cap')), - }; -} - -/** - * @typedef {Object} RatioPattern - * @property {BpsRatioPattern} ratioPct1 - * @property {CentsSatsUsdPattern} ratioPct1Price - * @property {BpsRatioPattern} ratioPct2 - * @property {CentsSatsUsdPattern} ratioPct2Price - * @property {BpsRatioPattern} ratioPct5 - * @property {CentsSatsUsdPattern} ratioPct5Price - * @property {BpsRatioPattern} ratioPct95 - * @property {CentsSatsUsdPattern} ratioPct95Price - * @property {BpsRatioPattern} ratioPct98 - * @property {CentsSatsUsdPattern} ratioPct98Price - * @property {BpsRatioPattern} ratioPct99 - * @property {CentsSatsUsdPattern} ratioPct99Price - * @property {BpsRatioPattern} ratioSma1m - * @property {BpsRatioPattern} ratioSma1w - */ - -/** - * Create a RatioPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RatioPattern} - */ -function createRatioPattern(client, acc) { - return { - ratioPct1: createBpsRatioPattern(client, _m(acc, 'pct1')), - ratioPct1Price: createCentsSatsUsdPattern(client, _m(acc, 'pct1')), - ratioPct2: createBpsRatioPattern(client, _m(acc, 'pct2')), - ratioPct2Price: createCentsSatsUsdPattern(client, _m(acc, 'pct2')), - ratioPct5: createBpsRatioPattern(client, _m(acc, 'pct5')), - ratioPct5Price: createCentsSatsUsdPattern(client, _m(acc, 'pct5')), - ratioPct95: createBpsRatioPattern(client, _m(acc, 'pct95')), - ratioPct95Price: createCentsSatsUsdPattern(client, _m(acc, 'pct95')), - ratioPct98: createBpsRatioPattern(client, _m(acc, 'pct98')), - ratioPct98Price: createCentsSatsUsdPattern(client, _m(acc, 'pct98')), - ratioPct99: createBpsRatioPattern(client, _m(acc, 'pct99')), - ratioPct99Price: createCentsSatsUsdPattern(client, _m(acc, 'pct99')), - ratioSma1m: createBpsRatioPattern(client, _m(acc, 'sma_1m')), - ratioSma1w: createBpsRatioPattern(client, _m(acc, 'sma_1w')), + netPnl: createChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), + peakRegret: createCumulativeHeightRelPattern(client, _m(acc, 'realized_peak_regret')), + price: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), + priceRatio: createBpsPercentilesRatioStdPattern(client, _m(acc, 'realized_price_ratio')), + profit: createCentsCumulativeFlowRelSumUsdValuePattern(client, acc), + profitToLossRatio: create_1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')), + sent: createInPattern3(client, _m(acc, 'sent_in')), + sopr: createAdjustedRatioValuePattern(client, acc), }; } @@ -2213,43 +1814,6 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { }; } -/** - * @typedef {Object} _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern - * @property {BpsPercentRatioPattern} _1m - * @property {BpsPercentRatioPattern} _1w - * @property {BpsPercentRatioPattern} _1y - * @property {BpsPercentRatioPattern} _24h - * @property {BtcCentsSatsUsdPattern} base - * @property {MetricPattern1} bps - * @property {BaseBtcCentsSatsUsdPattern} cumulative - * @property {MetricPattern18} height - * @property {MetricPattern1} percent - * @property {MetricPattern1} ratio - * @property {_1m1w1y24hPattern6} sum - */ - -/** - * Create a _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} - */ -function create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, acc) { - return { - _1m: createBpsPercentRatioPattern(client, _m(acc, 'dominance_1m')), - _1w: createBpsPercentRatioPattern(client, _m(acc, 'dominance_1w')), - _1y: createBpsPercentRatioPattern(client, _m(acc, 'dominance_1y')), - _24h: createBpsPercentRatioPattern(client, _m(acc, 'dominance_24h')), - base: createBtcCentsSatsUsdPattern(client, _m(acc, 'rewards')), - bps: createMetricPattern1(client, _m(acc, 'dominance_bps')), - cumulative: createBaseBtcCentsSatsUsdPattern(client, acc), - height: createMetricPattern18(client, _m(acc, 'blocks_mined')), - percent: createMetricPattern1(client, _m(acc, 'dominance')), - ratio: createMetricPattern1(client, _m(acc, 'dominance_ratio')), - sum: create_1m1w1y24hPattern6(client, acc), - }; -} - /** * @typedef {Object} AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern * @property {MetricPattern18} average @@ -2278,10 +1842,10 @@ function createAverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPatter max: createMetricPattern18(client, _m(acc, 'max')), median: createMetricPattern18(client, _m(acc, 'median')), min: createMetricPattern18(client, _m(acc, 'min')), - pct10: createMetricPattern18(client, _m(acc, 'p10')), - pct25: createMetricPattern18(client, _m(acc, 'p25')), - pct75: createMetricPattern18(client, _m(acc, 'p75')), - pct90: createMetricPattern18(client, _m(acc, 'p90')), + pct10: createMetricPattern18(client, _m(acc, 'pct10')), + pct25: createMetricPattern18(client, _m(acc, 'pct25')), + pct75: createMetricPattern18(client, _m(acc, 'pct75')), + pct90: createMetricPattern18(client, _m(acc, 'pct90')), rolling: createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, acc), sum: createMetricPattern18(client, _m(acc, 'sum')), }; @@ -2316,14 +1880,51 @@ function createAverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern max: create_1m1w1y24hPattern(client, _m(acc, 'max')), median: create_1m1w1y24hPattern(client, _m(acc, 'median')), min: create_1m1w1y24hPattern(client, _m(acc, 'min')), - pct10: create_1m1w1y24hPattern(client, _m(acc, 'p10')), - pct25: create_1m1w1y24hPattern(client, _m(acc, 'p25')), - pct75: create_1m1w1y24hPattern(client, _m(acc, 'p75')), - pct90: create_1m1w1y24hPattern(client, _m(acc, 'p90')), + pct10: create_1m1w1y24hPattern(client, _m(acc, 'pct10')), + pct25: create_1m1w1y24hPattern(client, _m(acc, 'pct25')), + pct75: create_1m1w1y24hPattern(client, _m(acc, 'pct75')), + pct90: create_1m1w1y24hPattern(client, _m(acc, 'pct90')), sum: create_1m1w1y24hPattern(client, _m(acc, 'sum')), }; } +/** + * @typedef {Object} CapitulationCentsCumulativeNegRelSumUsdValuePattern + * @property {MetricPattern1} capitulationFlow + * @property {MetricPattern1} cents + * @property {MetricPattern1} cumulative + * @property {MetricPattern1} neg + * @property {BpsPercentRatioPattern} relToRcap + * @property {_1m1w1y24hPattern3} sum + * @property {MetricPattern1} usd + * @property {MetricPattern1} valueCreated + * @property {_1m1w1y24hPattern} valueCreatedSum + * @property {MetricPattern1} valueDestroyed + * @property {_1m1w1y24hPattern} valueDestroyedSum + */ + +/** + * Create a CapitulationCentsCumulativeNegRelSumUsdValuePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapitulationCentsCumulativeNegRelSumUsdValuePattern} + */ +function createCapitulationCentsCumulativeNegRelSumUsdValuePattern(client, acc) { + return { + capitulationFlow: createMetricPattern1(client, _m(acc, 'capitulation_flow')), + cents: createMetricPattern1(client, _m(acc, 'realized_loss_cents')), + cumulative: createMetricPattern1(client, _m(acc, 'realized_loss_cumulative')), + neg: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), + relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'realized_loss')), + usd: createMetricPattern1(client, _m(acc, 'realized_loss')), + valueCreated: createMetricPattern1(client, _m(acc, 'loss_value_created')), + valueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'loss_value_created')), + valueDestroyed: createMetricPattern1(client, _m(acc, 'loss_value_destroyed')), + valueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'loss_value_destroyed')), + }; +} + /** * @typedef {Object} AverageGainsLossesRsiStochPattern * @property {MetricPattern1} averageGain @@ -2360,37 +1961,107 @@ function createAverageGainsLossesRsiStochPattern(client, acc) { } /** - * @typedef {Object} InvestedInvestorNegNetSupplyUnrealizedPattern - * @property {MetricPattern18} investedCapitalInLossRaw - * @property {MetricPattern18} investedCapitalInProfitRaw - * @property {MetricPattern18} investorCapInLossRaw - * @property {MetricPattern18} investorCapInProfitRaw - * @property {MetricPattern1} negUnrealizedLoss - * @property {CentsUsdPattern} netUnrealizedPnl - * @property {BtcCentsSatsUsdPattern} supplyInLoss - * @property {BtcCentsSatsUsdPattern} supplyInProfit - * @property {CentsUsdPattern} unrealizedLoss - * @property {CentsUsdPattern} unrealizedProfit + * @typedef {Object} BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern + * @property {MetricPattern1} bps + * @property {BpsPriceRatioPattern} pct1 + * @property {BpsPriceRatioPattern} pct2 + * @property {BpsPriceRatioPattern} pct5 + * @property {BpsPriceRatioPattern} pct95 + * @property {BpsPriceRatioPattern} pct98 + * @property {BpsPriceRatioPattern} pct99 + * @property {MetricPattern1} ratio + * @property {BpsRatioPattern} sma1m + * @property {BpsRatioPattern} sma1w */ /** - * Create a InvestedInvestorNegNetSupplyUnrealizedPattern pattern node + * Create a BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {InvestedInvestorNegNetSupplyUnrealizedPattern} + * @returns {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} */ -function createInvestedInvestorNegNetSupplyUnrealizedPattern(client, acc) { +function createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, acc) { return { - investedCapitalInLossRaw: createMetricPattern18(client, _m(acc, 'invested_capital_in_loss_raw')), - investedCapitalInProfitRaw: createMetricPattern18(client, _m(acc, 'invested_capital_in_profit_raw')), - investorCapInLossRaw: createMetricPattern18(client, _m(acc, 'investor_cap_in_loss_raw')), - investorCapInProfitRaw: createMetricPattern18(client, _m(acc, 'investor_cap_in_profit_raw')), - negUnrealizedLoss: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - netUnrealizedPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - supplyInLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')), - supplyInProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')), - unrealizedLoss: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - unrealizedProfit: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), + bps: createMetricPattern1(client, _m(acc, 'bps')), + pct1: createBpsPriceRatioPattern(client, _m(acc, 'pct1')), + pct2: createBpsPriceRatioPattern(client, _m(acc, 'pct2')), + pct5: createBpsPriceRatioPattern(client, _m(acc, 'pct5')), + pct95: createBpsPriceRatioPattern(client, _m(acc, 'pct95')), + pct98: createBpsPriceRatioPattern(client, _m(acc, 'pct98')), + pct99: createBpsPriceRatioPattern(client, _m(acc, 'pct99')), + ratio: createMetricPattern1(client, acc), + sma1m: createBpsRatioPattern(client, _m(acc, 'sma_1m')), + sma1w: createBpsRatioPattern(client, _m(acc, 'sma_1w')), + }; +} + +/** + * @typedef {Object} CapLossMvrvNetNuplPriceProfitSentSoprPattern + * @property {CentsDeltaUsdPattern} cap + * @property {CentsCumulativeNegSumUsdPattern} loss + * @property {MetricPattern1} mvrv + * @property {RawSumPattern} netPnl + * @property {BpsRatioPattern} nupl + * @property {CentsSatsUsdPattern} price + * @property {BpsRatioPattern} priceRatio + * @property {CentsCumulativeSumUsdPattern} profit + * @property {InPattern} sent + * @property {RatioValuePattern} sopr + */ + +/** + * Create a CapLossMvrvNetNuplPriceProfitSentSoprPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapLossMvrvNetNuplPriceProfitSentSoprPattern} + */ +function createCapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc) { + return { + cap: createCentsDeltaUsdPattern(client, _m(acc, 'realized_cap')), + loss: createCentsCumulativeNegSumUsdPattern(client, acc), + mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + netPnl: createRawSumPattern(client, _m(acc, 'net_realized_pnl')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), + price: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), + priceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), + profit: createCentsCumulativeSumUsdPattern(client, _m(acc, 'realized_profit')), + sent: createInPattern(client, _m(acc, 'sent_in')), + sopr: createRatioValuePattern(client, acc), + }; +} + +/** + * @typedef {Object} CentsCumulativeFlowRelSumUsdValuePattern + * @property {MetricPattern1} cents + * @property {MetricPattern1} cumulative + * @property {MetricPattern1} flow + * @property {BpsPercentRatioPattern} relToRcap + * @property {_1m1w1y24hPattern3} sum + * @property {MetricPattern1} usd + * @property {MetricPattern1} valueCreated + * @property {_1m1w1y24hPattern} valueCreatedSum + * @property {MetricPattern1} valueDestroyed + * @property {_1m1w1y24hPattern} valueDestroyedSum + */ + +/** + * Create a CentsCumulativeFlowRelSumUsdValuePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsCumulativeFlowRelSumUsdValuePattern} + */ +function createCentsCumulativeFlowRelSumUsdValuePattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'realized_profit_cents')), + cumulative: createMetricPattern1(client, _m(acc, 'realized_profit_cumulative')), + flow: createMetricPattern1(client, _m(acc, 'profit_flow')), + relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')), + sum: create_1m1w1y24hPattern3(client, _m(acc, 'realized_profit')), + usd: createMetricPattern1(client, _m(acc, 'realized_profit')), + valueCreated: createMetricPattern1(client, _m(acc, 'profit_value_created')), + valueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'profit_value_created')), + valueDestroyed: createMetricPattern1(client, _m(acc, 'profit_value_destroyed')), + valueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'profit_value_destroyed')), }; } @@ -2452,10 +2123,10 @@ function createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(client, acc) { max: createBtcCentsSatsUsdPattern(client, _m(acc, 'max')), median: createBtcCentsSatsUsdPattern(client, _m(acc, 'median')), min: createBtcCentsSatsUsdPattern(client, _m(acc, 'min')), - pct10: createBtcCentsSatsUsdPattern(client, _m(acc, 'p10')), - pct25: createBtcCentsSatsUsdPattern(client, _m(acc, 'p25')), - pct75: createBtcCentsSatsUsdPattern(client, _m(acc, 'p75')), - pct90: createBtcCentsSatsUsdPattern(client, _m(acc, 'p90')), + pct10: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct10')), + pct25: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct25')), + pct75: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct75')), + pct90: createBtcCentsSatsUsdPattern(client, _m(acc, 'pct90')), sum: createBtcCentsSatsUsdPattern(client, _m(acc, 'sum')), }; } @@ -2485,47 +2156,14 @@ function createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, acc) { max: create_1m1w1y24hPattern(client, _m(acc, 'max')), median: create_1m1w1y24hPattern(client, _m(acc, 'median')), min: create_1m1w1y24hPattern(client, _m(acc, 'min')), - pct10: create_1m1w1y24hPattern(client, _m(acc, 'p10')), - pct25: create_1m1w1y24hPattern(client, _m(acc, 'p25')), - pct75: create_1m1w1y24hPattern(client, _m(acc, 'p75')), - pct90: create_1m1w1y24hPattern(client, _m(acc, 'p90')), + pct10: create_1m1w1y24hPattern(client, _m(acc, 'pct10')), + pct25: create_1m1w1y24hPattern(client, _m(acc, 'pct25')), + pct75: create_1m1w1y24hPattern(client, _m(acc, 'pct75')), + pct90: create_1m1w1y24hPattern(client, _m(acc, 'pct90')), sum: create_1m1w1y24hPattern(client, _m(acc, 'sum')), }; } -/** - * @typedef {Object} MvrvRealizedPattern - * @property {MetricPattern1} mvrv - * @property {MetricPattern1} realizedCap - * @property {MetricPattern1} realizedCapCents - * @property {CumulativeHeightPattern} realizedLoss - * @property {_24hPattern} realizedLossSum - * @property {CentsSatsUsdPattern} realizedPrice - * @property {BpsRatioPattern} realizedPriceRatio - * @property {CumulativeHeightPattern} realizedProfit - * @property {_24hPattern} realizedProfitSum - */ - -/** - * Create a MvrvRealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {MvrvRealizedPattern} - */ -function createMvrvRealizedPattern(client, acc) { - return { - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - realizedCap: createMetricPattern1(client, _m(acc, 'realized_cap')), - realizedCapCents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), - realizedLoss: createCumulativeHeightPattern(client, _m(acc, 'realized_loss')), - realizedLossSum: create_24hPattern(client, _m(acc, 'realized_loss_24h')), - realizedPrice: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - realizedPriceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), - realizedProfit: createCumulativeHeightPattern(client, _m(acc, 'realized_profit')), - realizedProfitSum: create_24hPattern(client, _m(acc, 'realized_profit_24h')), - }; -} - /** * @typedef {Object} _1m1w1y24hBtcCentsSatsUsdPattern * @property {BtcCentsSatsUsdPattern} _1m @@ -2550,41 +2188,72 @@ function create_1m1w1y24hBtcCentsSatsUsdPattern(client, acc) { _1w: createBtcCentsSatsUsdPattern(client, _m(acc, '1w')), _1y: createBtcCentsSatsUsdPattern(client, _m(acc, '1y')), _24h: createBtcCentsSatsUsdPattern(client, _m(acc, '24h')), - btc: createMetricPattern18(client, _m(acc, 'btc')), + btc: createMetricPattern18(client, acc), cents: createMetricPattern18(client, _m(acc, 'cents')), - sats: createMetricPattern18(client, acc), + sats: createMetricPattern18(client, _m(acc, 'sats')), usd: createMetricPattern18(client, _m(acc, 'usd')), }; } /** - * @typedef {Object} CoinblocksCoindaysSentPattern2 - * @property {MetricPattern1} coinblocksDestroyed - * @property {MetricPattern1} coinblocksDestroyedCumulative - * @property {MetricPattern1} coindaysDestroyed - * @property {MetricPattern1} coindaysDestroyedCumulative - * @property {_1m1w1y24hPattern} coindaysDestroyedSum - * @property {MetricPattern1} sent - * @property {_24hPattern} sentSum - * @property {_1m1w1yPattern} sentSumExtended + * @typedef {Object} CapLossMvrvNuplPriceProfitSoprPattern + * @property {CentsUsdPattern} cap + * @property {CentsSumUsdPattern} loss + * @property {MetricPattern1} mvrv + * @property {BpsRatioPattern} nupl + * @property {CentsSatsUsdPattern} price + * @property {BpsRatioPattern} priceRatio + * @property {CentsSumUsdPattern} profit + * @property {ValuePattern} sopr */ /** - * Create a CoinblocksCoindaysSentPattern2 pattern node + * Create a CapLossMvrvNuplPriceProfitSoprPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CoinblocksCoindaysSentPattern2} + * @returns {CapLossMvrvNuplPriceProfitSoprPattern} */ -function createCoinblocksCoindaysSentPattern2(client, acc) { +function createCapLossMvrvNuplPriceProfitSoprPattern(client, acc) { return { - coinblocksDestroyed: createMetricPattern1(client, _m(acc, 'coinblocks_destroyed')), - coinblocksDestroyedCumulative: createMetricPattern1(client, _m(acc, 'coinblocks_destroyed_cumulative')), - coindaysDestroyed: createMetricPattern1(client, _m(acc, 'coindays_destroyed')), - coindaysDestroyedCumulative: createMetricPattern1(client, _m(acc, 'coindays_destroyed_cumulative')), - coindaysDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'coindays_destroyed')), - sent: createMetricPattern1(client, _m(acc, 'sent')), - sentSum: create_24hPattern(client, _m(acc, 'sent_24h')), - sentSumExtended: create_1m1w1yPattern(client, _m(acc, 'sent')), + cap: createCentsUsdPattern(client, _m(acc, 'realized_cap')), + loss: createCentsSumUsdPattern(client, _m(acc, 'realized_loss')), + mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), + price: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), + priceRatio: createBpsRatioPattern(client, _m(acc, 'realized_price_ratio')), + profit: createCentsSumUsdPattern(client, _m(acc, 'realized_profit')), + sopr: createValuePattern(client, _m(acc, 'value')), + }; +} + +/** + * @typedef {Object} Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern + * @property {BpsPriceRatioPattern} pct1 + * @property {BpsPriceRatioPattern} pct2 + * @property {BpsPriceRatioPattern} pct5 + * @property {BpsPriceRatioPattern} pct95 + * @property {BpsPriceRatioPattern} pct98 + * @property {BpsPriceRatioPattern} pct99 + * @property {BpsRatioPattern} sma1m + * @property {BpsRatioPattern} sma1w + */ + +/** + * Create a Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern} + */ +function createPct1Pct2Pct5Pct95Pct98Pct99SmaPattern(client, acc) { + return { + pct1: createBpsPriceRatioPattern(client, _m(acc, 'pct1')), + pct2: createBpsPriceRatioPattern(client, _m(acc, 'pct2')), + pct5: createBpsPriceRatioPattern(client, _m(acc, 'pct5')), + pct95: createBpsPriceRatioPattern(client, _m(acc, 'pct95')), + pct98: createBpsPriceRatioPattern(client, _m(acc, 'pct98')), + pct99: createBpsPriceRatioPattern(client, _m(acc, 'pct99')), + sma1m: createBpsRatioPattern(client, _m(acc, 'sma_1m')), + sma1w: createBpsRatioPattern(client, _m(acc, 'sma_1w')), }; } @@ -2614,10 +2283,10 @@ function createAverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, acc) { max: createMetricPattern18(client, _m(acc, 'max')), median: createMetricPattern18(client, _m(acc, 'median')), min: createMetricPattern18(client, _m(acc, 'min')), - pct10: createMetricPattern18(client, _m(acc, 'p10')), - pct25: createMetricPattern18(client, _m(acc, 'p25')), - pct75: createMetricPattern18(client, _m(acc, 'p75')), - pct90: createMetricPattern18(client, _m(acc, 'p90')), + pct10: createMetricPattern18(client, _m(acc, 'pct10')), + pct25: createMetricPattern18(client, _m(acc, 'pct25')), + pct75: createMetricPattern18(client, _m(acc, 'pct75')), + pct90: createMetricPattern18(client, _m(acc, 'pct90')), }; } @@ -2651,120 +2320,41 @@ function create_10y2y3y4y5y6y8yPattern(client, acc) { } /** - * @typedef {Object} ActivityAddrOutputsRealizedSupplyUnrealizedPattern - * @property {SentPattern} activity - * @property {MetricPattern1} addrCount - * @property {ChangeRatePattern} addrCountDelta - * @property {UtxoPattern} outputs - * @property {MvrvRealizedPattern} realized - * @property {DeltaHalvedTotalPattern} supply - * @property {SupplyPattern} unrealized + * @typedef {Object} _1m1w1y24hBpsPercentRatioPattern + * @property {BpsPercentRatioPattern} _1m + * @property {BpsPercentRatioPattern} _1w + * @property {BpsPercentRatioPattern} _1y + * @property {BpsPercentRatioPattern} _24h + * @property {MetricPattern1} bps + * @property {MetricPattern1} percent + * @property {MetricPattern1} ratio */ /** - * Create a ActivityAddrOutputsRealizedSupplyUnrealizedPattern pattern node + * Create a _1m1w1y24hBpsPercentRatioPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} + * @returns {_1m1w1y24hBpsPercentRatioPattern} */ -function createActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, acc) { +function create_1m1w1y24hBpsPercentRatioPattern(client, acc) { return { - activity: createSentPattern(client, _m(acc, 'sent')), - addrCount: createMetricPattern1(client, _m(acc, 'addr_count')), - addrCountDelta: createChangeRatePattern(client, _m(acc, 'addr_count_delta')), - outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createMvrvRealizedPattern(client, acc), - supply: createDeltaHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createSupplyPattern(client, _m(acc, 'supply_in')), - }; -} - -/** - * @typedef {Object} ActivityOutputsRealizedRelativeSupplyUnrealizedPattern - * @property {CoinblocksCoindaysSentPattern} activity - * @property {UtxoPattern} outputs - * @property {MvrvNegNetRealizedSentSoprValuePattern} realized - * @property {SupplyPattern2} relative - * @property {DeltaHalvedTotalPattern} supply - * @property {InvestedInvestorNegNetSupplyUnrealizedPattern} unrealized - */ - -/** - * Create a ActivityOutputsRealizedRelativeSupplyUnrealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} - */ -function createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, acc) { - return { - activity: createCoinblocksCoindaysSentPattern(client, acc), - outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createMvrvNegNetRealizedSentSoprValuePattern(client, acc), - relative: createSupplyPattern2(client, _m(acc, 'supply')), - supply: createDeltaHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createInvestedInvestorNegNetSupplyUnrealizedPattern(client, acc), - }; -} - -/** - * @typedef {Object} ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 - * @property {SentPattern} activity - * @property {UtxoPattern} outputs - * @property {MvrvNegNetRealizedSoprValuePattern} realized - * @property {SupplyPattern2} relative - * @property {DeltaHalvedTotalPattern} supply - * @property {NegNetSupplyUnrealizedPattern} unrealized - */ - -/** - * Create a ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} - */ -function createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, acc) { - return { - activity: createSentPattern(client, _m(acc, 'sent')), - outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createMvrvNegNetRealizedSoprValuePattern(client, acc), - relative: createSupplyPattern2(client, _m(acc, 'supply')), - supply: createDeltaHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createNegNetSupplyUnrealizedPattern(client, acc), - }; -} - -/** - * @typedef {Object} NegNetSupplyUnrealizedPattern - * @property {MetricPattern1} negUnrealizedLoss - * @property {CentsUsdPattern} netUnrealizedPnl - * @property {BtcCentsSatsUsdPattern} supplyInLoss - * @property {BtcCentsSatsUsdPattern} supplyInProfit - * @property {CentsUsdPattern} unrealizedLoss - * @property {CentsUsdPattern} unrealizedProfit - */ - -/** - * Create a NegNetSupplyUnrealizedPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {NegNetSupplyUnrealizedPattern} - */ -function createNegNetSupplyUnrealizedPattern(client, acc) { - return { - negUnrealizedLoss: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), - netUnrealizedPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - supplyInLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')), - supplyInProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')), - unrealizedLoss: createCentsUsdPattern(client, _m(acc, 'unrealized_loss')), - unrealizedProfit: createCentsUsdPattern(client, _m(acc, 'unrealized_profit')), + _1m: createBpsPercentRatioPattern(client, _m(acc, '1m')), + _1w: createBpsPercentRatioPattern(client, _m(acc, '1w')), + _1y: createBpsPercentRatioPattern(client, _m(acc, '1y')), + _24h: createBpsPercentRatioPattern(client, _m(acc, '24h')), + bps: createMetricPattern1(client, _m(acc, 'bps')), + percent: createMetricPattern1(client, acc), + ratio: createMetricPattern1(client, _m(acc, 'ratio')), }; } /** * @typedef {Object} _24hChangeRatePattern * @property {BpsCentsPercentRatioUsdPattern} _24h + * @property {_1mPattern3} change * @property {CentsUsdPattern} change1w * @property {CentsUsdPattern} change1y + * @property {_1mPattern2} rate * @property {BpsPercentRatioPattern} rate1w * @property {BpsPercentRatioPattern} rate1y */ @@ -2778,60 +2368,203 @@ function createNegNetSupplyUnrealizedPattern(client, acc) { function create_24hChangeRatePattern(client, acc) { return { _24h: createBpsCentsPercentRatioUsdPattern(client, acc), + change: create_1mPattern3(client, _m(acc, 'change_1m')), change1w: createCentsUsdPattern(client, _m(acc, 'change_1w')), change1y: createCentsUsdPattern(client, _m(acc, 'change_1y')), + rate: create_1mPattern2(client, _m(acc, 'rate_1m')), rate1w: createBpsPercentRatioPattern(client, _m(acc, 'rate_1w')), rate1y: createBpsPercentRatioPattern(client, _m(acc, 'rate_1y')), }; } /** - * @typedef {Object} ActivityOutputsRealizedSupplyUnrealizedPattern - * @property {SentPattern} activity - * @property {UtxoPattern} outputs - * @property {MvrvRealizedPattern} realized - * @property {DeltaHalvedTotalPattern} supply - * @property {SupplyPattern} unrealized + * @typedef {Object} ChangeCumulativeDeltaRawRelSumPattern + * @property {BpsPercentRatioPattern} change1mRelToMcap + * @property {BpsPercentRatioPattern} change1mRelToRcap + * @property {MetricPattern1} cumulative + * @property {_24hChangeRatePattern} delta + * @property {MetricPattern1} raw + * @property {BpsPercentRatioPattern} relToRcap + * @property {_1m1w1y24hPattern} sum */ /** - * Create a ActivityOutputsRealizedSupplyUnrealizedPattern pattern node + * Create a ChangeCumulativeDeltaRawRelSumPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {ActivityOutputsRealizedSupplyUnrealizedPattern} + * @returns {ChangeCumulativeDeltaRawRelSumPattern} */ -function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { +function createChangeCumulativeDeltaRawRelSumPattern(client, acc) { return { - activity: createSentPattern(client, _m(acc, 'sent')), - outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), - realized: createMvrvRealizedPattern(client, acc), - supply: createDeltaHalvedTotalPattern(client, _m(acc, 'supply')), - unrealized: createSupplyPattern(client, _m(acc, 'supply_in')), + change1mRelToMcap: createBpsPercentRatioPattern(client, _m(acc, 'pnl_change_1m_rel_to_market_cap')), + change1mRelToRcap: createBpsPercentRatioPattern(client, _m(acc, 'pnl_change_1m_rel_to_realized_cap')), + cumulative: createMetricPattern1(client, _m(acc, 'realized_pnl_cumulative')), + delta: create_24hChangeRatePattern(client, _m(acc, 'pnl_delta')), + raw: createMetricPattern1(client, _m(acc, 'realized_pnl')), + relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_pnl_rel_to_realized_cap')), + sum: create_1m1w1y24hPattern(client, _m(acc, 'realized_pnl')), }; } /** - * @typedef {Object} BaseBtcCentsSatsUsdPattern - * @property {MetricPattern1} base - * @property {MetricPattern1} btc - * @property {MetricPattern1} cents - * @property {MetricPattern1} sats - * @property {MetricPattern1} usd + * @typedef {Object} GrossInvestedInvestorLossNetProfitSentimentPattern + * @property {CentsUsdPattern} grossPnl + * @property {InPattern5} investedCapital + * @property {InPattern2} investorCap + * @property {CentsNegSumSupplyUsdPattern} loss + * @property {CentsUsdPattern} netPnl + * @property {CentsSumSupplyUsdPattern} profit + * @property {GreedNetPainPattern} sentiment */ /** - * Create a BaseBtcCentsSatsUsdPattern pattern node + * Create a GrossInvestedInvestorLossNetProfitSentimentPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {BaseBtcCentsSatsUsdPattern} + * @returns {GrossInvestedInvestorLossNetProfitSentimentPattern} */ -function createBaseBtcCentsSatsUsdPattern(client, acc) { +function createGrossInvestedInvestorLossNetProfitSentimentPattern(client, acc) { return { - base: createMetricPattern1(client, _m(acc, 'blocks_mined_cumulative')), - btc: createMetricPattern1(client, _m(acc, 'rewards_cumulative_btc')), - cents: createMetricPattern1(client, _m(acc, 'rewards_cumulative_cents')), - sats: createMetricPattern1(client, _m(acc, 'rewards_cumulative')), - usd: createMetricPattern1(client, _m(acc, 'rewards_cumulative_usd')), + grossPnl: createCentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')), + investedCapital: createInPattern5(client, _m(acc, 'invested_capital_in')), + investorCap: createInPattern2(client, _m(acc, 'investor_cap_in')), + loss: createCentsNegSumSupplyUsdPattern(client, acc), + netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), + profit: createCentsSumSupplyUsdPattern(client, acc), + sentiment: createGreedNetPainPattern(client, acc), + }; +} + +/** + * @typedef {Object} ActivityOutputsRealizedRelativeSupplyUnrealizedPattern + * @property {CoindaysSentPattern} activity + * @property {UtxoPattern2} outputs + * @property {CapLossMvrvNetNuplPriceProfitSentSoprPattern} realized + * @property {SupplyPattern} relative + * @property {DeltaHalvedTotalPattern} supply + * @property {InvestedInvestorLossNetProfitPattern} unrealized + */ + +/** + * Create a ActivityOutputsRealizedRelativeSupplyUnrealizedPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern} + */ +function createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(client, acc) { + return { + activity: createCoindaysSentPattern(client, acc), + outputs: createUtxoPattern2(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc), + relative: createSupplyPattern(client, _m(acc, 'supply')), + supply: createDeltaHalvedTotalPattern(client, _m(acc, 'supply')), + unrealized: createInvestedInvestorLossNetProfitPattern(client, acc), + }; +} + +/** + * @typedef {Object} ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 + * @property {CoindaysSentPattern} activity + * @property {UtxoPattern2} outputs + * @property {CapLossMvrvNetNuplPriceProfitSentSoprPattern} realized + * @property {SupplyPattern} relative + * @property {DeltaHalvedTotalPattern} supply + * @property {LossNetProfitPattern2} unrealized + */ + +/** + * Create a ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2} + */ +function createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(client, acc) { + return { + activity: createCoindaysSentPattern(client, acc), + outputs: createUtxoPattern2(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc), + relative: createSupplyPattern(client, _m(acc, 'supply')), + supply: createDeltaHalvedTotalPattern(client, _m(acc, 'supply')), + unrealized: createLossNetProfitPattern2(client, acc), + }; +} + +/** + * @typedef {Object} AdjustedRatioValuePattern + * @property {RatioValuePattern2} adjusted + * @property {_1m1w1y24hPattern} ratio + * @property {RawSumPattern} valueCreated + * @property {_1m1w1yPattern} valueCreatedSum + * @property {RawSumPattern} valueDestroyed + * @property {_1m1w1yPattern} valueDestroyedSum + */ + +/** + * Create a AdjustedRatioValuePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {AdjustedRatioValuePattern} + */ +function createAdjustedRatioValuePattern(client, acc) { + return { + adjusted: createRatioValuePattern2(client, _m(acc, 'adjusted')), + ratio: create_1m1w1y24hPattern(client, _m(acc, 'sopr')), + valueCreated: createRawSumPattern(client, _m(acc, 'value_created')), + valueCreatedSum: create_1m1w1yPattern(client, _m(acc, 'value_created')), + valueDestroyed: createRawSumPattern(client, _m(acc, 'value_destroyed')), + valueDestroyedSum: create_1m1w1yPattern(client, _m(acc, 'value_destroyed')), + }; +} + +/** + * @typedef {Object} CapLowerPriceUpperPattern + * @property {MetricPattern18} capRaw + * @property {CentsSatsUsdPattern} lowerPriceBand + * @property {CentsSatsUsdPattern} price + * @property {BpsRatioPattern} priceRatio + * @property {Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern} priceRatioPercentiles + * @property {CentsSatsUsdPattern} upperPriceBand + */ + +/** + * Create a CapLowerPriceUpperPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapLowerPriceUpperPattern} + */ +function createCapLowerPriceUpperPattern(client, acc) { + return { + capRaw: createMetricPattern18(client, _m(acc, 'investor_cap_raw')), + lowerPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'lower_price_band')), + price: createCentsSatsUsdPattern(client, _m(acc, 'investor_price')), + priceRatio: createBpsRatioPattern(client, _m(acc, 'investor_price_ratio')), + priceRatioPercentiles: createPct1Pct2Pct5Pct95Pct98Pct99SmaPattern(client, _m(acc, 'investor_price_ratio')), + upperPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'upper_price_band')), + }; +} + +/** + * @typedef {Object} AddrOutputsRealizedSupplyPattern + * @property {MetricPattern1} addrCount + * @property {ChangeRatePattern} addrCountDelta + * @property {UtxoPattern} outputs + * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized + * @property {HalvedTotalPattern} supply + */ + +/** + * Create a AddrOutputsRealizedSupplyPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {AddrOutputsRealizedSupplyPattern} + */ +function createAddrOutputsRealizedSupplyPattern(client, acc) { + return { + addrCount: createMetricPattern1(client, _m(acc, 'addr_count')), + addrCountDelta: createChangeRatePattern(client, _m(acc, 'addr_count_delta')), + outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), + supply: createHalvedTotalPattern(client, _m(acc, 'supply')), }; } @@ -2856,7 +2589,157 @@ function createBpsCentsPercentRatioUsdPattern(client, acc) { cents: createMetricPattern1(client, _m(acc, 'change_24h_cents')), percent: createMetricPattern1(client, _m(acc, 'rate_24h')), ratio: createMetricPattern1(client, _m(acc, 'rate_24h_ratio')), - usd: createMetricPattern1(client, _m(acc, 'change_24h_usd')), + usd: createMetricPattern1(client, _m(acc, 'change_24h')), + }; +} + +/** + * @typedef {Object} BtcCentsSatsSumUsdPattern2 + * @property {MetricPattern1} btc + * @property {MetricPattern1} cents + * @property {MetricPattern1} sats + * @property {_1m1w1y24hPattern4} sum + * @property {MetricPattern1} usd + */ + +/** + * Create a BtcCentsSatsSumUsdPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {BtcCentsSatsSumUsdPattern2} + */ +function createBtcCentsSatsSumUsdPattern2(client, acc) { + return { + btc: createMetricPattern1(client, acc), + cents: createMetricPattern1(client, _m(acc, 'cents')), + sats: createMetricPattern1(client, _m(acc, 'sats')), + sum: create_1m1w1y24hPattern4(client, acc), + usd: createMetricPattern1(client, _m(acc, 'usd')), + }; +} + +/** + * @typedef {Object} BtcCentsSatsSumUsdPattern + * @property {MetricPattern1} btc + * @property {MetricPattern1} cents + * @property {MetricPattern1} sats + * @property {_24hPattern3} sum + * @property {MetricPattern1} usd + */ + +/** + * Create a BtcCentsSatsSumUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {BtcCentsSatsSumUsdPattern} + */ +function createBtcCentsSatsSumUsdPattern(client, acc) { + return { + btc: createMetricPattern1(client, acc), + cents: createMetricPattern1(client, _m(acc, 'cents')), + sats: createMetricPattern1(client, _m(acc, 'sats')), + sum: create_24hPattern3(client, _m(acc, '24h')), + usd: createMetricPattern1(client, _m(acc, 'usd')), + }; +} + +/** + * @typedef {Object} CentsCumulativeNegSumUsdPattern + * @property {MetricPattern1} cents + * @property {MetricPattern1} cumulative + * @property {MetricPattern1} neg + * @property {_24hPattern} sum + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsCumulativeNegSumUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsCumulativeNegSumUsdPattern} + */ +function createCentsCumulativeNegSumUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'realized_loss_cents')), + cumulative: createMetricPattern1(client, _m(acc, 'realized_loss_cumulative')), + neg: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), + sum: create_24hPattern(client, _m(acc, 'realized_loss_24h')), + usd: createMetricPattern1(client, _m(acc, 'realized_loss')), + }; +} + +/** + * @typedef {Object} CentsDeltaRawRelUsdPattern + * @property {MetricPattern1} cents + * @property {_24hChangeRatePattern} delta + * @property {MetricPattern18} raw + * @property {BpsPercentRatioPattern} relToOwnMcap + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsDeltaRawRelUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsDeltaRawRelUsdPattern} + */ +function createCentsDeltaRawRelUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'realized_cap_cents')), + delta: create_24hChangeRatePattern(client, _m(acc, 'realized_cap_delta')), + raw: createMetricPattern18(client, _m(acc, 'cap_raw')), + relToOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_cap_rel_to_own_market_cap')), + usd: createMetricPattern1(client, _m(acc, 'realized_cap')), + }; +} + +/** + * @typedef {Object} CentsNegSumSupplyUsdPattern + * @property {MetricPattern1} cents + * @property {MetricPattern1} neg + * @property {_24hPattern} sum + * @property {BtcCentsSatsUsdPattern} supply + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsNegSumSupplyUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsNegSumSupplyUsdPattern} + */ +function createCentsNegSumSupplyUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'unrealized_loss_cents')), + neg: createMetricPattern1(client, _m(acc, 'neg_unrealized_loss')), + sum: create_24hPattern(client, _m(acc, 'unrealized_loss_24h')), + supply: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')), + usd: createMetricPattern1(client, _m(acc, 'unrealized_loss')), + }; +} + +/** + * @typedef {Object} CoinblocksCoindaysDormancySentVelocityPattern + * @property {CumulativeRawPattern} coinblocksDestroyed + * @property {CumulativeRawSumPattern} coindaysDestroyed + * @property {MetricPattern1} dormancy + * @property {RawSumPattern2} sent + * @property {MetricPattern1} velocity + */ + +/** + * Create a CoinblocksCoindaysDormancySentVelocityPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoinblocksCoindaysDormancySentVelocityPattern} + */ +function createCoinblocksCoindaysDormancySentVelocityPattern(client, acc) { + return { + coinblocksDestroyed: createCumulativeRawPattern(client, _m(acc, 'coinblocks_destroyed')), + coindaysDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')), + dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), + sent: createRawSumPattern2(client, _m(acc, 'sent')), + velocity: createMetricPattern1(client, _m(acc, 'velocity')), }; } @@ -2885,6 +2768,81 @@ function createEmaHistogramLineSignalPattern(client, acc) { }; } +/** + * @typedef {Object} InvestedInvestorLossNetProfitPattern + * @property {InPattern2} investedCapital + * @property {InPattern2} investorCap + * @property {CentsNegSumSupplyUsdPattern} loss + * @property {CentsUsdPattern} netPnl + * @property {CentsSumSupplyUsdPattern} profit + */ + +/** + * Create a InvestedInvestorLossNetProfitPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InvestedInvestorLossNetProfitPattern} + */ +function createInvestedInvestorLossNetProfitPattern(client, acc) { + return { + investedCapital: createInPattern2(client, _m(acc, 'invested_capital_in')), + investorCap: createInPattern2(client, _m(acc, 'investor_cap_in')), + loss: createCentsNegSumSupplyUsdPattern(client, acc), + netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), + profit: createCentsSumSupplyUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} PhsReboundThsPattern + * @property {MetricPattern1} phs + * @property {MetricPattern1} phsMin + * @property {BpsPercentRatioPattern} rebound + * @property {MetricPattern1} ths + * @property {MetricPattern1} thsMin + */ + +/** + * Create a PhsReboundThsPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {PhsReboundThsPattern} + */ +function createPhsReboundThsPattern(client, acc) { + return { + phs: createMetricPattern1(client, _m(acc, 'phs')), + phsMin: createMetricPattern1(client, _m(acc, 'phs_min')), + rebound: createBpsPercentRatioPattern(client, _m(acc, 'rebound')), + ths: createMetricPattern1(client, _m(acc, 'ths')), + thsMin: createMetricPattern1(client, _m(acc, 'ths_min')), + }; +} + +/** + * @typedef {Object} RatioValuePattern2 + * @property {_1m1w1y24hPattern} ratio + * @property {MetricPattern1} valueCreated + * @property {_1m1w1y24hPattern} valueCreatedSum + * @property {MetricPattern1} valueDestroyed + * @property {_1m1w1y24hPattern} valueDestroyedSum + */ + +/** + * Create a RatioValuePattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RatioValuePattern2} + */ +function createRatioValuePattern2(client, acc) { + return { + ratio: create_1m1w1y24hPattern(client, _m(acc, 'sopr')), + valueCreated: createMetricPattern1(client, _m(acc, 'value_created')), + valueCreatedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_created')), + valueDestroyed: createMetricPattern1(client, _m(acc, 'value_destroyed')), + valueDestroyedSum: create_1m1w1y24hPattern(client, _m(acc, 'value_destroyed')), + }; +} + /** * @template T * @typedef {Object} _1m1w1y24hHeightPattern @@ -2912,56 +2870,6 @@ function create_1m1w1y24hHeightPattern(client, acc) { }; } -/** - * @template T - * @typedef {Object} _24hChangeRatePattern2 - * @property {BaseBpsPercentRatioPattern} _24h - * @property {MetricPattern1} change1w - * @property {MetricPattern1} change1y - * @property {BpsPercentRatioPattern} rate1w - * @property {BpsPercentRatioPattern} rate1y - */ - -/** - * Create a _24hChangeRatePattern2 pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_24hChangeRatePattern2} - */ -function create_24hChangeRatePattern2(client, acc) { - return { - _24h: createBaseBpsPercentRatioPattern(client, acc), - change1w: createMetricPattern1(client, _m(acc, 'change_1w')), - change1y: createMetricPattern1(client, _m(acc, 'change_1y')), - rate1w: createBpsPercentRatioPattern(client, _m(acc, 'rate_1w')), - rate1y: createBpsPercentRatioPattern(client, _m(acc, 'rate_1y')), - }; -} - -/** - * @typedef {Object} _1m1w1y24hPattern6 - * @property {BaseBtcCentsSatsUsdPattern} _1m - * @property {BaseBtcCentsSatsUsdPattern} _1w - * @property {BaseBtcCentsSatsUsdPattern} _1y - * @property {BaseBtcCentsSatsUsdPattern} _24h - */ - -/** - * Create a _1m1w1y24hPattern6 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hPattern6} - */ -function create_1m1w1y24hPattern6(client, acc) { - return { - _1m: createBaseBtcCentsSatsUsdPattern(client, acc), - _1w: createBaseBtcCentsSatsUsdPattern(client, acc), - _1y: createBaseBtcCentsSatsUsdPattern(client, acc), - _24h: createBaseBtcCentsSatsUsdPattern(client, acc), - }; -} - /** * @typedef {Object} _1m1w1y24hPattern2 * @property {BpsPercentRatioPattern} _1m @@ -2986,7 +2894,7 @@ function create_1m1w1y24hPattern2(client, acc) { } /** - * @typedef {Object} _1m1w1y24hPattern5 + * @typedef {Object} _1m1w1y24hPattern7 * @property {BtcCentsSatsUsdPattern} _1m * @property {BtcCentsSatsUsdPattern} _1w * @property {BtcCentsSatsUsdPattern} _1y @@ -2994,12 +2902,12 @@ function create_1m1w1y24hPattern2(client, acc) { */ /** - * Create a _1m1w1y24hPattern5 pattern node + * Create a _1m1w1y24hPattern7 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hPattern5} + * @returns {_1m1w1y24hPattern7} */ -function create_1m1w1y24hPattern5(client, acc) { +function create_1m1w1y24hPattern7(client, acc) { return { _1m: createBtcCentsSatsUsdPattern(client, _m(acc, '1m')), _1w: createBtcCentsSatsUsdPattern(client, _m(acc, '1w')), @@ -3009,25 +2917,94 @@ function create_1m1w1y24hPattern5(client, acc) { } /** - * @typedef {Object} BaseBpsPercentRatioPattern - * @property {MetricPattern1} base - * @property {MetricPattern1} bps - * @property {MetricPattern1} percent - * @property {MetricPattern1} ratio + * @typedef {Object} _1m1w1y24hPattern3 + * @property {MetricPattern1} _1m + * @property {MetricPattern1} _1w + * @property {MetricPattern1} _1y + * @property {CentsUsdPattern} _24h */ /** - * Create a BaseBpsPercentRatioPattern pattern node + * Create a _1m1w1y24hPattern3 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {BaseBpsPercentRatioPattern} + * @returns {_1m1w1y24hPattern3} */ -function createBaseBpsPercentRatioPattern(client, acc) { +function create_1m1w1y24hPattern3(client, acc) { return { - base: createMetricPattern1(client, _m(acc, 'change_24h')), - bps: createMetricPattern1(client, _m(acc, 'rate_24h_bps')), - percent: createMetricPattern1(client, _m(acc, 'rate_24h')), - ratio: createMetricPattern1(client, _m(acc, 'rate_24h_ratio')), + _1m: createMetricPattern1(client, _m(acc, '1m')), + _1w: createMetricPattern1(client, _m(acc, '1w')), + _1y: createMetricPattern1(client, _m(acc, '1y')), + _24h: createCentsUsdPattern(client, _m(acc, '24h')), + }; +} + +/** + * @typedef {Object} _1m1w1y2wPattern + * @property {CentsSatsUsdPattern} _1m + * @property {CentsSatsUsdPattern} _1w + * @property {CentsSatsUsdPattern} _1y + * @property {CentsSatsUsdPattern} _2w + */ + +/** + * Create a _1m1w1y2wPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1m1w1y2wPattern} + */ +function create_1m1w1y2wPattern(client, acc) { + return { + _1m: createCentsSatsUsdPattern(client, _m(acc, '1m')), + _1w: createCentsSatsUsdPattern(client, _m(acc, '1w')), + _1y: createCentsSatsUsdPattern(client, _m(acc, '1y')), + _2w: createCentsSatsUsdPattern(client, _m(acc, '2w')), + }; +} + +/** + * @typedef {Object} _1m1w1y24hPattern4 + * @property {MetricPattern1} _1m + * @property {MetricPattern1} _1w + * @property {MetricPattern1} _1y + * @property {BtcCentsSatsUsdPattern} _24h + */ + +/** + * Create a _1m1w1y24hPattern4 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1m1w1y24hPattern4} + */ +function create_1m1w1y24hPattern4(client, acc) { + return { + _1m: createMetricPattern1(client, _m(acc, '1m')), + _1w: createMetricPattern1(client, _m(acc, '1w')), + _1y: createMetricPattern1(client, _m(acc, '1y')), + _24h: createBtcCentsSatsUsdPattern(client, _m(acc, '24h')), + }; +} + +/** + * @typedef {Object} _1y2y4yAllPattern + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} _1y + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} _2y + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} _4y + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} all + */ + +/** + * Create a _1y2y4yAllPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1y2y4yAllPattern} + */ +function create_1y2y4yAllPattern(client, acc) { + return { + _1y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), + _2y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), + _4y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), + all: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), }; } @@ -3054,6 +3031,29 @@ function createBothReactivatedReceivingSendingPattern(client, acc) { }; } +/** + * @typedef {Object} BpsPercentilesRatioStdPattern + * @property {MetricPattern1} bps + * @property {Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern} percentiles + * @property {MetricPattern1} ratio + * @property {_1y2y4yAllPattern} stdDev + */ + +/** + * Create a BpsPercentilesRatioStdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {BpsPercentilesRatioStdPattern} + */ +function createBpsPercentilesRatioStdPattern(client, acc) { + return { + bps: createMetricPattern1(client, _m(acc, 'bps')), + percentiles: createPct1Pct2Pct5Pct95Pct98Pct99SmaPattern(client, acc), + ratio: createMetricPattern1(client, acc), + stdDev: create_1y2y4yAllPattern(client, acc), + }; +} + /** * @typedef {Object} BtcCentsSatsUsdPattern * @property {MetricPattern1} btc @@ -3070,33 +3070,79 @@ function createBothReactivatedReceivingSendingPattern(client, acc) { */ function createBtcCentsSatsUsdPattern(client, acc) { return { - btc: createMetricPattern1(client, _m(acc, 'btc')), + btc: createMetricPattern1(client, acc), cents: createMetricPattern1(client, _m(acc, 'cents')), - sats: createMetricPattern1(client, acc), + sats: createMetricPattern1(client, _m(acc, 'sats')), usd: createMetricPattern1(client, _m(acc, 'usd')), }; } /** - * @typedef {Object} CoinblocksCoindaysSentPattern - * @property {MetricPattern1} coinblocksDestroyed - * @property {MetricPattern1} coindaysDestroyed - * @property {MetricPattern1} sent - * @property {_24hPattern} sentSum + * @typedef {Object} CentsCumulativeSumUsdPattern + * @property {MetricPattern1} cents + * @property {MetricPattern1} cumulative + * @property {_24hPattern} sum + * @property {MetricPattern1} usd */ /** - * Create a CoinblocksCoindaysSentPattern pattern node + * Create a CentsCumulativeSumUsdPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CoinblocksCoindaysSentPattern} + * @returns {CentsCumulativeSumUsdPattern} */ -function createCoinblocksCoindaysSentPattern(client, acc) { +function createCentsCumulativeSumUsdPattern(client, acc) { return { - coinblocksDestroyed: createMetricPattern1(client, _m(acc, 'coinblocks_destroyed')), - coindaysDestroyed: createMetricPattern1(client, _m(acc, 'coindays_destroyed')), - sent: createMetricPattern1(client, _m(acc, 'sent')), - sentSum: create_24hPattern(client, _m(acc, 'sent_24h')), + cents: createMetricPattern1(client, _m(acc, 'cents')), + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + sum: create_24hPattern(client, _m(acc, '24h')), + usd: createMetricPattern1(client, acc), + }; +} + +/** + * @typedef {Object} CentsSellSumUsdPattern + * @property {MetricPattern1} cents + * @property {_1m1w1y24hPattern2} sellSideRiskRatio + * @property {_1m1w1y24hPattern} sum + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsSellSumUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsSellSumUsdPattern} + */ +function createCentsSellSumUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'realized_gross_pnl_cents')), + sellSideRiskRatio: create_1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')), + sum: create_1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')), + usd: createMetricPattern1(client, _m(acc, 'realized_gross_pnl')), + }; +} + +/** + * @typedef {Object} CentsSumSupplyUsdPattern + * @property {MetricPattern1} cents + * @property {_24hPattern} sum + * @property {BtcCentsSatsUsdPattern} supply + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsSumSupplyUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsSumSupplyUsdPattern} + */ +function createCentsSumSupplyUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'unrealized_profit_cents')), + sum: create_24hPattern(client, _m(acc, 'unrealized_profit_24h')), + supply: createBtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')), + usd: createMetricPattern1(client, _m(acc, 'unrealized_profit')), }; } @@ -3124,25 +3170,25 @@ function createInvestedMaxMinPercentilesPattern(client, acc) { } /** - * @typedef {Object} RatioPattern2 - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} ratioSd - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} ratioSd1y - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} ratioSd2y - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} ratioSd4y + * @typedef {Object} OutputsRealizedSupplyUnrealizedPattern + * @property {UtxoPattern} outputs + * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized + * @property {HalvedTotalPattern} supply + * @property {LossProfitPattern2} unrealized */ /** - * Create a RatioPattern2 pattern node + * Create a OutputsRealizedSupplyUnrealizedPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {RatioPattern2} + * @returns {OutputsRealizedSupplyUnrealizedPattern} */ -function createRatioPattern2(client, acc) { +function createOutputsRealizedSupplyUnrealizedPattern(client, acc) { return { - ratioSd: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), - ratioSd1y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), - ratioSd2y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), - ratioSd4y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc), + outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), + supply: createHalvedTotalPattern(client, _m(acc, 'supply')), + unrealized: createLossProfitPattern2(client, acc), }; } @@ -3175,7 +3221,7 @@ function create_1m1w1y24hPattern(client, acc) { * @typedef {Object} BaseCumulativeSumPattern * @property {BtcCentsSatsUsdPattern} base * @property {BtcCentsSatsUsdPattern} cumulative - * @property {_1m1w1y24hPattern5} sum + * @property {_1m1w1y24hPattern7} sum */ /** @@ -3188,7 +3234,28 @@ function createBaseCumulativeSumPattern(client, acc) { return { base: createBtcCentsSatsUsdPattern(client, acc), cumulative: createBtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')), - sum: create_1m1w1y24hPattern5(client, _m(acc, 'sum')), + sum: create_1m1w1y24hPattern7(client, _m(acc, 'sum')), + }; +} + +/** + * @typedef {Object} BlocksDominanceRewardsPattern + * @property {CumulativeHeightSumPattern} blocksMined + * @property {_1m1w1y24hBpsPercentRatioPattern} dominance + * @property {BaseCumulativeSumPattern} rewards + */ + +/** + * Create a BlocksDominanceRewardsPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {BlocksDominanceRewardsPattern} + */ +function createBlocksDominanceRewardsPattern(client, acc) { + return { + blocksMined: createCumulativeHeightSumPattern(client, _m(acc, 'blocks_mined')), + dominance: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'dominance')), + rewards: createBaseCumulativeSumPattern(client, _m(acc, 'rewards')), }; } @@ -3228,9 +3295,9 @@ function createBpsPercentRatioPattern(client, acc) { */ function createBpsPriceRatioPattern(client, acc) { return { - bps: createMetricPattern1(client, _m(acc, 'ratio_bps')), + bps: createMetricPattern1(client, _m(acc, 'bps')), price: createCentsSatsUsdPattern(client, acc), - ratio: createMetricPattern1(client, _m(acc, 'ratio')), + ratio: createMetricPattern1(client, acc), }; } @@ -3255,6 +3322,48 @@ function createCentsSatsUsdPattern2(client, acc) { }; } +/** + * @typedef {Object} CentsDeltaUsdPattern + * @property {MetricPattern1} cents + * @property {ChangeRatePattern3} delta + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsDeltaUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsDeltaUsdPattern} + */ +function createCentsDeltaUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'cents')), + delta: createChangeRatePattern3(client, _m(acc, 'delta')), + usd: createMetricPattern1(client, acc), + }; +} + +/** + * @typedef {Object} CentsRawUsdPattern + * @property {MetricPattern1} cents + * @property {MetricPattern18} raw + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsRawUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsRawUsdPattern} + */ +function createCentsRawUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'cents')), + raw: createMetricPattern18(client, _m(acc, 'raw')), + usd: createMetricPattern1(client, acc), + }; +} + /** * @typedef {Object} CentsSatsUsdPattern * @property {MetricPattern1} cents @@ -3276,9 +3385,72 @@ function createCentsSatsUsdPattern(client, acc) { }; } +/** + * @typedef {Object} CentsSumUsdPattern + * @property {MetricPattern1} cents + * @property {_24hPattern} sum + * @property {MetricPattern1} usd + */ + +/** + * Create a CentsSumUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CentsSumUsdPattern} + */ +function createCentsSumUsdPattern(client, acc) { + return { + cents: createMetricPattern1(client, _m(acc, 'cents')), + sum: create_24hPattern(client, _m(acc, '24h')), + usd: createMetricPattern1(client, acc), + }; +} + +/** + * @typedef {Object} CumulativeHeightRelPattern + * @property {MetricPattern1} cumulative + * @property {MetricPattern18} height + * @property {BpsPercentRatioPattern} relToRcap + */ + +/** + * Create a CumulativeHeightRelPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeHeightRelPattern} + */ +function createCumulativeHeightRelPattern(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + height: createMetricPattern18(client, acc), + relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_realized_cap')), + }; +} + +/** + * @typedef {Object} CumulativeRawSumPattern + * @property {MetricPattern1} cumulative + * @property {MetricPattern1} raw + * @property {_1m1w1y24hPattern} sum + */ + +/** + * Create a CumulativeRawSumPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeRawSumPattern} + */ +function createCumulativeRawSumPattern(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + raw: createMetricPattern1(client, acc), + sum: create_1m1w1y24hPattern(client, acc), + }; +} + /** * @typedef {Object} DeltaHalvedTotalPattern - * @property {ChangeRatePattern} delta + * @property {ChangeRatePattern} delta * @property {BtcCentsSatsUsdPattern} halved * @property {BtcCentsSatsUsdPattern} total */ @@ -3298,23 +3470,191 @@ function createDeltaHalvedTotalPattern(client, acc) { } /** - * @typedef {Object} SupplyPattern2 - * @property {BpsPercentRatioPattern} supplyInLossRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyInProfitRelToCirculatingSupply - * @property {BpsPercentRatioPattern} supplyRelToCirculatingSupply + * @typedef {Object} DeltaHalvedTotalPattern2 + * @property {ChangeRatePattern2} delta + * @property {BtcCentsSatsUsdPattern} halved + * @property {BtcCentsSatsUsdPattern} total */ /** - * Create a SupplyPattern2 pattern node + * Create a DeltaHalvedTotalPattern2 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {SupplyPattern2} + * @returns {DeltaHalvedTotalPattern2} */ -function createSupplyPattern2(client, acc) { +function createDeltaHalvedTotalPattern2(client, acc) { return { - supplyInLossRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')), - supplyInProfitRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')), - supplyRelToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), + delta: createChangeRatePattern2(client, _m(acc, 'delta')), + halved: createBtcCentsSatsUsdPattern(client, _m(acc, 'halved')), + total: createBtcCentsSatsUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} GreedNetPainPattern + * @property {CentsUsdPattern} greedIndex + * @property {CentsUsdPattern} net + * @property {CentsUsdPattern} painIndex + */ + +/** + * Create a GreedNetPainPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {GreedNetPainPattern} + */ +function createGreedNetPainPattern(client, acc) { + return { + greedIndex: createCentsUsdPattern(client, _m(acc, 'greed_index')), + net: createCentsUsdPattern(client, _m(acc, 'net_sentiment')), + painIndex: createCentsUsdPattern(client, _m(acc, 'pain_index')), + }; +} + +/** + * @typedef {Object} InRelPattern + * @property {RelPattern} inLoss + * @property {RelPattern} inProfit + * @property {BpsPercentRatioPattern} relToCirculatingSupply + */ + +/** + * Create a InRelPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InRelPattern} + */ +function createInRelPattern(client, acc) { + return { + inLoss: createRelPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')), + inProfit: createRelPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')), + relToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), + }; +} + +/** + * @typedef {Object} InRelPattern2 + * @property {RelPattern5} inLoss + * @property {RelPattern5} inProfit + * @property {BpsPercentRatioPattern} relToCirculatingSupply + */ + +/** + * Create a InRelPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InRelPattern2} + */ +function createInRelPattern2(client, acc) { + return { + inLoss: createRelPattern5(client, _m(acc, 'in_loss_rel_to')), + inProfit: createRelPattern5(client, _m(acc, 'in_profit_rel_to')), + relToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')), + }; +} + +/** + * @typedef {Object} LossNetProfitPattern2 + * @property {CentsNegSumSupplyUsdPattern} loss + * @property {CentsUsdPattern} netPnl + * @property {CentsSumSupplyUsdPattern} profit + */ + +/** + * Create a LossNetProfitPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {LossNetProfitPattern2} + */ +function createLossNetProfitPattern2(client, acc) { + return { + loss: createCentsNegSumSupplyUsdPattern(client, acc), + netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), + profit: createCentsSumSupplyUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} LossNetProfitPattern3 + * @property {RelPattern6} loss + * @property {RelPattern7} netPnl + * @property {RelPattern6} profit + */ + +/** + * Create a LossNetProfitPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {LossNetProfitPattern3} + */ +function createLossNetProfitPattern3(client, acc) { + return { + loss: createRelPattern6(client, _m(acc, 'unrealized_loss_rel_to')), + netPnl: createRelPattern7(client, _m(acc, 'net_unrealized_pnl_rel_to_own')), + profit: createRelPattern6(client, _m(acc, 'unrealized_profit_rel_to')), + }; +} + +/** + * @typedef {Object} OutputsRealizedSupplyPattern + * @property {UtxoPattern} outputs + * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized + * @property {HalvedTotalPattern} supply + */ + +/** + * Create a OutputsRealizedSupplyPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {OutputsRealizedSupplyPattern} + */ +function createOutputsRealizedSupplyPattern(client, acc) { + return { + outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), + supply: createHalvedTotalPattern(client, _m(acc, 'supply')), + }; +} + +/** + * @typedef {Object} RatioValuePattern + * @property {_24hPattern2} ratio + * @property {RawSumPattern} valueCreated + * @property {RawSumPattern} valueDestroyed + */ + +/** + * Create a RatioValuePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RatioValuePattern} + */ +function createRatioValuePattern(client, acc) { + return { + ratio: create_24hPattern2(client, _m(acc, 'sopr_24h')), + valueCreated: createRawSumPattern(client, _m(acc, 'value_created')), + valueDestroyed: createRawSumPattern(client, _m(acc, 'value_destroyed')), + }; +} + +/** + * @typedef {Object} RelPattern6 + * @property {BpsPercentRatioPattern} relToMarketCap + * @property {BpsPercentRatioPattern} relToOwnGrossPnl + * @property {BpsPercentRatioPattern} relToOwnMarketCap + */ + +/** + * Create a RelPattern6 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RelPattern6} + */ +function createRelPattern6(client, acc) { + return { + relToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'market_cap')), + relToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'own_gross_pnl')), + relToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'own_market_cap')), }; } @@ -3408,7 +3748,7 @@ function createBaseCumulativePattern(client, acc) { /** * @typedef {Object} BlocksDominancePattern - * @property {CumulativeHeightPattern} blocksMined + * @property {CumulativeHeightPattern} blocksMined * @property {BpsPercentRatioPattern} dominance */ @@ -3459,7 +3799,7 @@ function createBpsRatioPattern(client, acc) { function createCentsUsdPattern(client, acc) { return { cents: createMetricPattern1(client, _m(acc, 'cents')), - usd: createMetricPattern1(client, _m(acc, 'usd')), + usd: createMetricPattern1(client, acc), }; } @@ -3482,10 +3822,29 @@ function createChangeRatePattern2(client, acc) { }; } +/** + * @typedef {Object} ChangeRatePattern + * @property {_1mPattern} change + * @property {_1mPattern2} rate + */ + +/** + * Create a ChangeRatePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {ChangeRatePattern} + */ +function createChangeRatePattern(client, acc) { + return { + change: create_1mPattern(client, _m(acc, 'change_1m')), + rate: create_1mPattern2(client, _m(acc, 'rate_1m')), + }; +} + /** * @typedef {Object} ChangeRatePattern3 - * @property {CentsUsdPattern} change1m - * @property {BpsPercentRatioPattern} rate1m + * @property {_1mPattern3} change + * @property {_1mPattern2} rate */ /** @@ -3496,8 +3855,84 @@ function createChangeRatePattern2(client, acc) { */ function createChangeRatePattern3(client, acc) { return { - change1m: createCentsUsdPattern(client, _m(acc, 'change_1m')), - rate1m: createBpsPercentRatioPattern(client, _m(acc, 'rate_1m')), + change: create_1mPattern3(client, _m(acc, 'change_1m')), + rate: create_1mPattern2(client, _m(acc, 'rate_1m')), + }; +} + +/** + * @typedef {Object} CoindaysSentPattern + * @property {RawSumPattern} coindaysDestroyed + * @property {RawSumPattern} sent + */ + +/** + * Create a CoindaysSentPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoindaysSentPattern} + */ +function createCoindaysSentPattern(client, acc) { + return { + coindaysDestroyed: createRawSumPattern(client, _m(acc, 'coindays_destroyed')), + sent: createRawSumPattern(client, _m(acc, 'sent')), + }; +} + +/** + * @typedef {Object} CumulativeRawPattern + * @property {MetricPattern1} cumulative + * @property {MetricPattern1} raw + */ + +/** + * Create a CumulativeRawPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeRawPattern} + */ +function createCumulativeRawPattern(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + raw: createMetricPattern1(client, acc), + }; +} + +/** + * @typedef {Object} CumulativeHeightPattern + * @property {MetricPattern1} cumulative + * @property {MetricPattern18} height + */ + +/** + * Create a CumulativeHeightPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CumulativeHeightPattern} + */ +function createCumulativeHeightPattern(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + height: createMetricPattern18(client, acc), + }; +} + +/** + * @typedef {Object} HalvedTotalPattern + * @property {BtcCentsSatsUsdPattern} halved + * @property {BtcCentsSatsUsdPattern} total + */ + +/** + * Create a HalvedTotalPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {HalvedTotalPattern} + */ +function createHalvedTotalPattern(client, acc) { + return { + halved: createBtcCentsSatsUsdPattern(client, _m(acc, 'halved')), + total: createBtcCentsSatsUsdPattern(client, acc), }; } @@ -3520,6 +3955,139 @@ function createHeightSumPattern(client, acc) { }; } +/** + * @typedef {Object} InPattern + * @property {BtcCentsSatsSumUsdPattern} inLoss + * @property {BtcCentsSatsSumUsdPattern} inProfit + */ + +/** + * Create a InPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InPattern} + */ +function createInPattern(client, acc) { + return { + inLoss: createBtcCentsSatsSumUsdPattern(client, _m(acc, 'loss')), + inProfit: createBtcCentsSatsSumUsdPattern(client, _m(acc, 'profit')), + }; +} + +/** + * @typedef {Object} InPattern3 + * @property {BtcCentsSatsSumUsdPattern2} inLoss + * @property {BtcCentsSatsSumUsdPattern2} inProfit + */ + +/** + * Create a InPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InPattern3} + */ +function createInPattern3(client, acc) { + return { + inLoss: createBtcCentsSatsSumUsdPattern2(client, _m(acc, 'loss')), + inProfit: createBtcCentsSatsSumUsdPattern2(client, _m(acc, 'profit')), + }; +} + +/** + * @typedef {Object} InPattern5 + * @property {CentsRawUsdPattern} inLoss + * @property {CentsRawUsdPattern} inProfit + */ + +/** + * Create a InPattern5 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InPattern5} + */ +function createInPattern5(client, acc) { + return { + inLoss: createCentsRawUsdPattern(client, _m(acc, 'loss')), + inProfit: createCentsRawUsdPattern(client, _m(acc, 'profit')), + }; +} + +/** + * @typedef {Object} InPattern2 + * @property {RawPattern} inLoss + * @property {RawPattern} inProfit + */ + +/** + * Create a InPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InPattern2} + */ +function createInPattern2(client, acc) { + return { + inLoss: createRawPattern(client, _m(acc, 'loss_raw')), + inProfit: createRawPattern(client, _m(acc, 'profit_raw')), + }; +} + +/** + * @typedef {Object} LossProfitPattern2 + * @property {CentsSumSupplyUsdPattern} loss + * @property {CentsSumSupplyUsdPattern} profit + */ + +/** + * Create a LossProfitPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {LossProfitPattern2} + */ +function createLossProfitPattern2(client, acc) { + return { + loss: createCentsSumSupplyUsdPattern(client, acc), + profit: createCentsSumSupplyUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} PriceValuePattern + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} value + */ + +/** + * Create a PriceValuePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {PriceValuePattern} + */ +function createPriceValuePattern(client, acc) { + return { + price: createCentsSatsUsdPattern(client, acc), + value: createMetricPattern1(client, acc), + }; +} + +/** + * @typedef {Object} RawSumPattern2 + * @property {MetricPattern1} raw + * @property {_1m1w1y24hPattern} sum + */ + +/** + * Create a RawSumPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RawSumPattern2} + */ +function createRawSumPattern2(client, acc) { + return { + raw: createMetricPattern1(client, acc), + sum: create_1m1w1y24hPattern(client, acc), + }; +} + /** * @typedef {Object} RealizedSupplyPattern * @property {MetricPattern1} realizedCap @@ -3539,6 +4107,63 @@ function createRealizedSupplyPattern(client, acc) { }; } +/** + * @typedef {Object} RelPattern5 + * @property {BpsPercentRatioPattern} relToCirculatingSupply + * @property {BpsPercentRatioPattern} relToOwnSupply + */ + +/** + * Create a RelPattern5 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RelPattern5} + */ +function createRelPattern5(client, acc) { + return { + relToCirculatingSupply: createBpsPercentRatioPattern(client, _m(acc, 'circulating_supply')), + relToOwnSupply: createBpsPercentRatioPattern(client, _m(acc, 'own_supply')), + }; +} + +/** + * @typedef {Object} RelPattern3 + * @property {BpsPercentRatioPattern} relToMarketCap + * @property {BpsPercentRatioPattern} relToOwnGrossPnl + */ + +/** + * Create a RelPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RelPattern3} + */ +function createRelPattern3(client, acc) { + return { + relToMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'market_cap')), + relToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'own_gross_pnl')), + }; +} + +/** + * @typedef {Object} RelPattern7 + * @property {BpsPercentRatioPattern} relToOwnGrossPnl + * @property {BpsPercentRatioPattern} relToOwnMarketCap + */ + +/** + * Create a RelPattern7 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RelPattern7} + */ +function createRelPattern7(client, acc) { + return { + relToOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'gross_pnl')), + relToOwnMarketCap: createBpsPercentRatioPattern(client, _m(acc, 'market_cap')), + }; +} + /** * @typedef {Object} SdSmaPattern * @property {MetricPattern1} sd @@ -3559,28 +4184,207 @@ function createSdSmaPattern(client, acc) { } /** - * @typedef {Object} SentPattern - * @property {MetricPattern1} sent - * @property {_24hPattern} sentSum + * @typedef {Object} SupplyUnrealizedPattern2 + * @property {InRelPattern2} supply + * @property {LossNetProfitPattern3} unrealized */ /** - * Create a SentPattern pattern node + * Create a SupplyUnrealizedPattern2 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {SentPattern} + * @returns {SupplyUnrealizedPattern2} */ -function createSentPattern(client, acc) { +function createSupplyUnrealizedPattern2(client, acc) { return { - sent: createMetricPattern1(client, acc), - sentSum: create_24hPattern(client, _m(acc, '24h')), + supply: createInRelPattern2(client, _m(acc, 'supply')), + unrealized: createLossNetProfitPattern3(client, acc), + }; +} + +/** + * @typedef {Object} UtxoPattern2 + * @property {MetricPattern1} utxoCount + * @property {ChangeRatePattern} utxoCountDelta + */ + +/** + * Create a UtxoPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {UtxoPattern2} + */ +function createUtxoPattern2(client, acc) { + return { + utxoCount: createMetricPattern1(client, acc), + utxoCountDelta: createChangeRatePattern(client, _m(acc, 'delta')), + }; +} + +/** + * @typedef {Object} UtxoPattern3 + * @property {MetricPattern1} utxoCount + * @property {ChangeRatePattern2} utxoCountDelta + */ + +/** + * Create a UtxoPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {UtxoPattern3} + */ +function createUtxoPattern3(client, acc) { + return { + utxoCount: createMetricPattern1(client, acc), + utxoCountDelta: createChangeRatePattern2(client, _m(acc, 'delta')), + }; +} + +/** + * @typedef {Object} ValuePattern + * @property {RawSumPattern} valueCreated + * @property {RawSumPattern} valueDestroyed + */ + +/** + * Create a ValuePattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {ValuePattern} + */ +function createValuePattern(client, acc) { + return { + valueCreated: createRawSumPattern(client, _m(acc, 'created')), + valueDestroyed: createRawSumPattern(client, _m(acc, 'destroyed')), + }; +} + +/** + * @template T + * @typedef {Object} RawSumPattern + * @property {MetricPattern1} raw + * @property {_24hPattern2} sum + */ + +/** + * Create a RawSumPattern pattern node + * @template T + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RawSumPattern} + */ +function createRawSumPattern(client, acc) { + return { + raw: createMetricPattern1(client, acc), + sum: create_24hPattern2(client, _m(acc, '24h')), + }; +} + +/** + * @typedef {Object} _1mPattern2 + * @property {BpsPercentRatioPattern} _1m + */ + +/** + * Create a _1mPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1mPattern2} + */ +function create_1mPattern2(client, acc) { + return { + _1m: createBpsPercentRatioPattern(client, acc), + }; +} + +/** + * @typedef {Object} _1mPattern3 + * @property {CentsUsdPattern} _1m + */ + +/** + * Create a _1mPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1mPattern3} + */ +function create_1mPattern3(client, acc) { + return { + _1m: createCentsUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} _24hPattern3 + * @property {BtcCentsSatsUsdPattern} _24h + */ + +/** + * Create a _24hPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_24hPattern3} + */ +function create_24hPattern3(client, acc) { + return { + _24h: createBtcCentsSatsUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} _24hPattern + * @property {CentsUsdPattern} _24h + */ + +/** + * Create a _24hPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_24hPattern} + */ +function create_24hPattern(client, acc) { + return { + _24h: createCentsUsdPattern(client, acc), + }; +} + +/** + * @typedef {Object} RelPattern + * @property {BpsPercentRatioPattern} relToCirculatingSupply + */ + +/** + * Create a RelPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RelPattern} + */ +function createRelPattern(client, acc) { + return { + relToCirculatingSupply: createBpsPercentRatioPattern(client, acc), + }; +} + +/** + * @typedef {Object} RelPattern2 + * @property {BpsPercentRatioPattern} relToOwnSupply + */ + +/** + * Create a RelPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RelPattern2} + */ +function createRelPattern2(client, acc) { + return { + relToOwnSupply: createBpsPercentRatioPattern(client, acc), }; } /** * @typedef {Object} SupplyPattern - * @property {BtcCentsSatsUsdPattern} supplyInLoss - * @property {BtcCentsSatsUsdPattern} supplyInProfit + * @property {InRelPattern} supply */ /** @@ -3591,15 +4395,13 @@ function createSentPattern(client, acc) { */ function createSupplyPattern(client, acc) { return { - supplyInLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'loss')), - supplyInProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'profit')), + supply: createInRelPattern(client, acc), }; } /** * @typedef {Object} UtxoPattern * @property {MetricPattern1} utxoCount - * @property {ChangeRatePattern} utxoCountDelta */ /** @@ -3611,71 +4413,66 @@ function createSupplyPattern(client, acc) { function createUtxoPattern(client, acc) { return { utxoCount: createMetricPattern1(client, acc), - utxoCountDelta: createChangeRatePattern(client, _m(acc, 'delta')), }; } /** * @template T - * @typedef {Object} ChangeRatePattern - * @property {MetricPattern1} change1m - * @property {BpsPercentRatioPattern} rate1m + * @typedef {Object} _1mPattern + * @property {MetricPattern1} _1m */ /** - * Create a ChangeRatePattern pattern node + * Create a _1mPattern pattern node * @template T * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {ChangeRatePattern} + * @returns {_1mPattern} */ -function createChangeRatePattern(client, acc) { +function create_1mPattern(client, acc) { return { - change1m: createMetricPattern1(client, _m(acc, 'change_1m')), - rate1m: createBpsPercentRatioPattern(client, _m(acc, 'rate_1m')), + _1m: createMetricPattern1(client, acc), }; } /** * @template T - * @typedef {Object} CumulativeHeightPattern - * @property {MetricPattern1} cumulative - * @property {MetricPattern18} height - */ - -/** - * Create a CumulativeHeightPattern pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CumulativeHeightPattern} - */ -function createCumulativeHeightPattern(client, acc) { - return { - cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), - height: createMetricPattern18(client, acc), - }; -} - -/** - * @template T - * @typedef {Object} _24hPattern + * @typedef {Object} _24hPattern2 * @property {MetricPattern1} _24h */ /** - * Create a _24hPattern pattern node + * Create a _24hPattern2 pattern node * @template T * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {_24hPattern} + * @returns {_24hPattern2} */ -function create_24hPattern(client, acc) { +function create_24hPattern2(client, acc) { return { _24h: createMetricPattern1(client, acc), }; } +/** + * @template T + * @typedef {Object} RawPattern + * @property {MetricPattern18} raw + */ + +/** + * Create a RawPattern pattern node + * @template T + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {RawPattern} + */ +function createRawPattern(client, acc) { + return { + raw: createMetricPattern18(client, acc), + }; +} + // Catalog tree typedefs /** @@ -3703,13 +4500,13 @@ function create_24hPattern(client, acc) { * @property {MetricPattern18} blockhash * @property {MetricsTree_Blocks_Difficulty} difficulty * @property {MetricsTree_Blocks_Time} time - * @property {MetricPattern18} totalSize + * @property {MetricsTree_Blocks_Size} size * @property {MetricsTree_Blocks_Weight} weight * @property {MetricsTree_Blocks_Count} count + * @property {MetricsTree_Blocks_Lookback} lookback * @property {_1m1w1y24hHeightPattern} interval * @property {MetricsTree_Blocks_Halving} halving * @property {AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern} vbytes - * @property {MetricsTree_Blocks_Size} size * @property {MetricsTree_Blocks_Fullness} fullness */ @@ -3730,6 +4527,21 @@ function create_24hPattern(client, acc) { * @property {MetricPattern18} timestampMonotonic */ +/** + * @typedef {Object} MetricsTree_Blocks_Size + * @property {MetricPattern18} totalSize + * @property {MetricPattern1} cumulative + * @property {_1m1w1y24hPattern} sum + * @property {_1m1w1y24hPattern} average + * @property {_1m1w1y24hPattern} min + * @property {_1m1w1y24hPattern} max + * @property {_1m1w1y24hPattern} pct10 + * @property {_1m1w1y24hPattern} pct25 + * @property {_1m1w1y24hPattern} median + * @property {_1m1w1y24hPattern} pct75 + * @property {_1m1w1y24hPattern} pct90 + */ + /** * @typedef {Object} MetricsTree_Blocks_Weight * @property {MetricPattern18} base @@ -3749,7 +4561,10 @@ function create_24hPattern(client, acc) { * @typedef {Object} MetricsTree_Blocks_Count * @property {MetricPattern1} blockCountTarget * @property {CumulativeHeightSumPattern} blockCount - * @property {_1m1w1y24hPattern} blockCountSum + */ + +/** + * @typedef {Object} MetricsTree_Blocks_Lookback * @property {MetricPattern18} height1hAgo * @property {MetricPattern18} height24hAgo * @property {MetricPattern18} height3dAgo @@ -3802,20 +4617,6 @@ function create_24hPattern(client, acc) { * @property {MetricPattern1} daysBeforeNextHalving */ -/** - * @typedef {Object} MetricsTree_Blocks_Size - * @property {MetricPattern1} cumulative - * @property {_1m1w1y24hPattern} sum - * @property {_1m1w1y24hPattern} average - * @property {_1m1w1y24hPattern} min - * @property {_1m1w1y24hPattern} max - * @property {_1m1w1y24hPattern} pct10 - * @property {_1m1w1y24hPattern} pct25 - * @property {_1m1w1y24hPattern} median - * @property {_1m1w1y24hPattern} pct75 - * @property {_1m1w1y24hPattern} pct90 - */ - /** * @typedef {Object} MetricsTree_Blocks_Fullness * @property {_1m1w1y24hHeightPattern} bps @@ -3993,10 +4794,8 @@ function create_24hPattern(client, acc) { * @property {BaseCumulativePattern} subsidy * @property {MetricsTree_Mining_Rewards_Fees} fees * @property {BaseCumulativeSumPattern} unclaimedRewards - * @property {BpsPercentRatioPattern} feeDominance - * @property {_1m1w1y24hPattern2} feeDominanceRolling - * @property {BpsPercentRatioPattern} subsidyDominance - * @property {_1m1w1y24hPattern2} subsidyDominanceRolling + * @property {_1m1w1y24hBpsPercentRatioPattern} feeDominance + * @property {_1m1w1y24hBpsPercentRatioPattern} subsidyDominance * @property {CentsUsdPattern} subsidySma1y */ @@ -4013,22 +4812,19 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Mining_Hashrate * @property {MetricPattern1} hashRate - * @property {MetricPattern1} hashRateSma1w - * @property {MetricPattern1} hashRateSma1m - * @property {MetricPattern1} hashRateSma2m - * @property {MetricPattern1} hashRateSma1y + * @property {MetricsTree_Mining_Hashrate_HashRateSma} hashRateSma * @property {MetricPattern1} hashRateAth * @property {BpsPercentRatioPattern} hashRateDrawdown - * @property {MetricPattern1} hashPriceThs - * @property {MetricPattern1} hashPriceThsMin - * @property {MetricPattern1} hashPricePhs - * @property {MetricPattern1} hashPricePhsMin - * @property {BpsPercentRatioPattern} hashPriceRebound - * @property {MetricPattern1} hashValueThs - * @property {MetricPattern1} hashValueThsMin - * @property {MetricPattern1} hashValuePhs - * @property {MetricPattern1} hashValuePhsMin - * @property {BpsPercentRatioPattern} hashValueRebound + * @property {PhsReboundThsPattern} hashPrice + * @property {PhsReboundThsPattern} hashValue + */ + +/** + * @typedef {Object} MetricsTree_Mining_Hashrate_HashRateSma + * @property {MetricPattern1} _1w + * @property {MetricPattern1} _1m + * @property {MetricPattern1} _2m + * @property {MetricPattern1} _1y */ /** @@ -4065,9 +4861,9 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Cointime_Value - * @property {CumulativeHeightSumPattern} cointimeValueDestroyed - * @property {CumulativeHeightSumPattern} cointimeValueCreated - * @property {CumulativeHeightSumPattern} cointimeValueStored + * @property {CumulativeHeightSumPattern} valueDestroyed + * @property {CumulativeHeightSumPattern} valueCreated + * @property {CumulativeHeightSumPattern} valueStored * @property {CumulativeHeightSumPattern} vocdd */ @@ -4083,20 +4879,20 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Cointime_Pricing * @property {CentsSatsUsdPattern} vaultedPrice - * @property {BpsRatioPattern2} vaultedPriceRatio + * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} vaultedPriceRatio * @property {CentsSatsUsdPattern} activePrice - * @property {BpsRatioPattern2} activePriceRatio + * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} activePriceRatio * @property {CentsSatsUsdPattern} trueMarketMean - * @property {BpsRatioPattern2} trueMarketMeanRatio + * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} trueMarketMeanRatio * @property {CentsSatsUsdPattern} cointimePrice - * @property {BpsRatioPattern2} cointimePriceRatio + * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} cointimePriceRatio */ /** * @typedef {Object} MetricsTree_Cointime_Adjusted - * @property {BpsPercentRatioPattern} cointimeAdjInflationRate - * @property {MetricPattern1} cointimeAdjTxVelocityBtc - * @property {MetricPattern1} cointimeAdjTxVelocityUsd + * @property {BpsPercentRatioPattern} adjInflationRate + * @property {MetricPattern1} adjTxVelocityBtc + * @property {MetricPattern1} adjTxVelocityUsd */ /** @@ -4132,8 +4928,8 @@ function create_24hPattern(client, acc) { * @typedef {Object} MetricsTree_Indexes * @property {MetricsTree_Indexes_Address} address * @property {MetricsTree_Indexes_Height} height - * @property {MetricsTree_Indexes_Difficultyepoch} difficultyepoch - * @property {MetricsTree_Indexes_Halvingepoch} halvingepoch + * @property {MetricsTree_Indexes_Epoch} epoch + * @property {MetricsTree_Indexes_Halving} halving * @property {MetricsTree_Indexes_Minute10} minute10 * @property {MetricsTree_Indexes_Minute30} minute30 * @property {MetricsTree_Indexes_Hour1} hour1 @@ -4238,8 +5034,8 @@ function create_24hPattern(client, acc) { * @property {MetricPattern18} hour12 * @property {MetricPattern18} day1 * @property {MetricPattern18} day3 - * @property {MetricPattern18} difficultyepoch - * @property {MetricPattern18} halvingepoch + * @property {MetricPattern18} epoch + * @property {MetricPattern18} halving * @property {MetricPattern18} week1 * @property {MetricPattern18} month1 * @property {MetricPattern18} month3 @@ -4250,14 +5046,14 @@ function create_24hPattern(client, acc) { */ /** - * @typedef {Object} MetricsTree_Indexes_Difficultyepoch + * @typedef {Object} MetricsTree_Indexes_Epoch * @property {MetricPattern17} identity * @property {MetricPattern17} firstHeight * @property {MetricPattern17} heightCount */ /** - * @typedef {Object} MetricsTree_Indexes_Halvingepoch + * @typedef {Object} MetricsTree_Indexes_Halving * @property {MetricPattern16} identity * @property {MetricPattern16} firstHeight */ @@ -4370,7 +5166,7 @@ function create_24hPattern(client, acc) { * @property {MetricsTree_Market_Ath} ath * @property {MetricsTree_Market_Lookback} lookback * @property {MetricsTree_Market_Returns} returns - * @property {MetricsTree_Market_Volatility} volatility + * @property {_1m1w1yPattern} volatility * @property {MetricsTree_Market_Range} range * @property {MetricsTree_Market_MovingAverage} movingAverage * @property {MetricsTree_Market_Dca} dca @@ -4379,12 +5175,12 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Market_Ath - * @property {CentsSatsUsdPattern} priceAth - * @property {BpsPercentRatioPattern} priceDrawdown - * @property {MetricPattern1} daysSincePriceAth - * @property {MetricPattern2} yearsSincePriceAth - * @property {MetricPattern1} maxDaysBetweenPriceAth - * @property {MetricPattern2} maxYearsBetweenPriceAth + * @property {CentsSatsUsdPattern} price + * @property {BpsPercentRatioPattern} drawdown + * @property {MetricPattern1} daysSince + * @property {MetricPattern2} yearsSince + * @property {MetricPattern1} maxDaysBetween + * @property {MetricPattern2} maxYearsBetween */ /** @@ -4408,9 +5204,7 @@ function create_24hPattern(client, acc) { * @typedef {Object} MetricsTree_Market_Returns * @property {MetricsTree_Market_Returns_PriceReturn} priceReturn * @property {_10y2y3y4y5y6y8yPattern} priceCagr - * @property {MetricsTree_Market_Returns_PriceReturn24hSd1w} priceReturn24hSd1w - * @property {MetricsTree_Market_Returns_PriceReturn24hSd1m} priceReturn24hSd1m - * @property {SdSmaPattern} priceReturn24hSd1y + * @property {MetricsTree_Market_Returns_PriceReturn24hSd} priceReturn24hSd */ /** @@ -4431,76 +5225,304 @@ function create_24hPattern(client, acc) { */ /** - * @typedef {Object} MetricsTree_Market_Returns_PriceReturn24hSd1w + * @typedef {Object} MetricsTree_Market_Returns_PriceReturn24hSd + * @property {MetricsTree_Market_Returns_PriceReturn24hSd_1w} _1w + * @property {MetricsTree_Market_Returns_PriceReturn24hSd_1m} _1m + * @property {SdSmaPattern} _1y + */ + +/** + * @typedef {Object} MetricsTree_Market_Returns_PriceReturn24hSd_1w * @property {MetricPattern1} sma * @property {MetricPattern1} sd */ /** - * @typedef {Object} MetricsTree_Market_Returns_PriceReturn24hSd1m + * @typedef {Object} MetricsTree_Market_Returns_PriceReturn24hSd_1m * @property {MetricPattern1} sma * @property {MetricPattern1} sd */ -/** - * @typedef {Object} MetricsTree_Market_Volatility - * @property {MetricPattern1} priceVolatility1w - * @property {MetricPattern1} priceVolatility1m - * @property {MetricPattern1} priceVolatility1y - */ - /** * @typedef {Object} MetricsTree_Market_Range - * @property {CentsSatsUsdPattern} priceMin1w - * @property {CentsSatsUsdPattern} priceMax1w - * @property {CentsSatsUsdPattern} priceMin2w - * @property {CentsSatsUsdPattern} priceMax2w - * @property {CentsSatsUsdPattern} priceMin1m - * @property {CentsSatsUsdPattern} priceMax1m - * @property {CentsSatsUsdPattern} priceMin1y - * @property {CentsSatsUsdPattern} priceMax1y - * @property {MetricPattern1} priceTrueRange - * @property {MetricPattern1} priceTrueRangeSum2w - * @property {BpsPercentRatioPattern} priceChoppinessIndex2w + * @property {_1m1w1y2wPattern} min + * @property {_1m1w1y2wPattern} max + * @property {MetricPattern1} trueRange + * @property {MetricPattern1} trueRangeSum2w + * @property {BpsPercentRatioPattern} choppinessIndex2w */ /** * @typedef {Object} MetricsTree_Market_MovingAverage - * @property {BpsPriceRatioPattern} priceSma1w - * @property {BpsPriceRatioPattern} priceSma8d - * @property {BpsPriceRatioPattern} priceSma13d - * @property {BpsPriceRatioPattern} priceSma21d - * @property {BpsPriceRatioPattern} priceSma1m - * @property {BpsPriceRatioPattern} priceSma34d - * @property {BpsPriceRatioPattern} priceSma55d - * @property {BpsPriceRatioPattern} priceSma89d - * @property {BpsPriceRatioPattern} priceSma111d - * @property {BpsPriceRatioPattern} priceSma144d - * @property {BpsPriceRatioPattern} priceSma200d - * @property {BpsPriceRatioPattern} priceSma350d - * @property {BpsPriceRatioPattern} priceSma1y - * @property {BpsPriceRatioPattern} priceSma2y - * @property {BpsPriceRatioPattern} priceSma200w - * @property {BpsPriceRatioPattern} priceSma4y - * @property {BpsPriceRatioPattern} priceEma1w - * @property {BpsPriceRatioPattern} priceEma8d - * @property {BpsPriceRatioPattern} priceEma12d - * @property {BpsPriceRatioPattern} priceEma13d - * @property {BpsPriceRatioPattern} priceEma21d - * @property {BpsPriceRatioPattern} priceEma26d - * @property {BpsPriceRatioPattern} priceEma1m - * @property {BpsPriceRatioPattern} priceEma34d - * @property {BpsPriceRatioPattern} priceEma55d - * @property {BpsPriceRatioPattern} priceEma89d - * @property {BpsPriceRatioPattern} priceEma144d - * @property {BpsPriceRatioPattern} priceEma200d - * @property {BpsPriceRatioPattern} priceEma1y - * @property {BpsPriceRatioPattern} priceEma2y - * @property {BpsPriceRatioPattern} priceEma200w - * @property {BpsPriceRatioPattern} priceEma4y - * @property {CentsSatsUsdPattern} priceSma200dX24 - * @property {CentsSatsUsdPattern} priceSma200dX08 - * @property {CentsSatsUsdPattern} priceSma350dX2 + * @property {MetricsTree_Market_MovingAverage_Sma} sma + * @property {MetricsTree_Market_MovingAverage_Ema} ema + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma + * @property {MetricsTree_Market_MovingAverage_Sma_1w} _1w + * @property {MetricsTree_Market_MovingAverage_Sma_8d} _8d + * @property {MetricsTree_Market_MovingAverage_Sma_13d} _13d + * @property {MetricsTree_Market_MovingAverage_Sma_21d} _21d + * @property {MetricsTree_Market_MovingAverage_Sma_1m} _1m + * @property {MetricsTree_Market_MovingAverage_Sma_34d} _34d + * @property {MetricsTree_Market_MovingAverage_Sma_55d} _55d + * @property {MetricsTree_Market_MovingAverage_Sma_89d} _89d + * @property {MetricsTree_Market_MovingAverage_Sma_111d} _111d + * @property {MetricsTree_Market_MovingAverage_Sma_144d} _144d + * @property {MetricsTree_Market_MovingAverage_Sma_200d} _200d + * @property {MetricsTree_Market_MovingAverage_Sma_350d} _350d + * @property {MetricsTree_Market_MovingAverage_Sma_1y} _1y + * @property {MetricsTree_Market_MovingAverage_Sma_2y} _2y + * @property {MetricsTree_Market_MovingAverage_Sma_200w} _200w + * @property {MetricsTree_Market_MovingAverage_Sma_4y} _4y + * @property {CentsSatsUsdPattern} _200dX24 + * @property {CentsSatsUsdPattern} _200dX08 + * @property {CentsSatsUsdPattern} _350dX2 + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_1w + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_8d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_13d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_21d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_1m + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_34d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_55d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_89d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_111d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_144d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_200d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_350d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_1y + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_2y + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_200w + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_4y + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema + * @property {MetricsTree_Market_MovingAverage_Ema_1w} _1w + * @property {MetricsTree_Market_MovingAverage_Ema_8d} _8d + * @property {MetricsTree_Market_MovingAverage_Ema_12d} _12d + * @property {MetricsTree_Market_MovingAverage_Ema_13d} _13d + * @property {MetricsTree_Market_MovingAverage_Ema_21d} _21d + * @property {MetricsTree_Market_MovingAverage_Ema_26d} _26d + * @property {MetricsTree_Market_MovingAverage_Ema_1m} _1m + * @property {MetricsTree_Market_MovingAverage_Ema_34d} _34d + * @property {MetricsTree_Market_MovingAverage_Ema_55d} _55d + * @property {MetricsTree_Market_MovingAverage_Ema_89d} _89d + * @property {MetricsTree_Market_MovingAverage_Ema_144d} _144d + * @property {MetricsTree_Market_MovingAverage_Ema_200d} _200d + * @property {MetricsTree_Market_MovingAverage_Ema_1y} _1y + * @property {MetricsTree_Market_MovingAverage_Ema_2y} _2y + * @property {MetricsTree_Market_MovingAverage_Ema_200w} _200w + * @property {MetricsTree_Market_MovingAverage_Ema_4y} _4y + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_1w + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_8d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_12d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_13d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_21d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_26d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_1m + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_34d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_55d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_89d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_144d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_200d + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_1y + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_2y + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_200w + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Ema_4y + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio */ /** @@ -4687,28 +5709,28 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Pools_Major - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} unknown - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} luxor - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} btccom - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} btctop - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} btcguild - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} eligius - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} f2pool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} braiinspool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} antpool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} btcc - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} bwpool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} bitfury - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} viabtc - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} poolin - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} spiderpool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} binancepool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} foundryusa - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} sbicrypto - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} marapool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} secpool - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} ocean - * @property {_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern} whitepool + * @property {BlocksDominanceRewardsPattern} unknown + * @property {BlocksDominanceRewardsPattern} luxor + * @property {BlocksDominanceRewardsPattern} btccom + * @property {BlocksDominanceRewardsPattern} btctop + * @property {BlocksDominanceRewardsPattern} btcguild + * @property {BlocksDominanceRewardsPattern} eligius + * @property {BlocksDominanceRewardsPattern} f2pool + * @property {BlocksDominanceRewardsPattern} braiinspool + * @property {BlocksDominanceRewardsPattern} antpool + * @property {BlocksDominanceRewardsPattern} btcc + * @property {BlocksDominanceRewardsPattern} bwpool + * @property {BlocksDominanceRewardsPattern} bitfury + * @property {BlocksDominanceRewardsPattern} viabtc + * @property {BlocksDominanceRewardsPattern} poolin + * @property {BlocksDominanceRewardsPattern} spiderpool + * @property {BlocksDominanceRewardsPattern} binancepool + * @property {BlocksDominanceRewardsPattern} foundryusa + * @property {BlocksDominanceRewardsPattern} sbicrypto + * @property {BlocksDominanceRewardsPattern} marapool + * @property {BlocksDominanceRewardsPattern} secpool + * @property {BlocksDominanceRewardsPattern} ocean + * @property {BlocksDominanceRewardsPattern} whitepool */ /** @@ -4904,8 +5926,8 @@ function create_24hPattern(client, acc) { * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern} totalAddrCount * @property {MetricsTree_Distribution_NewAddrCount} newAddrCount * @property {MetricsTree_Distribution_Delta} delta - * @property {MetricPattern34} fundedaddressindex - * @property {MetricPattern35} emptyaddressindex + * @property {MetricPattern34} fundedAddressIndex + * @property {MetricPattern35} emptyAddressIndex */ /** @@ -4946,75 +5968,86 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All - * @property {DeltaHalvedTotalPattern} supply - * @property {UtxoPattern} outputs - * @property {CoinblocksCoindaysSentPattern2} activity - * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized + * @property {DeltaHalvedTotalPattern2} supply + * @property {UtxoPattern3} outputs + * @property {CoinblocksCoindaysDormancySentVelocityPattern} activity + * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern} realized * @property {InvestedMaxMinPercentilesPattern} costBasis - * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized - * @property {MetricsTree_Distribution_UtxoCohorts_All_Adjusted} adjusted + * @property {GrossInvestedInvestorLossNetProfitSentimentPattern} unrealized * @property {MetricsTree_Distribution_UtxoCohorts_All_Relative} relative - * @property {MetricPattern1} dormancy - * @property {MetricPattern1} velocity - * @property {_24hChangeRatePattern2} supplyDeltaExtended - * @property {_24hChangeRatePattern2} utxoCountDeltaExtended - */ - -/** - * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Adjusted - * @property {MetricPattern1} adjustedValueCreated - * @property {MetricPattern1} adjustedValueDestroyed - * @property {_1m1w1y24hPattern} adjustedValueCreatedSum - * @property {_1m1w1y24hPattern} adjustedValueDestroyedSum - * @property {_1m1w1y24hPattern} adjustedSopr */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Relative - * @property {BpsPercentRatioPattern} supplyInProfitRelToOwnSupply - * @property {BpsPercentRatioPattern} supplyInLossRelToOwnSupply - * @property {BpsPercentRatioPattern} unrealizedProfitRelToMarketCap - * @property {BpsPercentRatioPattern} unrealizedLossRelToMarketCap - * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToMarketCap - * @property {MetricPattern1} nupl - * @property {BpsPercentRatioPattern} unrealizedProfitRelToOwnGrossPnl - * @property {BpsPercentRatioPattern} unrealizedLossRelToOwnGrossPnl - * @property {BpsPercentRatioPattern} netUnrealizedPnlRelToOwnGrossPnl + * @property {MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply} supply + * @property {MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized} unrealized + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply + * @property {RelPattern2} inProfit + * @property {RelPattern2} inLoss + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized + * @property {RelPattern3} profit + * @property {RelPattern3} loss + * @property {MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl} netPnl + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl + * @property {BpsPercentRatioPattern} relToOwnGrossPnl */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Sth - * @property {DeltaHalvedTotalPattern} supply - * @property {UtxoPattern} outputs - * @property {CoinblocksCoindaysSentPattern2} activity - * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized + * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern} realized + * @property {DeltaHalvedTotalPattern2} supply + * @property {UtxoPattern3} outputs + * @property {CoinblocksCoindaysDormancySentVelocityPattern} activity * @property {InvestedMaxMinPercentilesPattern} costBasis - * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized - * @property {NetNuplSupplyUnrealizedPattern2} relative - * @property {MetricPattern1} dormancy - * @property {MetricPattern1} velocity - * @property {_24hChangeRatePattern2} supplyDeltaExtended - * @property {_24hChangeRatePattern2} utxoCountDeltaExtended - * @property {MetricPattern1} adjustedValueCreated - * @property {MetricPattern1} adjustedValueDestroyed - * @property {_1m1w1y24hPattern} adjustedValueCreatedSum - * @property {_1m1w1y24hPattern} adjustedValueDestroyedSum - * @property {_1m1w1y24hPattern} adjustedSopr + * @property {GrossInvestedInvestorLossNetProfitSentimentPattern} unrealized + * @property {SupplyUnrealizedPattern2} relative */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Lth - * @property {DeltaHalvedTotalPattern} supply - * @property {UtxoPattern} outputs - * @property {CoinblocksCoindaysSentPattern2} activity - * @property {CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern} realized + * @property {DeltaHalvedTotalPattern2} supply + * @property {UtxoPattern3} outputs + * @property {CoinblocksCoindaysDormancySentVelocityPattern} activity + * @property {MetricsTree_Distribution_UtxoCohorts_Lth_Realized} realized * @property {InvestedMaxMinPercentilesPattern} costBasis - * @property {GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern} unrealized - * @property {NetNuplSupplyUnrealizedPattern2} relative - * @property {MetricPattern1} dormancy - * @property {MetricPattern1} velocity - * @property {_24hChangeRatePattern2} supplyDeltaExtended - * @property {_24hChangeRatePattern2} utxoCountDeltaExtended + * @property {GrossInvestedInvestorLossNetProfitSentimentPattern} unrealized + * @property {SupplyUnrealizedPattern2} relative + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Lth_Realized + * @property {CentsCumulativeFlowRelSumUsdValuePattern} profit + * @property {CapitulationCentsCumulativeNegRelSumUsdValuePattern} loss + * @property {CentsSellSumUsdPattern} grossPnl + * @property {ChangeCumulativeDeltaRawRelSumPattern} netPnl + * @property {MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr} sopr + * @property {InPattern3} sent + * @property {CumulativeHeightRelPattern} peakRegret + * @property {CapLowerPriceUpperPattern} investor + * @property {_1m1w1y24hPattern} profitToLossRatio + * @property {CentsDeltaRawRelUsdPattern} cap + * @property {BpsPercentilesRatioStdPattern} priceRatio + * @property {CentsSatsUsdPattern} price + * @property {MetricPattern1} mvrv + * @property {BpsRatioPattern} nupl + */ + +/** + * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr + * @property {_1m1w1yPattern} valueCreatedSum + * @property {_1m1w1yPattern} valueDestroyedSum + * @property {_1m1w1y24hPattern} ratio + * @property {RawSumPattern} valueCreated + * @property {RawSumPattern} valueDestroyed */ /** @@ -5119,70 +6152,70 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_GeAmount - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1sat - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10sats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100sats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1mSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10mSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1kBtc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10kBtc + * @property {OutputsRealizedSupplyPattern} _1sat + * @property {OutputsRealizedSupplyPattern} _10sats + * @property {OutputsRealizedSupplyPattern} _100sats + * @property {OutputsRealizedSupplyPattern} _1kSats + * @property {OutputsRealizedSupplyPattern} _10kSats + * @property {OutputsRealizedSupplyPattern} _100kSats + * @property {OutputsRealizedSupplyPattern} _1mSats + * @property {OutputsRealizedSupplyPattern} _10mSats + * @property {OutputsRealizedSupplyPattern} _1btc + * @property {OutputsRealizedSupplyPattern} _10btc + * @property {OutputsRealizedSupplyPattern} _100btc + * @property {OutputsRealizedSupplyPattern} _1kBtc + * @property {OutputsRealizedSupplyPattern} _10kBtc */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_AmountRange - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _0sats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1satTo10sats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10satsTo100sats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100satsTo1kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1kSatsTo10kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10kSatsTo100kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100kSatsTo1mSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1mSatsTo10mSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10mSatsTo1btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1btcTo10btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10btcTo100btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100btcTo1kBtc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1kBtcTo10kBtc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10kBtcTo100kBtc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100kBtcOrMore + * @property {OutputsRealizedSupplyPattern} _0sats + * @property {OutputsRealizedSupplyPattern} _1satTo10sats + * @property {OutputsRealizedSupplyPattern} _10satsTo100sats + * @property {OutputsRealizedSupplyPattern} _100satsTo1kSats + * @property {OutputsRealizedSupplyPattern} _1kSatsTo10kSats + * @property {OutputsRealizedSupplyPattern} _10kSatsTo100kSats + * @property {OutputsRealizedSupplyPattern} _100kSatsTo1mSats + * @property {OutputsRealizedSupplyPattern} _1mSatsTo10mSats + * @property {OutputsRealizedSupplyPattern} _10mSatsTo1btc + * @property {OutputsRealizedSupplyPattern} _1btcTo10btc + * @property {OutputsRealizedSupplyPattern} _10btcTo100btc + * @property {OutputsRealizedSupplyPattern} _100btcTo1kBtc + * @property {OutputsRealizedSupplyPattern} _1kBtcTo10kBtc + * @property {OutputsRealizedSupplyPattern} _10kBtcTo100kBtc + * @property {OutputsRealizedSupplyPattern} _100kBtcOrMore */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_LtAmount - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10sats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100sats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100kSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1mSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10mSats - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100btc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _1kBtc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _10kBtc - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} _100kBtc + * @property {OutputsRealizedSupplyPattern} _10sats + * @property {OutputsRealizedSupplyPattern} _100sats + * @property {OutputsRealizedSupplyPattern} _1kSats + * @property {OutputsRealizedSupplyPattern} _10kSats + * @property {OutputsRealizedSupplyPattern} _100kSats + * @property {OutputsRealizedSupplyPattern} _1mSats + * @property {OutputsRealizedSupplyPattern} _10mSats + * @property {OutputsRealizedSupplyPattern} _1btc + * @property {OutputsRealizedSupplyPattern} _10btc + * @property {OutputsRealizedSupplyPattern} _100btc + * @property {OutputsRealizedSupplyPattern} _1kBtc + * @property {OutputsRealizedSupplyPattern} _10kBtc + * @property {OutputsRealizedSupplyPattern} _100kBtc */ /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Type - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2pk65 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2pk33 - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2pkh - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2ms - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2sh - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2wpkh - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2wsh - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2tr - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} p2a - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} unknown - * @property {ActivityOutputsRealizedSupplyUnrealizedPattern} empty + * @property {OutputsRealizedSupplyUnrealizedPattern} p2pk65 + * @property {OutputsRealizedSupplyUnrealizedPattern} p2pk33 + * @property {OutputsRealizedSupplyUnrealizedPattern} p2pkh + * @property {OutputsRealizedSupplyUnrealizedPattern} p2ms + * @property {OutputsRealizedSupplyUnrealizedPattern} p2sh + * @property {OutputsRealizedSupplyUnrealizedPattern} p2wpkh + * @property {OutputsRealizedSupplyUnrealizedPattern} p2wsh + * @property {OutputsRealizedSupplyUnrealizedPattern} p2tr + * @property {OutputsRealizedSupplyUnrealizedPattern} p2a + * @property {OutputsRealizedSupplyUnrealizedPattern} unknown + * @property {OutputsRealizedSupplyUnrealizedPattern} empty */ /** @@ -5288,55 +6321,55 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_AddressCohorts_GeAmount - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1sat - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10sats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100sats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1mSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10mSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1kBtc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10kBtc + * @property {AddrOutputsRealizedSupplyPattern} _1sat + * @property {AddrOutputsRealizedSupplyPattern} _10sats + * @property {AddrOutputsRealizedSupplyPattern} _100sats + * @property {AddrOutputsRealizedSupplyPattern} _1kSats + * @property {AddrOutputsRealizedSupplyPattern} _10kSats + * @property {AddrOutputsRealizedSupplyPattern} _100kSats + * @property {AddrOutputsRealizedSupplyPattern} _1mSats + * @property {AddrOutputsRealizedSupplyPattern} _10mSats + * @property {AddrOutputsRealizedSupplyPattern} _1btc + * @property {AddrOutputsRealizedSupplyPattern} _10btc + * @property {AddrOutputsRealizedSupplyPattern} _100btc + * @property {AddrOutputsRealizedSupplyPattern} _1kBtc + * @property {AddrOutputsRealizedSupplyPattern} _10kBtc */ /** * @typedef {Object} MetricsTree_Distribution_AddressCohorts_AmountRange - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _0sats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1satTo10sats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10satsTo100sats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100satsTo1kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1kSatsTo10kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10kSatsTo100kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100kSatsTo1mSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1mSatsTo10mSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10mSatsTo1btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1btcTo10btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10btcTo100btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100btcTo1kBtc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1kBtcTo10kBtc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10kBtcTo100kBtc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100kBtcOrMore + * @property {AddrOutputsRealizedSupplyPattern} _0sats + * @property {AddrOutputsRealizedSupplyPattern} _1satTo10sats + * @property {AddrOutputsRealizedSupplyPattern} _10satsTo100sats + * @property {AddrOutputsRealizedSupplyPattern} _100satsTo1kSats + * @property {AddrOutputsRealizedSupplyPattern} _1kSatsTo10kSats + * @property {AddrOutputsRealizedSupplyPattern} _10kSatsTo100kSats + * @property {AddrOutputsRealizedSupplyPattern} _100kSatsTo1mSats + * @property {AddrOutputsRealizedSupplyPattern} _1mSatsTo10mSats + * @property {AddrOutputsRealizedSupplyPattern} _10mSatsTo1btc + * @property {AddrOutputsRealizedSupplyPattern} _1btcTo10btc + * @property {AddrOutputsRealizedSupplyPattern} _10btcTo100btc + * @property {AddrOutputsRealizedSupplyPattern} _100btcTo1kBtc + * @property {AddrOutputsRealizedSupplyPattern} _1kBtcTo10kBtc + * @property {AddrOutputsRealizedSupplyPattern} _10kBtcTo100kBtc + * @property {AddrOutputsRealizedSupplyPattern} _100kBtcOrMore */ /** * @typedef {Object} MetricsTree_Distribution_AddressCohorts_LtAmount - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10sats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100sats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100kSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1mSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10mSats - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100btc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _1kBtc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _10kBtc - * @property {ActivityAddrOutputsRealizedSupplyUnrealizedPattern} _100kBtc + * @property {AddrOutputsRealizedSupplyPattern} _10sats + * @property {AddrOutputsRealizedSupplyPattern} _100sats + * @property {AddrOutputsRealizedSupplyPattern} _1kSats + * @property {AddrOutputsRealizedSupplyPattern} _10kSats + * @property {AddrOutputsRealizedSupplyPattern} _100kSats + * @property {AddrOutputsRealizedSupplyPattern} _1mSats + * @property {AddrOutputsRealizedSupplyPattern} _10mSats + * @property {AddrOutputsRealizedSupplyPattern} _1btc + * @property {AddrOutputsRealizedSupplyPattern} _10btc + * @property {AddrOutputsRealizedSupplyPattern} _100btc + * @property {AddrOutputsRealizedSupplyPattern} _1kBtc + * @property {AddrOutputsRealizedSupplyPattern} _10kBtc + * @property {AddrOutputsRealizedSupplyPattern} _100kBtc */ /** @@ -5431,8 +6464,8 @@ class BrkClient extends BrkClientBase { "month6", "year1", "year10", - "halvingepoch", - "difficultyepoch", + "halving", + "epoch", "height", "txindex", "txinindex", @@ -6371,7 +7404,19 @@ class BrkClient extends BrkClientBase { date: createMetricPattern18(this, 'date'), timestampMonotonic: createMetricPattern18(this, 'timestamp_monotonic'), }, - totalSize: createMetricPattern18(this, 'total_size'), + size: { + totalSize: createMetricPattern18(this, 'total_size'), + cumulative: createMetricPattern1(this, 'block_size_cumulative'), + sum: create_1m1w1y24hPattern(this, 'block_size_sum'), + average: create_1m1w1y24hPattern(this, 'block_size_average'), + min: create_1m1w1y24hPattern(this, 'block_size_min'), + max: create_1m1w1y24hPattern(this, 'block_size_max'), + pct10: create_1m1w1y24hPattern(this, 'block_size_pct10'), + pct25: create_1m1w1y24hPattern(this, 'block_size_pct25'), + median: create_1m1w1y24hPattern(this, 'block_size_median'), + pct75: create_1m1w1y24hPattern(this, 'block_size_pct75'), + pct90: create_1m1w1y24hPattern(this, 'block_size_pct90'), + }, weight: { base: createMetricPattern18(this, 'block_weight'), cumulative: createMetricPattern1(this, 'block_weight_cumulative'), @@ -6379,16 +7424,17 @@ class BrkClient extends BrkClientBase { average: create_1m1w1y24hPattern(this, 'block_weight_average'), min: create_1m1w1y24hPattern(this, 'block_weight_min'), max: create_1m1w1y24hPattern(this, 'block_weight_max'), - pct10: create_1m1w1y24hPattern(this, 'block_weight_p10'), - pct25: create_1m1w1y24hPattern(this, 'block_weight_p25'), + pct10: create_1m1w1y24hPattern(this, 'block_weight_pct10'), + pct25: create_1m1w1y24hPattern(this, 'block_weight_pct25'), median: create_1m1w1y24hPattern(this, 'block_weight_median'), - pct75: create_1m1w1y24hPattern(this, 'block_weight_p75'), - pct90: create_1m1w1y24hPattern(this, 'block_weight_p90'), + pct75: create_1m1w1y24hPattern(this, 'block_weight_pct75'), + pct90: create_1m1w1y24hPattern(this, 'block_weight_pct90'), }, count: { blockCountTarget: createMetricPattern1(this, 'block_count_target'), blockCount: createCumulativeHeightSumPattern(this, 'block_count'), - blockCountSum: create_1m1w1y24hPattern(this, 'block_count_sum'), + }, + lookback: { height1hAgo: createMetricPattern18(this, 'height_1h_ago'), height24hAgo: createMetricPattern18(this, 'height_24h_ago'), height3dAgo: createMetricPattern18(this, 'height_3d_ago'), @@ -6440,18 +7486,6 @@ class BrkClient extends BrkClientBase { daysBeforeNextHalving: createMetricPattern1(this, 'days_before_next_halving'), }, vbytes: createAverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern(this, 'block_vbytes'), - size: { - cumulative: createMetricPattern1(this, 'block_size_cumulative'), - sum: create_1m1w1y24hPattern(this, 'block_size_sum'), - average: create_1m1w1y24hPattern(this, 'block_size_average'), - min: create_1m1w1y24hPattern(this, 'block_size_min'), - max: create_1m1w1y24hPattern(this, 'block_size_max'), - pct10: create_1m1w1y24hPattern(this, 'block_size_p10'), - pct25: create_1m1w1y24hPattern(this, 'block_size_p25'), - median: create_1m1w1y24hPattern(this, 'block_size_median'), - pct75: create_1m1w1y24hPattern(this, 'block_size_p75'), - pct90: create_1m1w1y24hPattern(this, 'block_size_p90'), - }, fullness: { bps: create_1m1w1y24hHeightPattern(this, 'block_fullness_bps'), ratio: createMetricPattern1(this, 'block_fullness_ratio'), @@ -6586,30 +7620,22 @@ class BrkClient extends BrkClientBase { _1y: createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2(this, 'fees_1y'), }, unclaimedRewards: createBaseCumulativeSumPattern(this, 'unclaimed_rewards'), - feeDominance: createBpsPercentRatioPattern(this, 'fee_dominance'), - feeDominanceRolling: create_1m1w1y24hPattern2(this, 'fee_dominance'), - subsidyDominance: createBpsPercentRatioPattern(this, 'subsidy_dominance'), - subsidyDominanceRolling: create_1m1w1y24hPattern2(this, 'subsidy_dominance'), + feeDominance: create_1m1w1y24hBpsPercentRatioPattern(this, 'fee_dominance'), + subsidyDominance: create_1m1w1y24hBpsPercentRatioPattern(this, 'subsidy_dominance'), subsidySma1y: createCentsUsdPattern(this, 'subsidy_sma_1y'), }, hashrate: { hashRate: createMetricPattern1(this, 'hash_rate'), - hashRateSma1w: createMetricPattern1(this, 'hash_rate_sma_1w'), - hashRateSma1m: createMetricPattern1(this, 'hash_rate_sma_1m'), - hashRateSma2m: createMetricPattern1(this, 'hash_rate_sma_2m'), - hashRateSma1y: createMetricPattern1(this, 'hash_rate_sma_1y'), + hashRateSma: { + _1w: createMetricPattern1(this, 'hash_rate_sma_1w'), + _1m: createMetricPattern1(this, 'hash_rate_sma_1m'), + _2m: createMetricPattern1(this, 'hash_rate_sma_2m'), + _1y: createMetricPattern1(this, 'hash_rate_sma_1y'), + }, hashRateAth: createMetricPattern1(this, 'hash_rate_ath'), hashRateDrawdown: createBpsPercentRatioPattern(this, 'hash_rate_drawdown'), - hashPriceThs: createMetricPattern1(this, 'hash_price_ths'), - hashPriceThsMin: createMetricPattern1(this, 'hash_price_ths_min'), - hashPricePhs: createMetricPattern1(this, 'hash_price_phs'), - hashPricePhsMin: createMetricPattern1(this, 'hash_price_phs_min'), - hashPriceRebound: createBpsPercentRatioPattern(this, 'hash_price_rebound'), - hashValueThs: createMetricPattern1(this, 'hash_value_ths'), - hashValueThsMin: createMetricPattern1(this, 'hash_value_ths_min'), - hashValuePhs: createMetricPattern1(this, 'hash_value_phs'), - hashValuePhsMin: createMetricPattern1(this, 'hash_value_phs_min'), - hashValueRebound: createBpsPercentRatioPattern(this, 'hash_value_rebound'), + hashPrice: createPhsReboundThsPattern(this, 'hash_price'), + hashValue: createPhsReboundThsPattern(this, 'hash_value'), }, }, positions: { @@ -6629,9 +7655,9 @@ class BrkClient extends BrkClientBase { activeSupply: createBtcCentsSatsUsdPattern(this, 'active_supply'), }, value: { - cointimeValueDestroyed: createCumulativeHeightSumPattern(this, 'cointime_value_destroyed'), - cointimeValueCreated: createCumulativeHeightSumPattern(this, 'cointime_value_created'), - cointimeValueStored: createCumulativeHeightSumPattern(this, 'cointime_value_stored'), + valueDestroyed: createCumulativeHeightSumPattern(this, 'cointime_value_destroyed'), + valueCreated: createCumulativeHeightSumPattern(this, 'cointime_value_created'), + valueStored: createCumulativeHeightSumPattern(this, 'cointime_value_stored'), vocdd: createCumulativeHeightSumPattern(this, 'vocdd'), }, cap: { @@ -6643,18 +7669,18 @@ class BrkClient extends BrkClientBase { }, pricing: { vaultedPrice: createCentsSatsUsdPattern(this, 'vaulted_price'), - vaultedPriceRatio: createBpsRatioPattern2(this, 'vaulted_price_ratio'), + vaultedPriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'vaulted_price_ratio'), activePrice: createCentsSatsUsdPattern(this, 'active_price'), - activePriceRatio: createBpsRatioPattern2(this, 'active_price_ratio'), + activePriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'active_price_ratio'), trueMarketMean: createCentsSatsUsdPattern(this, 'true_market_mean'), - trueMarketMeanRatio: createBpsRatioPattern2(this, 'true_market_mean_ratio'), + trueMarketMeanRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'true_market_mean_ratio'), cointimePrice: createCentsSatsUsdPattern(this, 'cointime_price'), - cointimePriceRatio: createBpsRatioPattern2(this, 'cointime_price_ratio'), + cointimePriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'cointime_price_ratio'), }, adjusted: { - cointimeAdjInflationRate: createBpsPercentRatioPattern(this, 'cointime_adj_inflation_rate'), - cointimeAdjTxVelocityBtc: createMetricPattern1(this, 'cointime_adj_tx_velocity_btc'), - cointimeAdjTxVelocityUsd: createMetricPattern1(this, 'cointime_adj_tx_velocity_usd'), + adjInflationRate: createBpsPercentRatioPattern(this, 'cointime_adj_inflation_rate'), + adjTxVelocityBtc: createMetricPattern1(this, 'cointime_adj_tx_velocity_btc'), + adjTxVelocityUsd: createMetricPattern1(this, 'cointime_adj_tx_velocity_usd'), }, reserveRisk: { vocddMedian1y: createMetricPattern18(this, 'vocdd_median_1y'), @@ -6730,8 +7756,8 @@ class BrkClient extends BrkClientBase { hour12: createMetricPattern18(this, 'hour12'), day1: createMetricPattern18(this, 'day1'), day3: createMetricPattern18(this, 'day3'), - difficultyepoch: createMetricPattern18(this, 'difficultyepoch'), - halvingepoch: createMetricPattern18(this, 'halvingepoch'), + epoch: createMetricPattern18(this, 'epoch'), + halving: createMetricPattern18(this, 'halving'), week1: createMetricPattern18(this, 'week1'), month1: createMetricPattern18(this, 'month1'), month3: createMetricPattern18(this, 'month3'), @@ -6740,13 +7766,13 @@ class BrkClient extends BrkClientBase { year10: createMetricPattern18(this, 'year10'), txindexCount: createMetricPattern18(this, 'txindex_count'), }, - difficultyepoch: { - identity: createMetricPattern17(this, 'difficultyepoch'), + epoch: { + identity: createMetricPattern17(this, 'epoch'), firstHeight: createMetricPattern17(this, 'first_height'), heightCount: createMetricPattern17(this, 'height_count'), }, - halvingepoch: { - identity: createMetricPattern16(this, 'halvingepoch'), + halving: { + identity: createMetricPattern16(this, 'halving'), firstHeight: createMetricPattern16(this, 'first_height'), }, minute10: { @@ -6823,12 +7849,12 @@ class BrkClient extends BrkClientBase { }, market: { ath: { - priceAth: createCentsSatsUsdPattern(this, 'price_ath'), - priceDrawdown: createBpsPercentRatioPattern(this, 'price_drawdown'), - daysSincePriceAth: createMetricPattern1(this, 'days_since_price_ath'), - yearsSincePriceAth: createMetricPattern2(this, 'years_since_price_ath'), - maxDaysBetweenPriceAth: createMetricPattern1(this, 'max_days_between_price_ath'), - maxYearsBetweenPriceAth: createMetricPattern2(this, 'max_years_between_price_ath'), + price: createCentsSatsUsdPattern(this, 'price_ath'), + drawdown: createBpsPercentRatioPattern(this, 'price_drawdown'), + daysSince: createMetricPattern1(this, 'days_since_price_ath'), + yearsSince: createMetricPattern2(this, 'years_since_price_ath'), + maxDaysBetween: createMetricPattern1(this, 'max_days_between_price_ath'), + maxYearsBetween: createMetricPattern2(this, 'max_years_between_price_ath'), }, lookback: { _24h: createCentsSatsUsdPattern(this, 'price_lookback_24h'), @@ -6862,70 +7888,194 @@ class BrkClient extends BrkClientBase { _10y: createBpsPercentRatioPattern(this, 'price_return_10y'), }, priceCagr: create_10y2y3y4y5y6y8yPattern(this, 'price_cagr'), - priceReturn24hSd1w: { - sma: createMetricPattern1(this, 'price_return_24h_sma_1w'), - sd: createMetricPattern1(this, 'price_return_24h_sd_1w'), + priceReturn24hSd: { + _1w: { + sma: createMetricPattern1(this, 'price_return_24h_sma_1w'), + sd: createMetricPattern1(this, 'price_return_24h_sd_1w'), + }, + _1m: { + sma: createMetricPattern1(this, 'price_return_24h_sma_1m'), + sd: createMetricPattern1(this, 'price_return_24h_sd_1m'), + }, + _1y: createSdSmaPattern(this, 'price_return_24h'), }, - priceReturn24hSd1m: { - sma: createMetricPattern1(this, 'price_return_24h_sma_1m'), - sd: createMetricPattern1(this, 'price_return_24h_sd_1m'), - }, - priceReturn24hSd1y: createSdSmaPattern(this, 'price_return_24h'), - }, - volatility: { - priceVolatility1w: createMetricPattern1(this, 'price_volatility_1w'), - priceVolatility1m: createMetricPattern1(this, 'price_volatility_1m'), - priceVolatility1y: createMetricPattern1(this, 'price_volatility_1y'), }, + volatility: create_1m1w1yPattern(this, 'price_volatility'), range: { - priceMin1w: createCentsSatsUsdPattern(this, 'price_min_1w'), - priceMax1w: createCentsSatsUsdPattern(this, 'price_max_1w'), - priceMin2w: createCentsSatsUsdPattern(this, 'price_min_2w'), - priceMax2w: createCentsSatsUsdPattern(this, 'price_max_2w'), - priceMin1m: createCentsSatsUsdPattern(this, 'price_min_1m'), - priceMax1m: createCentsSatsUsdPattern(this, 'price_max_1m'), - priceMin1y: createCentsSatsUsdPattern(this, 'price_min_1y'), - priceMax1y: createCentsSatsUsdPattern(this, 'price_max_1y'), - priceTrueRange: createMetricPattern1(this, 'price_true_range'), - priceTrueRangeSum2w: createMetricPattern1(this, 'price_true_range_sum_2w'), - priceChoppinessIndex2w: createBpsPercentRatioPattern(this, 'price_choppiness_index_2w'), + min: create_1m1w1y2wPattern(this, 'price_min'), + max: create_1m1w1y2wPattern(this, 'price_max'), + trueRange: createMetricPattern1(this, 'price_true_range'), + trueRangeSum2w: createMetricPattern1(this, 'price_true_range_sum_2w'), + choppinessIndex2w: createBpsPercentRatioPattern(this, 'price_choppiness_index_2w'), }, movingAverage: { - priceSma1w: createBpsPriceRatioPattern(this, 'price_sma_1w'), - priceSma8d: createBpsPriceRatioPattern(this, 'price_sma_8d'), - priceSma13d: createBpsPriceRatioPattern(this, 'price_sma_13d'), - priceSma21d: createBpsPriceRatioPattern(this, 'price_sma_21d'), - priceSma1m: createBpsPriceRatioPattern(this, 'price_sma_1m'), - priceSma34d: createBpsPriceRatioPattern(this, 'price_sma_34d'), - priceSma55d: createBpsPriceRatioPattern(this, 'price_sma_55d'), - priceSma89d: createBpsPriceRatioPattern(this, 'price_sma_89d'), - priceSma111d: createBpsPriceRatioPattern(this, 'price_sma_111d'), - priceSma144d: createBpsPriceRatioPattern(this, 'price_sma_144d'), - priceSma200d: createBpsPriceRatioPattern(this, 'price_sma_200d'), - priceSma350d: createBpsPriceRatioPattern(this, 'price_sma_350d'), - priceSma1y: createBpsPriceRatioPattern(this, 'price_sma_1y'), - priceSma2y: createBpsPriceRatioPattern(this, 'price_sma_2y'), - priceSma200w: createBpsPriceRatioPattern(this, 'price_sma_200w'), - priceSma4y: createBpsPriceRatioPattern(this, 'price_sma_4y'), - priceEma1w: createBpsPriceRatioPattern(this, 'price_ema_1w'), - priceEma8d: createBpsPriceRatioPattern(this, 'price_ema_8d'), - priceEma12d: createBpsPriceRatioPattern(this, 'price_ema_12d'), - priceEma13d: createBpsPriceRatioPattern(this, 'price_ema_13d'), - priceEma21d: createBpsPriceRatioPattern(this, 'price_ema_21d'), - priceEma26d: createBpsPriceRatioPattern(this, 'price_ema_26d'), - priceEma1m: createBpsPriceRatioPattern(this, 'price_ema_1m'), - priceEma34d: createBpsPriceRatioPattern(this, 'price_ema_34d'), - priceEma55d: createBpsPriceRatioPattern(this, 'price_ema_55d'), - priceEma89d: createBpsPriceRatioPattern(this, 'price_ema_89d'), - priceEma144d: createBpsPriceRatioPattern(this, 'price_ema_144d'), - priceEma200d: createBpsPriceRatioPattern(this, 'price_ema_200d'), - priceEma1y: createBpsPriceRatioPattern(this, 'price_ema_1y'), - priceEma2y: createBpsPriceRatioPattern(this, 'price_ema_2y'), - priceEma200w: createBpsPriceRatioPattern(this, 'price_ema_200w'), - priceEma4y: createBpsPriceRatioPattern(this, 'price_ema_4y'), - priceSma200dX24: createCentsSatsUsdPattern(this, 'price_sma_200d_x2_4'), - priceSma200dX08: createCentsSatsUsdPattern(this, 'price_sma_200d_x0_8'), - priceSma350dX2: createCentsSatsUsdPattern(this, 'price_sma_350d_x2'), + sma: { + _1w: { + price: createCentsSatsUsdPattern(this, 'price_sma_1w'), + bps: createMetricPattern1(this, 'price_sma_1w_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_1w_ratio'), + }, + _8d: { + price: createCentsSatsUsdPattern(this, 'price_sma_8d'), + bps: createMetricPattern1(this, 'price_sma_8d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_8d_ratio'), + }, + _13d: { + price: createCentsSatsUsdPattern(this, 'price_sma_13d'), + bps: createMetricPattern1(this, 'price_sma_13d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_13d_ratio'), + }, + _21d: { + price: createCentsSatsUsdPattern(this, 'price_sma_21d'), + bps: createMetricPattern1(this, 'price_sma_21d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_21d_ratio'), + }, + _1m: { + price: createCentsSatsUsdPattern(this, 'price_sma_1m'), + bps: createMetricPattern1(this, 'price_sma_1m_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_1m_ratio'), + }, + _34d: { + price: createCentsSatsUsdPattern(this, 'price_sma_34d'), + bps: createMetricPattern1(this, 'price_sma_34d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_34d_ratio'), + }, + _55d: { + price: createCentsSatsUsdPattern(this, 'price_sma_55d'), + bps: createMetricPattern1(this, 'price_sma_55d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_55d_ratio'), + }, + _89d: { + price: createCentsSatsUsdPattern(this, 'price_sma_89d'), + bps: createMetricPattern1(this, 'price_sma_89d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_89d_ratio'), + }, + _111d: { + price: createCentsSatsUsdPattern(this, 'price_sma_111d'), + bps: createMetricPattern1(this, 'price_sma_111d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_111d_ratio'), + }, + _144d: { + price: createCentsSatsUsdPattern(this, 'price_sma_144d'), + bps: createMetricPattern1(this, 'price_sma_144d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_144d_ratio'), + }, + _200d: { + price: createCentsSatsUsdPattern(this, 'price_sma_200d'), + bps: createMetricPattern1(this, 'price_sma_200d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_200d_ratio'), + }, + _350d: { + price: createCentsSatsUsdPattern(this, 'price_sma_350d'), + bps: createMetricPattern1(this, 'price_sma_350d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_350d_ratio'), + }, + _1y: { + price: createCentsSatsUsdPattern(this, 'price_sma_1y'), + bps: createMetricPattern1(this, 'price_sma_1y_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_1y_ratio'), + }, + _2y: { + price: createCentsSatsUsdPattern(this, 'price_sma_2y'), + bps: createMetricPattern1(this, 'price_sma_2y_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_2y_ratio'), + }, + _200w: { + price: createCentsSatsUsdPattern(this, 'price_sma_200w'), + bps: createMetricPattern1(this, 'price_sma_200w_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_200w_ratio'), + }, + _4y: { + price: createCentsSatsUsdPattern(this, 'price_sma_4y'), + bps: createMetricPattern1(this, 'price_sma_4y_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_4y_ratio'), + }, + _200dX24: createCentsSatsUsdPattern(this, 'price_sma_200d_x2_4'), + _200dX08: createCentsSatsUsdPattern(this, 'price_sma_200d_x0_8'), + _350dX2: createCentsSatsUsdPattern(this, 'price_sma_350d_x2'), + }, + ema: { + _1w: { + price: createCentsSatsUsdPattern(this, 'price_ema_1w'), + bps: createMetricPattern1(this, 'price_ema_1w_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_1w_ratio'), + }, + _8d: { + price: createCentsSatsUsdPattern(this, 'price_ema_8d'), + bps: createMetricPattern1(this, 'price_ema_8d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_8d_ratio'), + }, + _12d: { + price: createCentsSatsUsdPattern(this, 'price_ema_12d'), + bps: createMetricPattern1(this, 'price_ema_12d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_12d_ratio'), + }, + _13d: { + price: createCentsSatsUsdPattern(this, 'price_ema_13d'), + bps: createMetricPattern1(this, 'price_ema_13d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_13d_ratio'), + }, + _21d: { + price: createCentsSatsUsdPattern(this, 'price_ema_21d'), + bps: createMetricPattern1(this, 'price_ema_21d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_21d_ratio'), + }, + _26d: { + price: createCentsSatsUsdPattern(this, 'price_ema_26d'), + bps: createMetricPattern1(this, 'price_ema_26d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_26d_ratio'), + }, + _1m: { + price: createCentsSatsUsdPattern(this, 'price_ema_1m'), + bps: createMetricPattern1(this, 'price_ema_1m_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_1m_ratio'), + }, + _34d: { + price: createCentsSatsUsdPattern(this, 'price_ema_34d'), + bps: createMetricPattern1(this, 'price_ema_34d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_34d_ratio'), + }, + _55d: { + price: createCentsSatsUsdPattern(this, 'price_ema_55d'), + bps: createMetricPattern1(this, 'price_ema_55d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_55d_ratio'), + }, + _89d: { + price: createCentsSatsUsdPattern(this, 'price_ema_89d'), + bps: createMetricPattern1(this, 'price_ema_89d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_89d_ratio'), + }, + _144d: { + price: createCentsSatsUsdPattern(this, 'price_ema_144d'), + bps: createMetricPattern1(this, 'price_ema_144d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_144d_ratio'), + }, + _200d: { + price: createCentsSatsUsdPattern(this, 'price_ema_200d'), + bps: createMetricPattern1(this, 'price_ema_200d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_200d_ratio'), + }, + _1y: { + price: createCentsSatsUsdPattern(this, 'price_ema_1y'), + bps: createMetricPattern1(this, 'price_ema_1y_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_1y_ratio'), + }, + _2y: { + price: createCentsSatsUsdPattern(this, 'price_ema_2y'), + bps: createMetricPattern1(this, 'price_ema_2y_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_2y_ratio'), + }, + _200w: { + price: createCentsSatsUsdPattern(this, 'price_ema_200w'), + bps: createMetricPattern1(this, 'price_ema_200w_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_200w_ratio'), + }, + _4y: { + price: createCentsSatsUsdPattern(this, 'price_ema_4y'), + bps: createMetricPattern1(this, 'price_ema_4y_ratio_bps'), + ratio: createMetricPattern1(this, 'price_ema_4y_ratio'), + }, + }, }, dca: { dcaSatsPerDay: createMetricPattern18(this, 'dca_sats_per_day'), @@ -7066,28 +8216,28 @@ class BrkClient extends BrkClientBase { pools: { heightToPool: createMetricPattern18(this, 'pool'), major: { - unknown: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'unknown'), - luxor: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'luxor'), - btccom: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'btccom'), - btctop: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'btctop'), - btcguild: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'btcguild'), - eligius: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'eligius'), - f2pool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'f2pool'), - braiinspool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'braiinspool'), - antpool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'antpool'), - btcc: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'btcc'), - bwpool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'bwpool'), - bitfury: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'bitfury'), - viabtc: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'viabtc'), - poolin: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'poolin'), - spiderpool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'spiderpool'), - binancepool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'binancepool'), - foundryusa: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'foundryusa'), - sbicrypto: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'sbicrypto'), - marapool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'marapool'), - secpool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'secpool'), - ocean: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'ocean'), - whitepool: create_1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(this, 'whitepool'), + unknown: createBlocksDominanceRewardsPattern(this, 'unknown'), + luxor: createBlocksDominanceRewardsPattern(this, 'luxor'), + btccom: createBlocksDominanceRewardsPattern(this, 'btccom'), + btctop: createBlocksDominanceRewardsPattern(this, 'btctop'), + btcguild: createBlocksDominanceRewardsPattern(this, 'btcguild'), + eligius: createBlocksDominanceRewardsPattern(this, 'eligius'), + f2pool: createBlocksDominanceRewardsPattern(this, 'f2pool'), + braiinspool: createBlocksDominanceRewardsPattern(this, 'braiinspool'), + antpool: createBlocksDominanceRewardsPattern(this, 'antpool'), + btcc: createBlocksDominanceRewardsPattern(this, 'btcc'), + bwpool: createBlocksDominanceRewardsPattern(this, 'bwpool'), + bitfury: createBlocksDominanceRewardsPattern(this, 'bitfury'), + viabtc: createBlocksDominanceRewardsPattern(this, 'viabtc'), + poolin: createBlocksDominanceRewardsPattern(this, 'poolin'), + spiderpool: createBlocksDominanceRewardsPattern(this, 'spiderpool'), + binancepool: createBlocksDominanceRewardsPattern(this, 'binancepool'), + foundryusa: createBlocksDominanceRewardsPattern(this, 'foundryusa'), + sbicrypto: createBlocksDominanceRewardsPattern(this, 'sbicrypto'), + marapool: createBlocksDominanceRewardsPattern(this, 'marapool'), + secpool: createBlocksDominanceRewardsPattern(this, 'secpool'), + ocean: createBlocksDominanceRewardsPattern(this, 'ocean'), + whitepool: createBlocksDominanceRewardsPattern(this, 'whitepool'), }, minor: { blockfills: createBlocksDominancePattern(this, 'blockfills'), @@ -7272,65 +8422,64 @@ class BrkClient extends BrkClientBase { }, utxoCohorts: { all: { - supply: createDeltaHalvedTotalPattern(this, 'supply'), - outputs: createUtxoPattern(this, 'utxo_count'), - activity: createCoinblocksCoindaysSentPattern2(this, ''), - realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, ''), + supply: createDeltaHalvedTotalPattern2(this, 'supply'), + outputs: createUtxoPattern3(this, 'utxo_count'), + activity: createCoinblocksCoindaysDormancySentVelocityPattern(this, ''), + realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(this, ''), costBasis: createInvestedMaxMinPercentilesPattern(this, ''), - unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, ''), - adjusted: { - adjustedValueCreated: createMetricPattern1(this, 'adjusted_value_created'), - adjustedValueDestroyed: createMetricPattern1(this, 'adjusted_value_destroyed'), - adjustedValueCreatedSum: create_1m1w1y24hPattern(this, 'adjusted_value_created'), - adjustedValueDestroyedSum: create_1m1w1y24hPattern(this, 'adjusted_value_destroyed'), - adjustedSopr: create_1m1w1y24hPattern(this, 'adjusted_sopr'), - }, + unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern(this, ''), relative: { - supplyInProfitRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_profit_rel_to_own_supply'), - supplyInLossRelToOwnSupply: createBpsPercentRatioPattern(this, 'supply_in_loss_rel_to_own_supply'), - unrealizedProfitRelToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_market_cap'), - unrealizedLossRelToMarketCap: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_market_cap'), - netUnrealizedPnlRelToMarketCap: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_market_cap'), - nupl: createMetricPattern1(this, 'nupl'), - unrealizedProfitRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_profit_rel_to_own_gross_pnl'), - unrealizedLossRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'unrealized_loss_rel_to_own_gross_pnl'), - netUnrealizedPnlRelToOwnGrossPnl: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'), + supply: { + inProfit: createRelPattern2(this, 'supply_in_profit_rel_to_own_supply'), + inLoss: createRelPattern2(this, 'supply_in_loss_rel_to_own_supply'), + }, + unrealized: { + profit: createRelPattern3(this, 'unrealized_profit_rel_to'), + loss: createRelPattern3(this, 'unrealized_loss_rel_to'), + netPnl: { + relToOwnGrossPnl: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_rel_to_own_gross_pnl'), + }, + }, }, - dormancy: createMetricPattern1(this, 'dormancy'), - velocity: createMetricPattern1(this, 'velocity'), - supplyDeltaExtended: create_24hChangeRatePattern2(this, 'supply_delta'), - utxoCountDeltaExtended: create_24hChangeRatePattern2(this, 'utxo_count_delta'), }, sth: { - supply: createDeltaHalvedTotalPattern(this, 'sth_supply'), - outputs: createUtxoPattern(this, 'sth_utxo_count'), - activity: createCoinblocksCoindaysSentPattern2(this, 'sth'), - realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, 'sth'), + realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(this, 'sth'), + supply: createDeltaHalvedTotalPattern2(this, 'sth_supply'), + outputs: createUtxoPattern3(this, 'sth_utxo_count'), + activity: createCoinblocksCoindaysDormancySentVelocityPattern(this, 'sth'), costBasis: createInvestedMaxMinPercentilesPattern(this, 'sth'), - unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, 'sth'), - relative: createNetNuplSupplyUnrealizedPattern2(this, 'sth'), - dormancy: createMetricPattern1(this, 'sth_dormancy'), - velocity: createMetricPattern1(this, 'sth_velocity'), - supplyDeltaExtended: create_24hChangeRatePattern2(this, 'sth_supply_delta'), - utxoCountDeltaExtended: create_24hChangeRatePattern2(this, 'sth_utxo_count_delta'), - adjustedValueCreated: createMetricPattern1(this, 'sth_adjusted_value_created'), - adjustedValueDestroyed: createMetricPattern1(this, 'sth_adjusted_value_destroyed'), - adjustedValueCreatedSum: create_1m1w1y24hPattern(this, 'sth_adjusted_value_created'), - adjustedValueDestroyedSum: create_1m1w1y24hPattern(this, 'sth_adjusted_value_destroyed'), - adjustedSopr: create_1m1w1y24hPattern(this, 'sth_adjusted_sopr'), + unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern(this, 'sth'), + relative: createSupplyUnrealizedPattern2(this, 'sth'), }, lth: { - supply: createDeltaHalvedTotalPattern(this, 'lth_supply'), - outputs: createUtxoPattern(this, 'lth_utxo_count'), - activity: createCoinblocksCoindaysSentPattern2(this, 'lth'), - realized: createCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(this, 'lth'), + supply: createDeltaHalvedTotalPattern2(this, 'lth_supply'), + outputs: createUtxoPattern3(this, 'lth_utxo_count'), + activity: createCoinblocksCoindaysDormancySentVelocityPattern(this, 'lth'), + realized: { + profit: createCentsCumulativeFlowRelSumUsdValuePattern(this, 'lth'), + loss: createCapitulationCentsCumulativeNegRelSumUsdValuePattern(this, 'lth'), + grossPnl: createCentsSellSumUsdPattern(this, 'lth'), + netPnl: createChangeCumulativeDeltaRawRelSumPattern(this, 'lth_net'), + sopr: { + valueCreatedSum: create_1m1w1yPattern(this, 'lth_value_created'), + valueDestroyedSum: create_1m1w1yPattern(this, 'lth_value_destroyed'), + ratio: create_1m1w1y24hPattern(this, 'lth_sopr'), + valueCreated: createRawSumPattern(this, 'lth_value_created'), + valueDestroyed: createRawSumPattern(this, 'lth_value_destroyed'), + }, + sent: createInPattern3(this, 'lth_sent_in'), + peakRegret: createCumulativeHeightRelPattern(this, 'lth_realized_peak_regret'), + investor: createCapLowerPriceUpperPattern(this, 'lth'), + profitToLossRatio: create_1m1w1y24hPattern(this, 'lth_realized_profit_to_loss_ratio'), + cap: createCentsDeltaRawRelUsdPattern(this, 'lth'), + priceRatio: createBpsPercentilesRatioStdPattern(this, 'lth_realized_price_ratio'), + price: createCentsSatsUsdPattern(this, 'lth_realized_price'), + mvrv: createMetricPattern1(this, 'lth_mvrv'), + nupl: createBpsRatioPattern(this, 'lth_nupl_ratio'), + }, costBasis: createInvestedMaxMinPercentilesPattern(this, 'lth'), - unrealized: createGreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(this, 'lth'), - relative: createNetNuplSupplyUnrealizedPattern2(this, 'lth'), - dormancy: createMetricPattern1(this, 'lth_dormancy'), - velocity: createMetricPattern1(this, 'lth_velocity'), - supplyDeltaExtended: create_24hChangeRatePattern2(this, 'lth_supply_delta'), - utxoCountDeltaExtended: create_24hChangeRatePattern2(this, 'lth_utxo_count_delta'), + unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern(this, 'lth'), + relative: createSupplyUnrealizedPattern2(this, 'lth'), }, ageRange: { upTo1h: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern(this, 'utxos_under_1h_old'), @@ -7423,64 +8572,64 @@ class BrkClient extends BrkClientBase { _2026: createActivityOutputsRealizedRelativeSupplyUnrealizedPattern2(this, 'class_2026'), }, geAmount: { - _1sat: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1sat'), - _10sats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10sats'), - _100sats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_100sats'), - _1kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1k_sats'), - _10kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10k_sats'), - _100kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_100k_sats'), - _1mSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1m_sats'), - _10mSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10m_sats'), - _1btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1btc'), - _10btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10btc'), - _100btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_100btc'), - _1kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_1k_btc'), - _10kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_over_10k_btc'), + _1sat: createOutputsRealizedSupplyPattern(this, 'utxos_over_1sat'), + _10sats: createOutputsRealizedSupplyPattern(this, 'utxos_over_10sats'), + _100sats: createOutputsRealizedSupplyPattern(this, 'utxos_over_100sats'), + _1kSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_1k_sats'), + _10kSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_10k_sats'), + _100kSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_100k_sats'), + _1mSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_1m_sats'), + _10mSats: createOutputsRealizedSupplyPattern(this, 'utxos_over_10m_sats'), + _1btc: createOutputsRealizedSupplyPattern(this, 'utxos_over_1btc'), + _10btc: createOutputsRealizedSupplyPattern(this, 'utxos_over_10btc'), + _100btc: createOutputsRealizedSupplyPattern(this, 'utxos_over_100btc'), + _1kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_over_1k_btc'), + _10kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_over_10k_btc'), }, amountRange: { - _0sats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_with_0sats'), - _1satTo10sats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_1sat_under_10sats'), - _10satsTo100sats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_10sats_under_100sats'), - _100satsTo1kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_100sats_under_1k_sats'), - _1kSatsTo10kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_1k_sats_under_10k_sats'), - _10kSatsTo100kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_10k_sats_under_100k_sats'), - _100kSatsTo1mSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_100k_sats_under_1m_sats'), - _1mSatsTo10mSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_1m_sats_under_10m_sats'), - _10mSatsTo1btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_10m_sats_under_1btc'), - _1btcTo10btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_1btc_under_10btc'), - _10btcTo100btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_10btc_under_100btc'), - _100btcTo1kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_100btc_under_1k_btc'), - _1kBtcTo10kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_1k_btc_under_10k_btc'), - _10kBtcTo100kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_10k_btc_under_100k_btc'), - _100kBtcOrMore: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_above_100k_btc'), + _0sats: createOutputsRealizedSupplyPattern(this, 'utxos_with_0sats'), + _1satTo10sats: createOutputsRealizedSupplyPattern(this, 'utxos_above_1sat_under_10sats'), + _10satsTo100sats: createOutputsRealizedSupplyPattern(this, 'utxos_above_10sats_under_100sats'), + _100satsTo1kSats: createOutputsRealizedSupplyPattern(this, 'utxos_above_100sats_under_1k_sats'), + _1kSatsTo10kSats: createOutputsRealizedSupplyPattern(this, 'utxos_above_1k_sats_under_10k_sats'), + _10kSatsTo100kSats: createOutputsRealizedSupplyPattern(this, 'utxos_above_10k_sats_under_100k_sats'), + _100kSatsTo1mSats: createOutputsRealizedSupplyPattern(this, 'utxos_above_100k_sats_under_1m_sats'), + _1mSatsTo10mSats: createOutputsRealizedSupplyPattern(this, 'utxos_above_1m_sats_under_10m_sats'), + _10mSatsTo1btc: createOutputsRealizedSupplyPattern(this, 'utxos_above_10m_sats_under_1btc'), + _1btcTo10btc: createOutputsRealizedSupplyPattern(this, 'utxos_above_1btc_under_10btc'), + _10btcTo100btc: createOutputsRealizedSupplyPattern(this, 'utxos_above_10btc_under_100btc'), + _100btcTo1kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_above_100btc_under_1k_btc'), + _1kBtcTo10kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_above_1k_btc_under_10k_btc'), + _10kBtcTo100kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_above_10k_btc_under_100k_btc'), + _100kBtcOrMore: createOutputsRealizedSupplyPattern(this, 'utxos_above_100k_btc'), }, ltAmount: { - _10sats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10sats'), - _100sats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100sats'), - _1kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1k_sats'), - _10kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10k_sats'), - _100kSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100k_sats'), - _1mSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1m_sats'), - _10mSats: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10m_sats'), - _1btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1btc'), - _10btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10btc'), - _100btc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100btc'), - _1kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_1k_btc'), - _10kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_10k_btc'), - _100kBtc: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'utxos_under_100k_btc'), + _10sats: createOutputsRealizedSupplyPattern(this, 'utxos_under_10sats'), + _100sats: createOutputsRealizedSupplyPattern(this, 'utxos_under_100sats'), + _1kSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_1k_sats'), + _10kSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_10k_sats'), + _100kSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_100k_sats'), + _1mSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_1m_sats'), + _10mSats: createOutputsRealizedSupplyPattern(this, 'utxos_under_10m_sats'), + _1btc: createOutputsRealizedSupplyPattern(this, 'utxos_under_1btc'), + _10btc: createOutputsRealizedSupplyPattern(this, 'utxos_under_10btc'), + _100btc: createOutputsRealizedSupplyPattern(this, 'utxos_under_100btc'), + _1kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_under_1k_btc'), + _10kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_under_10k_btc'), + _100kBtc: createOutputsRealizedSupplyPattern(this, 'utxos_under_100k_btc'), }, type: { - p2pk65: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2pk65'), - p2pk33: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2pk33'), - p2pkh: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2pkh'), - p2ms: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2ms'), - p2sh: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2sh'), - p2wpkh: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2wpkh'), - p2wsh: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2wsh'), - p2tr: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2tr'), - p2a: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'p2a'), - unknown: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'unknown_outputs'), - empty: createActivityOutputsRealizedSupplyUnrealizedPattern(this, 'empty_outputs'), + p2pk65: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2pk65'), + p2pk33: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2pk33'), + p2pkh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2pkh'), + p2ms: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2ms'), + p2sh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2sh'), + p2wpkh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2wpkh'), + p2wsh: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2wsh'), + p2tr: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2tr'), + p2a: createOutputsRealizedSupplyUnrealizedPattern(this, 'p2a'), + unknown: createOutputsRealizedSupplyUnrealizedPattern(this, 'unknown_outputs'), + empty: createOutputsRealizedSupplyUnrealizedPattern(this, 'empty_outputs'), }, profitability: { range: { @@ -7566,51 +8715,51 @@ class BrkClient extends BrkClientBase { }, addressCohorts: { geAmount: { - _1sat: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1sat'), - _10sats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10sats'), - _100sats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100sats'), - _1kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_sats'), - _10kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_sats'), - _100kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100k_sats'), - _1mSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1m_sats'), - _10mSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10m_sats'), - _1btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1btc'), - _10btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10btc'), - _100btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_100btc'), - _1kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_1k_btc'), - _10kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_over_10k_btc'), + _1sat: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_1sat'), + _10sats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_10sats'), + _100sats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_100sats'), + _1kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_1k_sats'), + _10kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_10k_sats'), + _100kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_100k_sats'), + _1mSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_1m_sats'), + _10mSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_10m_sats'), + _1btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_1btc'), + _10btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_10btc'), + _100btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_100btc'), + _1kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_1k_btc'), + _10kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_over_10k_btc'), }, amountRange: { - _0sats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_with_0sats'), - _1satTo10sats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_1sat_under_10sats'), - _10satsTo100sats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_10sats_under_100sats'), - _100satsTo1kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_100sats_under_1k_sats'), - _1kSatsTo10kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_1k_sats_under_10k_sats'), - _10kSatsTo100kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_10k_sats_under_100k_sats'), - _100kSatsTo1mSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_100k_sats_under_1m_sats'), - _1mSatsTo10mSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_1m_sats_under_10m_sats'), - _10mSatsTo1btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_10m_sats_under_1btc'), - _1btcTo10btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_1btc_under_10btc'), - _10btcTo100btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_10btc_under_100btc'), - _100btcTo1kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_100btc_under_1k_btc'), - _1kBtcTo10kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_1k_btc_under_10k_btc'), - _10kBtcTo100kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_10k_btc_under_100k_btc'), - _100kBtcOrMore: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_above_100k_btc'), + _0sats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_with_0sats'), + _1satTo10sats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_1sat_under_10sats'), + _10satsTo100sats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_10sats_under_100sats'), + _100satsTo1kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_100sats_under_1k_sats'), + _1kSatsTo10kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_1k_sats_under_10k_sats'), + _10kSatsTo100kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_10k_sats_under_100k_sats'), + _100kSatsTo1mSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_100k_sats_under_1m_sats'), + _1mSatsTo10mSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_1m_sats_under_10m_sats'), + _10mSatsTo1btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_10m_sats_under_1btc'), + _1btcTo10btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_1btc_under_10btc'), + _10btcTo100btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_10btc_under_100btc'), + _100btcTo1kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_100btc_under_1k_btc'), + _1kBtcTo10kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_1k_btc_under_10k_btc'), + _10kBtcTo100kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_10k_btc_under_100k_btc'), + _100kBtcOrMore: createAddrOutputsRealizedSupplyPattern(this, 'addrs_above_100k_btc'), }, ltAmount: { - _10sats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10sats'), - _100sats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100sats'), - _1kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_sats'), - _10kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_sats'), - _100kSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_sats'), - _1mSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1m_sats'), - _10mSats: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10m_sats'), - _1btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1btc'), - _10btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10btc'), - _100btc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100btc'), - _1kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_1k_btc'), - _10kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_10k_btc'), - _100kBtc: createActivityAddrOutputsRealizedSupplyUnrealizedPattern(this, 'addrs_under_100k_btc'), + _10sats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_10sats'), + _100sats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_100sats'), + _1kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_1k_sats'), + _10kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_10k_sats'), + _100kSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_100k_sats'), + _1mSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_1m_sats'), + _10mSats: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_10m_sats'), + _1btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_1btc'), + _10btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_10btc'), + _100btc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_100btc'), + _1kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_1k_btc'), + _10kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_10k_btc'), + _100kBtc: createAddrOutputsRealizedSupplyPattern(this, 'addrs_under_100k_btc'), }, }, addrCount: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern(this, 'addr_count'), @@ -7649,8 +8798,8 @@ class BrkClient extends BrkClientBase { p2tr: createChangeRatePattern2(this, 'p2tr_addr_count'), p2a: createChangeRatePattern2(this, 'p2a_addr_count'), }, - fundedaddressindex: createMetricPattern34(this, 'fundedaddressindex'), - emptyaddressindex: createMetricPattern35(this, 'emptyaddressindex'), + fundedAddressIndex: createMetricPattern34(this, 'funded_address_index'), + emptyAddressIndex: createMetricPattern35(this, 'empty_address_index'), }, supply: { circulating: createBtcCentsSatsUsdPattern(this, 'circulating_supply'), diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 3beee10bb..e430c8c52 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -88,11 +88,11 @@ Limit = int Date = int Day1 = int Day3 = int -Epoch = int # US Dollar amount as floating point Dollars = float EmptyAddressIndex = TypeIndex EmptyOutputIndex = TypeIndex +Epoch = int # Fee rate in sats/vB FeeRate = float FundedAddressIndex = TypeIndex @@ -199,7 +199,7 @@ Year1 = int Year10 = int # Aggregation dimension for querying metrics. Includes time-based (date, week, month, year), # block-based (height, txindex), and address/output type indexes. -Index = Literal["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halvingepoch", "difficultyepoch", "height", "txindex", "txinindex", "txoutindex", "emptyoutputindex", "opreturnindex", "p2aaddressindex", "p2msoutputindex", "p2pk33addressindex", "p2pk65addressindex", "p2pkhaddressindex", "p2shaddressindex", "p2traddressindex", "p2wpkhaddressindex", "p2wshaddressindex", "unknownoutputindex", "fundedaddressindex", "emptyaddressindex", "pairoutputindex"] +Index = Literal["minute10", "minute30", "hour1", "hour4", "hour12", "day1", "day3", "week1", "month1", "month3", "month6", "year1", "year10", "halving", "epoch", "height", "txindex", "txinindex", "txoutindex", "emptyoutputindex", "opreturnindex", "p2aaddressindex", "p2msoutputindex", "p2pk33addressindex", "p2pk65addressindex", "p2pkhaddressindex", "p2shaddressindex", "p2traddressindex", "p2wpkhaddressindex", "p2wshaddressindex", "unknownoutputindex", "fundedaddressindex", "emptyaddressindex", "pairoutputindex"] # Hierarchical tree node for organizing metrics into categories TreeNode = Union[dict[str, "TreeNode"], "MetricLeafWithSchema"] class AddressChainStats(TypedDict): @@ -521,6 +521,22 @@ class EmptyAddressData(TypedDict): funded_txo_count: int transfered: Sats +class ErrorDetail(TypedDict): + """ + Attributes: + type: Error category: "invalid_request", "forbidden", "not_found", "unavailable", or "internal" + code: Machine-readable error code (e.g. "invalid_address", "metric_not_found") + message: Human-readable description + doc_url: Link to API documentation + """ + type: str + code: str + message: str + doc_url: str + +class ErrorBody(TypedDict): + error: ErrorDetail + class FundedAddressData(TypedDict): """ Data for a funded (non-empty) address with current balance @@ -575,12 +591,25 @@ class Health(TypedDict): Attributes: started_at: Server start time (ISO 8601) uptime_seconds: Uptime in seconds + indexed_height: Height of the last indexed block + computed_height: Height of the last computed block (metrics) + tip_height: Height of the chain tip (from Bitcoin node) + blocks_behind: Number of blocks behind the tip + last_indexed_at: Human-readable timestamp of the last indexed block (ISO 8601) + last_indexed_at_unix: Unix timestamp of the last indexed block """ status: str service: str + version: str timestamp: str started_at: str uptime_seconds: int + indexed_height: Height + computed_height: Height + tip_height: Height + blocks_behind: Height + last_indexed_at: str + last_indexed_at_unix: Timestamp class HeightParam(TypedDict): height: Height @@ -905,12 +934,14 @@ class SyncStatus(TypedDict): Attributes: indexed_height: Height of the last indexed block + computed_height: Height of the last computed block (metrics) tip_height: Height of the chain tip (from Bitcoin node) blocks_behind: Number of blocks behind the tip last_indexed_at: Human-readable timestamp of the last indexed block (ISO 8601) last_indexed_at_unix: Unix timestamp of the last indexed block """ indexed_height: Height + computed_height: Height tip_height: Height blocks_behind: Height last_indexed_at: str @@ -1571,8 +1602,8 @@ class MetricPattern(Protocol[T]): # Static index tuples -_i1 = ('minute10', 'minute30', 'hour1', 'hour4', 'hour12', 'day1', 'day3', 'week1', 'month1', 'month3', 'month6', 'year1', 'year10', 'halvingepoch', 'difficultyepoch', 'height') -_i2 = ('minute10', 'minute30', 'hour1', 'hour4', 'hour12', 'day1', 'day3', 'week1', 'month1', 'month3', 'month6', 'year1', 'year10', 'halvingepoch', 'difficultyepoch') +_i1 = ('minute10', 'minute30', 'hour1', 'hour4', 'hour12', 'day1', 'day3', 'week1', 'month1', 'month3', 'month6', 'year1', 'year10', 'halving', 'epoch', 'height') +_i2 = ('minute10', 'minute30', 'hour1', 'hour4', 'hour12', 'day1', 'day3', 'week1', 'month1', 'month3', 'month6', 'year1', 'year10', 'halving', 'epoch') _i3 = ('minute10',) _i4 = ('minute30',) _i5 = ('hour1',) @@ -1586,8 +1617,8 @@ _i12 = ('month3',) _i13 = ('month6',) _i14 = ('year1',) _i15 = ('year10',) -_i16 = ('halvingepoch',) -_i17 = ('difficultyepoch',) +_i16 = ('halving',) +_i17 = ('epoch',) _i18 = ('height',) _i19 = ('txindex',) _i20 = ('txinindex',) @@ -1630,8 +1661,8 @@ class _MetricPattern1By(Generic[T]): def month6(self) -> DateMetricEndpointBuilder[T]: return _dep(self._c, self._n, 'month6') def year1(self) -> DateMetricEndpointBuilder[T]: return _dep(self._c, self._n, 'year1') def year10(self) -> DateMetricEndpointBuilder[T]: return _dep(self._c, self._n, 'year10') - def halvingepoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'halvingepoch') - def difficultyepoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'difficultyepoch') + def halving(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'halving') + def epoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'epoch') def height(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'height') class MetricPattern1(Generic[T]): @@ -1657,8 +1688,8 @@ class _MetricPattern2By(Generic[T]): def month6(self) -> DateMetricEndpointBuilder[T]: return _dep(self._c, self._n, 'month6') def year1(self) -> DateMetricEndpointBuilder[T]: return _dep(self._c, self._n, 'year1') def year10(self) -> DateMetricEndpointBuilder[T]: return _dep(self._c, self._n, 'year10') - def halvingepoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'halvingepoch') - def difficultyepoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'difficultyepoch') + def halving(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'halving') + def epoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'epoch') class MetricPattern2(Generic[T]): by: _MetricPattern2By[T] @@ -1826,7 +1857,7 @@ class MetricPattern15(Generic[T]): class _MetricPattern16By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def halvingepoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'halvingepoch') + def halving(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'halving') class MetricPattern16(Generic[T]): by: _MetricPattern16By[T] @@ -1838,7 +1869,7 @@ class MetricPattern16(Generic[T]): class _MetricPattern17By(Generic[T]): def __init__(self, c: BrkClientBase, n: str): self._c, self._n = c, n - def difficultyepoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'difficultyepoch') + def epoch(self) -> MetricEndpointBuilder[T]: return _ep(self._c, self._n, 'epoch') class MetricPattern17(Generic[T]): by: _MetricPattern17By[T] @@ -2066,139 +2097,6 @@ class MetricPattern35(Generic[T]): # Reusable structural pattern classes -class CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cap_raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'cap_raw')) - self.capitulation_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'capitulation_flow')) - self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_gross_pnl')) - self.gross_pnl_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'gross_pnl_sum')) - self.investor_cap_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, _m(acc, 'investor_cap_raw')) - self.investor_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'investor_price')) - self.investor_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'investor_price_ratio')) - self.investor_price_ratio_percentiles: RatioPattern = RatioPattern(client, _m(acc, 'investor_price_ratio')) - self.loss_value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_created')) - self.loss_value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'loss_value_created')) - self.loss_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_destroyed')) - self.loss_value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'loss_value_destroyed')) - self.lower_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'lower_price_band')) - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) - self.net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_market_cap')) - self.net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_pnl_change_1m_rel_to_realized_cap')) - self.net_pnl_delta: ChangeRatePattern3 = ChangeRatePattern3(client, _m(acc, 'net_pnl_delta')) - self.net_pnl_delta_extended: _24hChangeRatePattern = _24hChangeRatePattern(client, _m(acc, 'net_pnl_delta')) - self.net_realized_pnl: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl')) - self.net_realized_pnl_cumulative: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl_cumulative')) - self.net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_realized_pnl_rel_to_realized_cap')) - self.net_realized_pnl_sum: _24hPattern[CentsSigned] = _24hPattern(client, _m(acc, 'net_realized_pnl_24h')) - self.net_realized_pnl_sum_extended: _1m1w1yPattern[CentsSigned] = _1m1w1yPattern(client, _m(acc, 'net_realized_pnl')) - self.peak_regret: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_peak_regret')) - self.peak_regret_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_peak_regret_rel_to_realized_cap')) - self.profit_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'profit_flow')) - self.profit_value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_created')) - self.profit_value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'profit_value_created')) - self.profit_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_destroyed')) - self.profit_value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'profit_value_destroyed')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_cap_delta: ChangeRatePattern3 = ChangeRatePattern3(client, _m(acc, 'realized_cap_delta')) - self.realized_cap_delta_extended: _24hChangeRatePattern = _24hChangeRatePattern(client, _m(acc, 'realized_cap_delta')) - self.realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_cap_rel_to_own_market_cap')) - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) - self.realized_loss_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')) - self.realized_loss_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_loss_24h')) - self.realized_loss_sum_extended: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, _m(acc, 'realized_loss')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_price_ratio_percentiles: RatioPattern = RatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_price_ratio_std_dev: RatioPattern2 = RatioPattern2(client, _m(acc, 'realized_price_ratio')) - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_rel_to_realized_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')) - self.realized_profit_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_profit_24h')) - self.realized_profit_sum_extended: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')) - self.sell_side_risk_ratio: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'sell_side_risk_ratio')) - self.sent_in_loss: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent_in_loss')) - self.sent_in_loss_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_in_loss_24h')) - self.sent_in_loss_sum_extended: _1m1w1yPattern[Sats] = _1m1w1yPattern(client, _m(acc, 'sent_in_loss')) - self.sent_in_profit: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent_in_profit')) - self.sent_in_profit_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_in_profit_24h')) - self.sent_in_profit_sum_extended: _1m1w1yPattern[Sats] = _1m1w1yPattern(client, _m(acc, 'sent_in_profit')) - self.sopr: _24hPattern[StoredF64] = _24hPattern(client, _m(acc, 'sopr_24h')) - self.sopr_extended: _1m1w1yPattern[StoredF64] = _1m1w1yPattern(client, _m(acc, 'sopr')) - self.upper_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'upper_price_band')) - self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_created')) - self.value_created_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'value_created_24h')) - self.value_created_sum_extended: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, _m(acc, 'value_created')) - self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) - self.value_destroyed_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'value_destroyed_24h')) - self.value_destroyed_sum_extended: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, _m(acc, 'value_destroyed')) - -class _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._0sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '0sd_4y')) - self.m0_5sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'm0_5sd_4y')) - self.m0_5sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'm0_5sd_4y')) - self.m1_5sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'm1_5sd_4y')) - self.m1_5sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'm1_5sd_4y')) - self.m1sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'm1sd_4y')) - self.m1sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'm1sd_4y')) - self.m2_5sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'm2_5sd_4y')) - self.m2_5sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'm2_5sd_4y')) - self.m2sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'm2sd_4y')) - self.m2sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'm2sd_4y')) - self.m3sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'm3sd_4y')) - self.m3sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'm3sd_4y')) - self.p0_5sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'p0_5sd_4y')) - self.p0_5sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'p0_5sd_4y')) - self.p1_5sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'p1_5sd_4y')) - self.p1_5sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'p1_5sd_4y')) - self.p1sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'p1sd_4y')) - self.p1sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'p1sd_4y')) - self.p2_5sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'p2_5sd_4y')) - self.p2_5sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'p2_5sd_4y')) - self.p2sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'p2sd_4y')) - self.p2sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'p2sd_4y')) - self.p3sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'p3sd_4y')) - self.p3sd_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'p3sd_4y')) - self.sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sd_4y')) - self.sma: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sma_4y')) - self.zscore: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'zscore_4y')) - -class MvrvNegNetRealizedSentSoprValuePattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) - self.net_realized_pnl: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl')) - self.net_realized_pnl_sum: _24hPattern[CentsSigned] = _24hPattern(client, _m(acc, 'net_realized_pnl_24h')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_cap_delta: ChangeRatePattern3 = ChangeRatePattern3(client, _m(acc, 'realized_cap_delta')) - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) - self.realized_loss_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_loss_24h')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_profit_24h')) - self.sent_in_loss: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent_in_loss')) - self.sent_in_loss_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_in_loss_24h')) - self.sent_in_profit: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent_in_profit')) - self.sent_in_profit_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_in_profit_24h')) - self.sopr: _24hPattern[StoredF64] = _24hPattern(client, _m(acc, 'sopr_24h')) - self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_created')) - self.value_created_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'value_created_24h')) - self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) - self.value_destroyed_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'value_destroyed_24h')) - class Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern: """Pattern struct for repeated tree structure.""" @@ -2224,114 +2122,47 @@ class Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct7 self.pct90: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct90')) self.pct95: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct95')) -class MvrvNegNetRealizedSoprValuePattern: +class _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" + self._0sd: PriceValuePattern = PriceValuePattern(client, _m(acc, '0sd_4y')) + self.m0_5sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'm0_5sd_4y')) + self.m1_5sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'm1_5sd_4y')) + self.m1sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'm1sd_4y')) + self.m2_5sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'm2_5sd_4y')) + self.m2sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'm2sd_4y')) + self.m3sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'm3sd_4y')) + self.p0_5sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'p0_5sd_4y')) + self.p1_5sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'p1_5sd_4y')) + self.p1sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'p1sd_4y')) + self.p2_5sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'p2_5sd_4y')) + self.p2sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'p2sd_4y')) + self.p3sd: PriceValuePattern = PriceValuePattern(client, _m(acc, 'p3sd_4y')) + self.sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sd_4y')) + self.sma: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sma_4y')) + self.zscore: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'zscore_4y')) + +class CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cap: CentsDeltaRawRelUsdPattern = CentsDeltaRawRelUsdPattern(client, acc) + self.gross_pnl: CentsSellSumUsdPattern = CentsSellSumUsdPattern(client, acc) + self.investor: CapLowerPriceUpperPattern = CapLowerPriceUpperPattern(client, acc) + self.loss: CapitulationCentsCumulativeNegRelSumUsdValuePattern = CapitulationCentsCumulativeNegRelSumUsdValuePattern(client, acc) self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.neg_realized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) - self.net_realized_pnl: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'net_realized_pnl')) - self.net_realized_pnl_sum: _24hPattern[CentsSigned] = _24hPattern(client, _m(acc, 'net_realized_pnl_24h')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_cap_delta: ChangeRatePattern3 = ChangeRatePattern3(client, _m(acc, 'realized_cap_delta')) - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) - self.realized_loss_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_loss_24h')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_profit_24h')) - self.sopr: _24hPattern[StoredF64] = _24hPattern(client, _m(acc, 'sopr_24h')) - self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_created')) - self.value_created_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'value_created_24h')) - self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) - self.value_destroyed_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'value_destroyed_24h')) - -class BpsRatioPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, _m(acc, 'bps')) - self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, acc) - self.ratio_pct1: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct1')) - self.ratio_pct1_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct1')) - self.ratio_pct2: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct2')) - self.ratio_pct2_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct2')) - self.ratio_pct5: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct5')) - self.ratio_pct5_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct5')) - self.ratio_pct95: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct95')) - self.ratio_pct95_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct95')) - self.ratio_pct98: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct98')) - self.ratio_pct98_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct98')) - self.ratio_pct99: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct99')) - self.ratio_pct99_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct99')) - self.ratio_sma_1m: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1m')) - self.ratio_sma_1w: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1w')) - -class GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.greed_index: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'greed_index')) - self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')) - self.invested_capital_in_loss: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'invested_capital_in_loss')) - self.invested_capital_in_loss_raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'invested_capital_in_loss_raw')) - self.invested_capital_in_profit: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'invested_capital_in_profit')) - self.invested_capital_in_profit_raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'invested_capital_in_profit_raw')) - self.investor_cap_in_loss_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, _m(acc, 'investor_cap_in_loss_raw')) - self.investor_cap_in_profit_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, _m(acc, 'investor_cap_in_profit_raw')) - self.neg_unrealized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.net_sentiment: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_sentiment')) - self.net_unrealized_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.pain_index: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'pain_index')) - self.supply_in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')) - self.supply_in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')) - self.unrealized_loss: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.unrealized_profit: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) - -class NetNuplSupplyUnrealizedPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_market_cap')) - self.net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_own_gross_pnl')) - self.net_unrealized_pnl_rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'net_unrealized_pnl_rel_to_own_market_cap')) - self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'nupl')) - self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_circulating_supply')) - self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_loss_rel_to_own_supply')) - self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_circulating_supply')) - self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_in_profit_rel_to_own_supply')) - self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_rel_to_circulating_supply')) - self.unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_market_cap')) - self.unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_gross_pnl')) - self.unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')) - self.unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_market_cap')) - self.unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_gross_pnl')) - self.unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_profit_rel_to_own_market_cap')) - -class RatioPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.ratio_pct1: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct1')) - self.ratio_pct1_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct1')) - self.ratio_pct2: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct2')) - self.ratio_pct2_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct2')) - self.ratio_pct5: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct5')) - self.ratio_pct5_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct5')) - self.ratio_pct95: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct95')) - self.ratio_pct95_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct95')) - self.ratio_pct98: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct98')) - self.ratio_pct98_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct98')) - self.ratio_pct99: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'pct99')) - self.ratio_pct99_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct99')) - self.ratio_sma_1m: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1m')) - self.ratio_sma_1w: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1w')) + self.net_pnl: ChangeCumulativeDeltaRawRelSumPattern = ChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) + self.peak_regret: CumulativeHeightRelPattern = CumulativeHeightRelPattern(client, _m(acc, 'realized_peak_regret')) + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) + self.price_ratio: BpsPercentilesRatioStdPattern = BpsPercentilesRatioStdPattern(client, _m(acc, 'realized_price_ratio')) + self.profit: CentsCumulativeFlowRelSumUsdValuePattern = CentsCumulativeFlowRelSumUsdValuePattern(client, acc) + self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')) + self.sent: InPattern3 = InPattern3(client, _m(acc, 'sent_in')) + self.sopr: AdjustedRatioValuePattern = AdjustedRatioValuePattern(client, acc) class _10y1m1w1y2y3m3y4y5y6m6y8yPattern2: """Pattern struct for repeated tree structure.""" @@ -2369,23 +2200,6 @@ class _10y1m1w1y2y3m3y4y5y6m6y8yPattern3: self._6y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '6y')) self._8y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '8y')) -class _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'dominance_1m')) - self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'dominance_1w')) - self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'dominance_1y')) - self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'dominance_24h')) - self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'rewards')) - self.bps: MetricPattern1[BasisPoints16] = MetricPattern1(client, _m(acc, 'dominance_bps')) - self.cumulative: BaseBtcCentsSatsUsdPattern = BaseBtcCentsSatsUsdPattern(client, acc) - self.height: MetricPattern18[StoredU32] = MetricPattern18(client, _m(acc, 'blocks_mined')) - self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dominance')) - self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dominance_ratio')) - self.sum: _1m1w1y24hPattern6 = _1m1w1y24hPattern6(client, acc) - class AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern: """Pattern struct for repeated tree structure.""" @@ -2396,10 +2210,10 @@ class AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern: self.max: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'max')) self.median: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'median')) self.min: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'min')) - self.pct10: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'p10')) - self.pct25: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'p25')) - self.pct75: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'p75')) - self.pct90: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'p90')) + self.pct10: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'pct10')) + self.pct25: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'pct25')) + self.pct75: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'pct75')) + self.pct90: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'pct90')) self.rolling: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern = AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, acc) self.sum: MetricPattern18[StoredU64] = MetricPattern18(client, _m(acc, 'sum')) @@ -2414,12 +2228,29 @@ class AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern: self.max: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'max')) self.median: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'median')) self.min: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'min')) - self.pct10: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p10')) - self.pct25: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p25')) - self.pct75: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p75')) - self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p90')) + self.pct10: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct10')) + self.pct25: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct25')) + self.pct75: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct75')) + self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct90')) self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'sum')) +class CapitulationCentsCumulativeNegRelSumUsdValuePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.capitulation_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'capitulation_flow')) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_cents')) + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_cumulative')) + self.neg: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) + self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'realized_loss')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_loss')) + self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_created')) + self.value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'loss_value_created')) + self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'loss_value_destroyed')) + self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'loss_value_destroyed')) + class AverageGainsLossesRsiStochPattern: """Pattern struct for repeated tree structure.""" @@ -2436,21 +2267,53 @@ class AverageGainsLossesRsiStochPattern: self.stoch_rsi_d: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'stoch_d_24h')) self.stoch_rsi_k: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'stoch_k_24h')) -class InvestedInvestorNegNetSupplyUnrealizedPattern: +class BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.invested_capital_in_loss_raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'invested_capital_in_loss_raw')) - self.invested_capital_in_profit_raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'invested_capital_in_profit_raw')) - self.investor_cap_in_loss_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, _m(acc, 'investor_cap_in_loss_raw')) - self.investor_cap_in_profit_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, _m(acc, 'investor_cap_in_profit_raw')) - self.neg_unrealized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.net_unrealized_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.supply_in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')) - self.supply_in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')) - self.unrealized_loss: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.unrealized_profit: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, _m(acc, 'bps')) + self.pct1: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct1')) + self.pct2: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct2')) + self.pct5: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct5')) + self.pct95: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct95')) + self.pct98: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct98')) + self.pct99: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct99')) + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, acc) + self.sma_1m: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1m')) + self.sma_1w: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1w')) + +class CapLossMvrvNetNuplPriceProfitSentSoprPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cap: CentsDeltaUsdPattern = CentsDeltaUsdPattern(client, _m(acc, 'realized_cap')) + self.loss: CentsCumulativeNegSumUsdPattern = CentsCumulativeNegSumUsdPattern(client, acc) + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) + self.net_pnl: RawSumPattern[CentsSigned] = RawSumPattern(client, _m(acc, 'net_realized_pnl')) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) + self.price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) + self.profit: CentsCumulativeSumUsdPattern = CentsCumulativeSumUsdPattern(client, _m(acc, 'realized_profit')) + self.sent: InPattern = InPattern(client, _m(acc, 'sent_in')) + self.sopr: RatioValuePattern = RatioValuePattern(client, acc) + +class CentsCumulativeFlowRelSumUsdValuePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_profit_cents')) + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_profit_cumulative')) + self.flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'profit_flow')) + self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'realized_profit')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_profit')) + self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_created')) + self.value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'profit_value_created')) + self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'profit_value_destroyed')) + self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'profit_value_destroyed')) class AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern: """Pattern struct for repeated tree structure.""" @@ -2476,10 +2339,10 @@ class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2: self.max: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'max')) self.median: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'median')) self.min: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'min')) - self.pct10: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'p10')) - self.pct25: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'p25')) - self.pct75: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'p75')) - self.pct90: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'p90')) + self.pct10: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct10')) + self.pct25: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct25')) + self.pct75: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct75')) + self.pct90: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'pct90')) self.sum: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'sum')) class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern: @@ -2491,27 +2354,12 @@ class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern: self.max: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'max')) self.median: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'median')) self.min: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'min')) - self.pct10: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p10')) - self.pct25: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p25')) - self.pct75: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p75')) - self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'p90')) + self.pct10: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct10')) + self.pct25: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct25')) + self.pct75: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct75')) + self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'pct90')) self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'sum')) -class MvrvRealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) - self.realized_cap_cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) - self.realized_loss: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_loss')) - self.realized_loss_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_loss_24h')) - self.realized_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) - self.realized_price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) - self.realized_profit: CumulativeHeightPattern[Cents] = CumulativeHeightPattern(client, _m(acc, 'realized_profit')) - self.realized_profit_sum: _24hPattern[Cents] = _24hPattern(client, _m(acc, 'realized_profit_24h')) - class _1m1w1y24hBtcCentsSatsUsdPattern: """Pattern struct for repeated tree structure.""" @@ -2521,24 +2369,38 @@ class _1m1w1y24hBtcCentsSatsUsdPattern: self._1w: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1w')) self._1y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1y')) self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '24h')) - self.btc: MetricPattern18[Bitcoin] = MetricPattern18(client, _m(acc, 'btc')) + self.btc: MetricPattern18[Bitcoin] = MetricPattern18(client, acc) self.cents: MetricPattern18[Cents] = MetricPattern18(client, _m(acc, 'cents')) - self.sats: MetricPattern18[Sats] = MetricPattern18(client, acc) + self.sats: MetricPattern18[Sats] = MetricPattern18(client, _m(acc, 'sats')) self.usd: MetricPattern18[Dollars] = MetricPattern18(client, _m(acc, 'usd')) -class CoinblocksCoindaysSentPattern2: +class CapLossMvrvNuplPriceProfitSoprPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.coinblocks_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinblocks_destroyed')) - self.coinblocks_destroyed_cumulative: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinblocks_destroyed_cumulative')) - self.coindays_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coindays_destroyed')) - self.coindays_destroyed_cumulative: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coindays_destroyed_cumulative')) - self.coindays_destroyed_sum: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'coindays_destroyed')) - self.sent: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent')) - self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_24h')) - self.sent_sum_extended: _1m1w1yPattern[Sats] = _1m1w1yPattern(client, _m(acc, 'sent')) + self.cap: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_cap')) + self.loss: CentsSumUsdPattern = CentsSumUsdPattern(client, _m(acc, 'realized_loss')) + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'realized_price')) + self.price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'realized_price_ratio')) + self.profit: CentsSumUsdPattern = CentsSumUsdPattern(client, _m(acc, 'realized_profit')) + self.sopr: ValuePattern = ValuePattern(client, _m(acc, 'value')) + +class Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.pct1: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct1')) + self.pct2: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct2')) + self.pct5: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct5')) + self.pct95: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct95')) + self.pct98: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct98')) + self.pct99: BpsPriceRatioPattern = BpsPriceRatioPattern(client, _m(acc, 'pct99')) + self.sma_1m: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1m')) + self.sma_1w: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'sma_1w')) class AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2549,10 +2411,10 @@ class AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern(Generic[T]): self.max: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'max')) self.median: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'median')) self.min: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'min')) - self.pct10: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'p10')) - self.pct25: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'p25')) - self.pct75: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'p75')) - self.pct90: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'p90')) + self.pct10: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'pct10')) + self.pct25: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'pct25')) + self.pct75: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'pct75')) + self.pct90: MetricPattern18[T] = MetricPattern18(client, _m(acc, 'pct90')) class _10y2y3y4y5y6y8yPattern: """Pattern struct for repeated tree structure.""" @@ -2567,54 +2429,18 @@ class _10y2y3y4y5y6y8yPattern: self._6y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '6y')) self._8y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '8y')) -class ActivityAddrOutputsRealizedSupplyUnrealizedPattern: +class _1m1w1y24hBpsPercentRatioPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.activity: SentPattern = SentPattern(client, _m(acc, 'sent')) - self.addr_count: MetricPattern1[StoredU64] = MetricPattern1(client, _m(acc, 'addr_count')) - self.addr_count_delta: ChangeRatePattern[StoredI64] = ChangeRatePattern(client, _m(acc, 'addr_count_delta')) - self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: MvrvRealizedPattern = MvrvRealizedPattern(client, acc) - self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: SupplyPattern = SupplyPattern(client, _m(acc, 'supply_in')) - -class ActivityOutputsRealizedRelativeSupplyUnrealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.activity: CoinblocksCoindaysSentPattern = CoinblocksCoindaysSentPattern(client, acc) - self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: MvrvNegNetRealizedSentSoprValuePattern = MvrvNegNetRealizedSentSoprValuePattern(client, acc) - self.relative: SupplyPattern2 = SupplyPattern2(client, _m(acc, 'supply')) - self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: InvestedInvestorNegNetSupplyUnrealizedPattern = InvestedInvestorNegNetSupplyUnrealizedPattern(client, acc) - -class ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.activity: SentPattern = SentPattern(client, _m(acc, 'sent')) - self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: MvrvNegNetRealizedSoprValuePattern = MvrvNegNetRealizedSoprValuePattern(client, acc) - self.relative: SupplyPattern2 = SupplyPattern2(client, _m(acc, 'supply')) - self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: NegNetSupplyUnrealizedPattern = NegNetSupplyUnrealizedPattern(client, acc) - -class NegNetSupplyUnrealizedPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.neg_unrealized_loss: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) - self.net_unrealized_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.supply_in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')) - self.supply_in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')) - self.unrealized_loss: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_loss')) - self.unrealized_profit: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_profit')) + self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1m')) + self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1w')) + self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1y')) + self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '24h')) + self.bps: MetricPattern1[BasisPoints16] = MetricPattern1(client, _m(acc, 'bps')) + self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, acc) + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) class _24hChangeRatePattern: """Pattern struct for repeated tree structure.""" @@ -2622,32 +2448,97 @@ class _24hChangeRatePattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self._24h: BpsCentsPercentRatioUsdPattern = BpsCentsPercentRatioUsdPattern(client, acc) + self.change: _1mPattern3 = _1mPattern3(client, _m(acc, 'change_1m')) self.change_1w: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'change_1w')) self.change_1y: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'change_1y')) + self.rate: _1mPattern2 = _1mPattern2(client, _m(acc, 'rate_1m')) self.rate_1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rate_1w')) self.rate_1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rate_1y')) -class ActivityOutputsRealizedSupplyUnrealizedPattern: +class ChangeCumulativeDeltaRawRelSumPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.activity: SentPattern = SentPattern(client, _m(acc, 'sent')) - self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) - self.realized: MvrvRealizedPattern = MvrvRealizedPattern(client, acc) - self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, _m(acc, 'supply')) - self.unrealized: SupplyPattern = SupplyPattern(client, _m(acc, 'supply_in')) + self.change_1m_rel_to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'pnl_change_1m_rel_to_market_cap')) + self.change_1m_rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'pnl_change_1m_rel_to_realized_cap')) + self.cumulative: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_pnl_cumulative')) + self.delta: _24hChangeRatePattern = _24hChangeRatePattern(client, _m(acc, 'pnl_delta')) + self.raw: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'realized_pnl')) + 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 BaseBtcCentsSatsUsdPattern: +class GrossInvestedInvestorLossNetProfitSentimentPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.base: MetricPattern1[StoredU32] = MetricPattern1(client, _m(acc, 'blocks_mined_cumulative')) - self.btc: MetricPattern1[Bitcoin] = MetricPattern1(client, _m(acc, 'rewards_cumulative_btc')) - self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'rewards_cumulative_cents')) - self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'rewards_cumulative')) - self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'rewards_cumulative_usd')) + self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')) + self.invested_capital: InPattern5 = InPattern5(client, _m(acc, 'invested_capital_in')) + self.investor_cap: InPattern2 = InPattern2(client, _m(acc, 'investor_cap_in')) + self.loss: CentsNegSumSupplyUsdPattern = CentsNegSumSupplyUsdPattern(client, acc) + self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) + self.profit: CentsSumSupplyUsdPattern = CentsSumSupplyUsdPattern(client, acc) + self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, acc) + +class ActivityOutputsRealizedRelativeSupplyUnrealizedPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.activity: CoindaysSentPattern = CoindaysSentPattern(client, acc) + self.outputs: UtxoPattern2 = UtxoPattern2(client, _m(acc, 'utxo_count')) + self.realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern = CapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc) + self.relative: SupplyPattern = SupplyPattern(client, _m(acc, 'supply')) + self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, _m(acc, 'supply')) + self.unrealized: InvestedInvestorLossNetProfitPattern = InvestedInvestorLossNetProfitPattern(client, acc) + +class ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.activity: CoindaysSentPattern = CoindaysSentPattern(client, acc) + self.outputs: UtxoPattern2 = UtxoPattern2(client, _m(acc, 'utxo_count')) + self.realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern = CapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc) + self.relative: SupplyPattern = SupplyPattern(client, _m(acc, 'supply')) + self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, _m(acc, 'supply')) + self.unrealized: LossNetProfitPattern2 = LossNetProfitPattern2(client, acc) + +class AdjustedRatioValuePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.adjusted: RatioValuePattern2 = RatioValuePattern2(client, _m(acc, 'adjusted')) + self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'sopr')) + self.value_created: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'value_created')) + self.value_created_sum: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, _m(acc, 'value_created')) + self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'value_destroyed')) + self.value_destroyed_sum: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, _m(acc, 'value_destroyed')) + +class CapLowerPriceUpperPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cap_raw: MetricPattern18[CentsSquaredSats] = MetricPattern18(client, _m(acc, 'investor_cap_raw')) + self.lower_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'lower_price_band')) + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'investor_price')) + self.price_ratio: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'investor_price_ratio')) + self.price_ratio_percentiles: Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern = Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern(client, _m(acc, 'investor_price_ratio')) + self.upper_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'upper_price_band')) + +class AddrOutputsRealizedSupplyPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.addr_count: MetricPattern1[StoredU64] = MetricPattern1(client, _m(acc, 'addr_count')) + self.addr_count_delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'addr_count_delta')) + self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) + self.realized: CapLossMvrvNuplPriceProfitSoprPattern = CapLossMvrvNuplPriceProfitSoprPattern(client, acc) + self.supply: HalvedTotalPattern = HalvedTotalPattern(client, _m(acc, 'supply')) class BpsCentsPercentRatioUsdPattern: """Pattern struct for repeated tree structure.""" @@ -2658,7 +2549,73 @@ class BpsCentsPercentRatioUsdPattern: self.cents: MetricPattern1[CentsSigned] = MetricPattern1(client, _m(acc, 'change_24h_cents')) self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'rate_24h')) self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'rate_24h_ratio')) - self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'change_24h_usd')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'change_24h')) + +class BtcCentsSatsSumUsdPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.btc: MetricPattern1[Bitcoin] = MetricPattern1(client, acc) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) + self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, acc) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) + +class BtcCentsSatsSumUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.btc: MetricPattern1[Bitcoin] = MetricPattern1(client, acc) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) + self.sum: _24hPattern3 = _24hPattern3(client, _m(acc, '24h')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) + +class CentsCumulativeNegSumUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_cents')) + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_loss_cumulative')) + self.neg: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, 'realized_loss_24h')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_loss')) + +class CentsDeltaRawRelUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_cap_cents')) + self.delta: _24hChangeRatePattern = _24hChangeRatePattern(client, _m(acc, 'realized_cap_delta')) + self.raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'cap_raw')) + self.rel_to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_cap_rel_to_own_market_cap')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) + +class CentsNegSumSupplyUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'unrealized_loss_cents')) + self.neg: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_unrealized_loss')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) + self.supply: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_loss')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'unrealized_loss')) + +class CoinblocksCoindaysDormancySentVelocityPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.coinblocks_destroyed: CumulativeRawPattern = CumulativeRawPattern(client, _m(acc, 'coinblocks_destroyed')) + self.coindays_destroyed: CumulativeRawSumPattern = CumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')) + self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) + self.sent: RawSumPattern2 = RawSumPattern2(client, _m(acc, 'sent')) + self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'velocity')) class EmaHistogramLineSignalPattern: """Pattern struct for repeated tree structure.""" @@ -2671,6 +2628,39 @@ class EmaHistogramLineSignalPattern: self.line: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'line_24h')) self.signal: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'signal_24h')) +class InvestedInvestorLossNetProfitPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """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: CentsNegSumSupplyUsdPattern = CentsNegSumSupplyUsdPattern(client, acc) + self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) + self.profit: CentsSumSupplyUsdPattern = CentsSumSupplyUsdPattern(client, acc) + +class PhsReboundThsPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.phs: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'phs')) + self.phs_min: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'phs_min')) + self.rebound: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rebound')) + self.ths: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ths')) + self.ths_min: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ths_min')) + +class RatioValuePattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'sopr')) + self.value_created: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_created')) + self.value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_created')) + self.value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'value_destroyed')) + self.value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, _m(acc, 'value_destroyed')) + class _1m1w1y24hHeightPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2682,27 +2672,6 @@ class _1m1w1y24hHeightPattern(Generic[T]): self._24h: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'average_24h')) self.height: MetricPattern18[T] = MetricPattern18(client, acc) -class _24hChangeRatePattern2(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._24h: BaseBpsPercentRatioPattern = BaseBpsPercentRatioPattern(client, acc) - self.change_1w: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'change_1w')) - self.change_1y: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'change_1y')) - self.rate_1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rate_1w')) - self.rate_1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rate_1y')) - -class _1m1w1y24hPattern6: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._1m: BaseBtcCentsSatsUsdPattern = BaseBtcCentsSatsUsdPattern(client, acc) - self._1w: BaseBtcCentsSatsUsdPattern = BaseBtcCentsSatsUsdPattern(client, acc) - self._1y: BaseBtcCentsSatsUsdPattern = BaseBtcCentsSatsUsdPattern(client, acc) - self._24h: BaseBtcCentsSatsUsdPattern = BaseBtcCentsSatsUsdPattern(client, acc) - class _1m1w1y24hPattern2: """Pattern struct for repeated tree structure.""" @@ -2713,7 +2682,7 @@ class _1m1w1y24hPattern2: self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1y')) self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '24h')) -class _1m1w1y24hPattern5: +class _1m1w1y24hPattern7: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -2723,15 +2692,45 @@ class _1m1w1y24hPattern5: self._1y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1y')) self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '24h')) -class BaseBpsPercentRatioPattern: +class _1m1w1y24hPattern3: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.base: MetricPattern1[SatsSigned] = MetricPattern1(client, _m(acc, 'change_24h')) - self.bps: MetricPattern1[BasisPointsSigned32] = MetricPattern1(client, _m(acc, 'rate_24h_bps')) - self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'rate_24h')) - self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'rate_24h_ratio')) + self._1m: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, '1m')) + self._1w: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, '1w')) + self._1y: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, '1y')) + self._24h: CentsUsdPattern = CentsUsdPattern(client, _m(acc, '24h')) + +class _1m1w1y2wPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._1m: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '1m')) + self._1w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '1w')) + self._1y: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '1y')) + self._2w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '2w')) + +class _1m1w1y24hPattern4: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._1m: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, '1m')) + self._1w: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, '1w')) + self._1y: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, '1y')) + self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '24h')) + +class _1y2y4yAllPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) + self._2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) + self._4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) + self.all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) class BothReactivatedReceivingSendingPattern: """Pattern struct for repeated tree structure.""" @@ -2743,25 +2742,55 @@ class BothReactivatedReceivingSendingPattern: self.receiving: _1m1w1y24hHeightPattern[StoredU32] = _1m1w1y24hHeightPattern(client, _m(acc, 'receiving')) self.sending: _1m1w1y24hHeightPattern[StoredU32] = _1m1w1y24hHeightPattern(client, _m(acc, 'sending')) +class BpsPercentilesRatioStdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, _m(acc, 'bps')) + self.percentiles: Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern = Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern(client, acc) + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, acc) + self.std_dev: _1y2y4yAllPattern = _1y2y4yAllPattern(client, acc) + class BtcCentsSatsUsdPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.btc: MetricPattern1[Bitcoin] = MetricPattern1(client, _m(acc, 'btc')) + self.btc: MetricPattern1[Bitcoin] = MetricPattern1(client, acc) self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) - self.sats: MetricPattern1[Sats] = MetricPattern1(client, acc) + self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) -class CoinblocksCoindaysSentPattern: +class CentsCumulativeSumUsdPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.coinblocks_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinblocks_destroyed')) - self.coindays_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coindays_destroyed')) - self.sent: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sent')) - self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, 'sent_24h')) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cumulative')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, '24h')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) + +class CentsSellSumUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'realized_gross_pnl_cents')) + 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')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_gross_pnl')) + +class CentsSumSupplyUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'unrealized_profit_cents')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_profit_24h')) + self.supply: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'supply_in_profit')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'unrealized_profit')) class InvestedMaxMinPercentilesPattern: """Pattern struct for repeated tree structure.""" @@ -2773,15 +2802,15 @@ class InvestedMaxMinPercentilesPattern: self.min: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')) self.percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis')) -class RatioPattern2: +class OutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) - self.ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) - self.ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) - self.ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) + 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) class _1m1w1y24hPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2800,7 +2829,16 @@ class BaseCumulativeSumPattern: """Create pattern node with accumulated metric name.""" self.base: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'cumulative')) - self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, _m(acc, 'sum')) + self.sum: _1m1w1y24hPattern7 = _1m1w1y24hPattern7(client, _m(acc, 'sum')) + +class BlocksDominanceRewardsPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.blocks_mined: CumulativeHeightSumPattern[StoredU32] = CumulativeHeightSumPattern(client, _m(acc, 'blocks_mined')) + self.dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'dominance')) + self.rewards: BaseCumulativeSumPattern = BaseCumulativeSumPattern(client, _m(acc, 'rewards')) class BpsPercentRatioPattern: """Pattern struct for repeated tree structure.""" @@ -2816,9 +2854,9 @@ class BpsPriceRatioPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, _m(acc, 'ratio_bps')) + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, _m(acc, 'bps')) self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, acc) - self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, acc) class CentsSatsUsdPattern2: """Pattern struct for repeated tree structure.""" @@ -2829,6 +2867,24 @@ class CentsSatsUsdPattern2: self.sats: MetricPattern2[Sats] = MetricPattern2(client, _m(acc, 'sats')) self.usd: MetricPattern2[Dollars] = MetricPattern2(client, acc) +class CentsDeltaUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.delta: ChangeRatePattern3 = ChangeRatePattern3(client, _m(acc, 'delta')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) + +class CentsRawUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.raw: MetricPattern18[CentsSats] = MetricPattern18(client, _m(acc, 'raw')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) + class CentsSatsUsdPattern: """Pattern struct for repeated tree structure.""" @@ -2838,23 +2894,122 @@ class CentsSatsUsdPattern: self.sats: MetricPattern1[SatsFract] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) +class CentsSumUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.sum: _24hPattern = _24hPattern(client, _m(acc, '24h')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) + +class CumulativeHeightRelPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cumulative')) + self.height: MetricPattern18[Cents] = MetricPattern18(client, acc) + self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_realized_cap')) + +class CumulativeRawSumPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'cumulative')) + self.raw: MetricPattern1[StoredF64] = MetricPattern1(client, acc) + self.sum: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, acc) + class DeltaHalvedTotalPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.delta: ChangeRatePattern[SatsSigned] = ChangeRatePattern(client, _m(acc, 'delta')) + self.delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) -class SupplyPattern2: +class DeltaHalvedTotalPattern2: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')) - self.supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')) - self.supply_rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) + self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) + self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) + self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) + +class GreedNetPainPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.greed_index: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'greed_index')) + self.net: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_sentiment')) + self.pain_index: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'pain_index')) + +class InRelPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.in_loss: RelPattern = RelPattern(client, _m(acc, 'in_loss_rel_to_circulating_supply')) + self.in_profit: RelPattern = RelPattern(client, _m(acc, 'in_profit_rel_to_circulating_supply')) + self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) + +class InRelPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.in_loss: RelPattern5 = RelPattern5(client, _m(acc, 'in_loss_rel_to')) + self.in_profit: RelPattern5 = RelPattern5(client, _m(acc, 'in_profit_rel_to')) + self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rel_to_circulating_supply')) + +class LossNetProfitPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.loss: CentsNegSumSupplyUsdPattern = CentsNegSumSupplyUsdPattern(client, acc) + self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) + self.profit: CentsSumSupplyUsdPattern = CentsSumSupplyUsdPattern(client, acc) + +class LossNetProfitPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.loss: RelPattern6 = RelPattern6(client, _m(acc, 'unrealized_loss_rel_to')) + self.net_pnl: RelPattern7 = RelPattern7(client, _m(acc, 'net_unrealized_pnl_rel_to_own')) + self.profit: RelPattern6 = RelPattern6(client, _m(acc, 'unrealized_profit_rel_to')) + +class OutputsRealizedSupplyPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) + self.realized: CapLossMvrvNuplPriceProfitSoprPattern = CapLossMvrvNuplPriceProfitSoprPattern(client, acc) + self.supply: HalvedTotalPattern = HalvedTotalPattern(client, _m(acc, 'supply')) + +class RatioValuePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.ratio: _24hPattern2[StoredF64] = _24hPattern2(client, _m(acc, 'sopr_24h')) + self.value_created: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'value_created')) + self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'value_destroyed')) + +class RelPattern6: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'market_cap')) + self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'own_gross_pnl')) + self.rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'own_market_cap')) class _1m1w1yPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2896,7 +3051,7 @@ class BlocksDominancePattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.blocks_mined: CumulativeHeightPattern[StoredU32] = CumulativeHeightPattern(client, _m(acc, 'blocks_mined')) + self.blocks_mined: CumulativeHeightPattern = CumulativeHeightPattern(client, _m(acc, 'blocks_mined')) self.dominance: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'dominance')) class BpsRatioPattern: @@ -2913,7 +3068,7 @@ class CentsUsdPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) - self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, acc) class ChangeRatePattern2: """Pattern struct for repeated tree structure.""" @@ -2923,13 +3078,53 @@ class ChangeRatePattern2: self.change: _1m1w1y24hPattern[StoredI64] = _1m1w1y24hPattern(client, _m(acc, 'change')) self.rate: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'rate')) +class ChangeRatePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.change: _1mPattern[StoredI64] = _1mPattern(client, _m(acc, 'change_1m')) + self.rate: _1mPattern2 = _1mPattern2(client, _m(acc, 'rate_1m')) + class ChangeRatePattern3: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.change_1m: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'change_1m')) - self.rate_1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rate_1m')) + self.change: _1mPattern3 = _1mPattern3(client, _m(acc, 'change_1m')) + self.rate: _1mPattern2 = _1mPattern2(client, _m(acc, 'rate_1m')) + +class CoindaysSentPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.coindays_destroyed: RawSumPattern[StoredF64] = RawSumPattern(client, _m(acc, 'coindays_destroyed')) + self.sent: RawSumPattern[Sats] = RawSumPattern(client, _m(acc, 'sent')) + +class CumulativeRawPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'cumulative')) + self.raw: MetricPattern1[StoredF64] = MetricPattern1(client, acc) + +class CumulativeHeightPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[StoredU32] = MetricPattern1(client, _m(acc, 'cumulative')) + self.height: MetricPattern18[StoredU32] = MetricPattern18(client, acc) + +class HalvedTotalPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) + self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) class HeightSumPattern: """Pattern struct for repeated tree structure.""" @@ -2939,6 +3134,62 @@ class HeightSumPattern: self.height: MetricPattern18[StoredU64] = MetricPattern18(client, acc) self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, _m(acc, 'sum')) +class InPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.in_loss: BtcCentsSatsSumUsdPattern = BtcCentsSatsSumUsdPattern(client, _m(acc, 'loss')) + self.in_profit: BtcCentsSatsSumUsdPattern = BtcCentsSatsSumUsdPattern(client, _m(acc, 'profit')) + +class InPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.in_loss: BtcCentsSatsSumUsdPattern2 = BtcCentsSatsSumUsdPattern2(client, _m(acc, 'loss')) + self.in_profit: BtcCentsSatsSumUsdPattern2 = BtcCentsSatsSumUsdPattern2(client, _m(acc, 'profit')) + +class InPattern5: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.in_loss: CentsRawUsdPattern = CentsRawUsdPattern(client, _m(acc, 'loss')) + self.in_profit: CentsRawUsdPattern = CentsRawUsdPattern(client, _m(acc, 'profit')) + +class InPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.in_loss: RawPattern[CentsSats] = RawPattern(client, _m(acc, 'loss_raw')) + self.in_profit: RawPattern[CentsSats] = RawPattern(client, _m(acc, 'profit_raw')) + +class LossProfitPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.loss: CentsSumSupplyUsdPattern = CentsSumSupplyUsdPattern(client, acc) + self.profit: CentsSumSupplyUsdPattern = CentsSumSupplyUsdPattern(client, acc) + +class PriceValuePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, acc) + self.value: MetricPattern1[StoredF32] = MetricPattern1(client, acc) + +class RawSumPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.raw: MetricPattern1[Sats] = MetricPattern1(client, acc) + self.sum: _1m1w1y24hPattern[Sats] = _1m1w1y24hPattern(client, acc) + class RealizedSupplyPattern: """Pattern struct for repeated tree structure.""" @@ -2947,6 +3198,30 @@ class RealizedSupplyPattern: self.realized_cap: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'realized_cap')) self.supply: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'supply')) +class RelPattern5: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'circulating_supply')) + self.rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'own_supply')) + +class RelPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'market_cap')) + self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'own_gross_pnl')) + +class RelPattern7: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'gross_pnl')) + self.rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'market_cap')) + class SdSmaPattern: """Pattern struct for repeated tree structure.""" @@ -2955,21 +3230,94 @@ class SdSmaPattern: self.sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sd_1y')) self.sma: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sma_1y')) -class SentPattern: +class SupplyUnrealizedPattern2: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.sent: MetricPattern1[Sats] = MetricPattern1(client, acc) - self.sent_sum: _24hPattern[Sats] = _24hPattern(client, _m(acc, '24h')) + self.supply: InRelPattern2 = InRelPattern2(client, _m(acc, 'supply')) + self.unrealized: LossNetProfitPattern3 = LossNetProfitPattern3(client, acc) + +class UtxoPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.utxo_count: MetricPattern1[StoredU64] = MetricPattern1(client, acc) + self.utxo_count_delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) + +class UtxoPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.utxo_count: MetricPattern1[StoredU64] = MetricPattern1(client, acc) + self.utxo_count_delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) + +class ValuePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.value_created: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'created')) + self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, _m(acc, 'destroyed')) + +class RawSumPattern(Generic[T]): + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.raw: MetricPattern1[T] = MetricPattern1(client, acc) + self.sum: _24hPattern2[T] = _24hPattern2(client, _m(acc, '24h')) + +class _1mPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, acc) + +class _1mPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._1m: CentsUsdPattern = CentsUsdPattern(client, acc) + +class _24hPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) + +class _24hPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._24h: CentsUsdPattern = CentsUsdPattern(client, acc) + +class RelPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.rel_to_circulating_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, acc) + +class RelPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, acc) class SupplyPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.supply_in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'loss')) - self.supply_in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'profit')) + self.supply: InRelPattern = InRelPattern(client, acc) class UtxoPattern: """Pattern struct for repeated tree structure.""" @@ -2977,31 +3325,28 @@ class UtxoPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.utxo_count: MetricPattern1[StoredU64] = MetricPattern1(client, acc) - self.utxo_count_delta: ChangeRatePattern[StoredI64] = ChangeRatePattern(client, _m(acc, 'delta')) -class ChangeRatePattern(Generic[T]): +class _1mPattern(Generic[T]): """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.change_1m: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'change_1m')) - self.rate_1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rate_1m')) + self._1m: MetricPattern1[T] = MetricPattern1(client, acc) -class CumulativeHeightPattern(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) - self.height: MetricPattern18[T] = MetricPattern18(client, acc) - -class _24hPattern(Generic[T]): +class _24hPattern2(Generic[T]): """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self._24h: MetricPattern1[T] = MetricPattern1(client, acc) +class RawPattern(Generic[T]): + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.raw: MetricPattern18[T] = MetricPattern18(client, acc) + # Metrics tree classes class MetricsTree_Blocks_Difficulty: @@ -3023,6 +3368,22 @@ class MetricsTree_Blocks_Time: self.date: MetricPattern18[Date] = MetricPattern18(client, 'date') self.timestamp_monotonic: MetricPattern18[Timestamp] = MetricPattern18(client, 'timestamp_monotonic') +class MetricsTree_Blocks_Size: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.total_size: MetricPattern18[StoredU64] = MetricPattern18(client, 'total_size') + self.cumulative: MetricPattern1[StoredU64] = MetricPattern1(client, 'block_size_cumulative') + self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_sum') + self.average: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_average') + self.min: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_min') + self.max: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_max') + self.pct10: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_pct10') + self.pct25: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_pct25') + self.median: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_median') + self.pct75: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_pct75') + self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_pct90') + class MetricsTree_Blocks_Weight: """Metrics tree node.""" @@ -3033,11 +3394,11 @@ class MetricsTree_Blocks_Weight: self.average: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_average') self.min: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_min') self.max: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_max') - self.pct10: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_p10') - self.pct25: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_p25') + self.pct10: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_pct10') + self.pct25: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_pct25') self.median: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_median') - self.pct75: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_p75') - self.pct90: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_p90') + self.pct75: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_pct75') + self.pct90: _1m1w1y24hPattern[Weight] = _1m1w1y24hPattern(client, 'block_weight_pct90') class MetricsTree_Blocks_Count: """Metrics tree node.""" @@ -3045,7 +3406,11 @@ class MetricsTree_Blocks_Count: def __init__(self, client: BrkClientBase, base_path: str = ''): self.block_count_target: MetricPattern1[StoredU64] = MetricPattern1(client, 'block_count_target') self.block_count: CumulativeHeightSumPattern[StoredU32] = CumulativeHeightSumPattern(client, 'block_count') - self.block_count_sum: _1m1w1y24hPattern[StoredU32] = _1m1w1y24hPattern(client, 'block_count_sum') + +class MetricsTree_Blocks_Lookback: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): self.height_1h_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_1h_ago') self.height_24h_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_24h_ago') self.height_3d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_3d_ago') @@ -3098,21 +3463,6 @@ class MetricsTree_Blocks_Halving: self.blocks_before_next_halving: MetricPattern1[StoredU32] = MetricPattern1(client, 'blocks_before_next_halving') self.days_before_next_halving: MetricPattern1[StoredF32] = MetricPattern1(client, 'days_before_next_halving') -class MetricsTree_Blocks_Size: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.cumulative: MetricPattern1[StoredU64] = MetricPattern1(client, 'block_size_cumulative') - self.sum: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_sum') - self.average: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_average') - self.min: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_min') - self.max: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_max') - self.pct10: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_p10') - self.pct25: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_p25') - self.median: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_median') - self.pct75: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_p75') - self.pct90: _1m1w1y24hPattern[StoredU64] = _1m1w1y24hPattern(client, 'block_size_p90') - class MetricsTree_Blocks_Fullness: """Metrics tree node.""" @@ -3128,13 +3478,13 @@ class MetricsTree_Blocks: self.blockhash: MetricPattern18[BlockHash] = MetricPattern18(client, 'blockhash') self.difficulty: MetricsTree_Blocks_Difficulty = MetricsTree_Blocks_Difficulty(client) self.time: MetricsTree_Blocks_Time = MetricsTree_Blocks_Time(client) - self.total_size: MetricPattern18[StoredU64] = MetricPattern18(client, 'total_size') + self.size: MetricsTree_Blocks_Size = MetricsTree_Blocks_Size(client) self.weight: MetricsTree_Blocks_Weight = MetricsTree_Blocks_Weight(client) self.count: MetricsTree_Blocks_Count = MetricsTree_Blocks_Count(client) + self.lookback: MetricsTree_Blocks_Lookback = MetricsTree_Blocks_Lookback(client) self.interval: _1m1w1y24hHeightPattern[Timestamp] = _1m1w1y24hHeightPattern(client, 'block_interval') self.halving: MetricsTree_Blocks_Halving = MetricsTree_Blocks_Halving(client) self.vbytes: AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern = AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, 'block_vbytes') - self.size: MetricsTree_Blocks_Size = MetricsTree_Blocks_Size(client) self.fullness: MetricsTree_Blocks_Fullness = MetricsTree_Blocks_Fullness(client) class MetricsTree_Transactions_Count: @@ -3330,33 +3680,29 @@ class MetricsTree_Mining_Rewards: self.subsidy: BaseCumulativePattern = BaseCumulativePattern(client, 'subsidy') self.fees: MetricsTree_Mining_Rewards_Fees = MetricsTree_Mining_Rewards_Fees(client) self.unclaimed_rewards: BaseCumulativeSumPattern = BaseCumulativeSumPattern(client, 'unclaimed_rewards') - self.fee_dominance: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'fee_dominance') - self.fee_dominance_rolling: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, 'fee_dominance') - self.subsidy_dominance: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'subsidy_dominance') - self.subsidy_dominance_rolling: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, 'subsidy_dominance') + self.fee_dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'fee_dominance') + self.subsidy_dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'subsidy_dominance') self.subsidy_sma_1y: CentsUsdPattern = CentsUsdPattern(client, 'subsidy_sma_1y') +class MetricsTree_Mining_Hashrate_HashRateSma: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self._1w: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_1w') + self._1m: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_1m') + self._2m: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_2m') + self._1y: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_1y') + class MetricsTree_Mining_Hashrate: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.hash_rate: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate') - self.hash_rate_sma_1w: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_1w') - self.hash_rate_sma_1m: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_1m') - self.hash_rate_sma_2m: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_2m') - self.hash_rate_sma_1y: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_sma_1y') + self.hash_rate_sma: MetricsTree_Mining_Hashrate_HashRateSma = MetricsTree_Mining_Hashrate_HashRateSma(client) self.hash_rate_ath: MetricPattern1[StoredF64] = MetricPattern1(client, 'hash_rate_ath') self.hash_rate_drawdown: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'hash_rate_drawdown') - self.hash_price_ths: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_price_ths') - self.hash_price_ths_min: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_price_ths_min') - self.hash_price_phs: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_price_phs') - self.hash_price_phs_min: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_price_phs_min') - self.hash_price_rebound: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'hash_price_rebound') - self.hash_value_ths: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_value_ths') - self.hash_value_ths_min: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_value_ths_min') - self.hash_value_phs: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_value_phs') - self.hash_value_phs_min: MetricPattern1[StoredF32] = MetricPattern1(client, 'hash_value_phs_min') - self.hash_value_rebound: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'hash_value_rebound') + self.hash_price: PhsReboundThsPattern = PhsReboundThsPattern(client, 'hash_price') + self.hash_value: PhsReboundThsPattern = PhsReboundThsPattern(client, 'hash_value') class MetricsTree_Mining: """Metrics tree node.""" @@ -3393,9 +3739,9 @@ class MetricsTree_Cointime_Value: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.cointime_value_destroyed: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, 'cointime_value_destroyed') - self.cointime_value_created: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, 'cointime_value_created') - self.cointime_value_stored: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, 'cointime_value_stored') + self.value_destroyed: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, 'cointime_value_destroyed') + self.value_created: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, 'cointime_value_created') + self.value_stored: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, 'cointime_value_stored') self.vocdd: CumulativeHeightSumPattern[StoredF64] = CumulativeHeightSumPattern(client, 'vocdd') class MetricsTree_Cointime_Cap: @@ -3413,21 +3759,21 @@ class MetricsTree_Cointime_Pricing: def __init__(self, client: BrkClientBase, base_path: str = ''): self.vaulted_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'vaulted_price') - self.vaulted_price_ratio: BpsRatioPattern2 = BpsRatioPattern2(client, 'vaulted_price_ratio') + self.vaulted_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'vaulted_price_ratio') self.active_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'active_price') - self.active_price_ratio: BpsRatioPattern2 = BpsRatioPattern2(client, 'active_price_ratio') + self.active_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'active_price_ratio') self.true_market_mean: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'true_market_mean') - self.true_market_mean_ratio: BpsRatioPattern2 = BpsRatioPattern2(client, 'true_market_mean_ratio') + self.true_market_mean_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'true_market_mean_ratio') self.cointime_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'cointime_price') - self.cointime_price_ratio: BpsRatioPattern2 = BpsRatioPattern2(client, 'cointime_price_ratio') + self.cointime_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'cointime_price_ratio') class MetricsTree_Cointime_Adjusted: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.cointime_adj_inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'cointime_adj_inflation_rate') - self.cointime_adj_tx_velocity_btc: MetricPattern1[StoredF64] = MetricPattern1(client, 'cointime_adj_tx_velocity_btc') - self.cointime_adj_tx_velocity_usd: MetricPattern1[StoredF64] = MetricPattern1(client, 'cointime_adj_tx_velocity_usd') + self.adj_inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'cointime_adj_inflation_rate') + self.adj_tx_velocity_btc: MetricPattern1[StoredF64] = MetricPattern1(client, 'cointime_adj_tx_velocity_btc') + self.adj_tx_velocity_usd: MetricPattern1[StoredF64] = MetricPattern1(client, 'cointime_adj_tx_velocity_usd') class MetricsTree_Cointime_ReserveRisk: """Metrics tree node.""" @@ -3573,8 +3919,8 @@ class MetricsTree_Indexes_Height: self.hour12: MetricPattern18[Hour12] = MetricPattern18(client, 'hour12') self.day1: MetricPattern18[Day1] = MetricPattern18(client, 'day1') self.day3: MetricPattern18[Day3] = MetricPattern18(client, 'day3') - self.difficultyepoch: MetricPattern18[Epoch] = MetricPattern18(client, 'difficultyepoch') - self.halvingepoch: MetricPattern18[Halving] = MetricPattern18(client, 'halvingepoch') + self.epoch: MetricPattern18[Epoch] = MetricPattern18(client, 'epoch') + self.halving: MetricPattern18[Halving] = MetricPattern18(client, 'halving') self.week1: MetricPattern18[Week1] = MetricPattern18(client, 'week1') self.month1: MetricPattern18[Month1] = MetricPattern18(client, 'month1') self.month3: MetricPattern18[Month3] = MetricPattern18(client, 'month3') @@ -3583,19 +3929,19 @@ class MetricsTree_Indexes_Height: self.year10: MetricPattern18[Year10] = MetricPattern18(client, 'year10') self.txindex_count: MetricPattern18[StoredU64] = MetricPattern18(client, 'txindex_count') -class MetricsTree_Indexes_Difficultyepoch: +class MetricsTree_Indexes_Epoch: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: MetricPattern17[Epoch] = MetricPattern17(client, 'difficultyepoch') + self.identity: MetricPattern17[Epoch] = MetricPattern17(client, 'epoch') self.first_height: MetricPattern17[Height] = MetricPattern17(client, 'first_height') self.height_count: MetricPattern17[StoredU64] = MetricPattern17(client, 'height_count') -class MetricsTree_Indexes_Halvingepoch: +class MetricsTree_Indexes_Halving: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.identity: MetricPattern16[Halving] = MetricPattern16(client, 'halvingepoch') + self.identity: MetricPattern16[Halving] = MetricPattern16(client, 'halving') self.first_height: MetricPattern16[Height] = MetricPattern16(client, 'first_height') class MetricsTree_Indexes_Minute10: @@ -3723,8 +4069,8 @@ class MetricsTree_Indexes: def __init__(self, client: BrkClientBase, base_path: str = ''): self.address: MetricsTree_Indexes_Address = MetricsTree_Indexes_Address(client) self.height: MetricsTree_Indexes_Height = MetricsTree_Indexes_Height(client) - self.difficultyepoch: MetricsTree_Indexes_Difficultyepoch = MetricsTree_Indexes_Difficultyepoch(client) - self.halvingepoch: MetricsTree_Indexes_Halvingepoch = MetricsTree_Indexes_Halvingepoch(client) + self.epoch: MetricsTree_Indexes_Epoch = MetricsTree_Indexes_Epoch(client) + self.halving: MetricsTree_Indexes_Halving = MetricsTree_Indexes_Halving(client) self.minute10: MetricsTree_Indexes_Minute10 = MetricsTree_Indexes_Minute10(client) self.minute30: MetricsTree_Indexes_Minute30 = MetricsTree_Indexes_Minute30(client) self.hour1: MetricsTree_Indexes_Hour1 = MetricsTree_Indexes_Hour1(client) @@ -3746,12 +4092,12 @@ class MetricsTree_Market_Ath: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.price_ath: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ath') - self.price_drawdown: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_drawdown') - self.days_since_price_ath: MetricPattern1[StoredF32] = MetricPattern1(client, 'days_since_price_ath') - self.years_since_price_ath: MetricPattern2[StoredF32] = MetricPattern2(client, 'years_since_price_ath') - self.max_days_between_price_ath: MetricPattern1[StoredF32] = MetricPattern1(client, 'max_days_between_price_ath') - self.max_years_between_price_ath: MetricPattern2[StoredF32] = MetricPattern2(client, 'max_years_between_price_ath') + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ath') + self.drawdown: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_drawdown') + self.days_since: MetricPattern1[StoredF32] = MetricPattern1(client, 'days_since_price_ath') + self.years_since: MetricPattern2[StoredF32] = MetricPattern2(client, 'years_since_price_ath') + self.max_days_between: MetricPattern1[StoredF32] = MetricPattern1(client, 'max_days_between_price_ath') + self.max_years_between: MetricPattern2[StoredF32] = MetricPattern2(client, 'max_years_between_price_ath') class MetricsTree_Market_Lookback: """Metrics tree node.""" @@ -3789,93 +4135,353 @@ class MetricsTree_Market_Returns_PriceReturn: self._8y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_8y') self._10y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_10y') -class MetricsTree_Market_Returns_PriceReturn24hSd1w: +class MetricsTree_Market_Returns_PriceReturn24hSd_1w: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.sma: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_return_24h_sma_1w') self.sd: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_return_24h_sd_1w') -class MetricsTree_Market_Returns_PriceReturn24hSd1m: +class MetricsTree_Market_Returns_PriceReturn24hSd_1m: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.sma: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_return_24h_sma_1m') self.sd: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_return_24h_sd_1m') +class MetricsTree_Market_Returns_PriceReturn24hSd: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self._1w: MetricsTree_Market_Returns_PriceReturn24hSd_1w = MetricsTree_Market_Returns_PriceReturn24hSd_1w(client) + self._1m: MetricsTree_Market_Returns_PriceReturn24hSd_1m = MetricsTree_Market_Returns_PriceReturn24hSd_1m(client) + self._1y: SdSmaPattern = SdSmaPattern(client, 'price_return_24h') + class MetricsTree_Market_Returns: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): self.price_return: MetricsTree_Market_Returns_PriceReturn = MetricsTree_Market_Returns_PriceReturn(client) self.price_cagr: _10y2y3y4y5y6y8yPattern = _10y2y3y4y5y6y8yPattern(client, 'price_cagr') - self.price_return_24h_sd_1w: MetricsTree_Market_Returns_PriceReturn24hSd1w = MetricsTree_Market_Returns_PriceReturn24hSd1w(client) - self.price_return_24h_sd_1m: MetricsTree_Market_Returns_PriceReturn24hSd1m = MetricsTree_Market_Returns_PriceReturn24hSd1m(client) - self.price_return_24h_sd_1y: SdSmaPattern = SdSmaPattern(client, 'price_return_24h') - -class MetricsTree_Market_Volatility: - """Metrics tree node.""" - - def __init__(self, client: BrkClientBase, base_path: str = ''): - self.price_volatility_1w: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_volatility_1w') - self.price_volatility_1m: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_volatility_1m') - self.price_volatility_1y: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_volatility_1y') + self.price_return_24h_sd: MetricsTree_Market_Returns_PriceReturn24hSd = MetricsTree_Market_Returns_PriceReturn24hSd(client) class MetricsTree_Market_Range: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.price_min_1w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_min_1w') - self.price_max_1w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_max_1w') - self.price_min_2w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_min_2w') - self.price_max_2w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_max_2w') - self.price_min_1m: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_min_1m') - self.price_max_1m: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_max_1m') - self.price_min_1y: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_min_1y') - self.price_max_1y: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_max_1y') - self.price_true_range: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_true_range') - self.price_true_range_sum_2w: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_true_range_sum_2w') - self.price_choppiness_index_2w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_choppiness_index_2w') + self.min: _1m1w1y2wPattern = _1m1w1y2wPattern(client, 'price_min') + self.max: _1m1w1y2wPattern = _1m1w1y2wPattern(client, 'price_max') + self.true_range: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_true_range') + self.true_range_sum_2w: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_true_range_sum_2w') + self.choppiness_index_2w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_choppiness_index_2w') + +class MetricsTree_Market_MovingAverage_Sma_1w: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_1w') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_1w_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_1w_ratio') + +class MetricsTree_Market_MovingAverage_Sma_8d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_8d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_8d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_8d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_13d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_13d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_13d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_13d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_21d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_21d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_21d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_21d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_1m: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_1m') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_1m_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_1m_ratio') + +class MetricsTree_Market_MovingAverage_Sma_34d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_34d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_34d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_34d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_55d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_55d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_55d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_55d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_89d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_89d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_89d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_89d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_111d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_111d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_111d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_111d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_144d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_144d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_144d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_144d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_200d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_200d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_200d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_350d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_350d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_350d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_350d_ratio') + +class MetricsTree_Market_MovingAverage_Sma_1y: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_1y') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_1y_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_1y_ratio') + +class MetricsTree_Market_MovingAverage_Sma_2y: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_2y') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_2y_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_2y_ratio') + +class MetricsTree_Market_MovingAverage_Sma_200w: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200w') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_200w_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_200w_ratio') + +class MetricsTree_Market_MovingAverage_Sma_4y: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_4y') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_4y_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_4y_ratio') + +class MetricsTree_Market_MovingAverage_Sma: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self._1w: MetricsTree_Market_MovingAverage_Sma_1w = MetricsTree_Market_MovingAverage_Sma_1w(client) + self._8d: MetricsTree_Market_MovingAverage_Sma_8d = MetricsTree_Market_MovingAverage_Sma_8d(client) + self._13d: MetricsTree_Market_MovingAverage_Sma_13d = MetricsTree_Market_MovingAverage_Sma_13d(client) + self._21d: MetricsTree_Market_MovingAverage_Sma_21d = MetricsTree_Market_MovingAverage_Sma_21d(client) + self._1m: MetricsTree_Market_MovingAverage_Sma_1m = MetricsTree_Market_MovingAverage_Sma_1m(client) + self._34d: MetricsTree_Market_MovingAverage_Sma_34d = MetricsTree_Market_MovingAverage_Sma_34d(client) + self._55d: MetricsTree_Market_MovingAverage_Sma_55d = MetricsTree_Market_MovingAverage_Sma_55d(client) + self._89d: MetricsTree_Market_MovingAverage_Sma_89d = MetricsTree_Market_MovingAverage_Sma_89d(client) + self._111d: MetricsTree_Market_MovingAverage_Sma_111d = MetricsTree_Market_MovingAverage_Sma_111d(client) + self._144d: MetricsTree_Market_MovingAverage_Sma_144d = MetricsTree_Market_MovingAverage_Sma_144d(client) + self._200d: MetricsTree_Market_MovingAverage_Sma_200d = MetricsTree_Market_MovingAverage_Sma_200d(client) + self._350d: MetricsTree_Market_MovingAverage_Sma_350d = MetricsTree_Market_MovingAverage_Sma_350d(client) + self._1y: MetricsTree_Market_MovingAverage_Sma_1y = MetricsTree_Market_MovingAverage_Sma_1y(client) + self._2y: MetricsTree_Market_MovingAverage_Sma_2y = MetricsTree_Market_MovingAverage_Sma_2y(client) + self._200w: MetricsTree_Market_MovingAverage_Sma_200w = MetricsTree_Market_MovingAverage_Sma_200w(client) + self._4y: MetricsTree_Market_MovingAverage_Sma_4y = MetricsTree_Market_MovingAverage_Sma_4y(client) + self._200d_x2_4: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x2_4') + self._200d_x0_8: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x0_8') + self._350d_x2: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_350d_x2') + +class MetricsTree_Market_MovingAverage_Ema_1w: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_1w') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_1w_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_1w_ratio') + +class MetricsTree_Market_MovingAverage_Ema_8d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_8d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_8d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_8d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_12d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_12d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_12d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_12d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_13d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_13d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_13d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_13d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_21d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_21d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_21d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_21d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_26d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_26d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_26d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_26d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_1m: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_1m') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_1m_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_1m_ratio') + +class MetricsTree_Market_MovingAverage_Ema_34d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_34d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_34d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_34d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_55d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_55d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_55d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_55d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_89d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_89d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_89d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_89d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_144d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_144d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_144d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_144d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_200d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_200d') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_200d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_200d_ratio') + +class MetricsTree_Market_MovingAverage_Ema_1y: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_1y') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_1y_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_1y_ratio') + +class MetricsTree_Market_MovingAverage_Ema_2y: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_2y') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_2y_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_2y_ratio') + +class MetricsTree_Market_MovingAverage_Ema_200w: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_200w') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_200w_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_200w_ratio') + +class MetricsTree_Market_MovingAverage_Ema_4y: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ema_4y') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_ema_4y_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_ema_4y_ratio') + +class MetricsTree_Market_MovingAverage_Ema: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self._1w: MetricsTree_Market_MovingAverage_Ema_1w = MetricsTree_Market_MovingAverage_Ema_1w(client) + self._8d: MetricsTree_Market_MovingAverage_Ema_8d = MetricsTree_Market_MovingAverage_Ema_8d(client) + self._12d: MetricsTree_Market_MovingAverage_Ema_12d = MetricsTree_Market_MovingAverage_Ema_12d(client) + self._13d: MetricsTree_Market_MovingAverage_Ema_13d = MetricsTree_Market_MovingAverage_Ema_13d(client) + self._21d: MetricsTree_Market_MovingAverage_Ema_21d = MetricsTree_Market_MovingAverage_Ema_21d(client) + self._26d: MetricsTree_Market_MovingAverage_Ema_26d = MetricsTree_Market_MovingAverage_Ema_26d(client) + self._1m: MetricsTree_Market_MovingAverage_Ema_1m = MetricsTree_Market_MovingAverage_Ema_1m(client) + self._34d: MetricsTree_Market_MovingAverage_Ema_34d = MetricsTree_Market_MovingAverage_Ema_34d(client) + self._55d: MetricsTree_Market_MovingAverage_Ema_55d = MetricsTree_Market_MovingAverage_Ema_55d(client) + self._89d: MetricsTree_Market_MovingAverage_Ema_89d = MetricsTree_Market_MovingAverage_Ema_89d(client) + self._144d: MetricsTree_Market_MovingAverage_Ema_144d = MetricsTree_Market_MovingAverage_Ema_144d(client) + self._200d: MetricsTree_Market_MovingAverage_Ema_200d = MetricsTree_Market_MovingAverage_Ema_200d(client) + self._1y: MetricsTree_Market_MovingAverage_Ema_1y = MetricsTree_Market_MovingAverage_Ema_1y(client) + self._2y: MetricsTree_Market_MovingAverage_Ema_2y = MetricsTree_Market_MovingAverage_Ema_2y(client) + self._200w: MetricsTree_Market_MovingAverage_Ema_200w = MetricsTree_Market_MovingAverage_Ema_200w(client) + self._4y: MetricsTree_Market_MovingAverage_Ema_4y = MetricsTree_Market_MovingAverage_Ema_4y(client) class MetricsTree_Market_MovingAverage: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.price_sma_1w: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_1w') - self.price_sma_8d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_8d') - self.price_sma_13d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_13d') - self.price_sma_21d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_21d') - self.price_sma_1m: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_1m') - self.price_sma_34d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_34d') - self.price_sma_55d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_55d') - self.price_sma_89d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_89d') - self.price_sma_111d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_111d') - self.price_sma_144d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_144d') - self.price_sma_200d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_200d') - self.price_sma_350d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_350d') - self.price_sma_1y: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_1y') - self.price_sma_2y: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_2y') - self.price_sma_200w: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_200w') - self.price_sma_4y: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_sma_4y') - self.price_ema_1w: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_1w') - self.price_ema_8d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_8d') - self.price_ema_12d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_12d') - self.price_ema_13d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_13d') - self.price_ema_21d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_21d') - self.price_ema_26d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_26d') - self.price_ema_1m: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_1m') - self.price_ema_34d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_34d') - self.price_ema_55d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_55d') - self.price_ema_89d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_89d') - self.price_ema_144d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_144d') - self.price_ema_200d: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_200d') - self.price_ema_1y: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_1y') - self.price_ema_2y: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_2y') - self.price_ema_200w: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_200w') - self.price_ema_4y: BpsPriceRatioPattern = BpsPriceRatioPattern(client, 'price_ema_4y') - self.price_sma_200d_x2_4: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x2_4') - self.price_sma_200d_x0_8: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x0_8') - self.price_sma_350d_x2: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_350d_x2') + self.sma: MetricsTree_Market_MovingAverage_Sma = MetricsTree_Market_MovingAverage_Sma(client) + self.ema: MetricsTree_Market_MovingAverage_Ema = MetricsTree_Market_MovingAverage_Ema(client) class MetricsTree_Market_Dca_PeriodCostBasis: """Metrics tree node.""" @@ -4073,7 +4679,7 @@ class MetricsTree_Market: self.ath: MetricsTree_Market_Ath = MetricsTree_Market_Ath(client) self.lookback: MetricsTree_Market_Lookback = MetricsTree_Market_Lookback(client) self.returns: MetricsTree_Market_Returns = MetricsTree_Market_Returns(client) - self.volatility: MetricsTree_Market_Volatility = MetricsTree_Market_Volatility(client) + self.volatility: _1m1w1yPattern[StoredF32] = _1m1w1yPattern(client, 'price_volatility') self.range: MetricsTree_Market_Range = MetricsTree_Market_Range(client) self.moving_average: MetricsTree_Market_MovingAverage = MetricsTree_Market_MovingAverage(client) self.dca: MetricsTree_Market_Dca = MetricsTree_Market_Dca(client) @@ -4083,28 +4689,28 @@ class MetricsTree_Pools_Major: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.unknown: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'unknown') - self.luxor: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'luxor') - self.btccom: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'btccom') - self.btctop: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'btctop') - self.btcguild: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'btcguild') - self.eligius: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'eligius') - self.f2pool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'f2pool') - self.braiinspool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'braiinspool') - self.antpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'antpool') - self.btcc: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'btcc') - self.bwpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'bwpool') - self.bitfury: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'bitfury') - self.viabtc: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'viabtc') - self.poolin: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'poolin') - self.spiderpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'spiderpool') - self.binancepool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'binancepool') - self.foundryusa: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'foundryusa') - self.sbicrypto: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'sbicrypto') - self.marapool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'marapool') - self.secpool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'secpool') - self.ocean: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'ocean') - self.whitepool: _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern = _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern(client, 'whitepool') + self.unknown: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'unknown') + self.luxor: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'luxor') + self.btccom: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'btccom') + self.btctop: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'btctop') + self.btcguild: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'btcguild') + self.eligius: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'eligius') + self.f2pool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'f2pool') + self.braiinspool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'braiinspool') + self.antpool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'antpool') + self.btcc: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'btcc') + self.bwpool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'bwpool') + self.bitfury: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'bitfury') + self.viabtc: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'viabtc') + self.poolin: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'poolin') + self.spiderpool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'spiderpool') + self.binancepool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'binancepool') + self.foundryusa: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'foundryusa') + self.sbicrypto: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'sbicrypto') + self.marapool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'marapool') + self.secpool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'secpool') + self.ocean: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'ocean') + self.whitepool: BlocksDominanceRewardsPattern = BlocksDominanceRewardsPattern(client, 'whitepool') class MetricsTree_Pools_Minor: """Metrics tree node.""" @@ -4320,83 +4926,98 @@ class MetricsTree_Distribution_AddressesData: self.funded: MetricPattern34[FundedAddressData] = MetricPattern34(client, 'fundedaddressdata') self.empty: MetricPattern35[EmptyAddressData] = MetricPattern35(client, 'emptyaddressdata') -class MetricsTree_Distribution_UtxoCohorts_All_Adjusted: +class MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.adjusted_value_created: MetricPattern1[Cents] = MetricPattern1(client, 'adjusted_value_created') - self.adjusted_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, 'adjusted_value_destroyed') - self.adjusted_value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'adjusted_value_created') - self.adjusted_value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'adjusted_value_destroyed') - self.adjusted_sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'adjusted_sopr') + self.in_profit: RelPattern2 = RelPattern2(client, 'supply_in_profit_rel_to_own_supply') + self.in_loss: RelPattern2 = RelPattern2(client, 'supply_in_loss_rel_to_own_supply') + +class MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_own_gross_pnl') + +class MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.profit: RelPattern3 = RelPattern3(client, 'unrealized_profit_rel_to') + self.loss: RelPattern3 = RelPattern3(client, 'unrealized_loss_rel_to') + self.net_pnl: MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl = MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized_NetPnl(client) class MetricsTree_Distribution_UtxoCohorts_All_Relative: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_profit_rel_to_own_supply') - self.supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'supply_in_loss_rel_to_own_supply') - self.unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_market_cap') - self.unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_market_cap') - self.net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_market_cap') - self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, 'nupl') - self.unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_profit_rel_to_own_gross_pnl') - self.unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'unrealized_loss_rel_to_own_gross_pnl') - self.net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_rel_to_own_gross_pnl') + self.supply: MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply = MetricsTree_Distribution_UtxoCohorts_All_Relative_Supply(client) + self.unrealized: MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized = MetricsTree_Distribution_UtxoCohorts_All_Relative_Unrealized(client) class MetricsTree_Distribution_UtxoCohorts_All: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, 'supply') - self.outputs: UtxoPattern = UtxoPattern(client, 'utxo_count') - self.activity: CoinblocksCoindaysSentPattern2 = CoinblocksCoindaysSentPattern2(client, '') - self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, '') + self.supply: DeltaHalvedTotalPattern2 = DeltaHalvedTotalPattern2(client, 'supply') + self.outputs: UtxoPattern3 = UtxoPattern3(client, 'utxo_count') + self.activity: CoinblocksCoindaysDormancySentVelocityPattern = CoinblocksCoindaysDormancySentVelocityPattern(client, '') + self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(client, '') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, '') - self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, '') - self.adjusted: MetricsTree_Distribution_UtxoCohorts_All_Adjusted = MetricsTree_Distribution_UtxoCohorts_All_Adjusted(client) + self.unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern = GrossInvestedInvestorLossNetProfitSentimentPattern(client, '') self.relative: MetricsTree_Distribution_UtxoCohorts_All_Relative = MetricsTree_Distribution_UtxoCohorts_All_Relative(client) - self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, 'dormancy') - self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, 'velocity') - self.supply_delta_extended: _24hChangeRatePattern2[SatsSigned] = _24hChangeRatePattern2(client, 'supply_delta') - self.utxo_count_delta_extended: _24hChangeRatePattern2[StoredI64] = _24hChangeRatePattern2(client, 'utxo_count_delta') class MetricsTree_Distribution_UtxoCohorts_Sth: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, 'sth_supply') - self.outputs: UtxoPattern = UtxoPattern(client, 'sth_utxo_count') - self.activity: CoinblocksCoindaysSentPattern2 = CoinblocksCoindaysSentPattern2(client, 'sth') - self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, 'sth') + self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(client, 'sth') + self.supply: DeltaHalvedTotalPattern2 = DeltaHalvedTotalPattern2(client, 'sth_supply') + self.outputs: UtxoPattern3 = UtxoPattern3(client, 'sth_utxo_count') + self.activity: CoinblocksCoindaysDormancySentVelocityPattern = CoinblocksCoindaysDormancySentVelocityPattern(client, 'sth') self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'sth') - self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, 'sth') - self.relative: NetNuplSupplyUnrealizedPattern2 = NetNuplSupplyUnrealizedPattern2(client, 'sth') - self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, 'sth_dormancy') - self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, 'sth_velocity') - self.supply_delta_extended: _24hChangeRatePattern2[SatsSigned] = _24hChangeRatePattern2(client, 'sth_supply_delta') - self.utxo_count_delta_extended: _24hChangeRatePattern2[StoredI64] = _24hChangeRatePattern2(client, 'sth_utxo_count_delta') - self.adjusted_value_created: MetricPattern1[Cents] = MetricPattern1(client, 'sth_adjusted_value_created') - self.adjusted_value_destroyed: MetricPattern1[Cents] = MetricPattern1(client, 'sth_adjusted_value_destroyed') - self.adjusted_value_created_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'sth_adjusted_value_created') - self.adjusted_value_destroyed_sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, 'sth_adjusted_value_destroyed') - self.adjusted_sopr: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'sth_adjusted_sopr') + self.unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern = GrossInvestedInvestorLossNetProfitSentimentPattern(client, 'sth') + self.relative: SupplyUnrealizedPattern2 = SupplyUnrealizedPattern2(client, 'sth') + +class MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.value_created_sum: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, 'lth_value_created') + self.value_destroyed_sum: _1m1w1yPattern[Cents] = _1m1w1yPattern(client, 'lth_value_destroyed') + self.ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_sopr') + self.value_created: RawSumPattern[Cents] = RawSumPattern(client, 'lth_value_created') + self.value_destroyed: RawSumPattern[Cents] = RawSumPattern(client, 'lth_value_destroyed') + +class MetricsTree_Distribution_UtxoCohorts_Lth_Realized: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.profit: CentsCumulativeFlowRelSumUsdValuePattern = CentsCumulativeFlowRelSumUsdValuePattern(client, 'lth') + self.loss: CapitulationCentsCumulativeNegRelSumUsdValuePattern = CapitulationCentsCumulativeNegRelSumUsdValuePattern(client, 'lth') + self.gross_pnl: CentsSellSumUsdPattern = CentsSellSumUsdPattern(client, 'lth') + self.net_pnl: ChangeCumulativeDeltaRawRelSumPattern = ChangeCumulativeDeltaRawRelSumPattern(client, 'lth_net') + self.sopr: MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr = MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr(client) + self.sent: InPattern3 = InPattern3(client, 'lth_sent_in') + self.peak_regret: CumulativeHeightRelPattern = CumulativeHeightRelPattern(client, 'lth_realized_peak_regret') + self.investor: CapLowerPriceUpperPattern = CapLowerPriceUpperPattern(client, 'lth') + self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, 'lth_realized_profit_to_loss_ratio') + self.cap: CentsDeltaRawRelUsdPattern = CentsDeltaRawRelUsdPattern(client, 'lth') + self.price_ratio: BpsPercentilesRatioStdPattern = BpsPercentilesRatioStdPattern(client, 'lth_realized_price_ratio') + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'lth_realized_price') + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_mvrv') + self.nupl: BpsRatioPattern = BpsRatioPattern(client, 'lth_nupl_ratio') class MetricsTree_Distribution_UtxoCohorts_Lth: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.supply: DeltaHalvedTotalPattern = DeltaHalvedTotalPattern(client, 'lth_supply') - self.outputs: UtxoPattern = UtxoPattern(client, 'lth_utxo_count') - self.activity: CoinblocksCoindaysSentPattern2 = CoinblocksCoindaysSentPattern2(client, 'lth') - self.realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern = CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern(client, 'lth') + self.supply: DeltaHalvedTotalPattern2 = DeltaHalvedTotalPattern2(client, 'lth_supply') + self.outputs: UtxoPattern3 = UtxoPattern3(client, 'lth_utxo_count') + self.activity: CoinblocksCoindaysDormancySentVelocityPattern = CoinblocksCoindaysDormancySentVelocityPattern(client, 'lth') + self.realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized = MetricsTree_Distribution_UtxoCohorts_Lth_Realized(client) self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'lth') - self.unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern = GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern(client, 'lth') - self.relative: NetNuplSupplyUnrealizedPattern2 = NetNuplSupplyUnrealizedPattern2(client, 'lth') - self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_dormancy') - self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_velocity') - self.supply_delta_extended: _24hChangeRatePattern2[SatsSigned] = _24hChangeRatePattern2(client, 'lth_supply_delta') - self.utxo_count_delta_extended: _24hChangeRatePattern2[StoredI64] = _24hChangeRatePattern2(client, 'lth_utxo_count_delta') + self.unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern = GrossInvestedInvestorLossNetProfitSentimentPattern(client, 'lth') + self.relative: SupplyUnrealizedPattern2 = SupplyUnrealizedPattern2(client, 'lth') class MetricsTree_Distribution_UtxoCohorts_AgeRange: """Metrics tree node.""" @@ -4507,73 +5128,73 @@ class MetricsTree_Distribution_UtxoCohorts_GeAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1sat: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1sat') - self._10sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10sats') - self._100sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_100sats') - self._1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1k_sats') - self._10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10k_sats') - self._100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_100k_sats') - self._1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1m_sats') - self._10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10m_sats') - self._1btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1btc') - self._10btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10btc') - self._100btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_100btc') - self._1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_1k_btc') - self._10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_over_10k_btc') + self._1sat: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1sat') + self._10sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10sats') + self._100sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_100sats') + self._1k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1k_sats') + self._10k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10k_sats') + self._100k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_100k_sats') + self._1m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1m_sats') + self._10m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10m_sats') + self._1btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1btc') + self._10btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10btc') + self._100btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_100btc') + self._1k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_1k_btc') + self._10k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_over_10k_btc') class MetricsTree_Distribution_UtxoCohorts_AmountRange: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._0sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_with_0sats') - self._1sat_to_10sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_1sat_under_10sats') - self._10sats_to_100sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_10sats_under_100sats') - self._100sats_to_1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_100sats_under_1k_sats') - self._1k_sats_to_10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_1k_sats_under_10k_sats') - self._10k_sats_to_100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_10k_sats_under_100k_sats') - self._100k_sats_to_1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_100k_sats_under_1m_sats') - self._1m_sats_to_10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_1m_sats_under_10m_sats') - self._10m_sats_to_1btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_10m_sats_under_1btc') - self._1btc_to_10btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_1btc_under_10btc') - self._10btc_to_100btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_10btc_under_100btc') - self._100btc_to_1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_100btc_under_1k_btc') - self._1k_btc_to_10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_1k_btc_under_10k_btc') - self._10k_btc_to_100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_10k_btc_under_100k_btc') - self._100k_btc_or_more: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_above_100k_btc') + self._0sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_with_0sats') + self._1sat_to_10sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_1sat_under_10sats') + self._10sats_to_100sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_10sats_under_100sats') + self._100sats_to_1k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_100sats_under_1k_sats') + self._1k_sats_to_10k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_1k_sats_under_10k_sats') + self._10k_sats_to_100k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_10k_sats_under_100k_sats') + self._100k_sats_to_1m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_100k_sats_under_1m_sats') + self._1m_sats_to_10m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_1m_sats_under_10m_sats') + self._10m_sats_to_1btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_10m_sats_under_1btc') + self._1btc_to_10btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_1btc_under_10btc') + self._10btc_to_100btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_10btc_under_100btc') + self._100btc_to_1k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_100btc_under_1k_btc') + self._1k_btc_to_10k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_1k_btc_under_10k_btc') + self._10k_btc_to_100k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_10k_btc_under_100k_btc') + self._100k_btc_or_more: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_above_100k_btc') class MetricsTree_Distribution_UtxoCohorts_LtAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._10sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10sats') - self._100sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100sats') - self._1k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1k_sats') - self._10k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10k_sats') - self._100k_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100k_sats') - self._1m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1m_sats') - self._10m_sats: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10m_sats') - self._1btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1btc') - self._10btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10btc') - self._100btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100btc') - self._1k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_1k_btc') - self._10k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_10k_btc') - self._100k_btc: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'utxos_under_100k_btc') + self._10sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10sats') + self._100sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100sats') + self._1k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1k_sats') + self._10k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10k_sats') + self._100k_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100k_sats') + self._1m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1m_sats') + self._10m_sats: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10m_sats') + self._1btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1btc') + self._10btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10btc') + self._100btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100btc') + self._1k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_1k_btc') + self._10k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_10k_btc') + self._100k_btc: OutputsRealizedSupplyPattern = OutputsRealizedSupplyPattern(client, 'utxos_under_100k_btc') class MetricsTree_Distribution_UtxoCohorts_Type: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.p2pk65: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2pk65') - self.p2pk33: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2pk33') - self.p2pkh: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2pkh') - self.p2ms: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2ms') - self.p2sh: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2sh') - self.p2wpkh: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2wpkh') - self.p2wsh: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2wsh') - self.p2tr: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2tr') - self.p2a: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'p2a') - self.unknown: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'unknown_outputs') - self.empty: ActivityOutputsRealizedSupplyUnrealizedPattern = ActivityOutputsRealizedSupplyUnrealizedPattern(client, 'empty_outputs') + self.p2pk65: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2pk65') + self.p2pk33: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2pk33') + self.p2pkh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2pkh') + self.p2ms: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2ms') + self.p2sh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2sh') + self.p2wpkh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2wpkh') + self.p2wsh: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2wsh') + self.p2tr: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2tr') + self.p2a: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'p2a') + self.unknown: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'unknown_outputs') + self.empty: OutputsRealizedSupplyUnrealizedPattern = OutputsRealizedSupplyUnrealizedPattern(client, 'empty_outputs') class MetricsTree_Distribution_UtxoCohorts_Profitability_Range: """Metrics tree node.""" @@ -4689,7 +5310,7 @@ class MetricsTree_Distribution_UtxoCohorts: self.ge_amount: MetricsTree_Distribution_UtxoCohorts_GeAmount = MetricsTree_Distribution_UtxoCohorts_GeAmount(client) self.amount_range: MetricsTree_Distribution_UtxoCohorts_AmountRange = MetricsTree_Distribution_UtxoCohorts_AmountRange(client) self.lt_amount: MetricsTree_Distribution_UtxoCohorts_LtAmount = MetricsTree_Distribution_UtxoCohorts_LtAmount(client) - self.type_: MetricsTree_Distribution_UtxoCohorts_Type = MetricsTree_Distribution_UtxoCohorts_Type(client) + self.r#type: MetricsTree_Distribution_UtxoCohorts_Type = MetricsTree_Distribution_UtxoCohorts_Type(client) self.profitability: MetricsTree_Distribution_UtxoCohorts_Profitability = MetricsTree_Distribution_UtxoCohorts_Profitability(client) self.matured: MetricsTree_Distribution_UtxoCohorts_Matured = MetricsTree_Distribution_UtxoCohorts_Matured(client) @@ -4697,57 +5318,57 @@ class MetricsTree_Distribution_AddressCohorts_GeAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._1sat: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1sat') - self._10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10sats') - self._100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100sats') - self._1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_sats') - self._10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_sats') - self._100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100k_sats') - self._1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1m_sats') - self._10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10m_sats') - self._1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1btc') - self._10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10btc') - self._100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_100btc') - self._1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_1k_btc') - self._10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_over_10k_btc') + self._1sat: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_1sat') + self._10sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_10sats') + self._100sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_100sats') + self._1k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_1k_sats') + self._10k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_10k_sats') + self._100k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_100k_sats') + self._1m_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_1m_sats') + self._10m_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_10m_sats') + self._1btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_1btc') + self._10btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_10btc') + self._100btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_100btc') + self._1k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_1k_btc') + self._10k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_over_10k_btc') class MetricsTree_Distribution_AddressCohorts_AmountRange: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._0sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_with_0sats') - self._1sat_to_10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_1sat_under_10sats') - self._10sats_to_100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_10sats_under_100sats') - self._100sats_to_1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_100sats_under_1k_sats') - self._1k_sats_to_10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_1k_sats_under_10k_sats') - self._10k_sats_to_100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_10k_sats_under_100k_sats') - self._100k_sats_to_1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_100k_sats_under_1m_sats') - self._1m_sats_to_10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_1m_sats_under_10m_sats') - self._10m_sats_to_1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_10m_sats_under_1btc') - self._1btc_to_10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_1btc_under_10btc') - self._10btc_to_100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_10btc_under_100btc') - self._100btc_to_1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_100btc_under_1k_btc') - self._1k_btc_to_10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_1k_btc_under_10k_btc') - self._10k_btc_to_100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_10k_btc_under_100k_btc') - self._100k_btc_or_more: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_above_100k_btc') + self._0sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_with_0sats') + self._1sat_to_10sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_1sat_under_10sats') + self._10sats_to_100sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_10sats_under_100sats') + self._100sats_to_1k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_100sats_under_1k_sats') + self._1k_sats_to_10k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_1k_sats_under_10k_sats') + self._10k_sats_to_100k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_10k_sats_under_100k_sats') + self._100k_sats_to_1m_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_100k_sats_under_1m_sats') + self._1m_sats_to_10m_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_1m_sats_under_10m_sats') + self._10m_sats_to_1btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_10m_sats_under_1btc') + self._1btc_to_10btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_1btc_under_10btc') + self._10btc_to_100btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_10btc_under_100btc') + self._100btc_to_1k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_100btc_under_1k_btc') + self._1k_btc_to_10k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_1k_btc_under_10k_btc') + self._10k_btc_to_100k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_10k_btc_under_100k_btc') + self._100k_btc_or_more: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_above_100k_btc') class MetricsTree_Distribution_AddressCohorts_LtAmount: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self._10sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10sats') - self._100sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100sats') - self._1k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_sats') - self._10k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_sats') - self._100k_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_sats') - self._1m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1m_sats') - self._10m_sats: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10m_sats') - self._1btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1btc') - self._10btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10btc') - self._100btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100btc') - self._1k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_1k_btc') - self._10k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_10k_btc') - self._100k_btc: ActivityAddrOutputsRealizedSupplyUnrealizedPattern = ActivityAddrOutputsRealizedSupplyUnrealizedPattern(client, 'addrs_under_100k_btc') + self._10sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_10sats') + self._100sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_100sats') + self._1k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_1k_sats') + self._10k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_10k_sats') + self._100k_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_100k_sats') + self._1m_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_1m_sats') + self._10m_sats: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_10m_sats') + self._1btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_1btc') + self._10btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_10btc') + self._100btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_100btc') + self._1k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_1k_btc') + self._10k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_10k_btc') + self._100k_btc: AddrOutputsRealizedSupplyPattern = AddrOutputsRealizedSupplyPattern(client, 'addrs_under_100k_btc') class MetricsTree_Distribution_AddressCohorts: """Metrics tree node.""" @@ -4814,8 +5435,8 @@ class MetricsTree_Distribution: self.total_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern(client, 'total_addr_count') self.new_addr_count: MetricsTree_Distribution_NewAddrCount = MetricsTree_Distribution_NewAddrCount(client) self.delta: MetricsTree_Distribution_Delta = MetricsTree_Distribution_Delta(client) - self.fundedaddressindex: MetricPattern34[FundedAddressIndex] = MetricPattern34(client, 'fundedaddressindex') - self.emptyaddressindex: MetricPattern35[EmptyAddressIndex] = MetricPattern35(client, 'emptyaddressindex') + self.funded_address_index: MetricPattern34[FundedAddressIndex] = MetricPattern34(client, 'funded_address_index') + self.empty_address_index: MetricPattern35[EmptyAddressIndex] = MetricPattern35(client, 'empty_address_index') class MetricsTree_Supply_Burned: """Metrics tree node.""" @@ -4893,8 +5514,8 @@ class BrkClient(BrkClientBase): "month6", "year1", "year10", - "halvingepoch", - "difficultyepoch", + "halving", + "epoch", "height", "txindex", "txinindex",