From d50c6e0a733a18975fea20478038ba8c42ceda5f Mon Sep 17 00:00:00 2001 From: nym21 Date: Tue, 10 Mar 2026 18:10:50 +0100 Subject: [PATCH] global: snapshot --- Cargo.lock | 29 +- Cargo.toml | 2 +- crates/brk_cli/Cargo.toml | 2 +- crates/brk_client/src/lib.rs | 1553 ++++++----------- crates/brk_computer/src/cointime/compute.rs | 1 - .../src/cointime/pricing/compute.rs | 143 +- .../src/cointime/pricing/import.rs | 76 +- .../brk_computer/src/cointime/pricing/vecs.rs | 28 +- .../src/distribution/cohorts/address/vecs.rs | 1 + .../src/distribution/cohorts/utxo/fenwick.rs | 83 +- .../distribution/cohorts/utxo/percentiles.rs | 36 +- .../src/distribution/metrics/activity/core.rs | 61 +- .../src/distribution/metrics/activity/full.rs | 19 + .../src/distribution/metrics/cohort/all.rs | 2 +- .../src/distribution/metrics/cohort/core.rs | 2 + .../distribution/metrics/cohort/extended.rs | 2 +- .../src/distribution/metrics/config.rs | 4 +- .../distribution/metrics/cost_basis/mod.rs | 29 +- .../src/distribution/metrics/mod.rs | 2 + .../src/distribution/metrics/outputs/full.rs | 1 + .../src/distribution/metrics/realized/core.rs | 68 +- .../src/distribution/metrics/realized/full.rs | 94 +- .../distribution/metrics/realized/minimal.rs | 55 +- crates/brk_computer/src/indicators/compute.rs | 83 +- crates/brk_computer/src/indicators/import.rs | 7 + crates/brk_computer/src/indicators/vecs.rs | 3 + .../src/internal/per_block/ratio/extended.rs | 52 - .../src/internal/per_block/ratio/mod.rs | 4 +- .../internal/per_block/ratio/percentiles.rs | 21 +- .../per_block/ratio/price_extended.rs | 116 +- .../src/internal/per_block/ratio/sma.rs | 86 + .../internal/per_block/ratio/std_dev_bands.rs | 17 +- .../src/internal/per_block/stddev/extended.rs | 112 +- crates/brk_computer/src/lib.rs | 51 +- .../src/market/moving_average/import.rs | 4 +- .../src/market/technical/compute.rs | 2 +- crates/brk_computer/src/supply/vecs.rs | 1 + crates/brk_query/Cargo.toml | 4 +- crates/brk_query/examples/list.rs | 34 + crates/brk_query/src/impl/metrics.rs | 11 +- crates/brk_server/Cargo.toml | 3 + crates/brk_server/src/api/metrics/bulk.rs | 27 +- crates/brk_server/src/api/metrics/data.rs | 27 +- crates/brk_server/src/api/metrics/legacy.rs | 27 +- crates/brk_server/src/extended/encoding.rs | 88 + crates/brk_server/src/extended/header_map.rs | 23 +- crates/brk_server/src/extended/mod.rs | 4 +- crates/brk_server/src/extended/response.rs | 59 - crates/brk_server/src/extended/result.rs | 49 - crates/brk_server/src/state.rs | 146 +- crates/brk_types/src/basis_points_32.rs | 21 + crates/brk_types/src/index.rs | 8 - modules/brk-client/index.js | 1497 +++++++--------- packages/brk_client/brk_client/__init__.py | 757 +++----- 54 files changed, 2398 insertions(+), 3239 deletions(-) delete mode 100644 crates/brk_computer/src/internal/per_block/ratio/extended.rs create mode 100644 crates/brk_computer/src/internal/per_block/ratio/sma.rs create mode 100644 crates/brk_query/examples/list.rs create mode 100644 crates/brk_server/src/extended/encoding.rs delete mode 100644 crates/brk_server/src/extended/result.rs diff --git a/Cargo.lock b/Cargo.lock index 8750b2337..020d22a8b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -649,7 +649,9 @@ dependencies = [ "brk_traversable", "brk_types", "brk_website", + "brotli", "derive_more", + "flate2", "jiff", "quick_cache", "schemars", @@ -660,6 +662,7 @@ dependencies = [ "tower-layer", "tracing", "vecdb", + "zstd", ] [[package]] @@ -1124,7 +1127,7 @@ dependencies = [ "libc", "option-ext", "redox_users", - "windows-sys 0.61.2", + "windows-sys 0.60.2", ] [[package]] @@ -1202,7 +1205,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" dependencies = [ "libc", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -1238,9 +1241,9 @@ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "fjall" -version = "3.0.4" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ebf22b812878dcd767879cb19e03124fd62563dce6410f96538175fba0c132d" +checksum = "40cb1eb0cef3792900897b32c8282f6417bc978f6af46400a2f14bf0e649ae30" dependencies = [ "byteorder-lite", "byteview", @@ -1865,7 +1868,7 @@ dependencies = [ "portable-atomic", "portable-atomic-util", "serde_core", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -2020,9 +2023,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "lsm-tree" -version = "3.0.4" +version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9bfd2a6ea0c1d430c13643002f35800a87f200fc8ac4827f18a2db9d9fd0644" +checksum = "fc5fa40c207eed45c811085aaa1b0a25fead22e298e286081cd4b98785fe759b" dependencies = [ "byteorder-lite", "byteview", @@ -2398,8 +2401,6 @@ dependencies = [ [[package]] name = "quickmatch" version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba3b8437da19ff13b614fc03438308e7d642b4e625e31f8e3b61e1843bffbc02" dependencies = [ "rustc-hash", ] @@ -2629,7 +2630,7 @@ dependencies = [ "errno", "libc", "linux-raw-sys", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -2988,7 +2989,7 @@ dependencies = [ "getrandom 0.4.2", "once_cell", "rustix", - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] @@ -3070,9 +3071,9 @@ dependencies = [ [[package]] name = "toml" -version = "1.0.4+spec-1.1.0" +version = "1.0.6+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c94c3321114413476740df133f0d8862c61d87c8d26f04c6841e033c8c80db47" +checksum = "399b1124a3c9e16766831c6bba21e50192572cdd98706ea114f9502509686ffc" dependencies = [ "indexmap", "serde_core", @@ -3479,7 +3480,7 @@ version = "0.1.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" dependencies = [ - "windows-sys 0.61.2", + "windows-sys 0.52.0", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index b44009eee..99dde2870 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,7 +68,7 @@ brk_website = { version = "0.1.9", path = "crates/brk_website" } byteview = "0.10.1" color-eyre = "0.6.5" derive_more = { version = "2.1.1", features = ["deref", "deref_mut"] } -fjall = "3.0.4" +fjall = "3.1.0" indexmap = { version = "2.13.0", features = ["serde"] } jiff = { version = "0.2.23", features = ["perf-inline", "tz-system"], default-features = false } minreq = { version = "2.14.1", features = ["https", "json-using-serde"] } diff --git a/crates/brk_cli/Cargo.toml b/crates/brk_cli/Cargo.toml index f960eeeae..5e815d977 100644 --- a/crates/brk_cli/Cargo.toml +++ b/crates/brk_cli/Cargo.toml @@ -26,7 +26,7 @@ owo-colors = { workspace = true } tracing = { workspace = true } serde = { workspace = true } tokio = { workspace = true } -toml = "1.0.4" +toml = "1.0.6" vecdb = { workspace = true } [[bin]] diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 70cb72d57..bc0f84483 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -990,8 +990,8 @@ impl Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75 } /// Pattern struct for repeated tree structure. -pub struct _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { - pub _0sd: PriceValuePattern, +pub struct _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern { + pub _0sd: CentsSatsUsdPattern, pub m0_5sd: PriceValuePattern, pub m1_5sd: PriceValuePattern, pub m1sd: PriceValuePattern, @@ -1005,15 +1005,14 @@ pub struct _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { pub p2sd: PriceValuePattern, pub p3sd: PriceValuePattern, pub sd: MetricPattern1, - pub sma: MetricPattern1, pub zscore: MetricPattern1, } -impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { +impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern { /// 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")), + _0sd: CentsSatsUsdPattern::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")), @@ -1027,52 +1026,11 @@ impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern { 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: RawSellSumPattern, - pub investor: CapLowerPriceUpperPattern, - pub loss: CapitulationCumulativeNegativeRawRelSumValuePattern, - pub mvrv: MetricPattern1, - pub net_pnl: ChangeCumulativeDeltaRawRelSumPattern, - pub nupl: BpsRatioPattern, - pub peak_regret: CumulativeRawRelPattern, - pub price: CentsSatsUsdPattern, - pub price_ratio: BpsPercentilesRatioStdPattern, - pub profit: CumulativeDistributionRawRelSumValuePattern, - pub profit_to_loss_ratio: _1m1w1y24hPattern, - pub sent: InPattern3, - pub sopr: AdjustedRatioValuePattern, -} - -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: RawSellSumPattern::new(client.clone(), acc.clone()), - investor: CapLowerPriceUpperPattern::new(client.clone(), acc.clone()), - loss: CapitulationCumulativeNegativeRawRelSumValuePattern::new(client.clone(), acc.clone()), - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - net_pnl: ChangeCumulativeDeltaRawRelSumPattern::new(client.clone(), _m(&acc, "net")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), - peak_regret: CumulativeRawRelPattern::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: CumulativeDistributionRawRelSumValuePattern::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()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 { pub _10y: BpsPercentRatioPattern, @@ -1145,6 +1103,42 @@ impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 { } } +/// Pattern struct for repeated tree structure. +pub struct CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern { + pub cap: CentsDeltaRawRelUsdPattern, + pub gross_pnl: RawSellSumPattern, + pub investor: CapLowerPriceUpperPattern, + pub loss: CapitulationCumulativeNegativeRawRelSumValuePattern, + pub mvrv: MetricPattern1, + pub net_pnl: ChangeCumulativeDeltaRawRelSumPattern, + pub nupl: BpsRatioPattern, + pub peak_regret: CumulativeRawRelPattern, + pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, + pub profit: CumulativeDistributionRawRelSumValuePattern, + pub profit_to_loss_ratio: _1m1w1y24hPattern, + pub sopr: AdjustedRatioValuePattern, +} + +impl CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern { + /// 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: RawSellSumPattern::new(client.clone(), acc.clone()), + investor: CapLowerPriceUpperPattern::new(client.clone(), acc.clone()), + loss: CapitulationCumulativeNegativeRawRelSumValuePattern::new(client.clone(), acc.clone()), + mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), + net_pnl: ChangeCumulativeDeltaRawRelSumPattern::new(client.clone(), _m(&acc, "net")), + nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl_ratio")), + peak_regret: CumulativeRawRelPattern::new(client.clone(), _m(&acc, "realized_peak_regret")), + price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + profit: CumulativeDistributionRawRelSumValuePattern::new(client.clone(), acc.clone()), + profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit_to_loss_ratio")), + sopr: AdjustedRatioValuePattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern { pub average: MetricPattern18, @@ -1245,70 +1239,6 @@ impl AverageGainsLossesRsiStochPattern { } } -/// Pattern struct for repeated tree structure. -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 BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern { - /// 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")), - 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: CumulativeNegativeRawSumPattern, - pub mvrv: MetricPattern1, - pub net_pnl: RawSumPattern2, - pub nupl: BpsRatioPattern, - pub price: CentsSatsUsdPattern, - pub price_ratio: BpsRatioPattern, - pub profit: CumulativeRawSumPattern2, - 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: CumulativeNegativeRawSumPattern::new(client.clone(), acc.clone()), - mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), - net_pnl: RawSumPattern2::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: CumulativeRawSumPattern2::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 AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern { pub all: MetricPattern1, @@ -1428,29 +1358,57 @@ impl _1m1w1y24hBtcCentsSatsUsdPattern { } /// Pattern struct for repeated tree structure. -pub struct CapLossMvrvNuplPriceProfitSoprPattern { - pub cap: CentsUsdPattern, - pub loss: RawSumPattern, - pub mvrv: MetricPattern1, - pub nupl: BpsRatioPattern, - pub price: CentsSatsUsdPattern, - pub price_ratio: BpsRatioPattern, - pub profit: RawSumPattern, - pub sopr: ValuePattern, +pub struct BpsCentsPercentilesRatioSatsSmaStdUsdPattern { + pub bps: MetricPattern1, + pub cents: MetricPattern1, + pub percentiles: Pct1Pct2Pct5Pct95Pct98Pct99Pattern, + pub ratio: MetricPattern1, + pub sats: MetricPattern1, + pub sma: _1m1w1y2y4yAllPattern, + pub std_dev: _1y2y4yAllPattern, + pub usd: MetricPattern1, } -impl CapLossMvrvNuplPriceProfitSoprPattern { +impl BpsCentsPercentilesRatioSatsSmaStdUsdPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - cap: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), - loss: RawSumPattern::new(client.clone(), _m(&acc, "realized_loss")), + bps: MetricPattern1::new(client.clone(), _m(&acc, "ratio_bps")), + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + percentiles: Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), _m(&acc, "ratio")), + ratio: MetricPattern1::new(client.clone(), _m(&acc, "ratio")), + sats: MetricPattern1::new(client.clone(), _m(&acc, "sats")), + sma: _1m1w1y2y4yAllPattern::new(client.clone(), _m(&acc, "ratio_sma")), + std_dev: _1y2y4yAllPattern::new(client.clone(), _m(&acc, "ratio")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "usd")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CapLossMvrvNetNuplPriceProfitSoprPattern { + pub cap: CentsDeltaUsdPattern, + pub loss: CumulativeNegativeRawSumPattern, + pub mvrv: MetricPattern1, + pub net_pnl: RawSumPattern2, + pub nupl: BpsRatioPattern, + pub price: BpsCentsRatioSatsUsdPattern, + pub profit: CumulativeRawSumPattern2, + pub sopr: RatioValuePattern, +} + +impl CapLossMvrvNetNuplPriceProfitSoprPattern { + /// 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: CumulativeNegativeRawSumPattern::new(client.clone(), acc.clone()), mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")), + net_pnl: RawSumPattern2::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: RawSumPattern::new(client.clone(), _m(&acc, "realized_profit")), - sopr: ValuePattern::new(client.clone(), _m(&acc, "value")), + price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + profit: CumulativeRawSumPattern2::new(client.clone(), _m(&acc, "realized_profit")), + sopr: RatioValuePattern::new(client.clone(), acc.clone()), } } } @@ -1462,7 +1420,7 @@ pub struct CapitulationCumulativeNegativeRawRelSumValuePattern { pub negative: MetricPattern1, pub raw: CentsUsdPattern, pub rel_to_rcap: BpsPercentRatioPattern, - pub sum: _1m1w1y24hPattern4, + pub sum: _1m1w1y24hPattern5, pub value_created: BaseSumPattern, pub value_destroyed: BaseSumPattern, } @@ -1476,69 +1434,13 @@ impl CapitulationCumulativeNegativeRawRelSumValuePattern { negative: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")), raw: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_loss")), rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")), - sum: _1m1w1y24hPattern4::new(client.clone(), _m(&acc, "realized_loss")), + sum: _1m1w1y24hPattern5::new(client.clone(), _m(&acc, "realized_loss")), value_created: BaseSumPattern::new(client.clone(), _m(&acc, "loss_value_created")), value_destroyed: BaseSumPattern::new(client.clone(), _m(&acc, "loss_value_destroyed")), } } } -/// Pattern struct for repeated tree structure. -pub struct CoindaysCoinyearsDormancySentVelocityPattern { - pub coindays_destroyed: CumulativeRawSumPattern, - pub coindays_destroyed_supply_adjusted: MetricPattern1, - pub coinyears_destroyed: MetricPattern1, - pub coinyears_destroyed_supply_adjusted: MetricPattern1, - pub dormancy: MetricPattern1, - pub dormancy_supply_adjusted: MetricPattern1, - pub sent: RawSumPattern3, - pub velocity: MetricPattern1, -} - -impl CoindaysCoinyearsDormancySentVelocityPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - coindays_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - coindays_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "coindays_destroyed_supply_adjusted")), - coinyears_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), - coinyears_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed_supply_adjusted")), - dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), - dormancy_supply_adjusted: MetricPattern1::new(client.clone(), _m(&acc, "dormancy_supply_adjusted")), - sent: RawSumPattern3::new(client.clone(), _m(&acc, "sent")), - velocity: MetricPattern1::new(client.clone(), _m(&acc, "velocity")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern { - pub pct1: BpsPriceRatioPattern, - 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")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern { pub average: MetricPattern18, @@ -1619,13 +1521,39 @@ impl _1m1w1y24hBpsPercentRatioPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CapLossMvrvNuplPriceProfitSoprPattern { + pub cap: CentsUsdPattern, + pub loss: RawSumPattern, + pub mvrv: MetricPattern1, + pub nupl: BpsRatioPattern, + pub price: BpsCentsRatioSatsUsdPattern, + pub profit: RawSumPattern, + pub sopr: ValuePattern, +} + +impl CapLossMvrvNuplPriceProfitSoprPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cap: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), + loss: RawSumPattern::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: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + profit: RawSumPattern::new(client.clone(), _m(&acc, "realized_profit")), + sopr: ValuePattern::new(client.clone(), _m(&acc, "value")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct CumulativeDistributionRawRelSumValuePattern { pub cumulative: MetricPattern1, pub distribution_flow: MetricPattern1, pub raw: CentsUsdPattern, pub rel_to_rcap: BpsPercentRatioPattern, - pub sum: _1m1w1y24hPattern4, + pub sum: _1m1w1y24hPattern5, pub value_created: BaseSumPattern, pub value_destroyed: BaseSumPattern, } @@ -1638,7 +1566,7 @@ impl CumulativeDistributionRawRelSumValuePattern { distribution_flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")), raw: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_profit")), rel_to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")), - sum: _1m1w1y24hPattern4::new(client.clone(), _m(&acc, "realized_profit")), + sum: _1m1w1y24hPattern5::new(client.clone(), _m(&acc, "realized_profit")), value_created: BaseSumPattern::new(client.clone(), _m(&acc, "profit_value_created")), value_destroyed: BaseSumPattern::new(client.clone(), _m(&acc, "profit_value_destroyed")), } @@ -1648,8 +1576,8 @@ impl CumulativeDistributionRawRelSumValuePattern { /// Pattern struct for repeated tree structure. pub struct GrossInvestedInvestorLossNetProfitSentimentPattern2 { pub gross_pnl: CentsUsdPattern, - pub invested_capital: InPattern4, - pub investor_cap: InPattern2, + pub invested_capital: InPattern2, + pub investor_cap: InPattern, pub loss: NegativeRawRelSumPattern2, pub net_pnl: CentsRelUsdPattern2, pub profit: RawRelSumPattern2, @@ -1661,8 +1589,8 @@ impl GrossInvestedInvestorLossNetProfitSentimentPattern2 { pub fn new(client: Arc, acc: String) -> Self { Self { gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_gross_pnl")), - invested_capital: InPattern4::new(client.clone(), _m(&acc, "invested_capital_in")), - investor_cap: InPattern2::new(client.clone(), _m(&acc, "investor_cap_in")), + invested_capital: InPattern2::new(client.clone(), _m(&acc, "invested_capital_in")), + investor_cap: InPattern::new(client.clone(), _m(&acc, "investor_cap_in")), loss: NegativeRawRelSumPattern2::new(client.clone(), acc.clone()), net_pnl: CentsRelUsdPattern2::new(client.clone(), _m(&acc, "net_unrealized_pnl")), profit: RawRelSumPattern2::new(client.clone(), _m(&acc, "unrealized_profit")), @@ -1671,6 +1599,54 @@ impl GrossInvestedInvestorLossNetProfitSentimentPattern2 { } } +/// Pattern struct for repeated tree structure. +pub struct _1m1w1y2y4yAllPattern { + pub _1m: BpsRatioPattern, + pub _1w: BpsRatioPattern, + pub _1y: BpsRatioPattern, + pub _2y: BpsRatioPattern, + pub _4y: BpsRatioPattern, + pub all: BpsRatioPattern, +} + +impl _1m1w1y2y4yAllPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: BpsRatioPattern::new(client.clone(), _m(&acc, "1m")), + _1w: BpsRatioPattern::new(client.clone(), _m(&acc, "1w")), + _1y: BpsRatioPattern::new(client.clone(), _m(&acc, "1y")), + _2y: BpsRatioPattern::new(client.clone(), _m(&acc, "2y")), + _4y: BpsRatioPattern::new(client.clone(), _m(&acc, "4y")), + all: BpsRatioPattern::new(client.clone(), _m(&acc, "all")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct BpsCentsPercentilesRatioSatsUsdPattern { + pub bps: MetricPattern1, + pub cents: MetricPattern1, + pub percentiles: Pct1Pct2Pct5Pct95Pct98Pct99Pattern, + pub ratio: MetricPattern1, + pub sats: MetricPattern1, + pub usd: MetricPattern1, +} + +impl BpsCentsPercentilesRatioSatsUsdPattern { + /// 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")), + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + percentiles: Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), _m(&acc, "ratio")), + ratio: MetricPattern1::new(client.clone(), _m(&acc, "ratio")), + sats: MetricPattern1::new(client.clone(), _m(&acc, "sats")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "usd")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct BtcCentsRelSatsUsdPattern3 { pub btc: MetricPattern1, @@ -1695,30 +1671,6 @@ impl BtcCentsRelSatsUsdPattern3 { } } -/// Pattern struct for repeated tree structure. -pub struct CapLowerPriceUpperPattern { - pub cap: RawPattern, - 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: RawPattern::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 ChangeCumulativeDeltaRawRelSumPattern { pub change_1m: RelPattern, @@ -1815,11 +1767,35 @@ impl NegativeRawRelSumPattern2 { } } +/// Pattern struct for repeated tree structure. +pub struct Pct1Pct2Pct5Pct95Pct98Pct99Pattern { + pub pct1: BpsPriceRatioPattern, + pub pct2: BpsPriceRatioPattern, + pub pct5: BpsPriceRatioPattern, + pub pct95: BpsPriceRatioPattern, + pub pct98: BpsPriceRatioPattern, + pub pct99: BpsPriceRatioPattern, +} + +impl Pct1Pct2Pct5Pct95Pct98Pct99Pattern { + /// 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")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct ActivityOutputsRealizedSupplyUnrealizedPattern { pub activity: CoindaysSentPattern, pub outputs: UtxoPattern2, - pub realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern, + pub realized: CapLossMvrvNetNuplPriceProfitSoprPattern, pub supply: DeltaHalvedInRelTotalPattern, pub unrealized: InvestedInvestorLossNetProfitPattern, } @@ -1830,7 +1806,7 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern { Self { activity: CoindaysSentPattern::new(client.clone(), acc.clone()), outputs: UtxoPattern2::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern::new(client.clone(), acc.clone()), + realized: CapLossMvrvNetNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), supply: DeltaHalvedInRelTotalPattern::new(client.clone(), _m(&acc, "supply")), unrealized: InvestedInvestorLossNetProfitPattern::new(client.clone(), acc.clone()), } @@ -1841,7 +1817,7 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern { pub struct ActivityOutputsRealizedSupplyUnrealizedPattern2 { pub activity: CoindaysSentPattern, pub outputs: UtxoPattern2, - pub realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern, + pub realized: CapLossMvrvNetNuplPriceProfitSoprPattern, pub supply: DeltaHalvedInRelTotalPattern, pub unrealized: LossNetProfitPattern, } @@ -1852,7 +1828,7 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern2 { Self { activity: CoindaysSentPattern::new(client.clone(), acc.clone()), outputs: UtxoPattern2::new(client.clone(), _m(&acc, "utxo_count")), - realized: CapLossMvrvNetNuplPriceProfitSentSoprPattern::new(client.clone(), acc.clone()), + realized: CapLossMvrvNetNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), supply: DeltaHalvedInRelTotalPattern::new(client.clone(), _m(&acc, "supply")), unrealized: LossNetProfitPattern::new(client.clone(), acc.clone()), } @@ -1860,23 +1836,23 @@ impl ActivityOutputsRealizedSupplyUnrealizedPattern2 { } /// 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, +pub struct BpsCentsRatioSatsUsdPattern { + pub bps: MetricPattern1, + pub cents: MetricPattern1, + pub ratio: MetricPattern1, + pub sats: MetricPattern1, + pub usd: MetricPattern1, } -impl AddrOutputsRealizedSupplyPattern { +impl BpsCentsRatioSatsUsdPattern { /// 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")), + bps: MetricPattern1::new(client.clone(), _m(&acc, "ratio_bps")), + cents: MetricPattern1::new(client.clone(), _m(&acc, "cents")), + ratio: MetricPattern1::new(client.clone(), _m(&acc, "ratio")), + sats: MetricPattern1::new(client.clone(), _m(&acc, "sats")), + usd: MetricPattern1::new(client.clone(), _m(&acc, "usd")), } } } @@ -1947,6 +1923,28 @@ impl CentsDeltaRawRelUsdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CoindaysCoinyearsDormancySentVelocityPattern { + pub coindays_destroyed: CumulativeRawSumPattern, + pub coinyears_destroyed: MetricPattern1, + pub dormancy: MetricPattern1, + pub sent: InRawSumPattern2, + pub velocity: MetricPattern1, +} + +impl CoindaysCoinyearsDormancySentVelocityPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + coindays_destroyed: CumulativeRawSumPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + coinyears_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "coinyears_destroyed")), + dormancy: MetricPattern1::new(client.clone(), _m(&acc, "dormancy")), + sent: InRawSumPattern2::new(client.clone(), _m(&acc, "sent")), + velocity: MetricPattern1::new(client.clone(), _m(&acc, "velocity")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct EmaHistogramLineSignalPattern { pub ema_fast: MetricPattern1, @@ -1971,8 +1969,8 @@ impl EmaHistogramLineSignalPattern { /// Pattern struct for repeated tree structure. pub struct InvestedInvestorLossNetProfitPattern { - pub invested_capital: InPattern2, - pub investor_cap: InPattern2, + pub invested_capital: InPattern, + pub investor_cap: InPattern, pub loss: NegativeRawSumPattern, pub net_pnl: CentsUsdPattern, pub profit: RawSumPattern, @@ -1982,8 +1980,8 @@ 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")), + invested_capital: InPattern::new(client.clone(), _m(&acc, "invested_capital_in")), + investor_cap: InPattern::new(client.clone(), _m(&acc, "investor_cap_in")), loss: NegativeRawSumPattern::new(client.clone(), acc.clone()), net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), profit: RawSumPattern::new(client.clone(), _m(&acc, "unrealized_profit")), @@ -1991,6 +1989,28 @@ impl InvestedInvestorLossNetProfitPattern { } } +/// Pattern struct for repeated tree structure. +pub struct InvestedMaxMinPercentilesSupplyPattern { + pub invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, + pub max: CentsSatsUsdPattern, + pub min: CentsSatsUsdPattern, + pub percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, + pub supply_density: BpsPercentRatioPattern, +} + +impl InvestedMaxMinPercentilesSupplyPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), _m(&acc, "invested_capital")), + max: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "cost_basis_max")), + min: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "cost_basis_min")), + percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), _m(&acc, "cost_basis")), + supply_density: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_density")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct PhsReboundThsPattern { pub phs: MetricPattern1, @@ -2098,14 +2118,14 @@ impl _1m1w1y24hPattern8 { } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern4 { +pub struct _1m1w1y24hPattern5 { pub _1m: MetricPattern1, pub _1w: MetricPattern1, pub _1y: MetricPattern1, pub _24h: CentsUsdPattern, } -impl _1m1w1y24hPattern4 { +impl _1m1w1y24hPattern5 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2138,14 +2158,14 @@ impl _1m1w1y2wPattern { } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern3 { +pub struct _1m1w1y24hPattern4 { pub _1m: CentsUsdPattern, pub _1w: CentsUsdPattern, pub _1y: CentsUsdPattern, pub _24h: CentsUsdPattern, } -impl _1m1w1y24hPattern3 { +impl _1m1w1y24hPattern4 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2158,14 +2178,14 @@ impl _1m1w1y24hPattern3 { } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern5 { +pub struct _1m1w1y24hPattern3 { pub _1m: MetricPattern1, pub _1w: MetricPattern1, pub _1y: MetricPattern1, pub _24h: BtcCentsSatsUsdPattern, } -impl _1m1w1y24hPattern5 { +impl _1m1w1y24hPattern3 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2179,20 +2199,40 @@ impl _1m1w1y24hPattern5 { /// Pattern struct for repeated tree structure. pub struct _1y2y4yAllPattern { - pub _1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, - pub _2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, - pub _4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, - pub all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern, + pub _1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern, + pub _2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern, + pub _4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern, + pub all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern, } 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()), + _1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern::new(client.clone(), acc.clone()), + _2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern::new(client.clone(), acc.clone()), + _4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern::new(client.clone(), acc.clone()), + all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct AddrOutputsRealizedSupplyPattern { + pub addr_count: BaseDeltaPattern, + 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: BaseDeltaPattern::new(client.clone(), _m(&acc, "addr_count")), + outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: CapLossMvrvNuplPriceProfitSoprPattern::new(client.clone(), acc.clone()), + supply: HalvedTotalPattern::new(client.clone(), _m(&acc, "supply")), } } } @@ -2237,26 +2277,6 @@ 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, @@ -2277,6 +2297,26 @@ impl BtcCentsSatsUsdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct CapLowerPriceUpperPattern { + pub cap: RawPattern, + pub lower_price_band: CentsSatsUsdPattern, + pub price: BpsCentsPercentilesRatioSatsUsdPattern, + 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: RawPattern::new(client.clone(), _m(&acc, "investor_cap_raw")), + lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")), + price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")), + upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct CentsRelUsdPattern2 { pub cents: MetricPattern1, @@ -2338,21 +2378,41 @@ impl HalvedInTotalPattern { } /// Pattern struct for repeated tree structure. -pub struct InvestedMaxMinPercentilesPattern { - pub invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, - pub max: CentsSatsUsdPattern, - pub min: CentsSatsUsdPattern, - pub percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, +pub struct InRawSumPattern { + pub in_loss: RawSumPattern4, + pub in_profit: RawSumPattern4, + pub raw: MetricPattern1, + pub sum: _24hPattern2, } -impl InvestedMaxMinPercentilesPattern { +impl InRawSumPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), _m(&acc, "invested_capital")), - max: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "cost_basis_max")), - min: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "cost_basis_min")), - percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), _m(&acc, "cost_basis")), + in_loss: RawSumPattern4::new(client.clone(), _m(&acc, "in_loss")), + in_profit: RawSumPattern4::new(client.clone(), _m(&acc, "in_profit")), + raw: MetricPattern1::new(client.clone(), acc.clone()), + sum: _24hPattern2::new(client.clone(), _m(&acc, "24h")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct InRawSumPattern2 { + pub in_loss: RawSumPattern5, + pub in_profit: RawSumPattern5, + pub raw: MetricPattern1, + pub sum: _1m1w1y24hPattern, +} + +impl InRawSumPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + in_loss: RawSumPattern5::new(client.clone(), _m(&acc, "in_loss")), + in_profit: RawSumPattern5::new(client.clone(), _m(&acc, "in_profit")), + raw: MetricPattern1::new(client.clone(), acc.clone()), + sum: _1m1w1y24hPattern::new(client.clone(), acc.clone()), } } } @@ -2771,6 +2831,38 @@ impl BaseSumPattern { } } +/// Pattern struct for repeated tree structure. +pub struct BaseDeltaPattern { + pub base: MetricPattern1, + pub delta: ChangeRatePattern, +} + +impl BaseDeltaPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + base: MetricPattern1::new(client.clone(), acc.clone()), + delta: ChangeRatePattern::new(client.clone(), _m(&acc, "delta")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct BaseDeltaPattern2 { + pub base: MetricPattern1, + pub delta: ChangeRatePattern2, +} + +impl BaseDeltaPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + base: MetricPattern1::new(client.clone(), acc.clone()), + delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct BlocksDominancePattern { pub blocks_mined: CumulativeRawPattern, @@ -2837,7 +2929,7 @@ impl ChangeRatePattern2 { /// Pattern struct for repeated tree structure. pub struct ChangeRatePattern4 { - pub change: _1m1w1y24hPattern3, + pub change: _1m1w1y24hPattern4, pub rate: _1m1w1y24hPattern2, } @@ -2845,7 +2937,7 @@ impl ChangeRatePattern4 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - change: _1m1w1y24hPattern3::new(client.clone(), _m(&acc, "change")), + change: _1m1w1y24hPattern4::new(client.clone(), _m(&acc, "change")), rate: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "rate")), } } @@ -2886,7 +2978,7 @@ impl ChangeRatePattern3 { /// Pattern struct for repeated tree structure. pub struct CoindaysSentPattern { pub coindays_destroyed: RawSumPattern2, - pub sent: RawSumPattern2, + pub sent: InRawSumPattern, } impl CoindaysSentPattern { @@ -2894,7 +2986,7 @@ impl CoindaysSentPattern { pub fn new(client: Arc, acc: String) -> Self { Self { coindays_destroyed: RawSumPattern2::new(client.clone(), _m(&acc, "coindays_destroyed")), - sent: RawSumPattern2::new(client.clone(), _m(&acc, "sent")), + sent: InRawSumPattern::new(client.clone(), _m(&acc, "sent")), } } } @@ -2916,12 +3008,12 @@ impl HalvedTotalPattern { } /// Pattern struct for repeated tree structure. -pub struct InPattern4 { +pub struct InPattern2 { pub in_loss: CentsRawUsdPattern, pub in_profit: CentsRawUsdPattern, } -impl InPattern4 { +impl InPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { @@ -2932,49 +3024,17 @@ impl InPattern4 { } /// Pattern struct for repeated tree structure. -pub struct InPattern2 { +pub struct InPattern { 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 InPattern { - pub in_loss: RawSumPattern4, - pub in_profit: RawSumPattern4, -} - impl InPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - in_loss: RawSumPattern4::new(client.clone(), _m(&acc, "loss")), - in_profit: RawSumPattern4::new(client.clone(), _m(&acc, "profit")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct InPattern3 { - pub in_loss: RawSumPattern5, - pub in_profit: RawSumPattern5, -} - -impl InPattern3 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - in_loss: RawSumPattern5::new(client.clone(), _m(&acc, "loss")), - in_profit: RawSumPattern5::new(client.clone(), _m(&acc, "profit")), + in_loss: RawPattern::new(client.clone(), _m(&acc, "loss_raw")), + in_profit: RawPattern::new(client.clone(), _m(&acc, "profit_raw")), } } } @@ -3014,7 +3074,7 @@ impl PriceValuePattern { /// Pattern struct for repeated tree structure. pub struct RawSumPattern5 { pub raw: BtcCentsSatsUsdPattern, - pub sum: _1m1w1y24hPattern5, + pub sum: _1m1w1y24hPattern3, } impl RawSumPattern5 { @@ -3022,7 +3082,7 @@ impl RawSumPattern5 { pub fn new(client: Arc, acc: String) -> Self { Self { raw: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), - sum: _1m1w1y24hPattern5::new(client.clone(), acc.clone()), + sum: _1m1w1y24hPattern3::new(client.clone(), acc.clone()), } } } @@ -3107,38 +3167,6 @@ impl SdSmaPattern { } } -/// Pattern struct for repeated tree structure. -pub struct UtxoPattern2 { - pub utxo_count: MetricPattern1, - pub utxo_count_delta: ChangeRatePattern, -} - -impl UtxoPattern2 { - /// 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()), - utxo_count_delta: ChangeRatePattern::new(client.clone(), _m(&acc, "delta")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct UtxoPattern3 { - pub utxo_count: MetricPattern1, - pub utxo_count_delta: ChangeRatePattern2, -} - -impl UtxoPattern3 { - /// 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()), - utxo_count_delta: ChangeRatePattern2::new(client.clone(), _m(&acc, "delta")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct ValuePattern { pub value_created: RawSumPattern2, @@ -3259,6 +3287,34 @@ impl _24hPattern { } } +/// Pattern struct for repeated tree structure. +pub struct UtxoPattern2 { + pub utxo_count: BaseDeltaPattern, +} + +impl UtxoPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + utxo_count: BaseDeltaPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct UtxoPattern3 { + pub utxo_count: BaseDeltaPattern2, +} + +impl UtxoPattern3 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + utxo_count: BaseDeltaPattern2::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct UtxoPattern { pub utxo_count: MetricPattern1, @@ -4257,44 +4313,28 @@ impl MetricsTree_Cointime_Cap { /// Metrics tree node. pub struct MetricsTree_Cointime_Pricing { - pub vaulted_price: CentsSatsUsdPattern, - pub vaulted_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, - pub active_price: CentsSatsUsdPattern, - pub active_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, - pub true_market_mean: CentsSatsUsdPattern, - pub true_market_mean_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, - pub cointime_price: CentsSatsUsdPattern, - pub cointime_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, - pub transfer_price: CentsSatsUsdPattern, - pub transfer_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, - pub balanced_price: CentsSatsUsdPattern, - pub balanced_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, - pub terminal_price: CentsSatsUsdPattern, - pub terminal_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, - pub delta_price: CentsSatsUsdPattern, - pub delta_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern, + pub vaulted_price: BpsCentsPercentilesRatioSatsUsdPattern, + pub active_price: BpsCentsPercentilesRatioSatsUsdPattern, + pub true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern, + pub cointime_price: BpsCentsPercentilesRatioSatsUsdPattern, + pub transfer_price: BpsCentsPercentilesRatioSatsUsdPattern, + pub balanced_price: BpsCentsPercentilesRatioSatsUsdPattern, + pub terminal_price: BpsCentsPercentilesRatioSatsUsdPattern, + pub delta_price: BpsCentsPercentilesRatioSatsUsdPattern, pub cumulative_market_cap: MetricPattern1, } 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: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "vaulted_price_ratio".to_string()), - active_price: CentsSatsUsdPattern::new(client.clone(), "active_price".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: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "true_market_mean_ratio".to_string()), - cointime_price: CentsSatsUsdPattern::new(client.clone(), "cointime_price".to_string()), - cointime_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "cointime_price_ratio".to_string()), - transfer_price: CentsSatsUsdPattern::new(client.clone(), "transfer_price".to_string()), - transfer_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "transfer_price_ratio".to_string()), - balanced_price: CentsSatsUsdPattern::new(client.clone(), "balanced_price".to_string()), - balanced_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "balanced_price_ratio".to_string()), - terminal_price: CentsSatsUsdPattern::new(client.clone(), "terminal_price".to_string()), - terminal_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "terminal_price_ratio".to_string()), - delta_price: CentsSatsUsdPattern::new(client.clone(), "delta_price".to_string()), - delta_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern::new(client.clone(), "delta_price_ratio".to_string()), + vaulted_price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "vaulted_price".to_string()), + active_price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "active_price".to_string()), + true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "true_market_mean".to_string()), + cointime_price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "cointime_price".to_string()), + transfer_price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "transfer_price".to_string()), + balanced_price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "balanced_price".to_string()), + terminal_price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "terminal_price".to_string()), + delta_price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "delta_price".to_string()), cumulative_market_cap: MetricPattern1::new(client.clone(), "cumulative_market_cap".to_string()), } } @@ -4961,6 +5001,12 @@ pub struct MetricsTree_Indicators { pub gini: BpsPercentRatioPattern, pub rhodl_ratio: BpsRatioPattern, pub thermocap_multiple: BpsRatioPattern, + pub coindays_destroyed_supply_adjusted: MetricPattern1, + pub coinyears_destroyed_supply_adjusted: MetricPattern1, + pub dormancy_supply_adjusted: MetricPattern1, + pub stock_to_flow: MetricPattern1, + pub dormancy_flow: MetricPattern1, + pub seller_exhaustion_constant: MetricPattern1, } impl MetricsTree_Indicators { @@ -4971,6 +5017,12 @@ impl MetricsTree_Indicators { gini: BpsPercentRatioPattern::new(client.clone(), "gini".to_string()), rhodl_ratio: BpsRatioPattern::new(client.clone(), "rhodl_ratio".to_string()), thermocap_multiple: BpsRatioPattern::new(client.clone(), "thermocap_multiple".to_string()), + coindays_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), "coindays_destroyed_supply_adjusted".to_string()), + coinyears_destroyed_supply_adjusted: MetricPattern1::new(client.clone(), "coinyears_destroyed_supply_adjusted".to_string()), + dormancy_supply_adjusted: MetricPattern1::new(client.clone(), "dormancy_supply_adjusted".to_string()), + stock_to_flow: MetricPattern1::new(client.clone(), "stock_to_flow".to_string()), + dormancy_flow: MetricPattern1::new(client.clone(), "dormancy_flow".to_string()), + seller_exhaustion_constant: MetricPattern1::new(client.clone(), "seller_exhaustion_constant".to_string()), } } } @@ -5218,22 +5270,22 @@ impl MetricsTree_Market_MovingAverage { /// 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 _1w: BpsCentsRatioSatsUsdPattern, + pub _8d: BpsCentsRatioSatsUsdPattern, + pub _13d: BpsCentsRatioSatsUsdPattern, + pub _21d: BpsCentsRatioSatsUsdPattern, + pub _1m: BpsCentsRatioSatsUsdPattern, + pub _34d: BpsCentsRatioSatsUsdPattern, + pub _55d: BpsCentsRatioSatsUsdPattern, + pub _89d: BpsCentsRatioSatsUsdPattern, + pub _111d: BpsCentsRatioSatsUsdPattern, + pub _144d: BpsCentsRatioSatsUsdPattern, + pub _200d: BpsCentsRatioSatsUsdPattern, + pub _350d: BpsCentsRatioSatsUsdPattern, + pub _1y: BpsCentsRatioSatsUsdPattern, + pub _2y: BpsCentsRatioSatsUsdPattern, + pub _200w: BpsCentsRatioSatsUsdPattern, + pub _4y: BpsCentsRatioSatsUsdPattern, pub _200d_x2_4: CentsSatsUsdPattern, pub _200d_x0_8: CentsSatsUsdPattern, pub _350d_x2: CentsSatsUsdPattern, @@ -5242,22 +5294,22 @@ pub struct MetricsTree_Market_MovingAverage_Sma { 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")), + _1w: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_1w".to_string()), + _8d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_8d".to_string()), + _13d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_13d".to_string()), + _21d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_21d".to_string()), + _1m: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_1m".to_string()), + _34d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_34d".to_string()), + _55d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_55d".to_string()), + _89d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_89d".to_string()), + _111d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_111d".to_string()), + _144d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_144d".to_string()), + _200d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_200d".to_string()), + _350d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_350d".to_string()), + _1y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_1y".to_string()), + _2y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_2y".to_string()), + _200w: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_200w".to_string()), + _4y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_4y".to_string()), _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()), @@ -5265,589 +5317,45 @@ impl MetricsTree_Market_MovingAverage_Sma { } } -/// 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, + pub _1w: BpsCentsRatioSatsUsdPattern, + pub _8d: BpsCentsRatioSatsUsdPattern, + pub _12d: BpsCentsRatioSatsUsdPattern, + pub _13d: BpsCentsRatioSatsUsdPattern, + pub _21d: BpsCentsRatioSatsUsdPattern, + pub _26d: BpsCentsRatioSatsUsdPattern, + pub _1m: BpsCentsRatioSatsUsdPattern, + pub _34d: BpsCentsRatioSatsUsdPattern, + pub _55d: BpsCentsRatioSatsUsdPattern, + pub _89d: BpsCentsRatioSatsUsdPattern, + pub _144d: BpsCentsRatioSatsUsdPattern, + pub _200d: BpsCentsRatioSatsUsdPattern, + pub _1y: BpsCentsRatioSatsUsdPattern, + pub _2y: BpsCentsRatioSatsUsdPattern, + pub _200w: BpsCentsRatioSatsUsdPattern, + pub _4y: BpsCentsRatioSatsUsdPattern, } 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()), + _1w: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_1w".to_string()), + _8d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_8d".to_string()), + _12d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_12d".to_string()), + _13d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_13d".to_string()), + _21d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_21d".to_string()), + _26d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_26d".to_string()), + _1m: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_1m".to_string()), + _34d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_34d".to_string()), + _55d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_55d".to_string()), + _89d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_89d".to_string()), + _144d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_144d".to_string()), + _200d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_200d".to_string()), + _1y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_1y".to_string()), + _2y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_2y".to_string()), + _200w: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_200w".to_string()), + _4y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_ema_4y".to_string()), } } } @@ -6813,8 +6321,8 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All { pub supply: MetricsTree_Distribution_UtxoCohorts_All_Supply, pub outputs: UtxoPattern3, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, - pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern, - pub cost_basis: InvestedMaxMinPercentilesPattern, + pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern, + pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, pub unrealized: MetricsTree_Distribution_UtxoCohorts_All_Unrealized, } @@ -6824,8 +6332,8 @@ impl MetricsTree_Distribution_UtxoCohorts_All { supply: MetricsTree_Distribution_UtxoCohorts_All_Supply::new(client.clone(), format!("{base_path}_supply")), outputs: UtxoPattern3::new(client.clone(), "utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "".to_string()), - realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern::new(client.clone(), "".to_string()), - cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "".to_string()), + realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern::new(client.clone(), "".to_string()), + cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "".to_string()), unrealized: MetricsTree_Distribution_UtxoCohorts_All_Unrealized::new(client.clone(), format!("{base_path}_unrealized")), } } @@ -6855,9 +6363,9 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Supply { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_All_Unrealized { pub gross_pnl: CentsUsdPattern, - pub invested_capital: InPattern4, + pub invested_capital: InPattern2, pub sentiment: GreedNetPainPattern, - pub investor_cap: InPattern2, + pub investor_cap: InPattern, pub loss: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss, pub net_pnl: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_NetPnl, pub profit: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit, @@ -6867,9 +6375,9 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Unrealized { pub fn new(client: Arc, base_path: String) -> Self { Self { gross_pnl: CentsUsdPattern::new(client.clone(), "unrealized_gross_pnl".to_string()), - invested_capital: InPattern4::new(client.clone(), "invested_capital_in".to_string()), + invested_capital: InPattern2::new(client.clone(), "invested_capital_in".to_string()), sentiment: GreedNetPainPattern::new(client.clone(), "".to_string()), - investor_cap: InPattern2::new(client.clone(), "investor_cap_in".to_string()), + investor_cap: InPattern::new(client.clone(), "investor_cap_in".to_string()), loss: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss::new(client.clone(), format!("{base_path}_loss")), net_pnl: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), profit: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit::new(client.clone(), format!("{base_path}_profit")), @@ -6936,22 +6444,22 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit { /// Metrics tree node. pub struct MetricsTree_Distribution_UtxoCohorts_Sth { - pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern, + pub realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern, pub supply: DeltaHalvedInRelTotalPattern2, pub outputs: UtxoPattern3, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, - pub cost_basis: InvestedMaxMinPercentilesPattern, + pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, pub unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2, } impl MetricsTree_Distribution_UtxoCohorts_Sth { pub fn new(client: Arc, base_path: String) -> Self { Self { - realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern::new(client.clone(), "sth".to_string()), + realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern::new(client.clone(), "sth".to_string()), supply: DeltaHalvedInRelTotalPattern2::new(client.clone(), "sth_supply".to_string()), outputs: UtxoPattern3::new(client.clone(), "sth_utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "sth".to_string()), - cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "sth".to_string()), + cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "sth".to_string()), unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2::new(client.clone(), "sth".to_string()), } } @@ -6963,7 +6471,7 @@ pub struct MetricsTree_Distribution_UtxoCohorts_Lth { pub outputs: UtxoPattern3, pub activity: CoindaysCoinyearsDormancySentVelocityPattern, pub realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized, - pub cost_basis: InvestedMaxMinPercentilesPattern, + pub cost_basis: InvestedMaxMinPercentilesSupplyPattern, pub unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2, } @@ -6974,7 +6482,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Lth { outputs: UtxoPattern3::new(client.clone(), "lth_utxo_count".to_string()), activity: CoindaysCoinyearsDormancySentVelocityPattern::new(client.clone(), "lth".to_string()), realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized::new(client.clone(), format!("{base_path}_realized")), - cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "lth".to_string()), + cost_basis: InvestedMaxMinPercentilesSupplyPattern::new(client.clone(), "lth".to_string()), unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2::new(client.clone(), "lth".to_string()), } } @@ -6987,13 +6495,11 @@ pub struct MetricsTree_Distribution_UtxoCohorts_Lth_Realized { pub gross_pnl: RawSellSumPattern, pub net_pnl: ChangeCumulativeDeltaRawRelSumPattern, pub sopr: MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr, - pub sent: InPattern3, pub peak_regret: CumulativeRawRelPattern, pub investor: CapLowerPriceUpperPattern, pub profit_to_loss_ratio: _1m1w1y24hPattern, pub cap: CentsDeltaRawRelUsdPattern, - pub price_ratio: BpsPercentilesRatioStdPattern, - pub price: CentsSatsUsdPattern, + pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, pub mvrv: MetricPattern1, pub nupl: BpsRatioPattern, } @@ -7006,13 +6512,11 @@ impl MetricsTree_Distribution_UtxoCohorts_Lth_Realized { gross_pnl: RawSellSumPattern::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: CumulativeRawRelPattern::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()), + price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern::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()), } @@ -7857,8 +7361,7 @@ pub struct MetricsTree_Supply { pub burned: MetricsTree_Supply_Burned, pub inflation_rate: BpsPercentRatioPattern, pub velocity: MetricsTree_Supply_Velocity, - pub market_cap: CentsUsdPattern, - pub market_cap_delta: ChangeRatePattern4, + pub market_cap: MetricsTree_Supply_MarketCap, pub market_minus_realized_cap_growth_rate: _1m1w1y24hPattern, pub hodled_or_lost_coins: BtcCentsSatsUsdPattern, } @@ -7870,8 +7373,7 @@ impl MetricsTree_Supply { burned: MetricsTree_Supply_Burned::new(client.clone(), format!("{base_path}_burned")), inflation_rate: BpsPercentRatioPattern::new(client.clone(), "inflation_rate".to_string()), velocity: MetricsTree_Supply_Velocity::new(client.clone(), format!("{base_path}_velocity")), - market_cap: CentsUsdPattern::new(client.clone(), "market_cap".to_string()), - market_cap_delta: ChangeRatePattern4::new(client.clone(), "market_cap_delta".to_string()), + market_cap: MetricsTree_Supply_MarketCap::new(client.clone(), format!("{base_path}_market_cap")), market_minus_realized_cap_growth_rate: _1m1w1y24hPattern::new(client.clone(), "market_minus_realized_cap_growth_rate".to_string()), hodled_or_lost_coins: BtcCentsSatsUsdPattern::new(client.clone(), "hodled_or_lost_coins".to_string()), } @@ -7908,6 +7410,23 @@ impl MetricsTree_Supply_Velocity { } } +/// Metrics tree node. +pub struct MetricsTree_Supply_MarketCap { + pub cents: MetricPattern1, + pub usd: MetricPattern1, + pub delta: ChangeRatePattern4, +} + +impl MetricsTree_Supply_MarketCap { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), "market_cap_cents".to_string()), + usd: MetricPattern1::new(client.clone(), "market_cap".to_string()), + delta: ChangeRatePattern4::new(client.clone(), "market_cap_delta".to_string()), + } + } +} + /// Main BRK client with metrics tree and API methods. pub struct BrkClient { base: Arc, diff --git a/crates/brk_computer/src/cointime/compute.rs b/crates/brk_computer/src/cointime/compute.rs index 382d634cf..4e18821dc 100644 --- a/crates/brk_computer/src/cointime/compute.rs +++ b/crates/brk_computer/src/cointime/compute.rs @@ -66,7 +66,6 @@ impl Vecs { self.pricing.compute( starting_indexes, prices, - blocks, distribution, &self.activity, &self.supply, diff --git a/crates/brk_computer/src/cointime/pricing/compute.rs b/crates/brk_computer/src/cointime/pricing/compute.rs index e28a09b08..395675242 100644 --- a/crates/brk_computer/src/cointime/pricing/compute.rs +++ b/crates/brk_computer/src/cointime/pricing/compute.rs @@ -4,7 +4,7 @@ use vecdb::{Exit, VecIndex}; use super::super::{activity, cap, supply}; use super::Vecs; -use crate::{blocks, distribution, prices}; +use crate::{distribution, prices}; impl Vecs { #[allow(clippy::too_many_arguments)] @@ -12,7 +12,6 @@ impl Vecs { &mut self, starting_indexes: &Indexes, prices: &prices::Vecs, - blocks: &blocks::Vecs, distribution: &distribution::Vecs, activity: &activity::Vecs, supply: &supply::Vecs, @@ -24,74 +23,70 @@ impl Vecs { let realized_price = &all_metrics.realized.price.cents.height; let realized_cap = &all_metrics.realized.cap.cents.height; - self.vaulted_price.cents.height.compute_transform2( - starting_indexes.height, - realized_price, - &activity.vaultedness.height, - |(i, price, vaultedness, ..)| { - (i, Cents::from(f64::from(price) / f64::from(vaultedness))) + self.vaulted_price.compute_all( + prices, + starting_indexes, + exit, + |v| { + Ok(v.compute_transform2( + starting_indexes.height, + realized_price, + &activity.vaultedness.height, + |(i, price, vaultedness, ..)| { + (i, Cents::from(f64::from(price) / f64::from(vaultedness))) + }, + exit, + )?) }, - exit, )?; - self.vaulted_price_ratio.compute_rest( - blocks, + self.active_price.compute_all( prices, starting_indexes, exit, - &self.vaulted_price.cents.height, - )?; - - self.active_price.cents.height.compute_multiply( - starting_indexes.height, - realized_price, - &activity.liveliness.height, - exit, - )?; - - self.active_price_ratio.compute_rest( - blocks, - prices, - starting_indexes, - exit, - &self.active_price.cents.height, - )?; - - self.true_market_mean.cents.height.compute_transform2( - starting_indexes.height, - &cap.investor_cap.cents.height, - &supply.active_supply.btc.height, - |(i, cap_cents, supply_btc, ..)| { - (i, Cents::from(f64::from(cap_cents) / f64::from(supply_btc))) + |v| { + Ok(v.compute_multiply( + starting_indexes.height, + realized_price, + &activity.liveliness.height, + exit, + )?) }, - exit, )?; - self.true_market_mean_ratio.compute_rest( - blocks, + self.true_market_mean.compute_all( prices, starting_indexes, exit, - &self.true_market_mean.cents.height, + |v| { + Ok(v.compute_transform2( + starting_indexes.height, + &cap.investor_cap.cents.height, + &supply.active_supply.btc.height, + |(i, cap_cents, supply_btc, ..)| { + (i, Cents::from(f64::from(cap_cents) / f64::from(supply_btc))) + }, + exit, + )?) + }, )?; // cointime_price = cointime_cap / circulating_supply - self.cointime_price.cents.height.compute_transform2( - starting_indexes.height, - &cap.cointime_cap.cents.height, - circulating_supply, - |(i, cap_cents, supply_btc, ..)| { - (i, Cents::from(f64::from(cap_cents) / f64::from(supply_btc))) - }, - exit, - )?; - - self.cointime_price_ratio.compute_rest( - blocks, + self.cointime_price.compute_all( prices, starting_indexes, exit, - &self.cointime_price.cents.height, + |v| { + Ok(v.compute_transform2( + starting_indexes.height, + &cap.cointime_cap.cents.height, + circulating_supply, + |(i, cap_cents, supply_btc, ..)| { + (i, Cents::from(f64::from(cap_cents) / f64::from(supply_btc))) + }, + exit, + )?) + }, )?; // transfer_price = cointime_price - vaulted_price @@ -99,38 +94,20 @@ impl Vecs { starting_indexes.height, &self.cointime_price.cents.height, &self.vaulted_price.cents.height, - |(i, cointime, vaulted, ..)| { - (i, cointime.saturating_sub(vaulted)) - }, + |(i, cointime, vaulted, ..)| (i, cointime.saturating_sub(vaulted)), exit, )?; - - self.transfer_price_ratio.compute_rest( - blocks, - prices, - starting_indexes, - exit, - &self.transfer_price.cents.height, - )?; + self.transfer_price.compute_rest(prices, starting_indexes, exit)?; // balanced_price = (realized_price + transfer_price) / 2 self.balanced_price.cents.height.compute_transform2( starting_indexes.height, realized_price, &self.transfer_price.cents.height, - |(i, realized, transfer, ..)| { - (i, (realized + transfer) / 2u64) - }, + |(i, realized, transfer, ..)| (i, (realized + transfer) / 2u64), exit, )?; - - self.balanced_price_ratio.compute_rest( - blocks, - prices, - starting_indexes, - exit, - &self.balanced_price.cents.height, - )?; + self.balanced_price.compute_rest(prices, starting_indexes, exit)?; // terminal_price = 21M × transfer_price / circulating_supply_btc self.terminal_price.cents.height.compute_transform2( @@ -147,14 +124,7 @@ impl Vecs { }, exit, )?; - - self.terminal_price_ratio.compute_rest( - blocks, - prices, - starting_indexes, - exit, - &self.terminal_price.cents.height, - )?; + self.terminal_price.compute_rest(prices, starting_indexes, exit)?; // cumulative_market_cap = Σ(market_cap) in dollars self.cumulative_market_cap @@ -183,14 +153,7 @@ impl Vecs { }, exit, )?; - - self.delta_price_ratio.compute_rest( - blocks, - prices, - starting_indexes, - exit, - &self.delta_price.cents.height, - )?; + self.delta_price.compute_rest(prices, starting_indexes, exit)?; Ok(()) } diff --git a/crates/brk_computer/src/cointime/pricing/import.rs b/crates/brk_computer/src/cointime/pricing/import.rs index d387dac2c..b77a646fc 100644 --- a/crates/brk_computer/src/cointime/pricing/import.rs +++ b/crates/brk_computer/src/cointime/pricing/import.rs @@ -5,7 +5,7 @@ use vecdb::Database; use super::Vecs; use crate::{ indexes, - internal::{ComputedPerBlock, RatioPerBlockExtended, Price}, + internal::{ComputedPerBlock, PriceWithRatioExtendedPerBlock}, }; impl Vecs { @@ -14,63 +14,27 @@ impl Vecs { version: Version, indexes: &indexes::Vecs, ) -> Result { - let vaulted_price = Price::forced_import(db, "vaulted_price", version, indexes)?; - let vaulted_price_ratio = - RatioPerBlockExtended::forced_import(db, "vaulted_price", version, indexes)?; - - let active_price = Price::forced_import(db, "active_price", version, indexes)?; - let active_price_ratio = - RatioPerBlockExtended::forced_import(db, "active_price", version, indexes)?; - - let true_market_mean = Price::forced_import(db, "true_market_mean", version, indexes)?; - let true_market_mean_ratio = RatioPerBlockExtended::forced_import( - db, - "true_market_mean", - version, - indexes, - )?; - - let cointime_price = Price::forced_import(db, "cointime_price", version, indexes)?; - let cointime_price_ratio = - RatioPerBlockExtended::forced_import(db, "cointime_price", version, indexes)?; - - let transfer_price = Price::forced_import(db, "transfer_price", version, indexes)?; - let transfer_price_ratio = - RatioPerBlockExtended::forced_import(db, "transfer_price", version, indexes)?; - - let balanced_price = Price::forced_import(db, "balanced_price", version, indexes)?; - let balanced_price_ratio = - RatioPerBlockExtended::forced_import(db, "balanced_price", version, indexes)?; - - let terminal_price = Price::forced_import(db, "terminal_price", version, indexes)?; - let terminal_price_ratio = - RatioPerBlockExtended::forced_import(db, "terminal_price", version, indexes)?; - - let delta_price = Price::forced_import(db, "delta_price", version, indexes)?; - let delta_price_ratio = - RatioPerBlockExtended::forced_import(db, "delta_price", version, indexes)?; - - let cumulative_market_cap = - ComputedPerBlock::forced_import(db, "cumulative_market_cap", version, indexes)?; + macro_rules! import { + ($name:expr) => { + PriceWithRatioExtendedPerBlock::forced_import(db, $name, version, indexes)? + }; + } Ok(Self { - vaulted_price, - vaulted_price_ratio, - active_price, - active_price_ratio, - true_market_mean, - true_market_mean_ratio, - cointime_price, - cointime_price_ratio, - transfer_price, - transfer_price_ratio, - balanced_price, - balanced_price_ratio, - terminal_price, - terminal_price_ratio, - delta_price, - delta_price_ratio, - cumulative_market_cap, + vaulted_price: import!("vaulted_price"), + active_price: import!("active_price"), + true_market_mean: import!("true_market_mean"), + cointime_price: import!("cointime_price"), + transfer_price: import!("transfer_price"), + balanced_price: import!("balanced_price"), + terminal_price: import!("terminal_price"), + delta_price: import!("delta_price"), + cumulative_market_cap: ComputedPerBlock::forced_import( + db, + "cumulative_market_cap", + version, + indexes, + )?, }) } } diff --git a/crates/brk_computer/src/cointime/pricing/vecs.rs b/crates/brk_computer/src/cointime/pricing/vecs.rs index f205341de..6e10d89db 100644 --- a/crates/brk_computer/src/cointime/pricing/vecs.rs +++ b/crates/brk_computer/src/cointime/pricing/vecs.rs @@ -1,27 +1,19 @@ use brk_traversable::Traversable; -use brk_types::{Cents, Dollars}; +use brk_types::Dollars; use vecdb::{Rw, StorageMode}; -use crate::internal::{ComputedPerBlock, RatioPerBlockExtended, Price}; +use crate::internal::{ComputedPerBlock, PriceWithRatioExtendedPerBlock}; #[derive(Traversable)] pub struct Vecs { - pub vaulted_price: Price>, - pub vaulted_price_ratio: RatioPerBlockExtended, - pub active_price: Price>, - pub active_price_ratio: RatioPerBlockExtended, - pub true_market_mean: Price>, - pub true_market_mean_ratio: RatioPerBlockExtended, - pub cointime_price: Price>, - pub cointime_price_ratio: RatioPerBlockExtended, - pub transfer_price: Price>, - pub transfer_price_ratio: RatioPerBlockExtended, - pub balanced_price: Price>, - pub balanced_price_ratio: RatioPerBlockExtended, - pub terminal_price: Price>, - pub terminal_price_ratio: RatioPerBlockExtended, - pub delta_price: Price>, - pub delta_price_ratio: RatioPerBlockExtended, + pub vaulted_price: PriceWithRatioExtendedPerBlock, + pub active_price: PriceWithRatioExtendedPerBlock, + pub true_market_mean: PriceWithRatioExtendedPerBlock, + pub cointime_price: PriceWithRatioExtendedPerBlock, + pub transfer_price: PriceWithRatioExtendedPerBlock, + pub balanced_price: PriceWithRatioExtendedPerBlock, + pub terminal_price: PriceWithRatioExtendedPerBlock, + pub delta_price: PriceWithRatioExtendedPerBlock, pub cumulative_market_cap: ComputedPerBlock, } diff --git a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs index ca1fce87d..001a38058 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs @@ -29,6 +29,7 @@ pub struct AddressCohortVecs { pub metrics: MinimalCohortMetrics, pub addr_count: ComputedPerBlock, + #[traversable(wrap = "addr_count", rename = "delta")] pub addr_count_delta: RollingDelta1m, } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs b/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs index 1adc72b92..c613ad752 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs @@ -31,6 +31,18 @@ pub(super) struct CostBasisNode { sth_usd: i128, } +impl CostBasisNode { + #[inline] + fn new(sats: i64, usd: i128, is_sth: bool) -> Self { + Self { + all_sats: sats, + sth_sats: if is_sth { sats } else { 0 }, + all_usd: usd, + sth_usd: if is_sth { usd } else { 0 }, + } + } +} + impl FenwickNode for CostBasisNode { #[inline(always)] fn add_assign(&mut self, other: &Self) { @@ -87,15 +99,13 @@ fn bucket_to_cents(bucket: usize) -> Cents { /// Map a CentsCompact price to a bucket index. #[inline] fn price_to_bucket(price: CentsCompact) -> usize { - let rounded = Cents::from(price).round_to_dollar(COST_BASIS_PRICE_DIGITS); - dollars_to_bucket(u64::from(rounded) / 100) + cents_to_bucket(price.into()) } /// Map a Cents price to a bucket index. #[inline] fn cents_to_bucket(price: Cents) -> usize { - let rounded = price.round_to_dollar(COST_BASIS_PRICE_DIGITS); - dollars_to_bucket(u64::from(rounded) / 100) + dollars_to_bucket(u64::from(price.round_to_dollar(COST_BASIS_PRICE_DIGITS)) / 100) } // --------------------------------------------------------------------------- @@ -143,13 +153,7 @@ impl CostBasisFenwick { return; } let bucket = price_to_bucket(price); - let net_usd = price.as_u128() as i128 * net_sats as i128; - let delta = CostBasisNode { - all_sats: net_sats, - sth_sats: if is_sth { net_sats } else { 0 }, - all_usd: net_usd, - sth_usd: if is_sth { net_usd } else { 0 }, - }; + let delta = CostBasisNode::new(net_sats, price.as_u128() as i128 * net_sats as i128, is_sth); self.tree.add(bucket, &delta); self.totals.add_assign(&delta); } @@ -167,13 +171,7 @@ impl CostBasisFenwick { for (&price, &sats) in map.iter() { let bucket = price_to_bucket(price); let s = u64::from(sats) as i64; - let usd = price.as_u128() as i128 * s as i128; - let node = CostBasisNode { - all_sats: s, - sth_sats: if is_sth { s } else { 0 }, - all_usd: usd, - sth_usd: if is_sth { usd } else { 0 }, - }; + let node = CostBasisNode::new(s, price.as_u128() as i128 * s as i128, is_sth); self.tree.add_raw(bucket, &node); self.totals.add_assign(&node); } @@ -242,9 +240,9 @@ impl CostBasisFenwick { .batch_kth(&sat_targets, &sat_field, &mut sat_buckets); result.min_price = bucket_to_cents(sat_buckets[0]); - for i in 0..PERCENTILES_LEN { + (0..PERCENTILES_LEN).for_each(|i| { result.sat_prices[i] = bucket_to_cents(sat_buckets[i + 1]); - } + }); result.max_price = bucket_to_cents(sat_buckets[PERCENTILES_LEN + 1]); // USD-weighted percentiles (batch) @@ -266,6 +264,51 @@ impl CostBasisFenwick { result } + // ----------------------------------------------------------------------- + // Supply density queries (±5% of spot price) + // ----------------------------------------------------------------------- + + /// Compute supply density: % of supply with cost basis within ±5% of spot. + /// Returns (all_bps, sth_bps, lth_bps) as basis points (0-10000). + pub(super) fn density(&self, spot_price: Cents) -> (u16, u16, u16) { + if self.totals.all_sats <= 0 { + return (0, 0, 0); + } + + let spot_f64 = u64::from(spot_price) as f64; + let low = Cents::from((spot_f64 * 0.95) as u64); + let high = Cents::from((spot_f64 * 1.05) as u64); + + let low_bucket = cents_to_bucket(low); + let high_bucket = cents_to_bucket(high); + + let cum_high = self.tree.prefix_sum(high_bucket); + let cum_low = if low_bucket > 0 { + self.tree.prefix_sum(low_bucket - 1) + } else { + CostBasisNode::default() + }; + + let all_range = (cum_high.all_sats - cum_low.all_sats).max(0); + let sth_range = (cum_high.sth_sats - cum_low.sth_sats).max(0); + let lth_range = all_range - sth_range; + + let to_bps = |range: i64, total: i64| -> u16 { + if total <= 0 { + 0 + } else { + (range as f64 / total as f64 * 10000.0) as u16 + } + }; + + let lth_total = self.totals.all_sats - self.totals.sth_sats; + ( + to_bps(all_range, self.totals.all_sats), + to_bps(sth_range, self.totals.sth_sats), + to_bps(lth_range, lth_total), + ) + } + // ----------------------------------------------------------------------- // Profitability queries (all cohort only) // ----------------------------------------------------------------------- diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/percentiles.rs b/crates/brk_computer/src/distribution/cohorts/utxo/percentiles.rs index 50a6eac2e..e853b1e8f 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/percentiles.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/percentiles.rs @@ -2,7 +2,7 @@ use std::{cmp::Reverse, collections::BinaryHeap, fs, path::Path}; use brk_cohort::{Filtered, PROFITABILITY_RANGE_COUNT, PROFIT_COUNT, TERM_NAMES}; use brk_error::Result; -use brk_types::{Cents, CentsCompact, CostBasisDistribution, Date, Dollars, Height, Sats}; +use brk_types::{BasisPoints16, Cents, CentsCompact, CostBasisDistribution, Date, Dollars, Height, Sats}; use crate::distribution::metrics::{CostBasis, ProfitabilityMetrics}; @@ -24,12 +24,7 @@ impl UTXOCohorts { states_path: &Path, ) -> Result<()> { if self.fenwick.is_initialized() { - // Per-block accurate percentiles from Fenwick tree - self.push_percentiles_from_fenwick(height)?; - - // Per-block accurate profitability from Fenwick tree with current spot_price - let prof = self.fenwick.profitability(spot_price); - push_profitability(height, &prof, &mut self.profitability)?; + self.push_fenwick_results(height, spot_price)?; } // Disk distributions only at day boundaries @@ -40,18 +35,21 @@ impl UTXOCohorts { Ok(()) } - /// Push Fenwick-computed percentiles for all/sth/lth to vecs. - fn push_percentiles_from_fenwick(&mut self, height: Height) -> Result<()> { + /// Push all Fenwick-derived per-block results: percentiles, density, profitability. + fn push_fenwick_results(&mut self, height: Height, spot_price: Cents) -> Result<()> { + let (all_d, sth_d, lth_d) = self.fenwick.density(spot_price); + let all = self.fenwick.percentiles_all(); - push_percentile_result(height, &all, &mut self.all.metrics.cost_basis)?; + push_cost_basis(height, &all, all_d, &mut self.all.metrics.cost_basis)?; let sth = self.fenwick.percentiles_sth(); - push_percentile_result(height, &sth, &mut self.sth.metrics.cost_basis)?; + push_cost_basis(height, &sth, sth_d, &mut self.sth.metrics.cost_basis)?; let lth = self.fenwick.percentiles_lth(); - push_percentile_result(height, <h, &mut self.lth.metrics.cost_basis)?; + push_cost_basis(height, <h, lth_d, &mut self.lth.metrics.cost_basis)?; - Ok(()) + let prof = self.fenwick.profitability(spot_price); + push_profitability(height, &prof, &mut self.profitability) } /// K-way merge only for writing daily cost basis distributions to disk. @@ -93,14 +91,16 @@ impl UTXOCohorts { } } -/// Push a PercentileResult to cost basis vecs. -fn push_percentile_result( +/// Push percentiles + density to cost basis vecs. +fn push_cost_basis( height: Height, - result: &PercentileResult, + percentiles: &PercentileResult, + density_bps: u16, cost_basis: &mut CostBasis, ) -> Result<()> { - cost_basis.truncate_push_minmax(height, result.min_price, result.max_price)?; - cost_basis.truncate_push_percentiles(height, &result.sat_prices, &result.usd_prices) + cost_basis.truncate_push_minmax(height, percentiles.min_price, percentiles.max_price)?; + cost_basis.truncate_push_percentiles(height, &percentiles.sat_prices, &percentiles.usd_prices)?; + cost_basis.truncate_push_density(height, BasisPoints16::from(density_bps)) } /// Convert raw (cents × sats) accumulator to Dollars (÷ 100 for cents→dollars, ÷ 1e8 for sats). diff --git a/crates/brk_computer/src/distribution/metrics/activity/core.rs b/crates/brk_computer/src/distribution/metrics/activity/core.rs index abe66a680..f36a8b921 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/core.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/core.rs @@ -6,13 +6,18 @@ use vecdb::{AnyStoredVec, AnyVec, Exit, Rw, StorageMode, WritableVec}; use crate::{ blocks, distribution::{metrics::ImportConfig, state::{CohortState, CostBasisOps, RealizedOps}}, - internal::PerBlockWithSum24h, + internal::{AmountPerBlockWithSum24h, PerBlockWithSum24h}, + prices, }; #[derive(Traversable)] pub struct ActivityCore { pub sent: PerBlockWithSum24h, pub coindays_destroyed: PerBlockWithSum24h, + #[traversable(wrap = "sent", rename = "in_profit")] + pub sent_in_profit: AmountPerBlockWithSum24h, + #[traversable(wrap = "sent", rename = "in_loss")] + pub sent_in_loss: AmountPerBlockWithSum24h, } impl ActivityCore { @@ -21,6 +26,8 @@ impl ActivityCore { Ok(Self { sent: cfg.import("sent", v1)?, coindays_destroyed: cfg.import("coindays_destroyed", v1)?, + sent_in_profit: cfg.import("sent_in_profit", v1)?, + sent_in_loss: cfg.import("sent_in_loss", v1)?, }) } @@ -30,6 +37,8 @@ impl ActivityCore { .height .len() .min(self.coindays_destroyed.raw.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( @@ -42,6 +51,16 @@ impl ActivityCore { height, StoredF64::from(Bitcoin::from(state.satdays_destroyed)), )?; + self.sent_in_profit + .raw + .sats + .height + .truncate_push(height, state.realized.sent_in_profit())?; + self.sent_in_loss + .raw + .sats + .height + .truncate_push(height, state.realized.sent_in_loss())?; Ok(()) } @@ -49,6 +68,10 @@ impl ActivityCore { vec![ &mut self.sent.raw.height as &mut dyn AnyStoredVec, &mut self.coindays_destroyed.raw.height, + &mut self.sent_in_profit.raw.sats.height, + &mut self.sent_in_profit.raw.cents.height, + &mut self.sent_in_loss.raw.sats.height, + &mut self.sent_in_loss.raw.cents.height, ] } @@ -72,6 +95,10 @@ impl ActivityCore { )?; sum_others!(self, starting_indexes, others, exit; coindays_destroyed.raw.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(()) } @@ -96,4 +123,36 @@ impl ActivityCore { )?; Ok(()) } + + pub(crate) fn compute_sent_profitability( + &mut self, + blocks: &blocks::Vecs, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + 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/activity/full.rs b/crates/brk_computer/src/distribution/metrics/activity/full.rs index 674e899c0..331ecbee5 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/full.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/full.rs @@ -24,6 +24,10 @@ pub struct ActivityFull { #[traversable(wrap = "sent", rename = "sum")] pub sent_sum_extended: RollingWindowsFrom1w, + #[traversable(wrap = "sent/in_profit", rename = "sum")] + pub sent_in_profit_sum_extended: RollingWindowsFrom1w, + #[traversable(wrap = "sent/in_loss", rename = "sum")] + pub sent_in_loss_sum_extended: RollingWindowsFrom1w, pub coinyears_destroyed: LazyPerBlock, @@ -49,6 +53,8 @@ impl ActivityFull { coindays_destroyed_cumulative: cfg.import("coindays_destroyed_cumulative", v1)?, coindays_destroyed_sum, sent_sum_extended: cfg.import("sent", v1)?, + sent_in_profit_sum_extended: cfg.import("sent_in_profit", v1)?, + sent_in_loss_sum_extended: cfg.import("sent_in_loss", v1)?, coinyears_destroyed, dormancy: cfg.import("dormancy", v1)?, velocity: cfg.import("velocity", v1)?, @@ -116,6 +122,19 @@ impl ActivityFull { exit, )?; + self.sent_in_profit_sum_extended.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.inner.sent_in_profit.raw.sats.height, + exit, + )?; + self.sent_in_loss_sum_extended.compute_rolling_sum( + starting_indexes.height, + &window_starts, + &self.inner.sent_in_loss.raw.sats.height, + exit, + )?; + Ok(()) } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index 9559f6dae..8b60975bd 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -37,7 +37,7 @@ pub struct AllCohortMetrics { #[traversable(wrap = "supply", rename = "delta")] pub supply_delta_extended: RollingDeltaExcept1m, - #[traversable(wrap = "outputs", rename = "utxo_count_delta")] + #[traversable(wrap = "outputs/utxo_count", rename = "delta")] pub utxo_count_delta_extended: RollingDeltaExcept1m, } diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index 6fc5f21cc..b2a5f3688 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -114,6 +114,8 @@ impl CoreCohortMetrics { self.activity .compute_rest_part1(blocks, starting_indexes, exit)?; + self.activity + .compute_sent_profitability(blocks, prices, starting_indexes, exit)?; self.realized .compute_rest_part1(blocks, starting_indexes, exit)?; diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index 2d5dfc874..1bdb123d1 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -33,7 +33,7 @@ pub struct ExtendedCohortMetrics { #[traversable(wrap = "supply", rename = "delta")] pub supply_delta_extended: RollingDeltaExcept1m, - #[traversable(wrap = "outputs", rename = "utxo_count_delta")] + #[traversable(wrap = "outputs/utxo_count", rename = "delta")] pub utxo_count_delta_extended: RollingDeltaExcept1m, } diff --git a/crates/brk_computer/src/distribution/metrics/config.rs b/crates/brk_computer/src/distribution/metrics/config.rs index 3353bcade..172271b7d 100644 --- a/crates/brk_computer/src/distribution/metrics/config.rs +++ b/crates/brk_computer/src/distribution/metrics/config.rs @@ -9,7 +9,7 @@ use crate::{ internal::{ AmountPerBlock, AmountPerBlockCumulative, AmountPerBlockWithSum24h, CentsType, ComputedPerBlock, ComputedPerBlockCumulative, ComputedPerBlockCumulativeSum, FiatPerBlockWithSum24h, - PerBlockWithSum24h, RatioPerBlock, RollingWindow24hAmountPerBlock, + PerBlockWithSum24h, PriceWithRatioExtendedPerBlock, PriceWithRatioPerBlock, RatioPerBlock, RollingWindow24hAmountPerBlock, RollingWindow24hFiatPerBlock, RollingWindow24hPerBlock, FiatPerBlock, FiatRollingDelta1m, FiatRollingDeltaExcept1m, NumericValue, PercentPerBlock, PercentRollingWindows, Price, RollingDelta1m, RollingDeltaExcept1m, @@ -40,6 +40,8 @@ impl_config_import!( AmountPerBlock, AmountPerBlockCumulative, RollingWindow24hAmountPerBlock, + PriceWithRatioPerBlock, + PriceWithRatioExtendedPerBlock, RatioPerBlock, RatioPerBlock, PercentPerBlock, diff --git a/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs b/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs index 782675161..ee6d8a8d3 100644 --- a/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs @@ -1,13 +1,13 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{Cents, Height, Version}; +use brk_types::{BasisPoints16, Cents, Height, Version}; use vecdb::{AnyStoredVec, AnyVec, Rw, StorageMode, WritableVec}; -use crate::internal::{ComputedPerBlock, PercentilesVecs, Price, PERCENTILES_LEN}; +use crate::internal::{ComputedPerBlock, PercentPerBlock, PercentilesVecs, Price, PERCENTILES_LEN}; use super::ImportConfig; -/// Cost basis metrics: min/max + percentiles. +/// Cost basis metrics: min/max + percentiles + supply density. /// Used by all/sth/lth cohorts only. #[derive(Traversable)] pub struct CostBasis { @@ -15,6 +15,7 @@ pub struct CostBasis { pub max: Price>, pub percentiles: PercentilesVecs, pub invested_capital: PercentilesVecs, + pub supply_density: PercentPerBlock, } impl CostBasis { @@ -34,11 +35,22 @@ impl CostBasis { cfg.version, cfg.indexes, )?, + supply_density: PercentPerBlock::forced_import( + cfg.db, + &cfg.name("supply_density"), + cfg.version, + cfg.indexes, + )?, }) } pub(crate) fn min_stateful_height_len(&self) -> usize { - self.min.cents.height.len().min(self.max.cents.height.len()) + self.min + .cents + .height + .len() + .min(self.max.cents.height.len()) + .min(self.supply_density.bps.height.len()) } pub(crate) fn truncate_push_minmax( @@ -63,6 +75,14 @@ impl CostBasis { Ok(()) } + pub(crate) fn truncate_push_density( + &mut self, + height: Height, + density_bps: BasisPoints16, + ) -> Result<()> { + Ok(self.supply_density.bps.height.truncate_push(height, density_bps)?) + } + pub(crate) fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { self.percentiles .validate_computed_version_or_reset(base_version)?; @@ -75,6 +95,7 @@ impl CostBasis { let mut vecs: Vec<&mut dyn AnyStoredVec> = vec![ &mut self.min.cents.height, &mut self.max.cents.height, + &mut self.supply_density.bps.height, ]; vecs.extend( self.percentiles diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index 26d2aa524..38a032461 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -188,6 +188,8 @@ pub trait CohortMetricsBase: CohortMetricsState { #[traversable(flatten)] pub base: OutputsBase, + #[traversable(wrap = "utxo_count", rename = "delta")] pub utxo_count_delta: RollingDelta1m, } diff --git a/crates/brk_computer/src/distribution/metrics/realized/core.rs b/crates/brk_computer/src/distribution/metrics/realized/core.rs index aa3d870c2..09ffa7cf8 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/core.rs @@ -3,14 +3,14 @@ use brk_traversable::Traversable; use brk_types::{Bitcoin, Cents, CentsSigned, Dollars, Height, Indexes, StoredF64, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{ - AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec, + AnyStoredVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, }; use crate::{ blocks, distribution::state::{CohortState, CostBasisOps, RealizedOps}, internal::{ - AmountPerBlockWithSum24h, ComputedPerBlock, FiatRollingDelta1m, LazyPerBlock, + ComputedPerBlock, FiatRollingDelta1m, LazyPerBlock, NegCentsUnsignedToDollars, PerBlockWithSum24h, RatioCents64, RollingWindow24hPerBlock, }, @@ -26,12 +26,6 @@ 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] @@ -51,7 +45,6 @@ pub struct RealizedCore { pub neg_loss: LazyPerBlock, pub net_pnl: PerBlockWithSum24h, pub sopr: RealizedSoprCore, - pub sent: RealizedSentCore, } impl RealizedCore { @@ -78,44 +71,20 @@ impl RealizedCore { 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.sent.in_profit.raw.sats.height.len()) - .min(self.sent.in_loss.raw.sats.height.len()) + self.minimal.min_stateful_height_len() } pub(crate) fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { self.minimal.truncate_push(height, state)?; - self.sent - .in_profit - .raw - .sats - .height - .truncate_push(height, state.realized.sent_in_profit())?; - self.sent - .in_loss - .raw - .sats - .height - .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.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 + self.minimal.collect_vecs_mut() } pub(crate) fn compute_from_stateful( @@ -128,11 +97,6 @@ impl RealizedCore { self.minimal .compute_from_stateful(starting_indexes, &minimal_refs, exit)?; - 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(()) } @@ -207,30 +171,6 @@ impl RealizedCore { 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 510912647..1d06ffae9 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{ BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSats, CentsSigned, CentsSquaredSats, - Dollars, Height, Indexes, Sats, StoredF64, Version, + Dollars, Height, Indexes, StoredF64, Version, }; use derive_more::{Deref, DerefMut}; use vecdb::{ @@ -16,9 +16,10 @@ use crate::{ internal::{ CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative, FiatPerBlock, FiatRollingDelta1m, FiatRollingDeltaExcept1m, LazyPerBlock, PercentPerBlock, - PercentRollingWindows, Price, RatioCents64, RatioCentsBp32, RatioCentsSignedCentsBps32, - RatioCentsSignedDollarsBps32, RatioDollarsBp32, RatioPerBlock, RatioPerBlockPercentiles, - RatioPerBlockStdDevBands, RollingWindows, RollingWindowsFrom1w, + PercentRollingWindows, Price, PriceWithRatioExtendedPerBlock, RatioCents64, RatioCentsBp32, + RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, RatioDollarsBp32, + RatioPerBlockPercentiles, RatioPerBlockStdDevBands, RatioSma, RollingWindows, + RollingWindowsFrom1w, }, prices, }; @@ -87,14 +88,6 @@ pub struct RealizedSopr { 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)] @@ -104,13 +97,11 @@ pub struct RealizedPeakRegret { #[derive(Traversable)] pub struct RealizedInvestor { - pub price: Price>, - pub price_ratio: RatioPerBlock, + pub price: PriceWithRatioExtendedPerBlock, pub lower_price_band: Price>, pub upper_price_band: Price>, #[traversable(wrap = "cap", rename = "raw")] pub cap_raw: M::Stored>, - pub price_ratio_percentiles: RatioPerBlockPercentiles, } #[derive(Deref, DerefMut, Traversable)] @@ -125,7 +116,6 @@ pub struct RealizedFull { pub gross_pnl: RealizedGrossPnl, pub net_pnl: RealizedNetPnl, pub sopr: RealizedSopr, - pub sent: RealizedSentFull, pub peak_regret: RealizedPeakRegret, pub investor: RealizedInvestor, @@ -139,9 +129,11 @@ pub struct RealizedFull { #[traversable(wrap = "cap", rename = "rel_to_own_mcap")] pub cap_rel_to_own_mcap: PercentPerBlock, - #[traversable(wrap = "price_ratio", rename = "percentiles")] + #[traversable(wrap = "price", rename = "percentiles")] pub price_ratio_percentiles: RatioPerBlockPercentiles, - #[traversable(wrap = "price_ratio", rename = "std_dev")] + #[traversable(wrap = "price", rename = "sma")] + pub price_ratio_sma: RatioSma, + #[traversable(wrap = "price", rename = "std_dev")] pub price_ratio_std_dev: RatioPerBlockStdDevBands, } @@ -218,12 +210,6 @@ impl RealizedFull { ratio_extended: cfg.import("sopr", v1)?, }; - // 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))?, @@ -234,16 +220,9 @@ impl RealizedFull { // 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 @@ -257,7 +236,6 @@ impl RealizedFull { gross_pnl, net_pnl, sopr, - sent, peak_regret, investor, profit_to_loss_ratio: cfg.import("realized_profit_to_loss_ratio", v1)?, @@ -270,6 +248,12 @@ impl RealizedFull { realized_price_version, cfg.indexes, )?, + price_ratio_sma: RatioSma::forced_import( + cfg.db, + &realized_price_name, + realized_price_version, + cfg.indexes, + )?, price_ratio_std_dev: RatioPerBlockStdDevBands::forced_import( cfg.db, &realized_price_name, @@ -513,20 +497,6 @@ impl RealizedFull { exit, )?; - // Sent rolling sums (1w, 1m, 1y) - self.sent.in_profit_sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.sent.in_profit.raw.sats.height, - exit, - )?; - self.sent.in_loss_sum_extended.compute_rolling_sum( - starting_indexes.height, - &window_starts, - &self.core.sent.in_loss.raw.sats.height, - exit, - )?; - // Profit/loss value created/destroyed rolling sums self.profit.value_created_sum.compute_rolling_sum( starting_indexes.height, @@ -616,11 +586,10 @@ impl RealizedFull { exit, )?; - // Investor price ratio and bands - self.investor.price_ratio.compute_ratio( + // Investor price ratio, percentiles and bands + self.investor.price.compute_rest( + prices, starting_indexes, - &prices.price.cents.height, - &self.investor.price.cents.height, exit, )?; @@ -727,31 +696,28 @@ impl RealizedFull { )?; } - // Price ratio: percentiles and std dev bands + // Price ratio: percentiles, sma and std dev bands self.price_ratio_percentiles.compute( + starting_indexes, + exit, + &self.core.minimal.price.ratio.height, + &self.core.minimal.price.cents.height, + )?; + + self.price_ratio_sma.compute( blocks, starting_indexes, exit, - &self.core.minimal.price_ratio.ratio.height, - &self.core.minimal.price.cents.height, + &self.core.minimal.price.ratio.height, )?; self.price_ratio_std_dev.compute( blocks, starting_indexes, exit, - &self.core.minimal.price_ratio.ratio.height, + &self.core.minimal.price.ratio.height, &self.core.minimal.price.cents.height, - )?; - - // 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, - investor_price, + &self.price_ratio_sma, )?; Ok(()) diff --git a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs index e9c493d33..07655e146 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs @@ -12,8 +12,8 @@ use crate::{ blocks, distribution::state::{CohortState, CostBasisOps, RealizedOps}, internal::{ - ComputedPerBlock, FiatPerBlock, FiatPerBlockWithSum24h, Identity, LazyPerBlock, - PerBlockWithSum24h, Price, RatioPerBlock, + FiatPerBlock, FiatPerBlockWithSum24h, Identity, LazyPerBlock, + PerBlockWithSum24h, PriceWithRatioPerBlock, RatioPerBlock, }, prices, }; @@ -33,8 +33,7 @@ pub struct RealizedMinimal { pub cap: FiatPerBlock, pub profit: FiatPerBlockWithSum24h, pub loss: FiatPerBlockWithSum24h, - pub price: Price>, - pub price_ratio: RatioPerBlock, + pub price: PriceWithRatioPerBlock, pub mvrv: LazyPerBlock, pub nupl: RatioPerBlock, @@ -47,12 +46,11 @@ impl RealizedMinimal { let cap: FiatPerBlock = cfg.import("realized_cap", Version::ZERO)?; - let realized_price = cfg.import("realized_price", v1)?; - let realized_price_ratio: RatioPerBlock = cfg.import("realized_price", v1)?; + let price: PriceWithRatioPerBlock = cfg.import("realized_price", v1)?; let mvrv = LazyPerBlock::from_lazy::, BasisPoints32>( &cfg.name("mvrv"), cfg.version, - &realized_price_ratio.ratio, + &price.ratio, ); let nupl = cfg.import("nupl", v1)?; @@ -61,8 +59,7 @@ impl RealizedMinimal { cap, profit: cfg.import("realized_profit", v1)?, loss: cfg.import("realized_loss", v1)?, - price: realized_price, - price_ratio: realized_price_ratio, + price, mvrv, nupl, sopr: RealizedSoprMinimal { @@ -164,28 +161,24 @@ impl RealizedMinimal { height_to_supply: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.price.cents.height.compute_transform2( - starting_indexes.height, - &self.cap.cents.height, - height_to_supply, - |(i, cap_cents, supply, ..)| { - let cap = cap_cents.as_u128(); - let supply_sats = Sats::from(supply).as_u128(); - if supply_sats == 0 { - (i, Cents::ZERO) - } else { - (i, Cents::from(cap * Sats::ONE_BTC_U128 / supply_sats)) - } - }, - exit, - )?; - - self.price_ratio.compute_ratio( - starting_indexes, - &prices.price.cents.height, - &self.price.cents.height, - exit, - )?; + let cap = &self.cap.cents.height; + self.price.compute_all(prices, starting_indexes, exit, |v| { + Ok(v.compute_transform2( + starting_indexes.height, + cap, + height_to_supply, + |(i, cap_cents, supply, ..)| { + let cap = cap_cents.as_u128(); + let supply_sats = Sats::from(supply).as_u128(); + if supply_sats == 0 { + (i, Cents::ZERO) + } else { + (i, Cents::from(cap * Sats::ONE_BTC_U128 / supply_sats)) + } + }, + exit, + )?) + })?; self.nupl.bps.height.compute_transform2( starting_indexes.height, diff --git a/crates/brk_computer/src/indicators/compute.rs b/crates/brk_computer/src/indicators/compute.rs index 8ea8d8691..62f546b4c 100644 --- a/crates/brk_computer/src/indicators/compute.rs +++ b/crates/brk_computer/src/indicators/compute.rs @@ -1,16 +1,18 @@ use brk_error::Result; -use brk_types::{Bitcoin, Dollars, Indexes, StoredF32}; -use vecdb::Exit; +use brk_types::{Bitcoin, Dollars, Indexes, Sats, StoredF32}; +use vecdb::{Exit, ReadableVec}; use super::{gini, Vecs}; -use crate::{distribution, internal::RatioDollarsBp32, mining, transactions}; +use crate::{distribution, internal::RatioDollarsBp32, market, mining, transactions}; impl Vecs { + #[allow(clippy::too_many_arguments)] pub(crate) fn compute( &mut self, mining: &mining::Vecs, distribution: &distribution::Vecs, transactions: &transactions::Vecs, + market: &market::Vecs, starting_indexes: &Indexes, exit: &Exit, ) -> Result<()> { @@ -72,7 +74,6 @@ impl Vecs { )?; // Thermocap Multiple: market_cap / thermo_cap - // thermo_cap = cumulative subsidy in USD self.thermocap_multiple .bps .compute_binary::( @@ -82,15 +83,9 @@ impl Vecs { exit, )?; - let all_activity = &distribution.utxo_cohorts.all.metrics.activity; - let supply_total_sats = &distribution - .utxo_cohorts - .all - .metrics - .supply - .total - .sats - .height; + let all_metrics = &distribution.utxo_cohorts.all.metrics; + let all_activity = &all_metrics.activity; + let supply_total_sats = &all_metrics.supply.total.sats.height; // Supply-Adjusted CDD = sum_24h(CDD) / circulating_supply_btc self.coindays_destroyed_supply_adjusted @@ -110,7 +105,7 @@ impl Vecs { exit, )?; - // Supply-Adjusted CYD = CYD / circulating_supply_btc (CYD = 1y rolling sum of CDD) + // Supply-Adjusted CYD = CYD / circulating_supply_btc self.coinyears_destroyed_supply_adjusted .height .compute_transform2( @@ -146,6 +141,66 @@ impl Vecs { exit, )?; + // Stock-to-Flow: supply / annual_issuance + // annual_issuance ≈ subsidy_per_block × 52560 (blocks/year) + self.stock_to_flow.height.compute_transform2( + starting_indexes.height, + supply_total_sats, + &mining.rewards.subsidy.base.sats.height, + |(i, supply_sats, subsidy_sats, ..)| { + let annual_flow = subsidy_sats.as_u128() as f64 * 52560.0; + if annual_flow == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + (i, StoredF32::from( + (supply_sats.as_u128() as f64 / annual_flow) as f32, + )) + } + }, + exit, + )?; + + // Dormancy Flow: supply_btc / dormancy + self.dormancy_flow.height.compute_transform2( + starting_indexes.height, + supply_total_sats, + &all_activity.dormancy.height, + |(i, supply_sats, dormancy, ..)| { + let d = f64::from(dormancy); + if d == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + let supply = f64::from(Bitcoin::from(supply_sats)); + (i, StoredF32::from((supply / d) as f32)) + } + }, + exit, + )?; + + // Seller Exhaustion Constant: % supply_in_profit × 30d_volatility + self.seller_exhaustion_constant + .height + .compute_transform2( + starting_indexes.height, + &all_metrics.supply.in_profit.sats.height, + &market.volatility._1m.height, + |(i, profit_sats, volatility, ..)| { + let total_sats: Sats = supply_total_sats + .collect_one(i) + .unwrap_or_default(); + let total = total_sats.as_u128() as f64; + if total == 0.0 { + (i, StoredF32::from(0.0f32)) + } else { + let pct_in_profit = profit_sats.as_u128() as f64 / total; + (i, StoredF32::from( + (pct_in_profit * f64::from(volatility)) as f32, + )) + } + }, + exit, + )?; + let _lock = exit.lock(); self.db.compact()?; Ok(()) diff --git a/crates/brk_computer/src/indicators/import.rs b/crates/brk_computer/src/indicators/import.rs index 6c2c31728..9fd947688 100644 --- a/crates/brk_computer/src/indicators/import.rs +++ b/crates/brk_computer/src/indicators/import.rs @@ -32,6 +32,10 @@ impl Vecs { ComputedPerBlock::forced_import(&db, "coinyears_destroyed_supply_adjusted", v, indexes)?; let dormancy_supply_adjusted = ComputedPerBlock::forced_import(&db, "dormancy_supply_adjusted", v, indexes)?; + let stock_to_flow = ComputedPerBlock::forced_import(&db, "stock_to_flow", v, indexes)?; + let dormancy_flow = ComputedPerBlock::forced_import(&db, "dormancy_flow", v, indexes)?; + let seller_exhaustion_constant = + ComputedPerBlock::forced_import(&db, "seller_exhaustion_constant", v, indexes)?; let this = Self { db, @@ -43,6 +47,9 @@ impl Vecs { coindays_destroyed_supply_adjusted, coinyears_destroyed_supply_adjusted, dormancy_supply_adjusted, + stock_to_flow, + dormancy_flow, + seller_exhaustion_constant, }; finalize_db(&this.db, &this)?; Ok(this) diff --git a/crates/brk_computer/src/indicators/vecs.rs b/crates/brk_computer/src/indicators/vecs.rs index 5c12a0168..b0dc8dcdb 100644 --- a/crates/brk_computer/src/indicators/vecs.rs +++ b/crates/brk_computer/src/indicators/vecs.rs @@ -16,4 +16,7 @@ pub struct Vecs { pub coindays_destroyed_supply_adjusted: ComputedPerBlock, pub coinyears_destroyed_supply_adjusted: ComputedPerBlock, pub dormancy_supply_adjusted: ComputedPerBlock, + pub stock_to_flow: ComputedPerBlock, + pub dormancy_flow: ComputedPerBlock, + pub seller_exhaustion_constant: ComputedPerBlock, } diff --git a/crates/brk_computer/src/internal/per_block/ratio/extended.rs b/crates/brk_computer/src/internal/per_block/ratio/extended.rs deleted file mode 100644 index 3f63f8622..000000000 --- a/crates/brk_computer/src/internal/per_block/ratio/extended.rs +++ /dev/null @@ -1,52 +0,0 @@ -use brk_error::Result; -use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Cents, Height, Indexes, Version}; -use derive_more::{Deref, DerefMut}; -use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; - -use crate::{blocks, indexes, prices}; - -use super::{RatioPerBlock, RatioPerBlockPercentiles}; - -#[derive(Deref, DerefMut, Traversable)] -pub struct RatioPerBlockExtended { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub base: RatioPerBlock, - #[traversable(flatten)] - pub percentiles: RatioPerBlockPercentiles, -} - -impl RatioPerBlockExtended { - pub(crate) fn forced_import( - db: &Database, - name: &str, - version: Version, - indexes: &indexes::Vecs, - ) -> Result { - Ok(Self { - base: RatioPerBlock::forced_import(db, name, version, indexes)?, - percentiles: RatioPerBlockPercentiles::forced_import( - db, name, version, indexes, - )?, - }) - } - - /// Compute ratio and all percentile metrics from an externally-provided metric price (in cents). - pub(crate) fn compute_rest( - &mut self, - blocks: &blocks::Vecs, - prices: &prices::Vecs, - starting_indexes: &Indexes, - exit: &Exit, - metric_price: &impl ReadableVec, - ) -> Result<()> { - let close_price = &prices.price.cents.height; - self.base - .compute_ratio(starting_indexes, close_price, metric_price, exit)?; - self.percentiles - .compute(blocks, starting_indexes, exit, &self.base.ratio.height, metric_price)?; - Ok(()) - } -} diff --git a/crates/brk_computer/src/internal/per_block/ratio/mod.rs b/crates/brk_computer/src/internal/per_block/ratio/mod.rs index d029ff60a..3e8af3f50 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/mod.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/mod.rs @@ -1,13 +1,13 @@ mod base; -mod extended; mod percentiles; mod price_extended; +mod sma; mod std_dev_bands; mod windows; pub use base::*; -pub use extended::*; pub use percentiles::*; pub use price_extended::*; +pub use sma::*; pub use std_dev_bands::*; pub use windows::*; 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 47edd812f..25ce422ec 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs @@ -7,7 +7,7 @@ use vecdb::{ }; use crate::{ - blocks, indexes, + indexes, internal::{ExpandingPercentiles, Price, PriceTimesRatioBp32Cents}, }; @@ -22,8 +22,6 @@ pub struct RatioBand { #[derive(Traversable)] pub struct RatioPerBlockPercentiles { - pub sma_1w: RatioPerBlock, - pub sma_1m: RatioPerBlock, pub pct99: RatioBand, pub pct98: RatioBand, pub pct95: RatioBand, @@ -73,8 +71,6 @@ impl RatioPerBlockPercentiles { } Ok(Self { - 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"), @@ -87,26 +83,11 @@ impl RatioPerBlockPercentiles { pub(crate) fn compute( &mut self, - blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit, ratio_source: &impl ReadableVec, metric_price: &impl ReadableVec, ) -> Result<()> { - self.sma_1w.bps.height.compute_rolling_average( - starting_indexes.height, - &blocks.lookback.height_1w_ago, - ratio_source, - exit, - )?; - - self.sma_1m.bps.height.compute_rolling_average( - starting_indexes.height, - &blocks.lookback.height_1m_ago, - ratio_source, - exit, - )?; - let ratio_version = ratio_source.version(); self.mut_pct_vecs().try_for_each(|v| -> Result<()> { v.validate_computed_version_or_reset(ratio_version)?; 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 219d85b28..81120fba0 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,21 +1,21 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Cents, Height, Indexes, Version}; +use brk_types::{BasisPoints32, Cents, Dollars, Height, Indexes, SatsFract, StoredF32, Version}; use derive_more::{Deref, DerefMut}; -use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode}; +use vecdb::{Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode}; -use crate::internal::{ComputedPerBlock, Price}; +use crate::internal::{ComputedPerBlock, LazyPerBlock, Price}; use crate::{indexes, prices}; -use super::RatioPerBlock; +use super::{RatioPerBlock, RatioPerBlockPercentiles}; -#[derive(Deref, DerefMut, Traversable)] +#[derive(Traversable)] pub struct PriceWithRatioPerBlock { - #[deref] - #[deref_mut] - #[traversable(flatten)] - pub inner: RatioPerBlock, - pub price: Price>, + pub cents: ComputedPerBlock, + pub usd: LazyPerBlock, + pub sats: LazyPerBlock, + pub bps: ComputedPerBlock, + pub ratio: LazyPerBlock, } impl PriceWithRatioPerBlock { @@ -25,13 +25,40 @@ impl PriceWithRatioPerBlock { version: Version, indexes: &indexes::Vecs, ) -> Result { - let v = version + Version::TWO; + let price = Price::forced_import(db, name, version, indexes)?; + let ratio = RatioPerBlock::forced_import(db, name, version, indexes)?; Ok(Self { - inner: RatioPerBlock::forced_import(db, name, version, indexes)?, - price: Price::forced_import(db, name, v, indexes)?, + cents: price.cents, + usd: price.usd, + sats: price.sats, + bps: ratio.bps, + ratio: ratio.ratio, }) } + /// Compute ratio from close price and this metric's price. + pub(crate) fn compute_ratio( + &mut self, + starting_indexes: &Indexes, + close_price: &impl ReadableVec, + exit: &Exit, + ) -> Result<()> { + self.bps.height.compute_transform2( + starting_indexes.height, + close_price, + &self.cents.height, + |(i, close, price, ..)| { + if price == Cents::ZERO { + (i, BasisPoints32::from(1.0)) + } else { + (i, BasisPoints32::from(f64::from(close) / f64::from(price))) + } + }, + exit, + )?; + Ok(()) + } + /// Compute price via closure (in cents), then compute ratio. pub(crate) fn compute_all( &mut self, @@ -43,10 +70,63 @@ impl PriceWithRatioPerBlock { where F: FnMut(&mut EagerVec>) -> Result<()>, { - compute_price(&mut self.price.cents.height)?; - let close_price = &prices.price.cents.height; - self.inner - .compute_ratio(starting_indexes, close_price, &self.price.cents.height, exit)?; - Ok(()) + compute_price(&mut self.cents.height)?; + self.compute_ratio(starting_indexes, &prices.price.cents.height, exit) + } +} + +#[derive(Deref, DerefMut, Traversable)] +pub struct PriceWithRatioExtendedPerBlock { + #[deref] + #[deref_mut] + #[traversable(flatten)] + pub base: PriceWithRatioPerBlock, + pub percentiles: RatioPerBlockPercentiles, +} + +impl PriceWithRatioExtendedPerBlock { + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + indexes: &indexes::Vecs, + ) -> Result { + Ok(Self { + base: PriceWithRatioPerBlock::forced_import(db, name, version, indexes)?, + percentiles: RatioPerBlockPercentiles::forced_import(db, name, version, indexes)?, + }) + } + + /// Compute ratio and percentiles from already-computed price cents. + pub(crate) fn compute_rest( + &mut self, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ) -> Result<()> { + let close_price = &prices.price.cents.height; + self.base.compute_ratio(starting_indexes, close_price, exit)?; + self.percentiles.compute( + starting_indexes, + exit, + &self.base.ratio.height, + &self.base.cents.height, + )?; + Ok(()) + } + + /// Compute price via closure (in cents), then compute ratio and percentiles. + pub(crate) fn compute_all( + &mut self, + prices: &prices::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + mut compute_price: F, + ) -> Result<()> + where + F: FnMut(&mut EagerVec>) -> Result<()>, + { + compute_price(&mut self.base.cents.height)?; + self.compute_rest(prices, starting_indexes, exit) } } diff --git a/crates/brk_computer/src/internal/per_block/ratio/sma.rs b/crates/brk_computer/src/internal/per_block/ratio/sma.rs new file mode 100644 index 000000000..e50df755e --- /dev/null +++ b/crates/brk_computer/src/internal/per_block/ratio/sma.rs @@ -0,0 +1,86 @@ +use brk_error::Result; +use brk_traversable::Traversable; +use brk_types::{BasisPoints32, Height, Indexes, StoredF32, Version}; +use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; + +use crate::{blocks, indexes}; + +use super::RatioPerBlock; + +#[derive(Traversable)] +pub struct RatioSma { + pub all: RatioPerBlock, + pub _1w: RatioPerBlock, + pub _1m: RatioPerBlock, + pub _1y: RatioPerBlock, + pub _2y: RatioPerBlock, + pub _4y: RatioPerBlock, +} + +const VERSION: Version = Version::new(4); + +impl RatioSma { + pub(crate) fn forced_import( + db: &Database, + name: &str, + version: Version, + indexes: &indexes::Vecs, + ) -> Result { + let v = version + VERSION; + + macro_rules! import { + ($suffix:expr) => { + RatioPerBlock::forced_import_raw( + db, + &format!("{name}_ratio_sma_{}", $suffix), + v, + indexes, + )? + }; + } + + Ok(Self { + all: import!("all"), + _1w: import!("1w"), + _1m: import!("1m"), + _1y: import!("1y"), + _2y: import!("2y"), + _4y: import!("4y"), + }) + } + + pub(crate) fn compute( + &mut self, + blocks: &blocks::Vecs, + starting_indexes: &Indexes, + exit: &Exit, + ratio_source: &impl ReadableVec, + ) -> Result<()> { + // Expanding SMA (all history) + self.all.bps.height.compute_sma_( + starting_indexes.height, + ratio_source, + usize::MAX, + exit, + None, + )?; + + // Rolling SMAs + for (sma, lookback) in [ + (&mut self._1w, &blocks.lookback.height_1w_ago), + (&mut self._1m, &blocks.lookback.height_1m_ago), + (&mut self._1y, &blocks.lookback.height_1y_ago), + (&mut self._2y, &blocks.lookback.height_2y_ago), + (&mut self._4y, &blocks.lookback.height_4y_ago), + ] { + sma.bps.height.compute_rolling_average( + starting_indexes.height, + lookback, + ratio_source, + exit, + )?; + } + + Ok(()) + } +} 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 3d664e1a5..cce22bdd6 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 @@ -5,6 +5,8 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, indexes, internal::StdDevPerBlockExtended}; +use super::RatioSma; + #[derive(Traversable)] pub struct RatioPerBlockStdDevBands { pub all: StdDevPerBlockExtended, @@ -52,15 +54,16 @@ impl RatioPerBlockStdDevBands { exit: &Exit, ratio_source: &impl ReadableVec, metric_price: &impl ReadableVec, + sma: &RatioSma, ) -> Result<()> { - for sd in [ - &mut self.all, - &mut self._4y, - &mut self._2y, - &mut self._1y, + for (sd, sma_ratio) in [ + (&mut self.all, &sma.all.ratio.height), + (&mut self._4y, &sma._4y.ratio.height), + (&mut self._2y, &sma._2y.ratio.height), + (&mut self._1y, &sma._1y.ratio.height), ] { - sd.compute_all(blocks, starting_indexes, exit, ratio_source)?; - sd.compute_cents_bands(starting_indexes, metric_price, exit)?; + sd.compute_all(blocks, starting_indexes, exit, ratio_source, sma_ratio)?; + sd.compute_cents_bands(starting_indexes, metric_price, sma_ratio, 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 678d8edc2..306501201 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,15 @@ use brk_error::Result; use brk_traversable::Traversable; use brk_types::{Cents, Height, Indexes, StoredF32, Version}; use vecdb::{ - AnyStoredVec, AnyVec, Database, EagerVec, Exit, Ident, PcoVec, ReadableCloneableVec, - ReadableVec, Rw, StorageMode, VecIndex, WritableVec, + AnyStoredVec, AnyVec, Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode, VecIndex, + WritableVec, }; use crate::{ blocks, indexes, - internal::{ComputedPerBlock, LazyPerBlock, Price, PriceTimesRatioCents}, + internal::{ComputedPerBlock, Price, PriceTimesRatioCents}, }; -use super::StdDevPerBlock; - #[derive(Traversable)] pub struct StdDevBand { #[traversable(flatten)] @@ -20,21 +18,13 @@ pub struct StdDevBand { pub price: Price>, } -#[derive(Traversable)] -pub struct LazyStdDevBand { - #[traversable(flatten)] - pub value: LazyPerBlock, - pub price: Price>, -} - #[derive(Traversable)] pub struct StdDevPerBlockExtended { - #[traversable(flatten)] - pub base: StdDevPerBlock, - + days: usize, + pub sd: ComputedPerBlock, pub zscore: ComputedPerBlock, - pub _0sd: LazyStdDevBand, + pub _0sd: Price>, pub p0_5sd: StdDevBand, pub p1sd: StdDevBand, pub p1_5sd: StdDevBand, @@ -87,29 +77,11 @@ impl StdDevPerBlockExtended { }; } - 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, + days, + sd: import!("sd"), zscore: import!("zscore"), - _0sd, + _0sd: import_price!("0sd"), p0_5sd: import_band!("p0_5sd"), p1sd: import_band!("p1sd"), p1_5sd: import_band!("p1_5sd"), @@ -131,19 +103,34 @@ impl StdDevPerBlockExtended { starting_indexes: &Indexes, exit: &Exit, source: &impl ReadableVec, + sma: &impl ReadableVec, ) -> Result<()> { - self.base - .compute_all(blocks, starting_indexes, exit, source)?; + if self.days == usize::MAX { + self.sd.height.compute_expanding_sd( + starting_indexes.height, + source, + sma, + exit, + )?; + } else { + let window_starts = blocks.lookback.start_vec(self.days); + self.sd.height.compute_rolling_sd( + starting_indexes.height, + window_starts, + source, + sma, + exit, + )?; + } - let sma_opt: Option<&EagerVec>> = None; - self.compute_bands(starting_indexes, exit, sma_opt, source) + self.compute_bands(starting_indexes, exit, sma, source) } - pub(crate) fn compute_bands( + fn compute_bands( &mut self, starting_indexes: &Indexes, exit: &Exit, - sma_opt: Option<&impl ReadableVec>, + sma: &impl ReadableVec, source: &impl ReadableVec, ) -> Result<()> { let source_version = source.version(); @@ -166,19 +153,11 @@ impl StdDevPerBlockExtended { let source_len = source.len(); let source_data = source.collect_range_at(start, source_len); - let sma_len = sma_opt - .map(|s| s.len()) - .unwrap_or(self.base.sma.height.len()); - let sma_data: Vec = if let Some(sma) = sma_opt { - sma.collect_range_at(start, sma_len) - } else { - self.base.sma.height.collect_range_at(start, sma_len) - }; + let sma_data = sma.collect_range_at(start, sma.len()); let sd_data = self - .base .sd .height - .collect_range_at(start, self.base.sd.height.len()); + .collect_range_at(start, self.sd.height.len()); const MULTIPLIERS: [f32; 12] = [ 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, -0.5, -1.0, -1.5, -2.0, -2.5, -3.0, @@ -197,23 +176,13 @@ impl StdDevPerBlockExtended { self.mut_band_height_vecs().try_for_each(|v| v.flush())?; } - if let Some(sma) = sma_opt { - self.zscore.height.compute_zscore( - starting_indexes.height, - source, - sma, - &self.base.sd.height, - exit, - )?; - } else { - self.zscore.height.compute_zscore( - starting_indexes.height, - source, - &self.base.sma.height, - &self.base.sd.height, - exit, - )?; - } + self.zscore.height.compute_zscore( + starting_indexes.height, + source, + sma, + &self.sd.height, + exit, + )?; Ok(()) } @@ -222,6 +191,7 @@ impl StdDevPerBlockExtended { &mut self, starting_indexes: &Indexes, metric_price: &impl ReadableVec, + sma: &impl ReadableVec, exit: &Exit, ) -> Result<()> { macro_rules! compute_band_price { @@ -237,7 +207,7 @@ impl StdDevPerBlockExtended { }; } - compute_band_price!(&mut self._0sd.price, &self.base.sma.height); + compute_band_price!(&mut self._0sd, sma); 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); diff --git a/crates/brk_computer/src/lib.rs b/crates/brk_computer/src/lib.rs index b9b16dcd5..676fad607 100644 --- a/crates/brk_computer/src/lib.rs +++ b/crates/brk_computer/src/lib.rs @@ -429,18 +429,6 @@ impl Computer { }) }); - let indicators = scope.spawn(|| { - timed("Computed indicators", || { - self.indicators.compute( - &self.mining, - &self.distribution, - &self.transactions, - &starting_indexes, - exit, - ) - }) - }); - timed("Computed supply", || { self.supply.compute( &self.scripts, @@ -455,20 +443,37 @@ impl Computer { })?; market.join().unwrap()?; - indicators.join().unwrap()?; Ok(()) })?; - timed("Computed cointime", || { - self.cointime.compute( - &starting_indexes, - &self.prices, - &self.blocks, - &self.mining, - &self.supply, - &self.distribution, - exit, - ) + thread::scope(|scope| -> Result<()> { + let indicators = scope.spawn(|| { + timed("Computed indicators", || { + self.indicators.compute( + &self.mining, + &self.distribution, + &self.transactions, + &self.market, + &starting_indexes, + exit, + ) + }) + }); + + timed("Computed cointime", || { + self.cointime.compute( + &starting_indexes, + &self.prices, + &self.blocks, + &self.mining, + &self.supply, + &self.distribution, + exit, + ) + })?; + + indicators.join().unwrap()?; + Ok(()) })?; info!("Total compute time: {:?}", compute_start.elapsed()); diff --git a/crates/brk_computer/src/market/moving_average/import.rs b/crates/brk_computer/src/market/moving_average/import.rs index 1a4ea1600..56dabfdd8 100644 --- a/crates/brk_computer/src/market/moving_average/import.rs +++ b/crates/brk_computer/src/market/moving_average/import.rs @@ -26,7 +26,7 @@ impl Vecs { let sma_200d = import!("price_sma_200d"); let sma_350d = import!("price_sma_350d"); - let price_sma_200d_source = &sma_200d.price.cents; + let price_sma_200d_source = &sma_200d.cents; let _200d_x2_4 = Price::from_cents_source::>( "price_sma_200d_x2_4", version, @@ -38,7 +38,7 @@ impl Vecs { price_sma_200d_source, ); - let price_sma_350d_source = &sma_350d.price.cents; + let price_sma_350d_source = &sma_350d.cents; let _350d_x2 = Price::from_cents_source::>( "price_sma_350d_x2", version, diff --git a/crates/brk_computer/src/market/technical/compute.rs b/crates/brk_computer/src/market/technical/compute.rs index 493b2b5f5..178a27f90 100644 --- a/crates/brk_computer/src/market/technical/compute.rs +++ b/crates/brk_computer/src/market/technical/compute.rs @@ -94,7 +94,7 @@ impl Vecs { .bps .compute_binary::( starting_indexes.height, - &moving_average.sma._111d.price.usd.height, + &moving_average.sma._111d.usd.height, &moving_average.sma._350d_x2.usd.height, exit, )?; diff --git a/crates/brk_computer/src/supply/vecs.rs b/crates/brk_computer/src/supply/vecs.rs index a2698a241..ec071eb9d 100644 --- a/crates/brk_computer/src/supply/vecs.rs +++ b/crates/brk_computer/src/supply/vecs.rs @@ -17,6 +17,7 @@ pub struct Vecs { pub inflation_rate: PercentPerBlock, pub velocity: velocity::Vecs, pub market_cap: LazyFiatPerBlock, + #[traversable(wrap = "market_cap", rename = "delta")] pub market_cap_delta: FiatRollingDelta, pub market_minus_realized_cap_growth_rate: RollingWindows, pub hodled_or_lost_coins: LazyAmountPerBlock, diff --git a/crates/brk_query/Cargo.toml b/crates/brk_query/Cargo.toml index 992d59d1a..191abc12c 100644 --- a/crates/brk_query/Cargo.toml +++ b/crates/brk_query/Cargo.toml @@ -23,7 +23,7 @@ brk_traversable = { workspace = true } brk_types = { workspace = true } derive_more = { workspace = true } jiff = { workspace = true } -# quickmatch = { path = "../../../quickmatch" } -quickmatch = "0.3.1" +quickmatch = { path = "../../../quickmatch" } +# quickmatch = "0.3.1" tokio = { workspace = true, optional = true } vecdb = { workspace = true } diff --git a/crates/brk_query/examples/list.rs b/crates/brk_query/examples/list.rs new file mode 100644 index 000000000..98aec90a6 --- /dev/null +++ b/crates/brk_query/examples/list.rs @@ -0,0 +1,34 @@ +use std::{env, fs, path::Path}; + +use brk_computer::Computer; +use brk_indexer::Indexer; +use brk_query::Vecs; +use vecdb::ReadOnlyClone; + +pub fn main() -> color_eyre::Result<()> { + color_eyre::install()?; + + let tmp = env::temp_dir().join("brk_search_gen"); + fs::create_dir_all(&tmp)?; + + let indexer = Indexer::forced_import(&tmp)?; + let computer = Computer::forced_import(&tmp, &indexer)?; + + let indexer_ro = indexer.read_only_clone(); + let computer_ro = computer.read_only_clone(); + + let vecs = Vecs::build(&indexer_ro, &computer_ro); + + let out_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("metrics.txt"); + let content = vecs.metrics.join("\n"); + fs::write(&out_path, &content)?; + eprintln!( + "Wrote {} metrics to {}", + vecs.metrics.len(), + out_path.display() + ); + + fs::remove_dir_all(&tmp)?; + + Ok(()) +} diff --git a/crates/brk_query/src/impl/metrics.rs b/crates/brk_query/src/impl/metrics.rs index 1ee3e5459..c06285caf 100644 --- a/crates/brk_query/src/impl/metrics.rs +++ b/crates/brk_query/src/impl/metrics.rs @@ -118,17 +118,8 @@ impl Query { } /// Calculate total weight of the vecs for the given range. - /// Applies index-specific cost multipliers for rate limiting. pub fn weight(vecs: &[&dyn AnyExportableVec], from: Option, to: Option) -> usize { - vecs.iter() - .map(|v| { - let base = v.range_weight(from, to); - let multiplier = Index::try_from(v.index_type_to_string()) - .map(|i| i.cost_multiplier()) - .unwrap_or(1); - base * multiplier - }) - .sum() + vecs.iter().map(|v| v.range_weight(from, to)).sum() } /// Resolve query metadata without formatting (cheap). diff --git a/crates/brk_server/Cargo.toml b/crates/brk_server/Cargo.toml index 585712f76..148215a0a 100644 --- a/crates/brk_server/Cargo.toml +++ b/crates/brk_server/Cargo.toml @@ -14,6 +14,8 @@ bindgen = ["dep:brk_bindgen"] [dependencies] aide = { workspace = true } axum = { workspace = true } +brotli = "8" +flate2 = "1" brk_bindgen = { workspace = true, optional = true } brk_computer = { workspace = true } brk_error = { workspace = true, features = ["jiff", "serde_json", "tokio", "vecdb"] } @@ -27,6 +29,7 @@ brk_traversable = { workspace = true } brk_website = { workspace = true } derive_more = { workspace = true } vecdb = { workspace = true } +zstd = "0.13" jiff = { workspace = true } quick_cache = "0.6.18" schemars = { workspace = true } diff --git a/crates/brk_server/src/api/metrics/bulk.rs b/crates/brk_server/src/api/metrics/bulk.rs index 151ca9720..7f4645eac 100644 --- a/crates/brk_server/src/api/metrics/bulk.rs +++ b/crates/brk_server/src/api/metrics/bulk.rs @@ -12,7 +12,7 @@ use brk_types::{Format, MetricSelection, Output}; use crate::{ Result, api::metrics::{CACHE_CONTROL, max_weight}, - extended::HeaderMapExtended, + extended::{ContentEncoding, HeaderMapExtended}, }; use super::AppState; @@ -38,15 +38,27 @@ pub async fn handler( } // Phase 2: Format (expensive, server-side cached) - let cache_key = format!("bulk-{}{}{}", uri.path(), uri.query().unwrap_or(""), etag); + let encoding = ContentEncoding::negotiate(&headers); + let cache_key = format!( + "bulk-{}{}{}-{}", + uri.path(), + uri.query().unwrap_or(""), + etag, + encoding.as_str() + ); let query = &state; let bytes = state .get_or_insert(&cache_key, async move { - let out = query.run(move |q| q.format(resolved)).await?; - Ok(match out.output { - Output::CSV(s) => Bytes::from(s), - Output::Json(v) => Bytes::from(v), - }) + query + .run(move |q| { + let out = q.format(resolved)?; + let raw = match out.output { + Output::CSV(s) => Bytes::from(s), + Output::Json(v) => Bytes::from(v), + }; + Ok(encoding.compress(raw)) + }) + .await }) .await?; @@ -54,6 +66,7 @@ pub async fn handler( let h = response.headers_mut(); h.insert_etag(etag.as_str()); h.insert_cache_control(CACHE_CONTROL); + h.insert_content_encoding(encoding); match format { Format::CSV => { h.insert_content_disposition_attachment(&csv_filename); diff --git a/crates/brk_server/src/api/metrics/data.rs b/crates/brk_server/src/api/metrics/data.rs index 9f1a6cb48..c9b8d2b65 100644 --- a/crates/brk_server/src/api/metrics/data.rs +++ b/crates/brk_server/src/api/metrics/data.rs @@ -12,7 +12,7 @@ use brk_types::{Format, MetricSelection, Output}; use crate::{ Result, api::metrics::{CACHE_CONTROL, max_weight}, - extended::HeaderMapExtended, + extended::{ContentEncoding, HeaderMapExtended}, }; use super::AppState; @@ -38,15 +38,27 @@ pub async fn handler( } // Phase 2: Format (expensive, server-side cached) - let cache_key = format!("single-{}{}{}", uri.path(), uri.query().unwrap_or(""), etag); + let encoding = ContentEncoding::negotiate(&headers); + let cache_key = format!( + "single-{}{}{}-{}", + uri.path(), + uri.query().unwrap_or(""), + etag, + encoding.as_str() + ); let query = &state; let bytes = state .get_or_insert(&cache_key, async move { - let out = query.run(move |q| q.format(resolved)).await?; - Ok(match out.output { - Output::CSV(s) => Bytes::from(s), - Output::Json(v) => Bytes::from(v), - }) + query + .run(move |q| { + let out = q.format(resolved)?; + let raw = match out.output { + Output::CSV(s) => Bytes::from(s), + Output::Json(v) => Bytes::from(v), + }; + Ok(encoding.compress(raw)) + }) + .await }) .await?; @@ -54,6 +66,7 @@ pub async fn handler( let h = response.headers_mut(); h.insert_etag(etag.as_str()); h.insert_cache_control(CACHE_CONTROL); + h.insert_content_encoding(encoding); match format { Format::CSV => { h.insert_content_disposition_attachment(&csv_filename); diff --git a/crates/brk_server/src/api/metrics/legacy.rs b/crates/brk_server/src/api/metrics/legacy.rs index 1b43b465d..f77f42a85 100644 --- a/crates/brk_server/src/api/metrics/legacy.rs +++ b/crates/brk_server/src/api/metrics/legacy.rs @@ -12,7 +12,7 @@ use brk_types::{Format, MetricSelection, OutputLegacy}; use crate::{ Result, api::metrics::{CACHE_CONTROL, max_weight}, - extended::HeaderMapExtended, + extended::{ContentEncoding, HeaderMapExtended}, }; const SUNSET: &str = "2027-01-01T00:00:00Z"; @@ -40,15 +40,27 @@ pub async fn handler( } // Phase 2: Format (expensive, server-side cached) - let cache_key = format!("legacy-{}{}{}", uri.path(), uri.query().unwrap_or(""), etag); + let encoding = ContentEncoding::negotiate(&headers); + let cache_key = format!( + "legacy-{}{}{}-{}", + uri.path(), + uri.query().unwrap_or(""), + etag, + encoding.as_str() + ); let query = &state; let bytes = state .get_or_insert(&cache_key, async move { - let out = query.run(move |q| q.format_legacy(resolved)).await?; - Ok(match out.output { - OutputLegacy::CSV(s) => Bytes::from(s), - OutputLegacy::Json(v) => Bytes::from(v.to_vec()), - }) + query + .run(move |q| { + let out = q.format_legacy(resolved)?; + let raw = match out.output { + OutputLegacy::CSV(s) => Bytes::from(s), + OutputLegacy::Json(v) => Bytes::from(v.to_vec()), + }; + Ok(encoding.compress(raw)) + }) + .await }) .await?; @@ -56,6 +68,7 @@ pub async fn handler( let h = response.headers_mut(); h.insert_etag(etag.as_str()); h.insert_cache_control(CACHE_CONTROL); + h.insert_content_encoding(encoding); match format { Format::CSV => { h.insert_content_disposition_attachment(&csv_filename); diff --git a/crates/brk_server/src/extended/encoding.rs b/crates/brk_server/src/extended/encoding.rs new file mode 100644 index 000000000..080ba00ae --- /dev/null +++ b/crates/brk_server/src/extended/encoding.rs @@ -0,0 +1,88 @@ +use axum::{ + body::Bytes, + http::{header, HeaderMap, HeaderValue}, +}; + +/// HTTP content encoding for pre-compressed caching. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum ContentEncoding { + Brotli, + Gzip, + Zstd, + Identity, +} + +impl ContentEncoding { + /// Negotiate the best encoding from the Accept-Encoding header. + /// Priority: br > zstd > gzip > identity. + pub fn negotiate(headers: &HeaderMap) -> Self { + let accept = match headers.get(header::ACCEPT_ENCODING) { + Some(v) => v, + None => return Self::Identity, + }; + let s = match accept.to_str() { + Ok(s) => s, + Err(_) => return Self::Identity, + }; + + let mut best = Self::Identity; + for part in s.split(',') { + let name = part.split(';').next().unwrap_or("").trim(); + match name { + "br" => return Self::Brotli, + "zstd" => best = Self::Zstd, + "gzip" if matches!(best, Self::Identity) => best = Self::Gzip, + _ => {} + } + } + best + } + + /// Compress bytes with this encoding. Identity returns bytes unchanged. + pub fn compress(self, bytes: Bytes) -> Bytes { + match self { + Self::Identity => bytes, + Self::Brotli => { + use std::io::Write; + let mut output = Vec::with_capacity(bytes.len() / 2); + { + let mut writer = brotli::CompressorWriter::new(&mut output, 4096, 4, 22); + writer.write_all(&bytes).expect("brotli compression failed"); + } + Bytes::from(output) + } + Self::Gzip => { + use flate2::write::GzEncoder; + use std::io::Write; + let mut encoder = GzEncoder::new( + Vec::with_capacity(bytes.len() / 2), + flate2::Compression::new(3), + ); + encoder.write_all(&bytes).expect("gzip compression failed"); + Bytes::from(encoder.finish().expect("gzip finish failed")) + } + Self::Zstd => Bytes::from( + zstd::encode_all(bytes.as_ref(), 3).expect("zstd compression failed"), + ), + } + } + + /// Wire name used for Content-Encoding header and cache key suffix. + #[inline] + pub fn as_str(self) -> &'static str { + match self { + Self::Brotli => "br", + Self::Gzip => "gzip", + Self::Zstd => "zstd", + Self::Identity => "identity", + } + } + + #[inline] + pub(crate) fn header_value(self) -> Option { + match self { + Self::Identity => None, + _ => Some(HeaderValue::from_static(self.as_str())), + } + } +} diff --git a/crates/brk_server/src/extended/header_map.rs b/crates/brk_server/src/extended/header_map.rs index df1afcdec..fc477a581 100644 --- a/crates/brk_server/src/extended/header_map.rs +++ b/crates/brk_server/src/extended/header_map.rs @@ -3,6 +3,8 @@ use axum::http::{ header::{self, IF_NONE_MATCH}, }; +use super::ContentEncoding; + pub trait HeaderMapExtended { fn has_etag(&self, etag: &str) -> bool; fn insert_etag(&mut self, etag: &str); @@ -12,10 +14,10 @@ pub trait HeaderMapExtended { fn insert_content_disposition_attachment(&mut self, filename: &str); + fn insert_content_encoding(&mut self, encoding: ContentEncoding); + 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); } @@ -45,6 +47,12 @@ impl HeaderMapExtended for HeaderMap { ); } + fn insert_content_encoding(&mut self, encoding: ContentEncoding) { + if let Some(value) = encoding.header_value() { + self.insert(header::CONTENT_ENCODING, value); + } + } + fn insert_content_type_application_json(&mut self) { self.insert(header::CONTENT_TYPE, "application/json".parse().unwrap()); } @@ -53,17 +61,6 @@ impl HeaderMapExtended for HeaderMap { self.insert(header::CONTENT_TYPE, "text/csv".parse().unwrap()); } - fn insert_content_type_text_plain(&mut self) { - self.insert(header::CONTENT_TYPE, "text/plain".parse().unwrap()); - } - - fn insert_content_type_octet_stream(&mut self) { - self.insert( - header::CONTENT_TYPE, - "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/mod.rs b/crates/brk_server/src/extended/mod.rs index 97492fb2b..cffdf2f1f 100644 --- a/crates/brk_server/src/extended/mod.rs +++ b/crates/brk_server/src/extended/mod.rs @@ -1,9 +1,9 @@ +mod encoding; mod header_map; mod response; -mod result; mod transform_operation; +pub use encoding::*; pub use header_map::*; pub use response::*; -pub use result::*; pub use transform_operation::*; diff --git a/crates/brk_server/src/extended/response.rs b/crates/brk_server/src/extended/response.rs index 1743178a7..b9eead3b3 100644 --- a/crates/brk_server/src/extended/response.rs +++ b/crates/brk_server/src/extended/response.rs @@ -13,22 +13,12 @@ where Self: Sized, { fn new_not_modified() -> Self; - fn new_json(value: T, etag: &str) -> Self - where - T: Serialize; - fn new_json_with(status: StatusCode, value: T, etag: &str) -> Self - where - T: Serialize; fn new_json_cached(value: T, params: &CacheParams) -> Self where T: Serialize; fn static_json(headers: &HeaderMap, value: T) -> Self where T: Serialize; - fn new_text(value: &str, etag: &str) -> Self; - fn new_text_with(status: StatusCode, value: &str, etag: &str) -> Self; - fn new_bytes(value: Vec, etag: &str) -> Self; - fn new_bytes_with(status: StatusCode, value: Vec, etag: &str) -> Self; } impl ResponseExtended for Response { @@ -38,55 +28,6 @@ impl ResponseExtended for Response { response } - fn new_json(value: T, etag: &str) -> Self - where - T: Serialize, - { - Self::new_json_with(StatusCode::default(), value, etag) - } - - fn new_json_with(status: StatusCode, value: T, etag: &str) -> Self - where - T: Serialize, - { - let bytes = serde_json::to_vec(&value).unwrap(); - let mut response = Response::builder().body(bytes.into()).unwrap(); - *response.status_mut() = status; - let headers = response.headers_mut(); - headers.insert_content_type_application_json(); - headers.insert_cache_control_must_revalidate(); - headers.insert_etag(etag); - response - } - - fn new_text(value: &str, etag: &str) -> Self { - Self::new_text_with(StatusCode::default(), value, etag) - } - - fn new_text_with(status: StatusCode, value: &str, etag: &str) -> Self { - let mut response = Response::builder().body(value.to_string().into()).unwrap(); - *response.status_mut() = status; - let headers = response.headers_mut(); - headers.insert_content_type_text_plain(); - headers.insert_cache_control_must_revalidate(); - headers.insert_etag(etag); - response - } - - fn new_bytes(value: Vec, etag: &str) -> Self { - Self::new_bytes_with(StatusCode::default(), value, etag) - } - - fn new_bytes_with(status: StatusCode, value: Vec, etag: &str) -> Self { - let mut response = Response::builder().body(value.into()).unwrap(); - *response.status_mut() = status; - let headers = response.headers_mut(); - headers.insert_content_type_octet_stream(); - headers.insert_cache_control_must_revalidate(); - headers.insert_etag(etag); - response - } - fn new_json_cached(value: T, params: &CacheParams) -> Self where T: Serialize, diff --git a/crates/brk_server/src/extended/result.rs b/crates/brk_server/src/extended/result.rs deleted file mode 100644 index b6c6a8881..000000000 --- a/crates/brk_server/src/extended/result.rs +++ /dev/null @@ -1,49 +0,0 @@ -use axum::response::Response; -use brk_error::Result; -use serde::Serialize; - -use crate::{Error, extended::ResponseExtended}; - -pub trait ResultExtended { - fn to_json_response(self, etag: &str) -> Response - where - T: Serialize; - fn to_text_response(self, etag: &str) -> Response - where - T: AsRef; - fn to_bytes_response(self, etag: &str) -> Response - where - T: Into>; -} - -impl ResultExtended for Result { - fn to_json_response(self, etag: &str) -> Response - where - T: Serialize, - { - match self { - Ok(value) => Response::new_json(&value, etag), - Err(e) => Error::from(e).into_response_with_etag(etag), - } - } - - fn to_text_response(self, etag: &str) -> Response - where - T: AsRef, - { - match self { - Ok(value) => Response::new_text(value.as_ref(), etag), - Err(e) => Error::from(e).into_response_with_etag(etag), - } - } - - fn to_bytes_response(self, etag: &str) -> Response - where - T: Into>, - { - match self { - Ok(value) => Response::new_bytes(value.into(), etag), - Err(e) => Error::from(e).into_response_with_etag(etag), - } - } -} diff --git a/crates/brk_server/src/state.rs b/crates/brk_server/src/state.rs index 35b2f8d12..719eba263 100644 --- a/crates/brk_server/src/state.rs +++ b/crates/brk_server/src/state.rs @@ -9,7 +9,7 @@ use derive_more::Deref; use axum::{ body::{Body, Bytes}, - http::{HeaderMap, Response, Uri}, + http::{HeaderMap, HeaderValue, Response, Uri, header}, }; use brk_query::AsyncQuery; use brk_rpc::Client; @@ -18,8 +18,8 @@ use quick_cache::sync::{Cache, GuardResult}; use serde::Serialize; use crate::{ - CacheParams, CacheStrategy, Website, - extended::{HeaderMapExtended, ResponseExtended, ResultExtended}, + CacheParams, CacheStrategy, Error, Website, + extended::{ContentEncoding, HeaderMapExtended, ResponseExtended}, }; #[derive(Clone, Deref)] @@ -40,6 +40,47 @@ impl AppState { CacheStrategy::MempoolHash(hash) } + /// Cached + pre-compressed response. Compression runs on the blocking thread. + async fn cached( + &self, + headers: &HeaderMap, + strategy: CacheStrategy, + uri: &Uri, + content_type: &'static str, + f: F, + ) -> Response + where + F: FnOnce(&brk_query::Query, ContentEncoding) -> brk_error::Result + Send + 'static, + { + let encoding = ContentEncoding::negotiate(headers); + let params = CacheParams::resolve(&strategy, || self.sync(|q| q.height().into())); + if params.matches_etag(headers) { + return ResponseExtended::new_not_modified(); + } + + let full_key = format!("{}-{}-{}", uri, params.etag_str(), encoding.as_str()); + let result = self + .get_or_insert(&full_key, async move { + self.run(move |q| f(q, encoding)).await + }) + .await; + + match result { + Ok(bytes) => { + let mut response = Response::new(Body::from(bytes)); + let h = response.headers_mut(); + h.insert(header::CONTENT_TYPE, HeaderValue::from_static(content_type)); + h.insert_cache_control(¶ms.cache_control); + h.insert_content_encoding(encoding); + if let Some(etag) = ¶ms.etag { + h.insert_etag(etag); + } + response + } + Err(e) => Error::from(e).into_response_with_etag(params.etag_str()), + } + } + /// JSON response with HTTP + server-side caching pub async fn cached_json( &self, @@ -52,32 +93,11 @@ impl AppState { T: Serialize + Send + 'static, F: FnOnce(&brk_query::Query) -> brk_error::Result + Send + 'static, { - let params = CacheParams::resolve(&strategy, || self.sync(|q| q.height().into())); - if params.matches_etag(headers) { - return ResponseExtended::new_not_modified(); - } - - let full_key = format!("{}-{}", uri, params.etag_str()); - let result = self - .get_or_insert(&full_key, async move { - let value = self.run(f).await?; - Ok(serde_json::to_vec(&value).unwrap().into()) - }) - .await; - - match result { - Ok(bytes) => { - let mut response = Response::new(Body::from(bytes)); - let h = response.headers_mut(); - h.insert_content_type_application_json(); - h.insert_cache_control(¶ms.cache_control); - if let Some(etag) = ¶ms.etag { - h.insert_etag(etag); - } - response - } - Err(e) => ResultExtended::::to_json_response(Err(e), params.etag_str()), - } + self.cached(headers, strategy, uri, "application/json", move |q, enc| { + let value = f(q)?; + Ok(enc.compress(Bytes::from(serde_json::to_vec(&value).unwrap()))) + }) + .await } /// Text response with HTTP + server-side caching @@ -92,32 +112,11 @@ impl AppState { T: AsRef + Send + 'static, F: FnOnce(&brk_query::Query) -> brk_error::Result + Send + 'static, { - let params = CacheParams::resolve(&strategy, || self.sync(|q| q.height().into())); - if params.matches_etag(headers) { - return ResponseExtended::new_not_modified(); - } - - let full_key = format!("{}-{}", uri, params.etag_str()); - let result = self - .get_or_insert(&full_key, async move { - let value = self.run(f).await?; - Ok(Bytes::from(value.as_ref().to_owned())) - }) - .await; - - match result { - Ok(bytes) => { - let mut response = Response::new(Body::from(bytes)); - let h = response.headers_mut(); - h.insert_content_type_text_plain(); - h.insert_cache_control(¶ms.cache_control); - if let Some(etag) = ¶ms.etag { - h.insert_etag(etag); - } - response - } - Err(e) => ResultExtended::::to_text_response(Err(e), params.etag_str()), - } + self.cached(headers, strategy, uri, "text/plain", move |q, enc| { + let value = f(q)?; + Ok(enc.compress(Bytes::from(value.as_ref().as_bytes().to_vec()))) + }) + .await } /// Binary response with HTTP + server-side caching @@ -132,32 +131,17 @@ impl AppState { T: Into> + Send + 'static, F: FnOnce(&brk_query::Query) -> brk_error::Result + Send + 'static, { - let params = CacheParams::resolve(&strategy, || self.sync(|q| q.height().into())); - if params.matches_etag(headers) { - return ResponseExtended::new_not_modified(); - } - - let full_key = format!("{}-{}", uri, params.etag_str()); - let result = self - .get_or_insert(&full_key, async move { - let value = self.run(f).await?; - Ok(Bytes::from(value.into())) - }) - .await; - - match result { - Ok(bytes) => { - let mut response = Response::new(Body::from(bytes)); - let h = response.headers_mut(); - h.insert_content_type_octet_stream(); - h.insert_cache_control(¶ms.cache_control); - if let Some(etag) = ¶ms.etag { - h.insert_etag(etag); - } - response - } - Err(e) => ResultExtended::::to_bytes_response(Err(e), params.etag_str()), - } + self.cached( + headers, + strategy, + uri, + "application/octet-stream", + move |q, enc| { + let value = f(q)?; + Ok(enc.compress(Bytes::from(value.into()))) + }, + ) + .await } /// Check server-side cache, compute on miss diff --git a/crates/brk_types/src/basis_points_32.rs b/crates/brk_types/src/basis_points_32.rs index ef4a26db7..05ea906c6 100644 --- a/crates/brk_types/src/basis_points_32.rs +++ b/crates/brk_types/src/basis_points_32.rs @@ -90,6 +90,27 @@ impl From for f64 { } } +impl From for BasisPoints32 { + #[inline] + fn from(value: f32) -> Self { + Self::from(value as f64) + } +} + +impl From for BasisPoints32 { + #[inline] + fn from(value: StoredF32) -> Self { + Self::from(f64::from(*value)) + } +} + +impl From for f32 { + #[inline] + fn from(value: BasisPoints32) -> Self { + value.0 as f32 / 10000.0 + } +} + impl From for StoredF32 { #[inline] fn from(value: BasisPoints32) -> Self { diff --git a/crates/brk_types/src/index.rs b/crates/brk_types/src/index.rs index 27443beb4..e6fb9ff85 100644 --- a/crates/brk_types/src/index.rs +++ b/crates/brk_types/src/index.rs @@ -184,14 +184,6 @@ impl Index { } } - /// Returns the query cost multiplier for this index type. - /// Used for rate limiting to account for expensive lazy computations. - pub const fn cost_multiplier(&self) -> usize { - match self { - Self::Epoch => 60, - _ => 1, - } - } /// Returns true if this index type is date-based. pub const fn is_date_based(&self) -> bool { diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index ada2642fb..8b3cca240 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -1647,8 +1647,8 @@ function createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65 } /** - * @typedef {Object} _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern - * @property {PriceValuePattern} _0sd + * @typedef {Object} _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern + * @property {CentsSatsUsdPattern} _0sd * @property {PriceValuePattern} m05sd * @property {PriceValuePattern} m15sd * @property {PriceValuePattern} m1sd @@ -1662,19 +1662,18 @@ function createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65 * @property {PriceValuePattern} p2sd * @property {PriceValuePattern} p3sd * @property {MetricPattern1} sd - * @property {MetricPattern1} sma * @property {MetricPattern1} zscore */ /** - * Create a _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern pattern node + * Create a _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} + * @returns {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern} */ -function create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client, acc) { +function create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc) { return { - _0sd: createPriceValuePattern(client, _m(acc, '0sd_4y')), + _0sd: createCentsSatsUsdPattern(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')), @@ -1688,54 +1687,10 @@ function create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern(client 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 {RawSellSumPattern} grossPnl - * @property {CapLowerPriceUpperPattern} investor - * @property {CapitulationCumulativeNegativeRawRelSumValuePattern} loss - * @property {MetricPattern1} mvrv - * @property {ChangeCumulativeDeltaRawRelSumPattern} netPnl - * @property {BpsRatioPattern} nupl - * @property {CumulativeRawRelPattern} peakRegret - * @property {CentsSatsUsdPattern} price - * @property {BpsPercentilesRatioStdPattern} priceRatio - * @property {CumulativeDistributionRawRelSumValuePattern} profit - * @property {_1m1w1y24hPattern} profitToLossRatio - * @property {InPattern3} sent - * @property {AdjustedRatioValuePattern} sopr - */ - -/** - * Create a CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern} - */ -function createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(client, acc) { - return { - cap: createCentsDeltaRawRelUsdPattern(client, acc), - grossPnl: createRawSellSumPattern(client, acc), - investor: createCapLowerPriceUpperPattern(client, acc), - loss: createCapitulationCumulativeNegativeRawRelSumValuePattern(client, acc), - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - netPnl: createChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), - peakRegret: createCumulativeRawRelPattern(client, _m(acc, 'realized_peak_regret')), - price: createCentsSatsUsdPattern(client, _m(acc, 'realized_price')), - priceRatio: createBpsPercentilesRatioStdPattern(client, _m(acc, 'realized_price_ratio')), - profit: createCumulativeDistributionRawRelSumValuePattern(client, acc), - profitToLossRatio: create_1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')), - sent: createInPattern3(client, _m(acc, 'sent_in')), - sopr: createAdjustedRatioValuePattern(client, acc), - }; -} - /** * @typedef {Object} _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 * @property {BpsPercentRatioPattern} _10y @@ -1814,6 +1769,45 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { }; } +/** + * @typedef {Object} CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern + * @property {CentsDeltaRawRelUsdPattern} cap + * @property {RawSellSumPattern} grossPnl + * @property {CapLowerPriceUpperPattern} investor + * @property {CapitulationCumulativeNegativeRawRelSumValuePattern} loss + * @property {MetricPattern1} mvrv + * @property {ChangeCumulativeDeltaRawRelSumPattern} netPnl + * @property {BpsRatioPattern} nupl + * @property {CumulativeRawRelPattern} peakRegret + * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price + * @property {CumulativeDistributionRawRelSumValuePattern} profit + * @property {_1m1w1y24hPattern} profitToLossRatio + * @property {AdjustedRatioValuePattern} sopr + */ + +/** + * Create a CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern} + */ +function createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(client, acc) { + return { + cap: createCentsDeltaRawRelUsdPattern(client, acc), + grossPnl: createRawSellSumPattern(client, acc), + investor: createCapLowerPriceUpperPattern(client, acc), + loss: createCapitulationCumulativeNegativeRawRelSumValuePattern(client, acc), + mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + netPnl: createChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), + peakRegret: createCumulativeRawRelPattern(client, _m(acc, 'realized_peak_regret')), + price: createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, _m(acc, 'realized_price')), + profit: createCumulativeDistributionRawRelSumValuePattern(client, acc), + profitToLossRatio: create_1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')), + sopr: createAdjustedRatioValuePattern(client, acc), + }; +} + /** * @typedef {Object} AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern * @property {MetricPattern18} average @@ -1923,76 +1917,6 @@ function createAverageGainsLossesRsiStochPattern(client, acc) { }; } -/** - * @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 BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} - */ -function createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, acc) { - return { - 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 {CumulativeNegativeRawSumPattern} loss - * @property {MetricPattern1} mvrv - * @property {RawSumPattern2} netPnl - * @property {BpsRatioPattern} nupl - * @property {CentsSatsUsdPattern} price - * @property {BpsRatioPattern} priceRatio - * @property {CumulativeRawSumPattern2} 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: createCumulativeNegativeRawSumPattern(client, acc), - mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), - netPnl: createRawSumPattern2(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: createCumulativeRawSumPattern2(client, _m(acc, 'realized_profit')), - sent: createInPattern(client, _m(acc, 'sent_in')), - sopr: createRatioValuePattern(client, acc), - }; -} - /** * @typedef {Object} AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern * @property {MetricPattern1} all @@ -2124,33 +2048,64 @@ function create_1m1w1y24hBtcCentsSatsUsdPattern(client, acc) { } /** - * @typedef {Object} CapLossMvrvNuplPriceProfitSoprPattern - * @property {CentsUsdPattern} cap - * @property {RawSumPattern} loss - * @property {MetricPattern1} mvrv - * @property {BpsRatioPattern} nupl - * @property {CentsSatsUsdPattern} price - * @property {BpsRatioPattern} priceRatio - * @property {RawSumPattern} profit - * @property {ValuePattern} sopr + * @typedef {Object} BpsCentsPercentilesRatioSatsSmaStdUsdPattern + * @property {MetricPattern1} bps + * @property {MetricPattern1} cents + * @property {Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles + * @property {MetricPattern1} ratio + * @property {MetricPattern1} sats + * @property {_1m1w1y2y4yAllPattern} sma + * @property {_1y2y4yAllPattern} stdDev + * @property {MetricPattern1} usd */ /** - * Create a CapLossMvrvNuplPriceProfitSoprPattern pattern node + * Create a BpsCentsPercentilesRatioSatsSmaStdUsdPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CapLossMvrvNuplPriceProfitSoprPattern} + * @returns {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} */ -function createCapLossMvrvNuplPriceProfitSoprPattern(client, acc) { +function createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, acc) { return { - cap: createCentsUsdPattern(client, _m(acc, 'realized_cap')), - loss: createRawSumPattern(client, _m(acc, 'realized_loss')), + bps: createMetricPattern1(client, _m(acc, 'ratio_bps')), + cents: createMetricPattern1(client, _m(acc, 'cents')), + percentiles: createPct1Pct2Pct5Pct95Pct98Pct99Pattern(client, _m(acc, 'ratio')), + ratio: createMetricPattern1(client, _m(acc, 'ratio')), + sats: createMetricPattern1(client, _m(acc, 'sats')), + sma: create_1m1w1y2y4yAllPattern(client, _m(acc, 'ratio_sma')), + stdDev: create_1y2y4yAllPattern(client, _m(acc, 'ratio')), + usd: createMetricPattern1(client, _m(acc, 'usd')), + }; +} + +/** + * @typedef {Object} CapLossMvrvNetNuplPriceProfitSoprPattern + * @property {CentsDeltaUsdPattern} cap + * @property {CumulativeNegativeRawSumPattern} loss + * @property {MetricPattern1} mvrv + * @property {RawSumPattern2} netPnl + * @property {BpsRatioPattern} nupl + * @property {BpsCentsRatioSatsUsdPattern} price + * @property {CumulativeRawSumPattern2} profit + * @property {RatioValuePattern} sopr + */ + +/** + * Create a CapLossMvrvNetNuplPriceProfitSoprPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapLossMvrvNetNuplPriceProfitSoprPattern} + */ +function createCapLossMvrvNetNuplPriceProfitSoprPattern(client, acc) { + return { + cap: createCentsDeltaUsdPattern(client, _m(acc, 'realized_cap')), + loss: createCumulativeNegativeRawSumPattern(client, acc), mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + netPnl: createRawSumPattern2(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: createRawSumPattern(client, _m(acc, 'realized_profit')), - sopr: createValuePattern(client, _m(acc, 'value')), + price: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), + profit: createCumulativeRawSumPattern2(client, _m(acc, 'realized_profit')), + sopr: createRatioValuePattern(client, acc), }; } @@ -2161,7 +2116,7 @@ function createCapLossMvrvNuplPriceProfitSoprPattern(client, acc) { * @property {MetricPattern1} negative * @property {CentsUsdPattern} raw * @property {BpsPercentRatioPattern} relToRcap - * @property {_1m1w1y24hPattern4} sum + * @property {_1m1w1y24hPattern5} sum * @property {BaseSumPattern} valueCreated * @property {BaseSumPattern} valueDestroyed */ @@ -2179,74 +2134,12 @@ function createCapitulationCumulativeNegativeRawRelSumValuePattern(client, acc) negative: createMetricPattern1(client, _m(acc, 'neg_realized_loss')), raw: createCentsUsdPattern(client, _m(acc, 'realized_loss')), relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')), - sum: create_1m1w1y24hPattern4(client, _m(acc, 'realized_loss')), + sum: create_1m1w1y24hPattern5(client, _m(acc, 'realized_loss')), valueCreated: createBaseSumPattern(client, _m(acc, 'loss_value_created')), valueDestroyed: createBaseSumPattern(client, _m(acc, 'loss_value_destroyed')), }; } -/** - * @typedef {Object} CoindaysCoinyearsDormancySentVelocityPattern - * @property {CumulativeRawSumPattern} coindaysDestroyed - * @property {MetricPattern1} coindaysDestroyedSupplyAdjusted - * @property {MetricPattern1} coinyearsDestroyed - * @property {MetricPattern1} coinyearsDestroyedSupplyAdjusted - * @property {MetricPattern1} dormancy - * @property {MetricPattern1} dormancySupplyAdjusted - * @property {RawSumPattern3} sent - * @property {MetricPattern1} velocity - */ - -/** - * Create a CoindaysCoinyearsDormancySentVelocityPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CoindaysCoinyearsDormancySentVelocityPattern} - */ -function createCoindaysCoinyearsDormancySentVelocityPattern(client, acc) { - return { - coindaysDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')), - coindaysDestroyedSupplyAdjusted: createMetricPattern1(client, _m(acc, 'coindays_destroyed_supply_adjusted')), - coinyearsDestroyed: createMetricPattern1(client, _m(acc, 'coinyears_destroyed')), - coinyearsDestroyedSupplyAdjusted: createMetricPattern1(client, _m(acc, 'coinyears_destroyed_supply_adjusted')), - dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), - dormancySupplyAdjusted: createMetricPattern1(client, _m(acc, 'dormancy_supply_adjusted')), - sent: createRawSumPattern3(client, _m(acc, 'sent')), - velocity: createMetricPattern1(client, _m(acc, 'velocity')), - }; -} - -/** - * @typedef {Object} Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern - * @property {BpsPriceRatioPattern} pct1 - * @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')), - }; -} - /** * @template T * @typedef {Object} AverageMaxMedianMinPct10Pct25Pct75Pct90Pattern @@ -2338,13 +2231,42 @@ function create_1m1w1y24hBpsPercentRatioPattern(client, acc) { }; } +/** + * @typedef {Object} CapLossMvrvNuplPriceProfitSoprPattern + * @property {CentsUsdPattern} cap + * @property {RawSumPattern} loss + * @property {MetricPattern1} mvrv + * @property {BpsRatioPattern} nupl + * @property {BpsCentsRatioSatsUsdPattern} price + * @property {RawSumPattern} profit + * @property {ValuePattern} sopr + */ + +/** + * Create a CapLossMvrvNuplPriceProfitSoprPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapLossMvrvNuplPriceProfitSoprPattern} + */ +function createCapLossMvrvNuplPriceProfitSoprPattern(client, acc) { + return { + cap: createCentsUsdPattern(client, _m(acc, 'realized_cap')), + loss: createRawSumPattern(client, _m(acc, 'realized_loss')), + mvrv: createMetricPattern1(client, _m(acc, 'mvrv')), + nupl: createBpsRatioPattern(client, _m(acc, 'nupl_ratio')), + price: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), + profit: createRawSumPattern(client, _m(acc, 'realized_profit')), + sopr: createValuePattern(client, _m(acc, 'value')), + }; +} + /** * @typedef {Object} CumulativeDistributionRawRelSumValuePattern * @property {MetricPattern1} cumulative * @property {MetricPattern1} distributionFlow * @property {CentsUsdPattern} raw * @property {BpsPercentRatioPattern} relToRcap - * @property {_1m1w1y24hPattern4} sum + * @property {_1m1w1y24hPattern5} sum * @property {BaseSumPattern} valueCreated * @property {BaseSumPattern} valueDestroyed */ @@ -2361,7 +2283,7 @@ function createCumulativeDistributionRawRelSumValuePattern(client, acc) { distributionFlow: createMetricPattern1(client, _m(acc, 'profit_flow')), raw: createCentsUsdPattern(client, _m(acc, 'realized_profit')), relToRcap: createBpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')), - sum: create_1m1w1y24hPattern4(client, _m(acc, 'realized_profit')), + sum: create_1m1w1y24hPattern5(client, _m(acc, 'realized_profit')), valueCreated: createBaseSumPattern(client, _m(acc, 'profit_value_created')), valueDestroyed: createBaseSumPattern(client, _m(acc, 'profit_value_destroyed')), }; @@ -2370,8 +2292,8 @@ function createCumulativeDistributionRawRelSumValuePattern(client, acc) { /** * @typedef {Object} GrossInvestedInvestorLossNetProfitSentimentPattern2 * @property {CentsUsdPattern} grossPnl - * @property {InPattern4} investedCapital - * @property {InPattern2} investorCap + * @property {InPattern2} investedCapital + * @property {InPattern} investorCap * @property {NegativeRawRelSumPattern2} loss * @property {CentsRelUsdPattern2} netPnl * @property {RawRelSumPattern2} profit @@ -2387,8 +2309,8 @@ function createCumulativeDistributionRawRelSumValuePattern(client, acc) { function createGrossInvestedInvestorLossNetProfitSentimentPattern2(client, acc) { return { grossPnl: createCentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')), - investedCapital: createInPattern4(client, _m(acc, 'invested_capital_in')), - investorCap: createInPattern2(client, _m(acc, 'investor_cap_in')), + investedCapital: createInPattern2(client, _m(acc, 'invested_capital_in')), + investorCap: createInPattern(client, _m(acc, 'investor_cap_in')), loss: createNegativeRawRelSumPattern2(client, acc), netPnl: createCentsRelUsdPattern2(client, _m(acc, 'net_unrealized_pnl')), profit: createRawRelSumPattern2(client, _m(acc, 'unrealized_profit')), @@ -2396,6 +2318,60 @@ function createGrossInvestedInvestorLossNetProfitSentimentPattern2(client, acc) }; } +/** + * @typedef {Object} _1m1w1y2y4yAllPattern + * @property {BpsRatioPattern} _1m + * @property {BpsRatioPattern} _1w + * @property {BpsRatioPattern} _1y + * @property {BpsRatioPattern} _2y + * @property {BpsRatioPattern} _4y + * @property {BpsRatioPattern} all + */ + +/** + * Create a _1m1w1y2y4yAllPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1m1w1y2y4yAllPattern} + */ +function create_1m1w1y2y4yAllPattern(client, acc) { + return { + _1m: createBpsRatioPattern(client, _m(acc, '1m')), + _1w: createBpsRatioPattern(client, _m(acc, '1w')), + _1y: createBpsRatioPattern(client, _m(acc, '1y')), + _2y: createBpsRatioPattern(client, _m(acc, '2y')), + _4y: createBpsRatioPattern(client, _m(acc, '4y')), + all: createBpsRatioPattern(client, _m(acc, 'all')), + }; +} + +/** + * @typedef {Object} BpsCentsPercentilesRatioSatsUsdPattern + * @property {MetricPattern1} bps + * @property {MetricPattern1} cents + * @property {Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles + * @property {MetricPattern1} ratio + * @property {MetricPattern1} sats + * @property {MetricPattern1} usd + */ + +/** + * Create a BpsCentsPercentilesRatioSatsUsdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {BpsCentsPercentilesRatioSatsUsdPattern} + */ +function createBpsCentsPercentilesRatioSatsUsdPattern(client, acc) { + return { + bps: createMetricPattern1(client, _m(acc, 'ratio_bps')), + cents: createMetricPattern1(client, _m(acc, 'cents')), + percentiles: createPct1Pct2Pct5Pct95Pct98Pct99Pattern(client, _m(acc, 'ratio')), + ratio: createMetricPattern1(client, _m(acc, 'ratio')), + sats: createMetricPattern1(client, _m(acc, 'sats')), + usd: createMetricPattern1(client, _m(acc, 'usd')), + }; +} + /** * @typedef {Object} BtcCentsRelSatsUsdPattern3 * @property {MetricPattern1} btc @@ -2423,33 +2399,6 @@ function createBtcCentsRelSatsUsdPattern3(client, acc) { }; } -/** - * @typedef {Object} CapLowerPriceUpperPattern - * @property {RawPattern} cap - * @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 { - cap: createRawPattern(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} ChangeCumulativeDeltaRawRelSumPattern * @property {RelPattern} change1m @@ -2558,11 +2507,38 @@ function createNegativeRawRelSumPattern2(client, acc) { }; } +/** + * @typedef {Object} Pct1Pct2Pct5Pct95Pct98Pct99Pattern + * @property {BpsPriceRatioPattern} pct1 + * @property {BpsPriceRatioPattern} pct2 + * @property {BpsPriceRatioPattern} pct5 + * @property {BpsPriceRatioPattern} pct95 + * @property {BpsPriceRatioPattern} pct98 + * @property {BpsPriceRatioPattern} pct99 + */ + +/** + * Create a Pct1Pct2Pct5Pct95Pct98Pct99Pattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {Pct1Pct2Pct5Pct95Pct98Pct99Pattern} + */ +function createPct1Pct2Pct5Pct95Pct98Pct99Pattern(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')), + }; +} + /** * @typedef {Object} ActivityOutputsRealizedSupplyUnrealizedPattern * @property {CoindaysSentPattern} activity * @property {UtxoPattern2} outputs - * @property {CapLossMvrvNetNuplPriceProfitSentSoprPattern} realized + * @property {CapLossMvrvNetNuplPriceProfitSoprPattern} realized * @property {DeltaHalvedInRelTotalPattern} supply * @property {InvestedInvestorLossNetProfitPattern} unrealized */ @@ -2577,7 +2553,7 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { return { activity: createCoindaysSentPattern(client, acc), outputs: createUtxoPattern2(client, _m(acc, 'utxo_count')), - realized: createCapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc), + realized: createCapLossMvrvNetNuplPriceProfitSoprPattern(client, acc), supply: createDeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')), unrealized: createInvestedInvestorLossNetProfitPattern(client, acc), }; @@ -2587,7 +2563,7 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern(client, acc) { * @typedef {Object} ActivityOutputsRealizedSupplyUnrealizedPattern2 * @property {CoindaysSentPattern} activity * @property {UtxoPattern2} outputs - * @property {CapLossMvrvNetNuplPriceProfitSentSoprPattern} realized + * @property {CapLossMvrvNetNuplPriceProfitSoprPattern} realized * @property {DeltaHalvedInRelTotalPattern} supply * @property {LossNetProfitPattern} unrealized */ @@ -2602,34 +2578,34 @@ function createActivityOutputsRealizedSupplyUnrealizedPattern2(client, acc) { return { activity: createCoindaysSentPattern(client, acc), outputs: createUtxoPattern2(client, _m(acc, 'utxo_count')), - realized: createCapLossMvrvNetNuplPriceProfitSentSoprPattern(client, acc), + realized: createCapLossMvrvNetNuplPriceProfitSoprPattern(client, acc), supply: createDeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')), unrealized: createLossNetProfitPattern(client, acc), }; } /** - * @typedef {Object} AddrOutputsRealizedSupplyPattern - * @property {MetricPattern1} addrCount - * @property {ChangeRatePattern} addrCountDelta - * @property {UtxoPattern} outputs - * @property {CapLossMvrvNuplPriceProfitSoprPattern} realized - * @property {HalvedTotalPattern} supply + * @typedef {Object} BpsCentsRatioSatsUsdPattern + * @property {MetricPattern1} bps + * @property {MetricPattern1} cents + * @property {MetricPattern1} ratio + * @property {MetricPattern1} sats + * @property {MetricPattern1} usd */ /** - * Create a AddrOutputsRealizedSupplyPattern pattern node + * Create a BpsCentsRatioSatsUsdPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {AddrOutputsRealizedSupplyPattern} + * @returns {BpsCentsRatioSatsUsdPattern} */ -function createAddrOutputsRealizedSupplyPattern(client, acc) { +function createBpsCentsRatioSatsUsdPattern(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')), + bps: createMetricPattern1(client, _m(acc, 'ratio_bps')), + cents: createMetricPattern1(client, _m(acc, 'cents')), + ratio: createMetricPattern1(client, _m(acc, 'ratio')), + sats: createMetricPattern1(client, _m(acc, 'sats')), + usd: createMetricPattern1(client, _m(acc, 'usd')), }; } @@ -2708,6 +2684,31 @@ function createCentsDeltaRawRelUsdPattern(client, acc) { }; } +/** + * @typedef {Object} CoindaysCoinyearsDormancySentVelocityPattern + * @property {CumulativeRawSumPattern} coindaysDestroyed + * @property {MetricPattern1} coinyearsDestroyed + * @property {MetricPattern1} dormancy + * @property {InRawSumPattern2} sent + * @property {MetricPattern1} velocity + */ + +/** + * Create a CoindaysCoinyearsDormancySentVelocityPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoindaysCoinyearsDormancySentVelocityPattern} + */ +function createCoindaysCoinyearsDormancySentVelocityPattern(client, acc) { + return { + coindaysDestroyed: createCumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')), + coinyearsDestroyed: createMetricPattern1(client, _m(acc, 'coinyears_destroyed')), + dormancy: createMetricPattern1(client, _m(acc, 'dormancy')), + sent: createInRawSumPattern2(client, _m(acc, 'sent')), + velocity: createMetricPattern1(client, _m(acc, 'velocity')), + }; +} + /** * @typedef {Object} EmaHistogramLineSignalPattern * @property {MetricPattern1} emaFast @@ -2735,8 +2736,8 @@ function createEmaHistogramLineSignalPattern(client, acc) { /** * @typedef {Object} InvestedInvestorLossNetProfitPattern - * @property {InPattern2} investedCapital - * @property {InPattern2} investorCap + * @property {InPattern} investedCapital + * @property {InPattern} investorCap * @property {NegativeRawSumPattern} loss * @property {CentsUsdPattern} netPnl * @property {RawSumPattern} profit @@ -2750,14 +2751,39 @@ function createEmaHistogramLineSignalPattern(client, acc) { */ function createInvestedInvestorLossNetProfitPattern(client, acc) { return { - investedCapital: createInPattern2(client, _m(acc, 'invested_capital_in')), - investorCap: createInPattern2(client, _m(acc, 'investor_cap_in')), + investedCapital: createInPattern(client, _m(acc, 'invested_capital_in')), + investorCap: createInPattern(client, _m(acc, 'investor_cap_in')), loss: createNegativeRawSumPattern(client, acc), netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), profit: createRawSumPattern(client, _m(acc, 'unrealized_profit')), }; } +/** + * @typedef {Object} InvestedMaxMinPercentilesSupplyPattern + * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} investedCapital + * @property {CentsSatsUsdPattern} max + * @property {CentsSatsUsdPattern} min + * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} percentiles + * @property {BpsPercentRatioPattern} supplyDensity + */ + +/** + * Create a InvestedMaxMinPercentilesSupplyPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InvestedMaxMinPercentilesSupplyPattern} + */ +function createInvestedMaxMinPercentilesSupplyPattern(client, acc) { + return { + investedCapital: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'invested_capital')), + max: createCentsSatsUsdPattern(client, _m(acc, 'cost_basis_max')), + min: createCentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')), + percentiles: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis')), + supplyDensity: createBpsPercentRatioPattern(client, _m(acc, 'supply_density')), + }; +} + /** * @typedef {Object} PhsReboundThsPattern * @property {MetricPattern1} phs @@ -2882,7 +2908,7 @@ function create_1m1w1y24hPattern8(client, acc) { } /** - * @typedef {Object} _1m1w1y24hPattern4 + * @typedef {Object} _1m1w1y24hPattern5 * @property {MetricPattern1} _1m * @property {MetricPattern1} _1w * @property {MetricPattern1} _1y @@ -2890,12 +2916,12 @@ function create_1m1w1y24hPattern8(client, acc) { */ /** - * Create a _1m1w1y24hPattern4 pattern node + * Create a _1m1w1y24hPattern5 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hPattern4} + * @returns {_1m1w1y24hPattern5} */ -function create_1m1w1y24hPattern4(client, acc) { +function create_1m1w1y24hPattern5(client, acc) { return { _1m: createMetricPattern1(client, _m(acc, '1m')), _1w: createMetricPattern1(client, _m(acc, '1w')), @@ -2928,13 +2954,36 @@ function create_1m1w1y2wPattern(client, acc) { } /** - * @typedef {Object} _1m1w1y24hPattern3 + * @typedef {Object} _1m1w1y24hPattern4 * @property {CentsUsdPattern} _1m * @property {CentsUsdPattern} _1w * @property {CentsUsdPattern} _1y * @property {CentsUsdPattern} _24h */ +/** + * Create a _1m1w1y24hPattern4 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1m1w1y24hPattern4} + */ +function create_1m1w1y24hPattern4(client, acc) { + return { + _1m: createCentsUsdPattern(client, _m(acc, '1m')), + _1w: createCentsUsdPattern(client, _m(acc, '1w')), + _1y: createCentsUsdPattern(client, _m(acc, '1y')), + _24h: createCentsUsdPattern(client, _m(acc, '24h')), + }; +} + +/** + * @typedef {Object} _1m1w1y24hPattern3 + * @property {MetricPattern1} _1m + * @property {MetricPattern1} _1w + * @property {MetricPattern1} _1y + * @property {BtcCentsSatsUsdPattern} _24h + */ + /** * Create a _1m1w1y24hPattern3 pattern node * @param {BrkClientBase} client @@ -2942,29 +2991,6 @@ function create_1m1w1y2wPattern(client, acc) { * @returns {_1m1w1y24hPattern3} */ function create_1m1w1y24hPattern3(client, acc) { - return { - _1m: createCentsUsdPattern(client, _m(acc, '1m')), - _1w: createCentsUsdPattern(client, _m(acc, '1w')), - _1y: createCentsUsdPattern(client, _m(acc, '1y')), - _24h: createCentsUsdPattern(client, _m(acc, '24h')), - }; -} - -/** - * @typedef {Object} _1m1w1y24hPattern5 - * @property {MetricPattern1} _1m - * @property {MetricPattern1} _1w - * @property {MetricPattern1} _1y - * @property {BtcCentsSatsUsdPattern} _24h - */ - -/** - * Create a _1m1w1y24hPattern5 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1m1w1y24hPattern5} - */ -function create_1m1w1y24hPattern5(client, acc) { return { _1m: createMetricPattern1(client, _m(acc, '1m')), _1w: createMetricPattern1(client, _m(acc, '1w')), @@ -2975,10 +3001,10 @@ function create_1m1w1y24hPattern5(client, acc) { /** * @typedef {Object} _1y2y4yAllPattern - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} _1y - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} _2y - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} _4y - * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern} all + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern} _1y + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern} _2y + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern} _4y + * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern} all */ /** @@ -2989,10 +3015,33 @@ function create_1m1w1y24hPattern5(client, acc) { */ 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), + _1y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc), + _2y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc), + _4y: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc), + all: create_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc), + }; +} + +/** + * @typedef {Object} AddrOutputsRealizedSupplyPattern + * @property {BaseDeltaPattern} addrCount + * @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: createBaseDeltaPattern(client, _m(acc, 'addr_count')), + outputs: createUtxoPattern(client, _m(acc, 'utxo_count')), + realized: createCapLossMvrvNuplPriceProfitSoprPattern(client, acc), + supply: createHalvedTotalPattern(client, _m(acc, 'supply')), }; } @@ -3042,29 +3091,6 @@ 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 @@ -3088,6 +3114,29 @@ function createBtcCentsSatsUsdPattern(client, acc) { }; } +/** + * @typedef {Object} CapLowerPriceUpperPattern + * @property {RawPattern} cap + * @property {CentsSatsUsdPattern} lowerPriceBand + * @property {BpsCentsPercentilesRatioSatsUsdPattern} price + * @property {CentsSatsUsdPattern} upperPriceBand + */ + +/** + * Create a CapLowerPriceUpperPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CapLowerPriceUpperPattern} + */ +function createCapLowerPriceUpperPattern(client, acc) { + return { + cap: createRawPattern(client, _m(acc, 'investor_cap_raw')), + lowerPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'lower_price_band')), + price: createBpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'investor_price')), + upperPriceBand: createCentsSatsUsdPattern(client, _m(acc, 'upper_price_band')), + }; +} + /** * @typedef {Object} CentsRelUsdPattern2 * @property {MetricPattern1} cents @@ -3158,25 +3207,48 @@ function createHalvedInTotalPattern(client, acc) { } /** - * @typedef {Object} InvestedMaxMinPercentilesPattern - * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} investedCapital - * @property {CentsSatsUsdPattern} max - * @property {CentsSatsUsdPattern} min - * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} percentiles + * @typedef {Object} InRawSumPattern + * @property {RawSumPattern4} inLoss + * @property {RawSumPattern4} inProfit + * @property {MetricPattern1} raw + * @property {_24hPattern2} sum */ /** - * Create a InvestedMaxMinPercentilesPattern pattern node + * Create a InRawSumPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {InvestedMaxMinPercentilesPattern} + * @returns {InRawSumPattern} */ -function createInvestedMaxMinPercentilesPattern(client, acc) { +function createInRawSumPattern(client, acc) { return { - investedCapital: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'invested_capital')), - max: createCentsSatsUsdPattern(client, _m(acc, 'cost_basis_max')), - min: createCentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')), - percentiles: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis')), + inLoss: createRawSumPattern4(client, _m(acc, 'in_loss')), + inProfit: createRawSumPattern4(client, _m(acc, 'in_profit')), + raw: createMetricPattern1(client, acc), + sum: create_24hPattern2(client, _m(acc, '24h')), + }; +} + +/** + * @typedef {Object} InRawSumPattern2 + * @property {RawSumPattern5} inLoss + * @property {RawSumPattern5} inProfit + * @property {MetricPattern1} raw + * @property {_1m1w1y24hPattern} sum + */ + +/** + * Create a InRawSumPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {InRawSumPattern2} + */ +function createInRawSumPattern2(client, acc) { + return { + inLoss: createRawSumPattern5(client, _m(acc, 'in_loss')), + inProfit: createRawSumPattern5(client, _m(acc, 'in_profit')), + raw: createMetricPattern1(client, acc), + sum: create_1m1w1y24hPattern(client, acc), }; } @@ -3669,6 +3741,44 @@ function createBaseSumPattern(client, acc) { }; } +/** + * @typedef {Object} BaseDeltaPattern + * @property {MetricPattern1} base + * @property {ChangeRatePattern} delta + */ + +/** + * Create a BaseDeltaPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {BaseDeltaPattern} + */ +function createBaseDeltaPattern(client, acc) { + return { + base: createMetricPattern1(client, acc), + delta: createChangeRatePattern(client, _m(acc, 'delta')), + }; +} + +/** + * @typedef {Object} BaseDeltaPattern2 + * @property {MetricPattern1} base + * @property {ChangeRatePattern2} delta + */ + +/** + * Create a BaseDeltaPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {BaseDeltaPattern2} + */ +function createBaseDeltaPattern2(client, acc) { + return { + base: createMetricPattern1(client, acc), + delta: createChangeRatePattern2(client, _m(acc, 'delta')), + }; +} + /** * @typedef {Object} BlocksDominancePattern * @property {CumulativeRawPattern} blocksMined @@ -3747,7 +3857,7 @@ function createChangeRatePattern2(client, acc) { /** * @typedef {Object} ChangeRatePattern4 - * @property {_1m1w1y24hPattern3} change + * @property {_1m1w1y24hPattern4} change * @property {_1m1w1y24hPattern2} rate */ @@ -3759,7 +3869,7 @@ function createChangeRatePattern2(client, acc) { */ function createChangeRatePattern4(client, acc) { return { - change: create_1m1w1y24hPattern3(client, _m(acc, 'change')), + change: create_1m1w1y24hPattern4(client, _m(acc, 'change')), rate: create_1m1w1y24hPattern2(client, _m(acc, 'rate')), }; } @@ -3805,7 +3915,7 @@ function createChangeRatePattern3(client, acc) { /** * @typedef {Object} CoindaysSentPattern * @property {RawSumPattern2} coindaysDestroyed - * @property {RawSumPattern2} sent + * @property {InRawSumPattern} sent */ /** @@ -3817,7 +3927,7 @@ function createChangeRatePattern3(client, acc) { function createCoindaysSentPattern(client, acc) { return { coindaysDestroyed: createRawSumPattern2(client, _m(acc, 'coindays_destroyed')), - sent: createRawSumPattern2(client, _m(acc, 'sent')), + sent: createInRawSumPattern(client, _m(acc, 'sent')), }; } @@ -3841,30 +3951,11 @@ function createHalvedTotalPattern(client, acc) { } /** - * @typedef {Object} InPattern4 + * @typedef {Object} InPattern2 * @property {CentsRawUsdPattern} inLoss * @property {CentsRawUsdPattern} inProfit */ -/** - * Create a InPattern4 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {InPattern4} - */ -function createInPattern4(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 @@ -3873,15 +3964,15 @@ function createInPattern4(client, acc) { */ function createInPattern2(client, acc) { return { - inLoss: createRawPattern(client, _m(acc, 'loss_raw')), - inProfit: createRawPattern(client, _m(acc, 'profit_raw')), + inLoss: createCentsRawUsdPattern(client, _m(acc, 'loss')), + inProfit: createCentsRawUsdPattern(client, _m(acc, 'profit')), }; } /** * @typedef {Object} InPattern - * @property {RawSumPattern4} inLoss - * @property {RawSumPattern4} inProfit + * @property {RawPattern} inLoss + * @property {RawPattern} inProfit */ /** @@ -3892,27 +3983,8 @@ function createInPattern2(client, acc) { */ function createInPattern(client, acc) { return { - inLoss: createRawSumPattern4(client, _m(acc, 'loss')), - inProfit: createRawSumPattern4(client, _m(acc, 'profit')), - }; -} - -/** - * @typedef {Object} InPattern3 - * @property {RawSumPattern5} inLoss - * @property {RawSumPattern5} inProfit - */ - -/** - * Create a InPattern3 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {InPattern3} - */ -function createInPattern3(client, acc) { - return { - inLoss: createRawSumPattern5(client, _m(acc, 'loss')), - inProfit: createRawSumPattern5(client, _m(acc, 'profit')), + inLoss: createRawPattern(client, _m(acc, 'loss_raw')), + inProfit: createRawPattern(client, _m(acc, 'profit_raw')), }; } @@ -3957,7 +4029,7 @@ function createPriceValuePattern(client, acc) { /** * @typedef {Object} RawSumPattern5 * @property {BtcCentsSatsUsdPattern} raw - * @property {_1m1w1y24hPattern5} sum + * @property {_1m1w1y24hPattern3} sum */ /** @@ -3969,7 +4041,7 @@ function createPriceValuePattern(client, acc) { function createRawSumPattern5(client, acc) { return { raw: createBtcCentsSatsUsdPattern(client, acc), - sum: create_1m1w1y24hPattern5(client, acc), + sum: create_1m1w1y24hPattern3(client, acc), }; } @@ -4068,44 +4140,6 @@ function createSdSmaPattern(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 {RawSumPattern2} valueCreated @@ -4256,6 +4290,40 @@ function create_24hPattern(client, acc) { }; } +/** + * @typedef {Object} UtxoPattern2 + * @property {BaseDeltaPattern} utxoCount + */ + +/** + * Create a UtxoPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {UtxoPattern2} + */ +function createUtxoPattern2(client, acc) { + return { + utxoCount: createBaseDeltaPattern(client, acc), + }; +} + +/** + * @typedef {Object} UtxoPattern3 + * @property {BaseDeltaPattern2} utxoCount + */ + +/** + * Create a UtxoPattern3 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {UtxoPattern3} + */ +function createUtxoPattern3(client, acc) { + return { + utxoCount: createBaseDeltaPattern2(client, acc), + }; +} + /** * @typedef {Object} UtxoPattern * @property {MetricPattern1} utxoCount @@ -4746,22 +4814,14 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Cointime_Pricing - * @property {CentsSatsUsdPattern} vaultedPrice - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} vaultedPriceRatio - * @property {CentsSatsUsdPattern} activePrice - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} activePriceRatio - * @property {CentsSatsUsdPattern} trueMarketMean - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} trueMarketMeanRatio - * @property {CentsSatsUsdPattern} cointimePrice - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} cointimePriceRatio - * @property {CentsSatsUsdPattern} transferPrice - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} transferPriceRatio - * @property {CentsSatsUsdPattern} balancedPrice - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} balancedPriceRatio - * @property {CentsSatsUsdPattern} terminalPrice - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} terminalPriceRatio - * @property {CentsSatsUsdPattern} deltaPrice - * @property {BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern} deltaPriceRatio + * @property {BpsCentsPercentilesRatioSatsUsdPattern} vaultedPrice + * @property {BpsCentsPercentilesRatioSatsUsdPattern} activePrice + * @property {BpsCentsPercentilesRatioSatsUsdPattern} trueMarketMean + * @property {BpsCentsPercentilesRatioSatsUsdPattern} cointimePrice + * @property {BpsCentsPercentilesRatioSatsUsdPattern} transferPrice + * @property {BpsCentsPercentilesRatioSatsUsdPattern} balancedPrice + * @property {BpsCentsPercentilesRatioSatsUsdPattern} terminalPrice + * @property {BpsCentsPercentilesRatioSatsUsdPattern} deltaPrice * @property {MetricPattern1} cumulativeMarketCap */ @@ -5045,6 +5105,12 @@ function createRawPattern(client, acc) { * @property {BpsPercentRatioPattern} gini * @property {BpsRatioPattern} rhodlRatio * @property {BpsRatioPattern} thermocapMultiple + * @property {MetricPattern1} coindaysDestroyedSupplyAdjusted + * @property {MetricPattern1} coinyearsDestroyedSupplyAdjusted + * @property {MetricPattern1} dormancySupplyAdjusted + * @property {MetricPattern1} stockToFlow + * @property {MetricPattern1} dormancyFlow + * @property {MetricPattern1} sellerExhaustionConstant */ /** @@ -5153,269 +5219,45 @@ function createRawPattern(client, acc) { /** * @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 {BpsCentsRatioSatsUsdPattern} _1w + * @property {BpsCentsRatioSatsUsdPattern} _8d + * @property {BpsCentsRatioSatsUsdPattern} _13d + * @property {BpsCentsRatioSatsUsdPattern} _21d + * @property {BpsCentsRatioSatsUsdPattern} _1m + * @property {BpsCentsRatioSatsUsdPattern} _34d + * @property {BpsCentsRatioSatsUsdPattern} _55d + * @property {BpsCentsRatioSatsUsdPattern} _89d + * @property {BpsCentsRatioSatsUsdPattern} _111d + * @property {BpsCentsRatioSatsUsdPattern} _144d + * @property {BpsCentsRatioSatsUsdPattern} _200d + * @property {BpsCentsRatioSatsUsdPattern} _350d + * @property {BpsCentsRatioSatsUsdPattern} _1y + * @property {BpsCentsRatioSatsUsdPattern} _2y + * @property {BpsCentsRatioSatsUsdPattern} _200w + * @property {BpsCentsRatioSatsUsdPattern} _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 + * @property {BpsCentsRatioSatsUsdPattern} _1w + * @property {BpsCentsRatioSatsUsdPattern} _8d + * @property {BpsCentsRatioSatsUsdPattern} _12d + * @property {BpsCentsRatioSatsUsdPattern} _13d + * @property {BpsCentsRatioSatsUsdPattern} _21d + * @property {BpsCentsRatioSatsUsdPattern} _26d + * @property {BpsCentsRatioSatsUsdPattern} _1m + * @property {BpsCentsRatioSatsUsdPattern} _34d + * @property {BpsCentsRatioSatsUsdPattern} _55d + * @property {BpsCentsRatioSatsUsdPattern} _89d + * @property {BpsCentsRatioSatsUsdPattern} _144d + * @property {BpsCentsRatioSatsUsdPattern} _200d + * @property {BpsCentsRatioSatsUsdPattern} _1y + * @property {BpsCentsRatioSatsUsdPattern} _2y + * @property {BpsCentsRatioSatsUsdPattern} _200w + * @property {BpsCentsRatioSatsUsdPattern} _4y */ /** @@ -5862,8 +5704,8 @@ function createRawPattern(client, acc) { * @property {MetricsTree_Distribution_UtxoCohorts_All_Supply} supply * @property {UtxoPattern3} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity - * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern} realized - * @property {InvestedMaxMinPercentilesPattern} costBasis + * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern} realized + * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis * @property {MetricsTree_Distribution_UtxoCohorts_All_Unrealized} unrealized */ @@ -5879,9 +5721,9 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_All_Unrealized * @property {CentsUsdPattern} grossPnl - * @property {InPattern4} investedCapital + * @property {InPattern2} investedCapital * @property {GreedNetPainPattern} sentiment - * @property {InPattern2} investorCap + * @property {InPattern} investorCap * @property {MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss} loss * @property {MetricsTree_Distribution_UtxoCohorts_All_Unrealized_NetPnl} netPnl * @property {MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit} profit @@ -5913,11 +5755,11 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Distribution_UtxoCohorts_Sth - * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern} realized + * @property {CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern} realized * @property {DeltaHalvedInRelTotalPattern2} supply * @property {UtxoPattern3} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity - * @property {InvestedMaxMinPercentilesPattern} costBasis + * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis * @property {GrossInvestedInvestorLossNetProfitSentimentPattern2} unrealized */ @@ -5927,7 +5769,7 @@ function createRawPattern(client, acc) { * @property {UtxoPattern3} outputs * @property {CoindaysCoinyearsDormancySentVelocityPattern} activity * @property {MetricsTree_Distribution_UtxoCohorts_Lth_Realized} realized - * @property {InvestedMaxMinPercentilesPattern} costBasis + * @property {InvestedMaxMinPercentilesSupplyPattern} costBasis * @property {GrossInvestedInvestorLossNetProfitSentimentPattern2} unrealized */ @@ -5938,13 +5780,11 @@ function createRawPattern(client, acc) { * @property {RawSellSumPattern} grossPnl * @property {ChangeCumulativeDeltaRawRelSumPattern} netPnl * @property {MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr} sopr - * @property {InPattern3} sent * @property {CumulativeRawRelPattern} peakRegret * @property {CapLowerPriceUpperPattern} investor * @property {_1m1w1y24hPattern} profitToLossRatio * @property {CentsDeltaRawRelUsdPattern} cap - * @property {BpsPercentilesRatioStdPattern} priceRatio - * @property {CentsSatsUsdPattern} price + * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price * @property {MetricPattern1} mvrv * @property {BpsRatioPattern} nupl */ @@ -6335,8 +6175,7 @@ function createRawPattern(client, acc) { * @property {MetricsTree_Supply_Burned} burned * @property {BpsPercentRatioPattern} inflationRate * @property {MetricsTree_Supply_Velocity} velocity - * @property {CentsUsdPattern} marketCap - * @property {ChangeRatePattern4} marketCapDelta + * @property {MetricsTree_Supply_MarketCap} marketCap * @property {_1m1w1y24hPattern} marketMinusRealizedCapGrowthRate * @property {BtcCentsSatsUsdPattern} hodledOrLostCoins */ @@ -6353,6 +6192,13 @@ function createRawPattern(client, acc) { * @property {MetricPattern1} usd */ +/** + * @typedef {Object} MetricsTree_Supply_MarketCap + * @property {MetricPattern1} cents + * @property {MetricPattern1} usd + * @property {ChangeRatePattern4} delta + */ + /** * Main BRK client with metrics tree and API methods * @extends BrkClientBase @@ -7585,22 +7431,14 @@ class BrkClient extends BrkClientBase { aviv: createBpsRatioPattern(this, 'aviv_ratio'), }, pricing: { - vaultedPrice: createCentsSatsUsdPattern(this, 'vaulted_price'), - vaultedPriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'vaulted_price_ratio'), - activePrice: createCentsSatsUsdPattern(this, 'active_price'), - activePriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'active_price_ratio'), - trueMarketMean: createCentsSatsUsdPattern(this, 'true_market_mean'), - trueMarketMeanRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'true_market_mean_ratio'), - cointimePrice: createCentsSatsUsdPattern(this, 'cointime_price'), - cointimePriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'cointime_price_ratio'), - transferPrice: createCentsSatsUsdPattern(this, 'transfer_price'), - transferPriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'transfer_price_ratio'), - balancedPrice: createCentsSatsUsdPattern(this, 'balanced_price'), - balancedPriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'balanced_price_ratio'), - terminalPrice: createCentsSatsUsdPattern(this, 'terminal_price'), - terminalPriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'terminal_price_ratio'), - deltaPrice: createCentsSatsUsdPattern(this, 'delta_price'), - deltaPriceRatio: createBpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(this, 'delta_price_ratio'), + vaultedPrice: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'vaulted_price'), + activePrice: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'active_price'), + trueMarketMean: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'true_market_mean'), + cointimePrice: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'cointime_price'), + transferPrice: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'transfer_price'), + balancedPrice: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'balanced_price'), + terminalPrice: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'terminal_price'), + deltaPrice: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'delta_price'), cumulativeMarketCap: createMetricPattern1(this, 'cumulative_market_cap'), }, adjusted: { @@ -7779,6 +7617,12 @@ class BrkClient extends BrkClientBase { gini: createBpsPercentRatioPattern(this, 'gini'), rhodlRatio: createBpsRatioPattern(this, 'rhodl_ratio'), thermocapMultiple: createBpsRatioPattern(this, 'thermocap_multiple'), + coindaysDestroyedSupplyAdjusted: createMetricPattern1(this, 'coindays_destroyed_supply_adjusted'), + coinyearsDestroyedSupplyAdjusted: createMetricPattern1(this, 'coinyears_destroyed_supply_adjusted'), + dormancySupplyAdjusted: createMetricPattern1(this, 'dormancy_supply_adjusted'), + stockToFlow: createMetricPattern1(this, 'stock_to_flow'), + dormancyFlow: createMetricPattern1(this, 'dormancy_flow'), + sellerExhaustionConstant: createMetricPattern1(this, 'seller_exhaustion_constant'), }, market: { ath: { @@ -7847,171 +7691,43 @@ class BrkClient extends BrkClientBase { }, movingAverage: { 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'), - }, + _1w: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_1w'), + _8d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_8d'), + _13d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_13d'), + _21d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_21d'), + _1m: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_1m'), + _34d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_34d'), + _55d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_55d'), + _89d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_89d'), + _111d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_111d'), + _144d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_144d'), + _200d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_200d'), + _350d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_350d'), + _1y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_1y'), + _2y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_2y'), + _200w: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_200w'), + _4y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_4y'), _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'), - }, + _1w: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_1w'), + _8d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_8d'), + _12d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_12d'), + _13d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_13d'), + _21d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_21d'), + _26d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_26d'), + _1m: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_1m'), + _34d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_34d'), + _55d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_55d'), + _89d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_89d'), + _144d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_144d'), + _200d: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_200d'), + _1y: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_1y'), + _2y: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_2y'), + _200w: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_200w'), + _4y: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_4y'), }, }, dca: { @@ -8365,13 +8081,13 @@ class BrkClient extends BrkClientBase { }, outputs: createUtxoPattern3(this, 'utxo_count'), activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, ''), - realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(this, ''), - costBasis: createInvestedMaxMinPercentilesPattern(this, ''), + realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(this, ''), + costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, ''), unrealized: { grossPnl: createCentsUsdPattern(this, 'unrealized_gross_pnl'), - investedCapital: createInPattern4(this, 'invested_capital_in'), + investedCapital: createInPattern2(this, 'invested_capital_in'), sentiment: createGreedNetPainPattern(this, ''), - investorCap: createInPattern2(this, 'investor_cap_in'), + investorCap: createInPattern(this, 'investor_cap_in'), loss: { negative: createMetricPattern1(this, 'neg_unrealized_loss'), raw: createCentsUsdPattern(this, 'unrealized_loss'), @@ -8393,11 +8109,11 @@ class BrkClient extends BrkClientBase { }, }, sth: { - realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(this, 'sth'), + realized: createCapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(this, 'sth'), supply: createDeltaHalvedInRelTotalPattern2(this, 'sth_supply'), outputs: createUtxoPattern3(this, 'sth_utxo_count'), activity: createCoindaysCoinyearsDormancySentVelocityPattern(this, 'sth'), - costBasis: createInvestedMaxMinPercentilesPattern(this, 'sth'), + costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'sth'), unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern2(this, 'sth'), }, lth: { @@ -8420,17 +8136,15 @@ class BrkClient extends BrkClientBase { }, ratio: create_1m1w1y24hPattern(this, 'lth_sopr'), }, - sent: createInPattern3(this, 'lth_sent_in'), peakRegret: createCumulativeRawRelPattern(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'), + price: createBpsCentsPercentilesRatioSatsSmaStdUsdPattern(this, 'lth_realized_price'), mvrv: createMetricPattern1(this, 'lth_mvrv'), nupl: createBpsRatioPattern(this, 'lth_nupl_ratio'), }, - costBasis: createInvestedMaxMinPercentilesPattern(this, 'lth'), + costBasis: createInvestedMaxMinPercentilesSupplyPattern(this, 'lth'), unrealized: createGrossInvestedInvestorLossNetProfitSentimentPattern2(this, 'lth'), }, ageRange: { @@ -8765,8 +8479,11 @@ class BrkClient extends BrkClientBase { btc: createMetricPattern1(this, 'velocity_btc'), usd: createMetricPattern1(this, 'velocity_usd'), }, - marketCap: createCentsUsdPattern(this, 'market_cap'), - marketCapDelta: createChangeRatePattern4(this, 'market_cap_delta'), + marketCap: { + cents: createMetricPattern1(this, 'market_cap_cents'), + usd: createMetricPattern1(this, 'market_cap'), + delta: createChangeRatePattern4(this, 'market_cap_delta'), + }, marketMinusRealizedCapGrowthRate: create_1m1w1y24hPattern(this, 'market_minus_realized_cap_growth_rate'), hodledOrLostCoins: createBtcCentsSatsUsdPattern(this, 'hodled_or_lost_coins'), }, diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 6b0aad419..0c5422891 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2122,12 +2122,12 @@ class Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct7 self.pct90: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct90')) self.pct95: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'pct95')) -class _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern: +class _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern: """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._0sd: CentsSatsUsdPattern = CentsSatsUsdPattern(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')) @@ -2141,29 +2141,8 @@ class _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern: 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: RawSellSumPattern = RawSellSumPattern(client, acc) - self.investor: CapLowerPriceUpperPattern = CapLowerPriceUpperPattern(client, acc) - self.loss: CapitulationCumulativeNegativeRawRelSumValuePattern = CapitulationCumulativeNegativeRawRelSumValuePattern(client, acc) - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.net_pnl: ChangeCumulativeDeltaRawRelSumPattern = ChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) - self.peak_regret: CumulativeRawRelPattern = CumulativeRawRelPattern(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: CumulativeDistributionRawRelSumValuePattern = CumulativeDistributionRawRelSumValuePattern(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.""" @@ -2200,6 +2179,24 @@ class _10y1m1w1y2y3m3y4y5y6m6y8yPattern3: self._6y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '6y')) self._8y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '8y')) +class CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern: + """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: RawSellSumPattern = RawSellSumPattern(client, acc) + self.investor: CapLowerPriceUpperPattern = CapLowerPriceUpperPattern(client, acc) + self.loss: CapitulationCumulativeNegativeRawRelSumValuePattern = CapitulationCumulativeNegativeRawRelSumValuePattern(client, acc) + self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) + self.net_pnl: ChangeCumulativeDeltaRawRelSumPattern = ChangeCumulativeDeltaRawRelSumPattern(client, _m(acc, 'net')) + self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl_ratio')) + self.peak_regret: CumulativeRawRelPattern = CumulativeRawRelPattern(client, _m(acc, 'realized_peak_regret')) + self.price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern = BpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, _m(acc, 'realized_price')) + self.profit: CumulativeDistributionRawRelSumValuePattern = CumulativeDistributionRawRelSumValuePattern(client, acc) + self.profit_to_loss_ratio: _1m1w1y24hPattern[StoredF64] = _1m1w1y24hPattern(client, _m(acc, 'realized_profit_to_loss_ratio')) + self.sopr: AdjustedRatioValuePattern = AdjustedRatioValuePattern(client, acc) + class AverageCumulativeMaxMedianMinPct10Pct25Pct75Pct90RollingSumPattern: """Pattern struct for repeated tree structure.""" @@ -2250,38 +2247,6 @@ 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 BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern: - """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.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: CumulativeNegativeRawSumPattern = CumulativeNegativeRawSumPattern(client, acc) - self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) - self.net_pnl: RawSumPattern2[CentsSigned] = RawSumPattern2(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: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'realized_profit')) - self.sent: InPattern = InPattern(client, _m(acc, 'sent_in')) - self.sopr: RatioValuePattern = RatioValuePattern(client, acc) - class AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern: """Pattern struct for repeated tree structure.""" @@ -2341,19 +2306,33 @@ class _1m1w1y24hBtcCentsSatsUsdPattern: self.sats: MetricPattern18[Sats] = MetricPattern18(client, _m(acc, 'sats')) self.usd: MetricPattern18[Dollars] = MetricPattern18(client, _m(acc, 'usd')) -class CapLossMvrvNuplPriceProfitSoprPattern: +class BpsCentsPercentilesRatioSatsSmaStdUsdPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.cap: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_cap')) - self.loss: RawSumPattern = RawSumPattern(client, _m(acc, 'realized_loss')) + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, _m(acc, 'ratio_bps')) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.percentiles: Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, _m(acc, 'ratio')) + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) + self.sats: MetricPattern1[SatsFract] = MetricPattern1(client, _m(acc, 'sats')) + self.sma: _1m1w1y2y4yAllPattern = _1m1w1y2y4yAllPattern(client, _m(acc, 'ratio_sma')) + self.std_dev: _1y2y4yAllPattern = _1y2y4yAllPattern(client, _m(acc, 'ratio')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) + +class CapLossMvrvNetNuplPriceProfitSoprPattern: + """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: CumulativeNegativeRawSumPattern = CumulativeNegativeRawSumPattern(client, acc) self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'mvrv')) + self.net_pnl: RawSumPattern2[CentsSigned] = RawSumPattern2(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: RawSumPattern = RawSumPattern(client, _m(acc, 'realized_profit')) - self.sopr: ValuePattern = ValuePattern(client, _m(acc, 'value')) + self.price: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) + self.profit: CumulativeRawSumPattern2 = CumulativeRawSumPattern2(client, _m(acc, 'realized_profit')) + self.sopr: RatioValuePattern = RatioValuePattern(client, acc) class CapitulationCumulativeNegativeRawRelSumValuePattern: """Pattern struct for repeated tree structure.""" @@ -2365,38 +2344,10 @@ class CapitulationCumulativeNegativeRawRelSumValuePattern: self.negative: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'neg_realized_loss')) self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_loss')) self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_loss_rel_to_realized_cap')) - self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, _m(acc, 'realized_loss')) + self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, _m(acc, 'realized_loss')) self.value_created: BaseSumPattern = BaseSumPattern(client, _m(acc, 'loss_value_created')) self.value_destroyed: BaseSumPattern = BaseSumPattern(client, _m(acc, 'loss_value_destroyed')) -class CoindaysCoinyearsDormancySentVelocityPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.coindays_destroyed: CumulativeRawSumPattern[StoredF64] = CumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')) - self.coindays_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'coindays_destroyed_supply_adjusted')) - self.coinyears_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinyears_destroyed')) - self.coinyears_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'coinyears_destroyed_supply_adjusted')) - self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) - self.dormancy_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy_supply_adjusted')) - self.sent: RawSumPattern3[Sats] = RawSumPattern3(client, _m(acc, 'sent')) - self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'velocity')) - -class Pct1Pct2Pct5Pct95Pct98Pct99SmaPattern: - """Pattern struct for repeated tree structure.""" - - 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.""" @@ -2437,6 +2388,19 @@ class _1m1w1y24hBpsPercentRatioPattern: self.percent: MetricPattern1[StoredF32] = MetricPattern1(client, acc) self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) +class CapLossMvrvNuplPriceProfitSoprPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cap: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_cap')) + self.loss: RawSumPattern = RawSumPattern(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: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) + self.profit: RawSumPattern = RawSumPattern(client, _m(acc, 'realized_profit')) + self.sopr: ValuePattern = ValuePattern(client, _m(acc, 'value')) + class CumulativeDistributionRawRelSumValuePattern: """Pattern struct for repeated tree structure.""" @@ -2446,7 +2410,7 @@ class CumulativeDistributionRawRelSumValuePattern: self.distribution_flow: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'profit_flow')) self.raw: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'realized_profit')) self.rel_to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'realized_profit_rel_to_realized_cap')) - self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, _m(acc, 'realized_profit')) + self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, _m(acc, 'realized_profit')) self.value_created: BaseSumPattern = BaseSumPattern(client, _m(acc, 'profit_value_created')) self.value_destroyed: BaseSumPattern = BaseSumPattern(client, _m(acc, 'profit_value_destroyed')) @@ -2456,13 +2420,37 @@ class GrossInvestedInvestorLossNetProfitSentimentPattern2: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'unrealized_gross_pnl')) - self.invested_capital: InPattern4 = InPattern4(client, _m(acc, 'invested_capital_in')) - self.investor_cap: InPattern2 = InPattern2(client, _m(acc, 'investor_cap_in')) + self.invested_capital: InPattern2 = InPattern2(client, _m(acc, 'invested_capital_in')) + self.investor_cap: InPattern = InPattern(client, _m(acc, 'investor_cap_in')) self.loss: NegativeRawRelSumPattern2 = NegativeRawRelSumPattern2(client, acc) self.net_pnl: CentsRelUsdPattern2 = CentsRelUsdPattern2(client, _m(acc, 'net_unrealized_pnl')) self.profit: RawRelSumPattern2 = RawRelSumPattern2(client, _m(acc, 'unrealized_profit')) self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, acc) +class _1m1w1y2y4yAllPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._1m: BpsRatioPattern = BpsRatioPattern(client, _m(acc, '1m')) + self._1w: BpsRatioPattern = BpsRatioPattern(client, _m(acc, '1w')) + self._1y: BpsRatioPattern = BpsRatioPattern(client, _m(acc, '1y')) + self._2y: BpsRatioPattern = BpsRatioPattern(client, _m(acc, '2y')) + self._4y: BpsRatioPattern = BpsRatioPattern(client, _m(acc, '4y')) + self.all: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'all')) + +class BpsCentsPercentilesRatioSatsUsdPattern: + """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, 'ratio_bps')) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.percentiles: Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, _m(acc, 'ratio')) + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) + self.sats: MetricPattern1[SatsFract] = MetricPattern1(client, _m(acc, 'sats')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) + class BtcCentsRelSatsUsdPattern3: """Pattern struct for repeated tree structure.""" @@ -2475,18 +2463,6 @@ class BtcCentsRelSatsUsdPattern3: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) -class CapLowerPriceUpperPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cap: RawPattern[CentsSquaredSats] = RawPattern(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 ChangeCumulativeDeltaRawRelSumPattern: """Pattern struct for repeated tree structure.""" @@ -2535,6 +2511,18 @@ class NegativeRawRelSumPattern2: self.rel_to_own_market_cap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'unrealized_loss_rel_to_own_market_cap')) self.sum: _24hPattern = _24hPattern(client, _m(acc, 'unrealized_loss_24h')) +class Pct1Pct2Pct5Pct95Pct98Pct99Pattern: + """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')) + class ActivityOutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -2542,7 +2530,7 @@ class ActivityOutputsRealizedSupplyUnrealizedPattern: """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.realized: CapLossMvrvNetNuplPriceProfitSoprPattern = CapLossMvrvNetNuplPriceProfitSoprPattern(client, acc) self.supply: DeltaHalvedInRelTotalPattern = DeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')) self.unrealized: InvestedInvestorLossNetProfitPattern = InvestedInvestorLossNetProfitPattern(client, acc) @@ -2553,20 +2541,20 @@ class ActivityOutputsRealizedSupplyUnrealizedPattern2: """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.realized: CapLossMvrvNetNuplPriceProfitSoprPattern = CapLossMvrvNetNuplPriceProfitSoprPattern(client, acc) self.supply: DeltaHalvedInRelTotalPattern = DeltaHalvedInRelTotalPattern(client, _m(acc, 'supply')) self.unrealized: LossNetProfitPattern = LossNetProfitPattern(client, acc) -class AddrOutputsRealizedSupplyPattern: +class BpsCentsRatioSatsUsdPattern: """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')) + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, _m(acc, 'ratio_bps')) + self.cents: MetricPattern1[Cents] = MetricPattern1(client, _m(acc, 'cents')) + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'ratio')) + self.sats: MetricPattern1[SatsFract] = MetricPattern1(client, _m(acc, 'sats')) + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) class BtcCentsRelSatsUsdPattern: """Pattern struct for repeated tree structure.""" @@ -2601,6 +2589,17 @@ class CentsDeltaRawRelUsdPattern: 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 CoindaysCoinyearsDormancySentVelocityPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.coindays_destroyed: CumulativeRawSumPattern[StoredF64] = CumulativeRawSumPattern(client, _m(acc, 'coindays_destroyed')) + self.coinyears_destroyed: MetricPattern1[StoredF64] = MetricPattern1(client, _m(acc, 'coinyears_destroyed')) + self.dormancy: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'dormancy')) + self.sent: InRawSumPattern2 = InRawSumPattern2(client, _m(acc, 'sent')) + self.velocity: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'velocity')) + class EmaHistogramLineSignalPattern: """Pattern struct for repeated tree structure.""" @@ -2617,12 +2616,23 @@ class InvestedInvestorLossNetProfitPattern: 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.invested_capital: InPattern = InPattern(client, _m(acc, 'invested_capital_in')) + self.investor_cap: InPattern = InPattern(client, _m(acc, 'investor_cap_in')) self.loss: NegativeRawSumPattern = NegativeRawSumPattern(client, acc) self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) self.profit: RawSumPattern = RawSumPattern(client, _m(acc, 'unrealized_profit')) +class InvestedMaxMinPercentilesSupplyPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'invested_capital')) + self.max: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'cost_basis_max')) + self.min: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')) + self.percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis')) + self.supply_density: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'supply_density')) + class PhsReboundThsPattern: """Pattern struct for repeated tree structure.""" @@ -2676,7 +2686,7 @@ class _1m1w1y24hPattern8: self._1y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '1y')) self._24h: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '24h')) -class _1m1w1y24hPattern4: +class _1m1w1y24hPattern5: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -2696,7 +2706,7 @@ class _1m1w1y2wPattern: self._1y: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '1y')) self._2w: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, '2w')) -class _1m1w1y24hPattern3: +class _1m1w1y24hPattern4: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -2706,7 +2716,7 @@ class _1m1w1y24hPattern3: self._1y: CentsUsdPattern = CentsUsdPattern(client, _m(acc, '1y')) self._24h: CentsUsdPattern = CentsUsdPattern(client, _m(acc, '24h')) -class _1m1w1y24hPattern5: +class _1m1w1y24hPattern3: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -2721,10 +2731,20 @@ class _1y2y4yAllPattern: 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) + self._1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc) + self._2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc) + self._4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc) + self.all: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern = _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern(client, acc) + +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: BaseDeltaPattern = BaseDeltaPattern(client, _m(acc, 'addr_count')) + self.outputs: UtxoPattern = UtxoPattern(client, _m(acc, 'utxo_count')) + self.realized: CapLossMvrvNuplPriceProfitSoprPattern = CapLossMvrvNuplPriceProfitSoprPattern(client, acc) + self.supply: HalvedTotalPattern = HalvedTotalPattern(client, _m(acc, 'supply')) class AdjustedRatioValuePattern: """Pattern struct for repeated tree structure.""" @@ -2746,16 +2766,6 @@ 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.""" @@ -2766,6 +2776,16 @@ class BtcCentsSatsUsdPattern: self.sats: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'sats')) self.usd: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) +class CapLowerPriceUpperPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cap: RawPattern[CentsSquaredSats] = RawPattern(client, _m(acc, 'investor_cap_raw')) + self.lower_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'lower_price_band')) + self.price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, _m(acc, 'investor_price')) + self.upper_price_band: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'upper_price_band')) + class CentsRelUsdPattern2: """Pattern struct for repeated tree structure.""" @@ -2796,15 +2816,25 @@ class HalvedInTotalPattern: self.in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'in_profit')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) -class InvestedMaxMinPercentilesPattern: +class InRawSumPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.invested_capital: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'invested_capital')) - self.max: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'cost_basis_max')) - self.min: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')) - self.percentiles: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis')) + self.in_loss: RawSumPattern4 = RawSumPattern4(client, _m(acc, 'in_loss')) + self.in_profit: RawSumPattern4 = RawSumPattern4(client, _m(acc, 'in_profit')) + self.raw: MetricPattern1[Sats] = MetricPattern1(client, acc) + self.sum: _24hPattern2[Sats] = _24hPattern2(client, _m(acc, '24h')) + +class InRawSumPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.in_loss: RawSumPattern5 = RawSumPattern5(client, _m(acc, 'in_loss')) + self.in_profit: RawSumPattern5 = RawSumPattern5(client, _m(acc, 'in_profit')) + self.raw: MetricPattern1[Sats] = MetricPattern1(client, acc) + self.sum: _1m1w1y24hPattern[Sats] = _1m1w1y24hPattern(client, acc) class OutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -3013,6 +3043,22 @@ class BaseSumPattern: self.base: MetricPattern1[Cents] = MetricPattern1(client, acc) self.sum: _1m1w1y24hPattern[Cents] = _1m1w1y24hPattern(client, acc) +class BaseDeltaPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.base: MetricPattern1[StoredU64] = MetricPattern1(client, acc) + self.delta: ChangeRatePattern = ChangeRatePattern(client, _m(acc, 'delta')) + +class BaseDeltaPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.base: MetricPattern1[StoredU64] = MetricPattern1(client, acc) + self.delta: ChangeRatePattern2 = ChangeRatePattern2(client, _m(acc, 'delta')) + class BlocksDominancePattern: """Pattern struct for repeated tree structure.""" @@ -3050,7 +3096,7 @@ class ChangeRatePattern4: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.change: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, _m(acc, 'change')) + self.change: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, _m(acc, 'change')) self.rate: _1m1w1y24hPattern2 = _1m1w1y24hPattern2(client, _m(acc, 'rate')) class ChangeRatePattern: @@ -3075,7 +3121,7 @@ class CoindaysSentPattern: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.coindays_destroyed: RawSumPattern2[StoredF64] = RawSumPattern2(client, _m(acc, 'coindays_destroyed')) - self.sent: RawSumPattern2[Sats] = RawSumPattern2(client, _m(acc, 'sent')) + self.sent: InRawSumPattern = InRawSumPattern(client, _m(acc, 'sent')) class HalvedTotalPattern: """Pattern struct for repeated tree structure.""" @@ -3085,7 +3131,7 @@ class HalvedTotalPattern: self.halved: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'halved')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) -class InPattern4: +class InPattern2: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -3093,7 +3139,7 @@ class InPattern4: self.in_loss: CentsRawUsdPattern = CentsRawUsdPattern(client, _m(acc, 'loss')) self.in_profit: CentsRawUsdPattern = CentsRawUsdPattern(client, _m(acc, 'profit')) -class InPattern2: +class InPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): @@ -3101,22 +3147,6 @@ class InPattern2: self.in_loss: RawPattern[CentsSats] = RawPattern(client, _m(acc, 'loss_raw')) self.in_profit: RawPattern[CentsSats] = RawPattern(client, _m(acc, 'profit_raw')) -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: RawSumPattern4 = RawSumPattern4(client, _m(acc, 'loss')) - self.in_profit: RawSumPattern4 = RawSumPattern4(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: RawSumPattern5 = RawSumPattern5(client, _m(acc, 'loss')) - self.in_profit: RawSumPattern5 = RawSumPattern5(client, _m(acc, 'profit')) - class LossProfitPattern2: """Pattern struct for repeated tree structure.""" @@ -3139,7 +3169,7 @@ class RawSumPattern5: def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" self.raw: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) - self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, acc) + self.sum: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, acc) class RawSumPattern4: """Pattern struct for repeated tree structure.""" @@ -3181,22 +3211,6 @@ class SdSmaPattern: self.sd: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sd_1y')) self.sma: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, 'sma_1y')) -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.""" @@ -3257,6 +3271,20 @@ class _24hPattern: """Create pattern node with accumulated metric name.""" self._24h: CentsUsdPattern = CentsUsdPattern(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: BaseDeltaPattern = BaseDeltaPattern(client, acc) + +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: BaseDeltaPattern2 = BaseDeltaPattern2(client, acc) + class UtxoPattern: """Pattern struct for repeated tree structure.""" @@ -3707,22 +3735,14 @@ class MetricsTree_Cointime_Pricing: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.vaulted_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'vaulted_price') - self.vaulted_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'vaulted_price_ratio') - self.active_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'active_price') - 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: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'true_market_mean_ratio') - self.cointime_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'cointime_price') - self.cointime_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'cointime_price_ratio') - self.transfer_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'transfer_price') - self.transfer_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'transfer_price_ratio') - self.balanced_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'balanced_price') - self.balanced_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'balanced_price_ratio') - self.terminal_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'terminal_price') - self.terminal_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'terminal_price_ratio') - self.delta_price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'delta_price') - self.delta_price_ratio: BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern = BpsPct1Pct2Pct5Pct95Pct98Pct99RatioSmaPattern(client, 'delta_price_ratio') + self.vaulted_price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'vaulted_price') + self.active_price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'active_price') + self.true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'true_market_mean') + self.cointime_price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'cointime_price') + self.transfer_price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'transfer_price') + self.balanced_price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'balanced_price') + self.terminal_price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'terminal_price') + self.delta_price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'delta_price') self.cumulative_market_cap: MetricPattern1[Dollars] = MetricPattern1(client, 'cumulative_market_cap') class MetricsTree_Cointime_Adjusted: @@ -4055,6 +4075,12 @@ class MetricsTree_Indicators: self.gini: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'gini') self.rhodl_ratio: BpsRatioPattern = BpsRatioPattern(client, 'rhodl_ratio') self.thermocap_multiple: BpsRatioPattern = BpsRatioPattern(client, 'thermocap_multiple') + self.coindays_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, 'coindays_destroyed_supply_adjusted') + self.coinyears_destroyed_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, 'coinyears_destroyed_supply_adjusted') + self.dormancy_supply_adjusted: MetricPattern1[StoredF32] = MetricPattern1(client, 'dormancy_supply_adjusted') + self.stock_to_flow: MetricPattern1[StoredF32] = MetricPattern1(client, 'stock_to_flow') + self.dormancy_flow: MetricPattern1[StoredF32] = MetricPattern1(client, 'dormancy_flow') + self.seller_exhaustion_constant: MetricPattern1[StoredF32] = MetricPattern1(client, 'seller_exhaustion_constant') class MetricsTree_Market_Ath: """Metrics tree node.""" @@ -4151,306 +4177,50 @@ class MetricsTree_Market_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._1w: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_1w') + self._8d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_8d') + self._13d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_13d') + self._21d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_21d') + self._1m: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_1m') + self._34d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_34d') + self._55d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_55d') + self._89d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_89d') + self._111d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_111d') + self._144d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_144d') + self._200d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_200d') + self._350d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_350d') + self._1y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_1y') + self._2y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_2y') + self._200w: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_200w') + self._4y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_4y') 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) + self._1w: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_1w') + self._8d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_8d') + self._12d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_12d') + self._13d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_13d') + self._21d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_21d') + self._26d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_26d') + self._1m: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_1m') + self._34d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_34d') + self._55d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_55d') + self._89d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_89d') + self._144d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_144d') + self._200d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_200d') + self._1y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_1y') + self._2y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_2y') + self._200w: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_200w') + self._4y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_ema_4y') class MetricsTree_Market_MovingAverage: """Metrics tree node.""" @@ -4941,9 +4711,9 @@ class MetricsTree_Distribution_UtxoCohorts_All_Unrealized: def __init__(self, client: BrkClientBase, base_path: str = ''): self.gross_pnl: CentsUsdPattern = CentsUsdPattern(client, 'unrealized_gross_pnl') - self.invested_capital: InPattern4 = InPattern4(client, 'invested_capital_in') + self.invested_capital: InPattern2 = InPattern2(client, 'invested_capital_in') self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, '') - self.investor_cap: InPattern2 = InPattern2(client, 'investor_cap_in') + self.investor_cap: InPattern = InPattern(client, 'investor_cap_in') self.loss: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss = MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Loss(client) self.net_pnl: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_NetPnl = MetricsTree_Distribution_UtxoCohorts_All_Unrealized_NetPnl(client) self.profit: MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit = MetricsTree_Distribution_UtxoCohorts_All_Unrealized_Profit(client) @@ -4955,19 +4725,19 @@ class MetricsTree_Distribution_UtxoCohorts_All: self.supply: MetricsTree_Distribution_UtxoCohorts_All_Supply = MetricsTree_Distribution_UtxoCohorts_All_Supply(client) self.outputs: UtxoPattern3 = UtxoPattern3(client, 'utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, '') - self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(client, '') - self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, '') + self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(client, '') + self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, '') self.unrealized: MetricsTree_Distribution_UtxoCohorts_All_Unrealized = MetricsTree_Distribution_UtxoCohorts_All_Unrealized(client) class MetricsTree_Distribution_UtxoCohorts_Sth: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSentSoprPattern(client, 'sth') + self.realized: CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern = CapGrossInvestorLossMvrvNetNuplPeakPriceProfitSoprPattern(client, 'sth') self.supply: DeltaHalvedInRelTotalPattern2 = DeltaHalvedInRelTotalPattern2(client, 'sth_supply') self.outputs: UtxoPattern3 = UtxoPattern3(client, 'sth_utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'sth') - self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'sth') + self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, 'sth') self.unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2 = GrossInvestedInvestorLossNetProfitSentimentPattern2(client, 'sth') class MetricsTree_Distribution_UtxoCohorts_Lth_Realized_Sopr_ValueCreated: @@ -5001,13 +4771,11 @@ class MetricsTree_Distribution_UtxoCohorts_Lth_Realized: self.gross_pnl: RawSellSumPattern = RawSellSumPattern(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: CumulativeRawRelPattern = CumulativeRawRelPattern(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.price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern = BpsCentsPercentilesRatioSatsSmaStdUsdPattern(client, 'lth_realized_price') self.mvrv: MetricPattern1[StoredF32] = MetricPattern1(client, 'lth_mvrv') self.nupl: BpsRatioPattern = BpsRatioPattern(client, 'lth_nupl_ratio') @@ -5019,7 +4787,7 @@ class MetricsTree_Distribution_UtxoCohorts_Lth: self.outputs: UtxoPattern3 = UtxoPattern3(client, 'lth_utxo_count') self.activity: CoindaysCoinyearsDormancySentVelocityPattern = CoindaysCoinyearsDormancySentVelocityPattern(client, 'lth') self.realized: MetricsTree_Distribution_UtxoCohorts_Lth_Realized = MetricsTree_Distribution_UtxoCohorts_Lth_Realized(client) - self.cost_basis: InvestedMaxMinPercentilesPattern = InvestedMaxMinPercentilesPattern(client, 'lth') + self.cost_basis: InvestedMaxMinPercentilesSupplyPattern = InvestedMaxMinPercentilesSupplyPattern(client, 'lth') self.unrealized: GrossInvestedInvestorLossNetProfitSentimentPattern2 = GrossInvestedInvestorLossNetProfitSentimentPattern2(client, 'lth') class MetricsTree_Distribution_UtxoCohorts_AgeRange: @@ -5456,6 +5224,14 @@ class MetricsTree_Supply_Velocity: self.btc: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_btc') self.usd: MetricPattern1[StoredF64] = MetricPattern1(client, 'velocity_usd') +class MetricsTree_Supply_MarketCap: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.cents: MetricPattern1[Cents] = MetricPattern1(client, 'market_cap_cents') + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, 'market_cap') + self.delta: ChangeRatePattern4 = ChangeRatePattern4(client, 'market_cap_delta') + class MetricsTree_Supply: """Metrics tree node.""" @@ -5464,8 +5240,7 @@ class MetricsTree_Supply: self.burned: MetricsTree_Supply_Burned = MetricsTree_Supply_Burned(client) self.inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'inflation_rate') self.velocity: MetricsTree_Supply_Velocity = MetricsTree_Supply_Velocity(client) - self.market_cap: CentsUsdPattern = CentsUsdPattern(client, 'market_cap') - self.market_cap_delta: ChangeRatePattern4 = ChangeRatePattern4(client, 'market_cap_delta') + self.market_cap: MetricsTree_Supply_MarketCap = MetricsTree_Supply_MarketCap(client) self.market_minus_realized_cap_growth_rate: _1m1w1y24hPattern[BasisPointsSigned32] = _1m1w1y24hPattern(client, 'market_minus_realized_cap_growth_rate') self.hodled_or_lost_coins: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'hodled_or_lost_coins')