From 00984112d82d793fa0317e2fdb56c90d223535a9 Mon Sep 17 00:00:00 2001 From: nym21 Date: Mon, 20 Jul 2026 18:28:12 +0200 Subject: [PATCH] global: replace most bps with ppm --- Cargo.lock | 199 ++- Cargo.toml | 12 +- crates/brk_bindgen/src/analysis/positions.rs | 14 +- crates/brk_bindgen/src/backends/javascript.rs | 2 +- crates/brk_bindgen/src/syntax.rs | 4 +- crates/brk_bindgen/src/types/positions.rs | 2 +- crates/brk_bindgen/src/types/structs.rs | 2 +- crates/brk_client/src/lib.rs | 1378 ++++++++------- .../src/blocks/difficulty/compute.rs | 2 +- .../src/blocks/difficulty/vecs.rs | 4 +- .../brk_computer/src/blocks/weight/compute.rs | 6 +- crates/brk_computer/src/blocks/weight/vecs.rs | 4 +- .../src/cointime/adjusted/compute.rs | 8 +- .../src/cointime/adjusted/import.rs | 2 +- .../src/cointime/adjusted/vecs.rs | 4 +- crates/brk_computer/src/cointime/cap/vecs.rs | 4 +- .../src/distribution/addr/delta.rs | 6 +- .../distribution/addr/reused/events/vecs.rs | 10 +- .../src/distribution/addr/supply/share.rs | 13 +- .../src/distribution/cohorts/addr/vecs.rs | 6 +- .../src/distribution/cohorts/utxo/fenwick.rs | 39 +- .../distribution/cohorts/utxo/percentiles.rs | 10 +- .../src/distribution/metrics/config.rs | 15 +- .../distribution/metrics/cost_basis/mod.rs | 12 +- .../src/distribution/metrics/outputs/base.rs | 8 +- .../src/distribution/metrics/profitability.rs | 14 +- .../src/distribution/metrics/realized/core.rs | 12 +- .../src/distribution/metrics/realized/full.rs | 35 +- .../distribution/metrics/realized/minimal.rs | 10 +- .../relative/extended_own_market_cap.rs | 16 +- .../metrics/relative/extended_own_pnl.rs | 16 +- .../src/distribution/metrics/relative/full.rs | 20 +- .../metrics/relative/invested_capital.rs | 12 +- .../src/distribution/metrics/supply/base.rs | 25 +- .../metrics/unrealized/minimal.rs | 12 +- crates/brk_computer/src/indicators/compute.rs | 20 +- crates/brk_computer/src/indicators/gini.rs | 22 +- crates/brk_computer/src/indicators/vecs.rs | 12 +- .../brk_computer/src/inputs/by_type/vecs.rs | 6 +- .../src/internal/algo/drawdown.rs | 8 +- .../internal/algo/expanding_percentiles.rs | 39 +- .../src/internal/containers/percent.rs | 2 +- .../per_block/computed/with_deltas.rs | 6 +- .../fiat/cumulative_sum_with_deltas.rs | 6 +- .../internal/per_block/fiat/with_deltas.rs | 6 +- .../src/internal/per_block/percent/base.rs | 29 +- .../per_block/percent/cumulative_rolling.rs | 20 +- .../src/internal/per_block/percent/lazy.rs | 26 +- .../percent/lazy_cumulative_rolling.rs | 10 +- .../per_block/percent/lazy_windows.rs | 10 +- .../src/internal/per_block/percent/vec.rs | 20 +- .../src/internal/per_block/percent/windows.rs | 8 +- .../src/internal/per_block/ratio/base.rs | 32 +- .../internal/per_block/ratio/percentiles.rs | 54 +- .../per_block/ratio/price_extended.rs | 17 +- .../src/internal/per_block/ratio/sma.rs | 18 +- .../src/internal/per_block/ratio/windows.rs | 13 +- .../src/internal/per_block/rolling/delta.rs | 84 +- .../internal/per_block/value/with_deltas.rs | 6 +- crates/brk_computer/src/internal/traits.rs | 46 +- .../src/internal/transform/arithmetic.rs | 10 +- .../src/internal/transform/bps.rs | 76 - .../src/internal/transform/derived.rs | 12 +- .../src/internal/transform/fixed_ratio.rs | 35 + .../src/internal/transform/mod.rs | 18 +- .../src/internal/transform/ratio.rs | 182 +- .../src/internal/with_addr_types.rs | 8 +- crates/brk_computer/src/investing/compute.rs | 16 +- crates/brk_computer/src/investing/vecs.rs | 10 +- crates/brk_computer/src/market/ath/vecs.rs | 4 +- .../brk_computer/src/market/range/compute.rs | 10 +- crates/brk_computer/src/market/range/vecs.rs | 4 +- .../src/market/returns/compute.rs | 14 +- .../brk_computer/src/market/returns/vecs.rs | 6 +- .../src/market/technical/compute.rs | 8 +- .../brk_computer/src/market/technical/rsi.rs | 34 +- .../brk_computer/src/market/technical/vecs.rs | 16 +- .../src/mining/hashrate/compute.rs | 8 +- .../src/mining/hashrate/import.rs | 4 +- .../brk_computer/src/mining/hashrate/vecs.rs | 6 +- .../src/mining/rewards/compute.rs | 10 +- .../brk_computer/src/mining/rewards/import.rs | 4 +- .../brk_computer/src/mining/rewards/vecs.rs | 8 +- crates/brk_computer/src/op_return/compute.rs | 13 +- crates/brk_computer/src/op_return/vecs.rs | 8 +- .../brk_computer/src/outputs/by_type/vecs.rs | 6 +- crates/brk_computer/src/pools/major.rs | 8 +- crates/brk_computer/src/pools/minor.rs | 8 +- crates/brk_computer/src/supply/compute.rs | 12 +- crates/brk_computer/src/supply/import.rs | 6 +- crates/brk_computer/src/supply/vecs.rs | 9 +- crates/brk_store/Cargo.toml | 1 - crates/brk_store/src/lib.rs | 10 - crates/brk_traversable_derive/Cargo.toml | 4 +- crates/brk_traversable_derive/src/lib.rs | 2 +- crates/brk_types/src/basis_points_16.rs | 214 --- .../brk_types/src/basis_points_signed_16.rs | 213 --- crates/brk_types/src/lib.rs | 16 +- ...s_points_32.rs => parts_per_million_32.rs} | 142 +- crates/brk_types/src/parts_per_million_64.rs | 245 +++ ...d_32.rs => parts_per_million_signed_32.rs} | 118 +- .../src/parts_per_million_signed_64.rs | 259 +++ modules/brk-client/index.js | 1520 ++++++++--------- modules/brk-client/package.json | 3 +- modules/brk-client/tests/basic.js | 18 +- modules/brk-client/tests/metric_data.js | 8 +- modules/brk-client/tests/tree.js | 3 +- packages/brk_client/brk_client/__init__.py | 727 ++++---- website_next/explore/block/format.js | 2 +- .../explore/block/preview/heatmap/geometry.js | 4 +- 110 files changed, 3320 insertions(+), 3220 deletions(-) delete mode 100644 crates/brk_computer/src/internal/transform/bps.rs create mode 100644 crates/brk_computer/src/internal/transform/fixed_ratio.rs delete mode 100644 crates/brk_types/src/basis_points_16.rs delete mode 100644 crates/brk_types/src/basis_points_signed_16.rs rename crates/brk_types/src/{basis_points_32.rs => parts_per_million_32.rs} (57%) create mode 100644 crates/brk_types/src/parts_per_million_64.rs rename crates/brk_types/src/{basis_points_signed_32.rs => parts_per_million_signed_32.rs} (59%) create mode 100644 crates/brk_types/src/parts_per_million_signed_64.rs diff --git a/Cargo.lock b/Cargo.lock index 293836f4e..7113f7869 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -73,9 +73,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a4385e2e34eb35d6b3efe798b9eb88096925d87726c0798709bf56d9ed84af3" +checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470" [[package]] name = "arrayvec" @@ -222,7 +222,7 @@ dependencies = [ "regex", "rustc-hash", "shlex 1.3.0", - "syn", + "syn 2.0.119", ] [[package]] @@ -658,7 +658,6 @@ dependencies = [ "byteview", "fjall", "rustc-hash", - "tracing", ] [[package]] @@ -680,7 +679,7 @@ version = "0.3.6" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.2", ] [[package]] @@ -750,9 +749,9 @@ checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" [[package]] name = "bytemuck" -version = "1.25.1" +version = "1.25.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6aedf8ae72766347502cf3cb4f41cf5e9cc37d28bee90f1fdaaae15f9cf9424" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" [[package]] name = "byteorder" @@ -780,9 +779,9 @@ checksum = "1c53ba0f290bfc610084c05582d9c5d421662128fc69f4bf236707af6fd321b9" [[package]] name = "cc" -version = "1.2.67" +version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e17dd265a7d0f31ef544e1b20e03add05d3b45b491b633b10d67145d2acc1a38" +checksum = "c89588d05638b5b4594a3348a2d6c20277e43a7f5c5202b05cc56888475a47b8" dependencies = [ "find-msvc-tools", "jobserver", @@ -1109,7 +1108,7 @@ dependencies = [ "defmt-parser", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1146,7 +1145,7 @@ dependencies = [ "proc-macro2", "quote", "rustc_version", - "syn", + "syn 2.0.119", "unicode-xid", ] @@ -1179,7 +1178,7 @@ checksum = "1ac70aa55017e108007fbaf5aa0f54b021c98f92ff8af59d42eda9da96e3dd4f" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1239,7 +1238,7 @@ dependencies = [ "once_cell", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1270,9 +1269,9 @@ dependencies = [ [[package]] name = "fastrand" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f1f227452a390804cdb637b74a86990f2a7d7ba4b7d5693aac9b4dd6defd8d6" +checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223" [[package]] name = "fdeflate" @@ -1291,9 +1290,9 @@ checksum = "5baebc0774151f905a1a2cc41989300b1e6fbb29aff0ceffa1064fdd3088d582" [[package]] name = "fjall" -version = "3.1.6" +version = "3.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fcdc69609906151dff9b534e30eaf8515082055d36f628e382bd0b5d6a1d362" +checksum = "420a84699b8ccbb1ed573e38e88f4f23637b45beab6432066452f834be469c57" dependencies = [ "byteorder-lite", "byteview", @@ -1374,7 +1373,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -1405,36 +1404,36 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" [[package]] name = "futures-sink" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" +checksum = "e34418ac499d6305c2fb5ad0ed2f6ac998c5f8ca209b4510f7f94242c647e307" [[package]] name = "futures-task" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" +checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" [[package]] name = "futures-util" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" dependencies = [ "futures-core", "futures-task", @@ -1598,9 +1597,9 @@ checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" [[package]] name = "hyper" -version = "1.10.1" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55281c53a1894c864990125767da440a4e630446785086f52523b20033b74498" +checksum = "d22053281f852e11534f5198498373cbb59295120a20771d90f7ed1897490a72" dependencies = [ "atomic-waker", "bytes", @@ -1863,11 +1862,12 @@ checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" [[package]] name = "jiff" -version = "0.2.32" +version = "0.2.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "961d16382652bfdd8c6f68b223b26a8c93e0d475c672f414411db31c6c5c900e" +checksum = "e184d09547b80eb7e20d141ba2fb1fbac843ca53f4cf1b31210adc4c1adc6e16" dependencies = [ "defmt", + "jiff-core", "jiff-static", "log", "portable-atomic", @@ -1877,14 +1877,24 @@ dependencies = [ ] [[package]] -name = "jiff-static" -version = "0.2.32" +name = "jiff-core" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0879bd39df99c4c5e2c6615ccc026391a423dde10532c573e6086eb94a802cc" +checksum = "7feca88439efe53da3754500c1851dedf3cb36c524dd5cf8225cc0794de95d09" dependencies = [ + "defmt", +] + +[[package]] +name = "jiff-static" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "323da076b7a6faf914dc677cb05a4b907742ff7375c8322c9e7f5061e5e0e9de" +dependencies = [ + "jiff-core", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -2018,9 +2028,9 @@ checksum = "0ceec5bc11778974d1bcb055b18002eba7f4b3518b6a0081b3af5f21666da9ad" [[package]] name = "lsm-tree" -version = "3.1.6" +version = "3.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39ca67401338b98d58447387dd5230552d2241bc388206e491d137b18dfea9d6" +checksum = "055a908d502129cf63bedae52f2db222e4436d2da32a69df9b84ac9fb9147761" dependencies = [ "byteorder-lite", "byteview", @@ -2330,9 +2340,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.13.1" +version = "1.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c33a9471896f1c69cecef8d20cbe2f7accd12527ce60845ff44c153bb2a21b49" +checksum = "3d20d5497ef88037a52ff98267d066e7f11fcc5e99bbfbd58a42336193aacec3" [[package]] name = "portable-atomic-util" @@ -2360,9 +2370,9 @@ checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" [[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] @@ -2388,9 +2398,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] @@ -2482,22 +2492,22 @@ dependencies = [ [[package]] name = "ref-cast" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +checksum = "216e8f773d7923bcba9ceb86a86c93cabb3903a11872fc3f138c49630e50b96d" dependencies = [ "ref-cast-impl", ] [[package]] name = "ref-cast-impl" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +checksum = "2c9283685feec7d69af75fb0e858d5e7378f33fe4fc699383b2916ab9273e03c" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.2", ] [[package]] @@ -2665,7 +2675,7 @@ dependencies = [ "proc-macro2", "quote", "serde_derive_internals", - "syn", + "syn 2.0.119", ] [[package]] @@ -2708,9 +2718,9 @@ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -2728,22 +2738,22 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.2", ] [[package]] @@ -2754,14 +2764,14 @@ checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "serde_json" -version = "1.0.150" +version = "1.0.151" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8014e44b4736ed0538adeecded0fce2a272f22dc9578a7eb6b2d9993c74cfb9" +checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14" dependencies = [ "indexmap", "itoa", @@ -2909,7 +2919,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -2948,6 +2958,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "3.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a207d6d6a2b7fc470b80443726053f18a2481b7e1eee970597051596567987a3" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "sync_wrapper" version = "1.0.2" @@ -2962,7 +2983,7 @@ checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -2980,22 +3001,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "2.0.18" +version = "2.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4288b5bcbc7920c07a1149a35cf9590a2aa808e0bc1eafaade0b80947865fbc4" +checksum = "09a43598840e33d5b0331f38c5e30d13bb11c11210a4b58f0d9b18a5a5eefcd9" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "2.0.18" +version = "2.0.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebc4ee7f67670e9b64d05fa4253e753e016c6c95ff35b89b7941d6b856dec1d5" +checksum = "43cbfe0cf76104d42a574802844187e84a305e531ed54455f11fbde0f10541cd" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.2", ] [[package]] @@ -3009,9 +3030,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.53" +version = "0.3.54" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "18dfaaeddcb932337b5e7866ee7d0ce9b76d2fd092997146f187ec09b4558a50" +checksum = "3e1d5e639ff6bab73cb6885cc7e7b1de96c3f32c68ec55f3952614bec1092244" dependencies = [ "deranged", "num-conv", @@ -3029,9 +3050,9 @@ checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" [[package]] name = "time-macros" -version = "0.2.31" +version = "0.2.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c431b87111666e491a90baa837f914fb45cd5dc3c268591b0220ff5057f2085f" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" dependencies = [ "num-conv", "time-core", @@ -3049,9 +3070,9 @@ dependencies = [ [[package]] name = "tokio" -version = "1.52.4" +version = "1.53.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "317fafbbe3f02fc663dad00ea6186197de963cd4190e86a26d8d0fae095539af" +checksum = "d988bcd52dbe076d3d46903332f58c912b87a2c49b1428419a5845154762ffee" dependencies = [ "libc", "mio", @@ -3063,13 +3084,13 @@ dependencies = [ [[package]] name = "tokio-macros" -version = "2.7.0" +version = "2.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "385a6cb71ab9ab790c5fe8d67f1645e6c450a7ce006a33de03daa956cf70a496" +checksum = "6328af13490e73a9b4694030fafd93f8c8c6a9dede33e821c3fc63eddf8042ba" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3193,7 +3214,7 @@ checksum = "7490cfa5ec963746568740651ac6781f701c9c5ea257c58e057f3ba8cf69e8da" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3246,9 +3267,9 @@ checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4" [[package]] name = "twox-hash" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ea3136b675547379c4bd395ca6b938e5ad3c3d20fad76e7fe85f9e0d011419c" +checksum = "8464ec13c3691491391d9fce00f6416c9a48e46972f72d7865688be2080192c9" [[package]] name = "unicode-ident" @@ -3373,7 +3394,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87e6ddc694828bd6d372573727e02ea07047f4b65f78aaf859dae2fbf2dbbcfe" dependencies = [ "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3430,7 +3451,7 @@ dependencies = [ "bumpalo", "proc-macro2", "quote", - "syn", + "syn 2.0.119", "wasm-bindgen-shared", ] @@ -3455,9 +3476,9 @@ dependencies = [ [[package]] name = "webpki-roots" -version = "1.0.8" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf85cb06032201fa7c6f829d7db5a7e5aa45bcc0655327713065f6f0576731bf" +checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a" dependencies = [ "rustls-pki-types", ] @@ -3520,7 +3541,7 @@ checksum = "053e2e040ab57b9dc951b72c264860db7eb3b0200ba345b4e4c3b14f67855ddf" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3531,7 +3552,7 @@ checksum = "3f316c4a2570ba26bbec722032c4099d8c8bc095efccdc15688708623367e358" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3697,7 +3718,7 @@ checksum = "de844c262c8848816172cef550288e7dc6c7b7814b4ee56b3e1553f275f1858e" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] @@ -3718,7 +3739,7 @@ checksum = "e2e817b7b52d0c7358d3246da9d69935ebb18116b2b102b4230dac079b4862f5" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -3738,7 +3759,7 @@ checksum = "11532158c46691caf0f2593ea8358fed6bbf68a0315e80aae9bd41fbade684a1" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", "synstructure", ] @@ -3778,7 +3799,7 @@ checksum = "625dc425cab0dca6dc3c3319506e6593dcb08a9f387ea3b284dbd52a92c40555" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 832f3424b..48e7d780f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,9 +64,9 @@ color-eyre = "0.6.5" corepc-jsonrpc = { package = "jsonrpc", version = "0.19.0", features = ["simple_http"], default-features = false } corepc-types = { version = "0.15.0", features = ["std"], default-features = false } derive_more = { version = "2.1.1", features = ["deref", "deref_mut"] } -fjall = "3.1.6" +fjall = "3.1.8" indexmap = { version = "2.14.0", features = ["serde"] } -jiff = { version = "0.2.32", features = ["perf-inline", "tz-system"], default-features = false } +jiff = { version = "0.2.34", features = ["perf-inline", "tz-system"], default-features = false } owo-colors = "4.3.0" parking_lot = "0.12.5" pco = "1.0.2" @@ -74,12 +74,12 @@ rayon = "1.12.0" rapidhash = "4.5.1" rustc-hash = "2.1.3" schemars = { version = "1.2.1", features = ["indexmap2"] } -serde = "1.0.228" +serde = "1.0.229" serde_bytes = "0.11.19" -serde_derive = "1.0.228" -serde_json = { version = "1.0.150", features = ["float_roundtrip", "preserve_order"] } +serde_derive = "1.0.229" +serde_json = { version = "1.0.151", features = ["float_roundtrip", "preserve_order"] } smallvec = "1.15.2" -tokio = { version = "1.52.4", features = ["rt-multi-thread"] } +tokio = { version = "1.53.0", features = ["rt-multi-thread"] } tower-http = { version = "0.7.0", features = ["catch-panic", "compression-br", "compression-gzip", "compression-zstd", "cors", "normalize-path", "timeout", "trace"] } tower-layer = "0.3" tracing = { version = "0.1", default-features = false, features = ["std"] } diff --git a/crates/brk_bindgen/src/analysis/positions.rs b/crates/brk_bindgen/src/analysis/positions.rs index aacf370dd..07d69b1c0 100644 --- a/crates/brk_bindgen/src/analysis/positions.rs +++ b/crates/brk_bindgen/src/analysis/positions.rs @@ -291,7 +291,7 @@ fn collect_instance_analyses( /// /// Supports two cases: /// 1. **Embedded discriminator**: a substring varies per instance within field_parts. -/// E.g., `ratio_pct99_bps` vs `ratio_pct1_bps` → template `ratio_{disc}_bps` +/// E.g., `ratio_pct99_ppm` vs `ratio_pct1_ppm` → template `ratio_{disc}_ppm` /// 2. **Suffix discriminator**: a common suffix is appended to all field_parts. /// E.g., `ratio_sd` vs `ratio_sd_4y` → template `ratio_sd{disc}` fn try_detect_template( @@ -307,11 +307,11 @@ fn try_detect_template( return Some(mode); } - // Strategy 2: embedded discriminator (e.g., ratio_pct99_bps vs ratio_pct1_bps) + // Strategy 2: embedded discriminator (e.g., ratio_pct99_ppm vs ratio_pct1_ppm) try_embedded_disc(majority, fields) } -/// Strategy 1: embedded discriminator (e.g., pct99 inside ratio_pct99_bps) +/// Strategy 1: embedded discriminator (e.g., pct99 inside ratio_pct99_ppm) fn try_embedded_disc( majority: &[&InstanceAnalysis], fields: &[PatternField], @@ -772,7 +772,7 @@ mod tests { use std::collections::BTreeSet; let fields = vec![ PatternField { - name: "bps".into(), + name: "ppm".into(), rust_type: "T".into(), json_type: "n".into(), indexes: BTreeSet::new(), @@ -796,7 +796,7 @@ mod tests { let pct99 = InstanceAnalysis { base: "realized_price".into(), field_parts: [ - ("bps".into(), "ratio_pct99_bps".into()), + ("ppm".into(), "ratio_pct99_ppm".into()), ("price".into(), "pct99".into()), ("ratio".into(), "ratio_pct99".into()), ] @@ -808,7 +808,7 @@ mod tests { let pct1 = InstanceAnalysis { base: "realized_price".into(), field_parts: [ - ("bps".into(), "ratio_pct1_bps".into()), + ("ppm".into(), "ratio_pct1_ppm".into()), ("price".into(), "pct1".into()), ("ratio".into(), "ratio_pct1".into()), ] @@ -821,7 +821,7 @@ mod tests { assert!(mode.is_some()); match mode.unwrap() { PatternMode::Templated { templates } => { - assert_eq!(templates.get("bps").unwrap(), "ratio_{disc}_bps"); + assert_eq!(templates.get("ppm").unwrap(), "ratio_{disc}_ppm"); assert_eq!(templates.get("price").unwrap(), "{disc}"); assert_eq!(templates.get("ratio").unwrap(), "ratio_{disc}"); } diff --git a/crates/brk_bindgen/src/backends/javascript.rs b/crates/brk_bindgen/src/backends/javascript.rs index 92eeeb3ef..ea3e1bc62 100644 --- a/crates/brk_bindgen/src/backends/javascript.rs +++ b/crates/brk_bindgen/src/backends/javascript.rs @@ -89,7 +89,7 @@ impl LanguageSyntax for JavaScriptSyntax { format!("_m({}, '{}')", var_name, template) } else { // Template with {disc}: use nested _m for proper separator handling - // "ratio_{disc}_bps" → split on {disc} → _m(_m(acc, 'ratio'), disc) then _bps + // "ratio_{disc}_ppm" → split on {disc} → _m(_m(acc, 'ratio'), disc) then _ppm // But this is complex. For embedded disc, use string interpolation. // For suffix disc (ends with {disc}), use _m composition. if let Some(static_part) = template.strip_suffix("{disc}") { diff --git a/crates/brk_bindgen/src/syntax.rs b/crates/brk_bindgen/src/syntax.rs index c1490c318..5f2b87653 100644 --- a/crates/brk_bindgen/src/syntax.rs +++ b/crates/brk_bindgen/src/syntax.rs @@ -107,7 +107,7 @@ pub trait LanguageSyntax { /// - `"pct99"` (static) → `'pct99'` (JS) / `"pct99".to_string()` (Rust) /// - `""` (empty) → `disc` (pass parent's disc through) /// - `"p1sd{disc}"` (suffix) → `_m('p1sd', disc)` (composed) - /// - `"ratio_{disc}_bps"` (embedded) → `` `ratio_${disc}_bps` `` (template literal) + /// - `"ratio_{disc}_ppm"` (embedded) → `` `ratio_${disc}_ppm` `` (template literal) fn disc_arg_expr(&self, template: &str) -> String; /// Format a templated mode expression: substitute `{disc}` at runtime. @@ -117,6 +117,6 @@ pub trait LanguageSyntax { /// /// # Arguments /// * `acc_var` - The accumulator variable (e.g., "acc") - /// * `template` - Template like `"ratio_{disc}_bps"` or `"{disc}"` + /// * `template` - Template like `"ratio_{disc}_ppm"` or `"{disc}"` fn template_expr(&self, acc_var: &str, template: &str) -> String; } diff --git a/crates/brk_bindgen/src/types/positions.rs b/crates/brk_bindgen/src/types/positions.rs index a758b1ad8..22ed8a933 100644 --- a/crates/brk_bindgen/src/types/positions.rs +++ b/crates/brk_bindgen/src/types/positions.rs @@ -26,7 +26,7 @@ pub enum PatternMode { /// Fields construct series names using a template with a discriminator placeholder. /// Factory takes two params: `acc` (base) and `disc` (discriminator). /// Formula: `_m(acc, template.replace("{disc}", disc))` - /// Example: template `"ratio_{disc}_bps"` with disc `"pct99"` → `_m(acc, "ratio_pct99_bps")` + /// Example: template `"ratio_{disc}_ppm"` with disc `"pct99"` → `_m(acc, "ratio_pct99_ppm")` Templated { /// Maps field name to its template string containing `{disc}` placeholder templates: BTreeMap, diff --git a/crates/brk_bindgen/src/types/structs.rs b/crates/brk_bindgen/src/types/structs.rs index 5bcbade14..aee8194b9 100644 --- a/crates/brk_bindgen/src/types/structs.rs +++ b/crates/brk_bindgen/src/types/structs.rs @@ -128,7 +128,7 @@ impl StructuralPattern { } /// Extract the discriminator value by matching a template against a concrete string. -/// E.g., template `"ratio_{disc}_bps"` matched against `"ratio_pct99_bps"` yields `"pct99"`. +/// E.g., template `"ratio_{disc}_ppm"` matched against `"ratio_pct99_ppm"` yields `"pct99"`. fn extract_disc(template: &str, value: &str) -> Option { let (prefix, suffix) = template.split_once("{disc}")?; if value.starts_with(prefix) && value.ends_with(suffix) { diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 978991564..2927e3b2d 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -1179,42 +1179,6 @@ impl AllEmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern { } } -/// Pattern struct for repeated tree structure. -pub struct _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 { - pub _10y: BpsPercentRatioPattern, - pub _1m: BpsPercentRatioPattern, - pub _1w: BpsPercentRatioPattern, - pub _1y: BpsPercentRatioPattern, - pub _2y: BpsPercentRatioPattern, - pub _3m: BpsPercentRatioPattern, - pub _3y: BpsPercentRatioPattern, - pub _4y: BpsPercentRatioPattern, - pub _5y: BpsPercentRatioPattern, - pub _6m: BpsPercentRatioPattern, - pub _6y: BpsPercentRatioPattern, - pub _8y: BpsPercentRatioPattern, -} - -impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _10y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "10y")), - _1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1m")), - _1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1w")), - _1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1y")), - _2y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "2y")), - _3m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "3m")), - _3y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "3y")), - _4y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "4y")), - _5y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "5y")), - _6m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "6m")), - _6y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "6y")), - _8y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "8y")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 { pub _10y: BtcCentsSatsUsdPattern, @@ -1251,6 +1215,42 @@ impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 { } } +/// Pattern struct for repeated tree structure. +pub struct _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 { + pub _10y: PercentRatioRawPattern, + pub _1m: PercentRatioRawPattern, + pub _1w: PercentRatioRawPattern, + pub _1y: PercentRatioRawPattern, + pub _2y: PercentRatioRawPattern, + pub _3m: PercentRatioRawPattern, + pub _3y: PercentRatioRawPattern, + pub _4y: PercentRatioRawPattern, + pub _5y: PercentRatioRawPattern, + pub _6m: PercentRatioRawPattern, + pub _6y: PercentRatioRawPattern, + pub _8y: PercentRatioRawPattern, +} + +impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _10y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "10y")), + _1m: PercentRatioRawPattern::new(client.clone(), _m(&acc, "1m")), + _1w: PercentRatioRawPattern::new(client.clone(), _m(&acc, "1w")), + _1y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "1y")), + _2y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "2y")), + _3m: PercentRatioRawPattern::new(client.clone(), _m(&acc, "3m")), + _3y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "3y")), + _4y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "4y")), + _5y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "5y")), + _6m: PercentRatioRawPattern::new(client.clone(), _m(&acc, "6m")), + _6y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "6y")), + _8y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "8y")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct AllEmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern { pub all: AverageBlockCumulativeSumPattern, @@ -1276,7 +1276,7 @@ pub struct CapCapitalizedGrossLossMvrvNetPeakPriceProfitSellSoprPattern { pub mvrv: SeriesPattern1, pub net_pnl: BlockChangeCumulativeDeltaSumPattern, pub peak_regret: BlockCumulativeSumPattern, - pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, + pub price: CentsPercentilesRatioRawSatsSmaStdUsdPattern, pub profit: BlockCumulativeSumPattern, pub profit_to_loss_ratio: _1m1w1y24hPattern, pub sell_side_risk_ratio: _1m1w1y24hPattern8, @@ -1292,7 +1292,7 @@ pub struct CapCapitalizedGrossLossMvrvNetPeakPriceProfitSellSoprPattern2 { pub mvrv: SeriesPattern1, pub net_pnl: BlockChangeCumulativeDeltaSumPattern, pub peak_regret: BlockCumulativeSumPattern, - pub price: BpsCentsPercentilesRatioSatsSmaStdUsdPattern, + pub price: CentsPercentilesRatioRawSatsSmaStdUsdPattern, pub profit: BlockCumulativeSumPattern, pub profit_to_loss_ratio: _1m1w1y24hPattern, pub sell_side_risk_ratio: _1m1w1y24hPattern8, @@ -1301,36 +1301,36 @@ pub struct CapCapitalizedGrossLossMvrvNetPeakPriceProfitSellSoprPattern2 { /// Pattern struct for repeated tree structure. pub struct EmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2 { - pub empty: _1m1w1y24hBpsPercentRatioPattern, - pub op_return: _1m1w1y24hBpsPercentRatioPattern, - pub p2a: _1m1w1y24hBpsPercentRatioPattern, - pub p2ms: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk33: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk65: _1m1w1y24hBpsPercentRatioPattern, - pub p2pkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2sh: _1m1w1y24hBpsPercentRatioPattern, - pub p2tr: _1m1w1y24hBpsPercentRatioPattern, - pub p2wpkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2wsh: _1m1w1y24hBpsPercentRatioPattern, - pub unknown: _1m1w1y24hBpsPercentRatioPattern, + pub empty: _1m1w1y24hPercentRatioRawPattern, + pub op_return: _1m1w1y24hPercentRatioRawPattern, + pub p2a: _1m1w1y24hPercentRatioRawPattern, + pub p2ms: _1m1w1y24hPercentRatioRawPattern, + pub p2pk33: _1m1w1y24hPercentRatioRawPattern, + pub p2pk65: _1m1w1y24hPercentRatioRawPattern, + pub p2pkh: _1m1w1y24hPercentRatioRawPattern, + pub p2sh: _1m1w1y24hPercentRatioRawPattern, + pub p2tr: _1m1w1y24hPercentRatioRawPattern, + pub p2wpkh: _1m1w1y24hPercentRatioRawPattern, + pub p2wsh: _1m1w1y24hPercentRatioRawPattern, + pub unknown: _1m1w1y24hPercentRatioRawPattern, } impl EmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2 { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - empty: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "empty_outputs_output")), - op_return: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "op_return_output")), - p2a: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2a_output")), - p2ms: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2ms_output")), - p2pk33: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2pk33_output")), - p2pk65: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2pk65_output")), - p2pkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2pkh_output")), - p2sh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2sh_output")), - p2tr: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2tr_output")), - p2wpkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2wpkh_output")), - p2wsh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2wsh_output")), - unknown: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "unknown_outputs_output")), + empty: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "empty_outputs_output")), + op_return: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "op_return_output")), + p2a: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2a_output")), + p2ms: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2ms_output")), + p2pk33: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2pk33_output")), + p2pk65: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2pk65_output")), + p2pkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2pkh_output")), + p2sh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2sh_output")), + p2tr: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2tr_output")), + p2wpkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2wpkh_output")), + p2wsh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2wsh_output")), + unknown: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "unknown_outputs_output")), } } } @@ -1371,34 +1371,34 @@ impl AverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern { /// Pattern struct for repeated tree structure. pub struct EmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2 { - pub empty: _1m1w1y24hBpsPercentRatioPattern, - pub p2a: _1m1w1y24hBpsPercentRatioPattern, - pub p2ms: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk33: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk65: _1m1w1y24hBpsPercentRatioPattern, - pub p2pkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2sh: _1m1w1y24hBpsPercentRatioPattern, - pub p2tr: _1m1w1y24hBpsPercentRatioPattern, - pub p2wpkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2wsh: _1m1w1y24hBpsPercentRatioPattern, - pub unknown: _1m1w1y24hBpsPercentRatioPattern, + pub empty: _1m1w1y24hPercentRatioRawPattern, + pub p2a: _1m1w1y24hPercentRatioRawPattern, + pub p2ms: _1m1w1y24hPercentRatioRawPattern, + pub p2pk33: _1m1w1y24hPercentRatioRawPattern, + pub p2pk65: _1m1w1y24hPercentRatioRawPattern, + pub p2pkh: _1m1w1y24hPercentRatioRawPattern, + pub p2sh: _1m1w1y24hPercentRatioRawPattern, + pub p2tr: _1m1w1y24hPercentRatioRawPattern, + pub p2wpkh: _1m1w1y24hPercentRatioRawPattern, + pub p2wsh: _1m1w1y24hPercentRatioRawPattern, + pub unknown: _1m1w1y24hPercentRatioRawPattern, } impl EmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2 { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - empty: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "empty_outputs_prevout")), - p2a: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2a_prevout")), - p2ms: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2ms_prevout")), - p2pk33: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2pk33_prevout")), - p2pk65: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2pk65_prevout")), - p2pkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2pkh_prevout")), - p2sh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2sh_prevout")), - p2tr: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2tr_prevout")), - p2wpkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2wpkh_prevout")), - p2wsh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "p2wsh_prevout")), - unknown: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "unknown_outputs_prevout")), + empty: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "empty_outputs_prevout")), + p2a: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2a_prevout")), + p2ms: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2ms_prevout")), + p2pk33: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2pk33_prevout")), + p2pk65: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2pk65_prevout")), + p2pkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2pkh_prevout")), + p2sh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2sh_prevout")), + p2tr: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2tr_prevout")), + p2wpkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2wpkh_prevout")), + p2wsh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "p2wsh_prevout")), + unknown: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "unknown_outputs_prevout")), } } } @@ -1515,30 +1515,30 @@ impl AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6 { /// Pattern struct for repeated tree structure. pub struct AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern5 { - pub all: BpsPercentRatioPattern2, - pub p2a: BpsPercentRatioPattern2, - pub p2pk33: BpsPercentRatioPattern2, - pub p2pk65: BpsPercentRatioPattern2, - pub p2pkh: BpsPercentRatioPattern2, - pub p2sh: BpsPercentRatioPattern2, - pub p2tr: BpsPercentRatioPattern2, - pub p2wpkh: BpsPercentRatioPattern2, - pub p2wsh: BpsPercentRatioPattern2, + pub all: PercentRatioRawPattern2, + pub p2a: PercentRatioRawPattern2, + pub p2pk33: PercentRatioRawPattern2, + pub p2pk65: PercentRatioRawPattern2, + pub p2pkh: PercentRatioRawPattern2, + pub p2sh: PercentRatioRawPattern2, + pub p2tr: PercentRatioRawPattern2, + pub p2wpkh: PercentRatioRawPattern2, + pub p2wsh: PercentRatioRawPattern2, } impl AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern5 { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - all: BpsPercentRatioPattern2::new(client.clone(), acc.clone()), - p2a: BpsPercentRatioPattern2::new(client.clone(), _p("p2a", &acc)), - p2pk33: BpsPercentRatioPattern2::new(client.clone(), _p("p2pk33", &acc)), - p2pk65: BpsPercentRatioPattern2::new(client.clone(), _p("p2pk65", &acc)), - p2pkh: BpsPercentRatioPattern2::new(client.clone(), _p("p2pkh", &acc)), - p2sh: BpsPercentRatioPattern2::new(client.clone(), _p("p2sh", &acc)), - p2tr: BpsPercentRatioPattern2::new(client.clone(), _p("p2tr", &acc)), - p2wpkh: BpsPercentRatioPattern2::new(client.clone(), _p("p2wpkh", &acc)), - p2wsh: BpsPercentRatioPattern2::new(client.clone(), _p("p2wsh", &acc)), + all: PercentRatioRawPattern2::new(client.clone(), acc.clone()), + p2a: PercentRatioRawPattern2::new(client.clone(), _p("p2a", &acc)), + p2pk33: PercentRatioRawPattern2::new(client.clone(), _p("p2pk33", &acc)), + p2pk65: PercentRatioRawPattern2::new(client.clone(), _p("p2pk65", &acc)), + p2pkh: PercentRatioRawPattern2::new(client.clone(), _p("p2pkh", &acc)), + p2sh: PercentRatioRawPattern2::new(client.clone(), _p("p2sh", &acc)), + p2tr: PercentRatioRawPattern2::new(client.clone(), _p("p2tr", &acc)), + p2wpkh: PercentRatioRawPattern2::new(client.clone(), _p("p2wpkh", &acc)), + p2wsh: PercentRatioRawPattern2::new(client.clone(), _p("p2wsh", &acc)), } } } @@ -1575,30 +1575,30 @@ impl AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern4 { /// Pattern struct for repeated tree structure. pub struct AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7 { - pub all: _1m1w1y24hBpsPercentRatioPattern, - pub p2a: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk33: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk65: _1m1w1y24hBpsPercentRatioPattern, - pub p2pkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2sh: _1m1w1y24hBpsPercentRatioPattern, - pub p2tr: _1m1w1y24hBpsPercentRatioPattern, - pub p2wpkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2wsh: _1m1w1y24hBpsPercentRatioPattern, + pub all: _1m1w1y24hPercentRatioRawPattern, + pub p2a: _1m1w1y24hPercentRatioRawPattern, + pub p2pk33: _1m1w1y24hPercentRatioRawPattern, + pub p2pk65: _1m1w1y24hPercentRatioRawPattern, + pub p2pkh: _1m1w1y24hPercentRatioRawPattern, + pub p2sh: _1m1w1y24hPercentRatioRawPattern, + pub p2tr: _1m1w1y24hPercentRatioRawPattern, + pub p2wpkh: _1m1w1y24hPercentRatioRawPattern, + pub p2wsh: _1m1w1y24hPercentRatioRawPattern, } impl AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7 { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - all: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), acc.clone()), - p2a: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2a", &acc)), - p2pk33: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2pk33", &acc)), - p2pk65: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2pk65", &acc)), - p2pkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2pkh", &acc)), - p2sh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2sh", &acc)), - p2tr: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2tr", &acc)), - p2wpkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2wpkh", &acc)), - p2wsh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _p("p2wsh", &acc)), + all: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), acc.clone()), + p2a: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2a", &acc)), + p2pk33: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2pk33", &acc)), + p2pk65: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2pk65", &acc)), + p2pkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2pkh", &acc)), + p2sh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2sh", &acc)), + p2tr: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2tr", &acc)), + p2wpkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2wpkh", &acc)), + p2wsh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _p("p2wsh", &acc)), } } } @@ -1641,7 +1641,7 @@ pub struct CapitalizedGrossInvestedLossNetNuplProfitSentimentPattern2 { pub invested_capital: InPattern2, pub loss: CentsNegativeToUsdPattern2, pub net_pnl: CentsToUsdPattern3, - pub nupl: BpsRatioPattern, + pub nupl: RatioRawPattern, pub profit: CentsToUsdPattern4, pub sentiment: GreedNetPainPattern, } @@ -1656,7 +1656,7 @@ impl CapitalizedGrossInvestedLossNetNuplProfitSentimentPattern2 { invested_capital: InPattern2::new(client.clone(), _m(&acc, "invested_capital_in")), loss: CentsNegativeToUsdPattern2::new(client.clone(), _m(&acc, "unrealized_loss")), net_pnl: CentsToUsdPattern3::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + nupl: RatioRawPattern::new(client.clone(), _m(&acc, "nupl")), profit: CentsToUsdPattern4::new(client.clone(), _m(&acc, "unrealized_profit")), sentiment: GreedNetPainPattern::new(client.clone(), acc.clone()), } @@ -1664,11 +1664,11 @@ impl CapitalizedGrossInvestedLossNetNuplProfitSentimentPattern2 { } /// Pattern struct for repeated tree structure. -pub struct BpsCentsPercentilesRatioSatsSmaStdUsdPattern { - pub bps: SeriesPattern1, +pub struct CentsPercentilesRatioRawSatsSmaStdUsdPattern { pub cents: SeriesPattern1, pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, pub sats: SeriesPattern1, pub sma: _1m1w1y2y4yAllPattern, pub std_dev: _1y2y4yAllPattern, @@ -1677,80 +1677,80 @@ pub struct BpsCentsPercentilesRatioSatsSmaStdUsdPattern { /// Pattern struct for repeated tree structure. pub struct Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern { - pub pct0_5: BpsPriceRatioPattern, - pub pct1: BpsPriceRatioPattern, - pub pct2: BpsPriceRatioPattern, - pub pct5: BpsPriceRatioPattern, - pub pct95: BpsPriceRatioPattern, - pub pct98: BpsPriceRatioPattern, - pub pct99: BpsPriceRatioPattern, - pub pct99_5: BpsPriceRatioPattern, + pub pct0_5: PriceRatioRawPattern, + pub pct1: PriceRatioRawPattern, + pub pct2: PriceRatioRawPattern, + pub pct5: PriceRatioRawPattern, + pub pct95: PriceRatioRawPattern, + pub pct98: PriceRatioRawPattern, + pub pct99: PriceRatioRawPattern, + pub pct99_5: PriceRatioRawPattern, } impl Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - pct0_5: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct0_5".to_string()), - pct1: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct1".to_string()), - pct2: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct2".to_string()), - pct5: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct5".to_string()), - pct95: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct95".to_string()), - pct98: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct98".to_string()), - pct99: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct99".to_string()), - pct99_5: BpsPriceRatioPattern::new(client.clone(), acc.clone(), "pct99_5".to_string()), + pct0_5: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct0_5".to_string()), + pct1: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct1".to_string()), + pct2: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct2".to_string()), + pct5: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct5".to_string()), + pct95: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct95".to_string()), + pct98: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct98".to_string()), + pct99: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct99".to_string()), + pct99_5: PriceRatioRawPattern::new(client.clone(), acc.clone(), "pct99_5".to_string()), } } } /// Pattern struct for repeated tree structure. pub struct _10y2y3y4y5y6y8yPattern { - pub _10y: BpsPercentRatioPattern, - pub _2y: BpsPercentRatioPattern, - pub _3y: BpsPercentRatioPattern, - pub _4y: BpsPercentRatioPattern, - pub _5y: BpsPercentRatioPattern, - pub _6y: BpsPercentRatioPattern, - pub _8y: BpsPercentRatioPattern, + pub _10y: PercentRatioRawPattern, + pub _2y: PercentRatioRawPattern, + pub _3y: PercentRatioRawPattern, + pub _4y: PercentRatioRawPattern, + pub _5y: PercentRatioRawPattern, + pub _6y: PercentRatioRawPattern, + pub _8y: PercentRatioRawPattern, } impl _10y2y3y4y5y6y8yPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - _10y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "10y")), - _2y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "2y")), - _3y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "3y")), - _4y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "4y")), - _5y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "5y")), - _6y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "6y")), - _8y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "8y")), + _10y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "10y")), + _2y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "2y")), + _3y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "3y")), + _4y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "4y")), + _5y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "5y")), + _6y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "6y")), + _8y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "8y")), } } } /// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hBpsPercentRatioPattern { - pub _1m: BpsPercentRatioPattern2, - pub _1w: BpsPercentRatioPattern2, - pub _1y: BpsPercentRatioPattern2, - pub _24h: BpsPercentRatioPattern2, - pub bps: SeriesPattern1, +pub struct _1m1w1y24hPercentRatioRawPattern { + pub _1m: PercentRatioRawPattern2, + pub _1w: PercentRatioRawPattern2, + pub _1y: PercentRatioRawPattern2, + pub _24h: PercentRatioRawPattern2, pub percent: SeriesPattern1, pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, } -impl _1m1w1y24hBpsPercentRatioPattern { +impl _1m1w1y24hPercentRatioRawPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - _1m: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "1m")), - _1w: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "1w")), - _1y: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "1y")), - _24h: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "24h")), - bps: SeriesPattern1::new(client.clone(), _m(&acc, "bps")), + _1m: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "1m")), + _1w: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "1w")), + _1y: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "1y")), + _24h: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "24h")), percent: SeriesPattern1::new(client.clone(), acc.clone()), ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ppm")), } } } @@ -1763,7 +1763,7 @@ pub struct ActiveInputOutputSpendablePattern { pub input_from_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7, pub output_to_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6, pub output_to_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7, - pub spendable_output_to_reused_addr_share: _1m1w1y24hBpsPercentRatioPattern, + pub spendable_output_to_reused_addr_share: _1m1w1y24hPercentRatioRawPattern, } /// Pattern struct for repeated tree structure. @@ -1783,7 +1783,7 @@ pub struct CapLossMvrvNetPriceProfitSoprPattern { pub loss: BlockCumulativeNegativeSumPattern, pub mvrv: SeriesPattern1, pub net_pnl: BlockCumulativeDeltaSumPattern, - pub price: BpsCentsRatioSatsUsdPattern, + pub price: CentsRatioRawSatsUsdPattern, pub profit: BlockCumulativeSumPattern, pub sopr: RatioValuePattern, } @@ -1796,7 +1796,7 @@ impl CapLossMvrvNetPriceProfitSoprPattern { loss: BlockCumulativeNegativeSumPattern::new(client.clone(), _m(&acc, "realized_loss")), mvrv: SeriesPattern1::new(client.clone(), _m(&acc, "mvrv")), net_pnl: BlockCumulativeDeltaSumPattern::new(client.clone(), _m(&acc, "net_realized_pnl")), - price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + price: CentsRatioRawSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), profit: BlockCumulativeSumPattern::new(client.clone(), _m(&acc, "realized_profit")), sopr: RatioValuePattern::new(client.clone(), acc.clone()), } @@ -1811,7 +1811,7 @@ pub struct InMaxMinPerSupplyPattern { pub min: CentsSatsUsdPattern, pub per_coin: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, pub per_dollar: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, - pub supply_density: BpsPercentRatioPattern2, + pub supply_density: PercentRatioRawPattern2, } impl InMaxMinPerSupplyPattern { @@ -1824,7 +1824,7 @@ impl InMaxMinPerSupplyPattern { min: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "cost_basis_min")), per_coin: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), _m(&acc, "cost_basis_per_coin")), per_dollar: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), _m(&acc, "cost_basis_per_dollar")), - supply_density: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "supply_density")), + supply_density: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "supply_density")), } } } @@ -1883,24 +1883,24 @@ impl MaxMedianMinPct10Pct25Pct75Pct90Pattern { /// Pattern struct for repeated tree structure. pub struct _1m1w1y2y4yAllPattern { - pub _1m: BpsRatioPattern2, - pub _1w: BpsRatioPattern2, - pub _1y: BpsRatioPattern2, - pub _2y: BpsRatioPattern2, - pub _4y: BpsRatioPattern2, - pub all: BpsRatioPattern2, + pub _1m: RatioRawPattern2, + pub _1w: RatioRawPattern2, + pub _1y: RatioRawPattern2, + pub _2y: RatioRawPattern2, + pub _4y: RatioRawPattern2, + pub all: RatioRawPattern2, } impl _1m1w1y2y4yAllPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - _1m: BpsRatioPattern2::new(client.clone(), _m(&acc, "1m")), - _1w: BpsRatioPattern2::new(client.clone(), _m(&acc, "1w")), - _1y: BpsRatioPattern2::new(client.clone(), _m(&acc, "1y")), - _2y: BpsRatioPattern2::new(client.clone(), _m(&acc, "2y")), - _4y: BpsRatioPattern2::new(client.clone(), _m(&acc, "4y")), - all: BpsRatioPattern2::new(client.clone(), _m(&acc, "all")), + _1m: RatioRawPattern2::new(client.clone(), _m(&acc, "1m")), + _1w: RatioRawPattern2::new(client.clone(), _m(&acc, "1w")), + _1y: RatioRawPattern2::new(client.clone(), _m(&acc, "1y")), + _2y: RatioRawPattern2::new(client.clone(), _m(&acc, "2y")), + _4y: RatioRawPattern2::new(client.clone(), _m(&acc, "4y")), + all: RatioRawPattern2::new(client.clone(), _m(&acc, "all")), } } } @@ -1953,37 +1953,13 @@ impl AverageBlockCumulativeInSumPattern { } } -/// Pattern struct for repeated tree structure. -pub struct BpsCentsPercentilesRatioSatsUsdPattern { - pub bps: SeriesPattern1, - pub cents: SeriesPattern1, - pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, - pub ratio: SeriesPattern1, - pub sats: SeriesPattern1, - pub usd: SeriesPattern1, -} - -impl BpsCentsPercentilesRatioSatsUsdPattern { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "ratio_bps")), - cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), - percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), acc.clone()), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), - sats: SeriesPattern1::new(client.clone(), _m(&acc, "sats")), - usd: SeriesPattern1::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct CentsNegativeToUsdPattern2 { pub cents: SeriesPattern1, pub negative: SeriesPattern1, - pub to_mcap: BpsPercentRatioPattern2, - pub to_own_gross_pnl: BpsPercentRatioPattern2, - pub to_own_mcap: BpsPercentRatioPattern4, + pub to_mcap: PercentRatioRawPattern2, + pub to_own_gross_pnl: PercentRatioRawPattern2, + pub to_own_mcap: PercentRatioRawPattern2, pub usd: SeriesPattern1, } @@ -1993,9 +1969,33 @@ impl CentsNegativeToUsdPattern2 { Self { cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), negative: SeriesPattern1::new(client.clone(), _m(&acc, "neg")), - to_mcap: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "to_mcap")), - to_own_gross_pnl: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "to_own_gross_pnl")), - to_own_mcap: BpsPercentRatioPattern4::new(client.clone(), _m(&acc, "to_own_mcap")), + to_mcap: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "to_mcap")), + to_own_gross_pnl: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "to_own_gross_pnl")), + to_own_mcap: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "to_own_mcap")), + usd: SeriesPattern1::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CentsPercentilesRatioRawSatsUsdPattern { + pub cents: SeriesPattern1, + pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, + pub sats: SeriesPattern1, + pub usd: SeriesPattern1, +} + +impl CentsPercentilesRatioRawSatsUsdPattern { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), + percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), acc.clone()), + ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ratio_ppm")), + sats: SeriesPattern1::new(client.clone(), _m(&acc, "sats")), usd: SeriesPattern1::new(client.clone(), acc.clone()), } } @@ -2003,9 +2003,9 @@ impl CentsNegativeToUsdPattern2 { /// Pattern struct for repeated tree structure. pub struct ChainDataOutputTxPattern { - pub chain_share: BpsPercentRatioPattern2, + pub chain_share: PercentRatioRawPattern2, pub data_bytes: AverageBlockCumulativeSumPattern, - pub data_share: BpsPercentRatioPattern2, + pub data_share: PercentRatioRawPattern2, pub output_count: AverageBlockCumulativeSumPattern, pub tx_count: AverageBlockCumulativeSumPattern, pub tx_vsize: AverageBlockCumulativeSumPattern, @@ -2015,9 +2015,9 @@ impl ChainDataOutputTxPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - chain_share: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "chain_share")), + chain_share: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "chain_share")), data_bytes: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "data_bytes")), - data_share: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "data_share")), + data_share: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "data_share")), output_count: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "output_count")), tx_count: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "tx_count")), tx_vsize: AverageBlockCumulativeSumPattern::new(client.clone(), _m(&acc, "tx_vsize")), @@ -2028,7 +2028,7 @@ impl ChainDataOutputTxPattern { /// Pattern struct for repeated tree structure. pub struct DeltaDominanceHalfInTotalPattern2 { pub delta: AbsoluteRatePattern3, - pub dominance: BpsPercentRatioPattern2, + pub dominance: PercentRatioRawPattern2, pub half: BtcCentsSatsUsdPattern, pub in_loss: BtcCentsSatsShareUsdPattern, pub in_profit: BtcCentsSatsShareUsdPattern, @@ -2040,7 +2040,7 @@ impl DeltaDominanceHalfInTotalPattern2 { pub fn new(client: Arc, acc: String) -> Self { Self { delta: AbsoluteRatePattern3::new(client.clone(), _m(&acc, "delta")), - dominance: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "dominance")), + dominance: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "dominance")), half: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "half")), in_loss: BtcCentsSatsShareUsdPattern::new(client.clone(), _m(&acc, "in_loss")), in_profit: BtcCentsSatsShareUsdPattern::new(client.clone(), _m(&acc, "in_profit")), @@ -2052,7 +2052,7 @@ impl DeltaDominanceHalfInTotalPattern2 { /// Pattern struct for repeated tree structure. pub struct DeltaDominanceHalfInTotalPattern { pub delta: AbsoluteRatePattern3, - pub dominance: BpsPercentRatioPattern2, + pub dominance: PercentRatioRawPattern2, pub half: BtcCentsSatsUsdPattern, pub in_loss: BtcCentsSatsUsdPattern, pub in_profit: BtcCentsSatsUsdPattern, @@ -2064,7 +2064,7 @@ impl DeltaDominanceHalfInTotalPattern { pub fn new(client: Arc, acc: String) -> Self { Self { delta: AbsoluteRatePattern3::new(client.clone(), _m(&acc, "delta")), - dominance: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "dominance")), + dominance: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "dominance")), half: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "half")), in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "in_loss")), in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "in_profit")), @@ -2227,28 +2227,6 @@ impl BlockChangeCumulativeDeltaSumPattern { } } -/// Pattern struct for repeated tree structure. -pub struct BpsCentsRatioSatsUsdPattern { - pub bps: SeriesPattern1, - pub cents: SeriesPattern1, - pub ratio: SeriesPattern1, - pub sats: SeriesPattern1, - pub usd: SeriesPattern1, -} - -impl BpsCentsRatioSatsUsdPattern { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "ratio_bps")), - cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), - sats: SeriesPattern1::new(client.clone(), _m(&acc, "sats")), - usd: SeriesPattern1::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct BtcCentsDeltaSatsUsdPattern { pub btc: SeriesPattern1, @@ -2276,7 +2254,7 @@ pub struct BtcCentsSatsShareUsdPattern { pub btc: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub share: BpsPercentRatioPattern2, + pub share: PercentRatioRawPattern2, pub usd: SeriesPattern1, } @@ -2287,7 +2265,7 @@ impl BtcCentsSatsShareUsdPattern { btc: SeriesPattern1::new(client.clone(), acc.clone()), cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), sats: SeriesPattern1::new(client.clone(), _m(&acc, "sats")), - share: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "share")), + share: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "share")), usd: SeriesPattern1::new(client.clone(), _m(&acc, "usd")), } } @@ -2298,7 +2276,7 @@ pub struct CapLossMvrvPriceProfitPattern { pub cap: CentsDeltaUsdPattern, pub loss: BlockCumulativeSumPattern, pub mvrv: SeriesPattern1, - pub price: BpsCentsRatioSatsUsdPattern, + pub price: CentsRatioRawSatsUsdPattern, pub profit: BlockCumulativeSumPattern, } @@ -2309,18 +2287,40 @@ impl CapLossMvrvPriceProfitPattern { cap: CentsDeltaUsdPattern::new(client.clone(), _m(&acc, "realized_cap")), loss: BlockCumulativeSumPattern::new(client.clone(), _m(&acc, "realized_loss")), mvrv: SeriesPattern1::new(client.clone(), _m(&acc, "mvrv")), - price: BpsCentsRatioSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), + price: CentsRatioRawSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")), profit: BlockCumulativeSumPattern::new(client.clone(), _m(&acc, "realized_profit")), } } } +/// Pattern struct for repeated tree structure. +pub struct CentsRatioRawSatsUsdPattern { + pub cents: SeriesPattern1, + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, + pub sats: SeriesPattern1, + pub usd: SeriesPattern1, +} + +impl CentsRatioRawSatsUsdPattern { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), + ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ratio_ppm")), + sats: SeriesPattern1::new(client.clone(), _m(&acc, "sats")), + usd: SeriesPattern1::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct CentsToUsdPattern4 { pub cents: SeriesPattern1, - pub to_mcap: BpsPercentRatioPattern2, - pub to_own_gross_pnl: BpsPercentRatioPattern2, - pub to_own_mcap: BpsPercentRatioPattern2, + pub to_mcap: PercentRatioRawPattern2, + pub to_own_gross_pnl: PercentRatioRawPattern2, + pub to_own_mcap: PercentRatioRawPattern2, pub usd: SeriesPattern1, } @@ -2329,9 +2329,9 @@ impl CentsToUsdPattern4 { pub fn new(client: Arc, acc: String) -> Self { Self { cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), - to_mcap: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "to_mcap")), - to_own_gross_pnl: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "to_own_gross_pnl")), - to_own_mcap: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "to_own_mcap")), + to_mcap: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "to_mcap")), + to_own_gross_pnl: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "to_own_gross_pnl")), + to_own_mcap: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "to_own_mcap")), usd: SeriesPattern1::new(client.clone(), acc.clone()), } } @@ -2350,7 +2350,7 @@ pub struct EmaHistogramLineSignalPattern { pub struct PhsReboundThsPattern { pub phs: SeriesPattern1, pub phs_min: SeriesPattern1, - pub rebound: BpsPercentRatioPattern, + pub rebound: PercentRatioRawPattern, pub ths: SeriesPattern1, pub ths_min: SeriesPattern1, } @@ -2361,53 +2361,13 @@ impl PhsReboundThsPattern { Self { phs: SeriesPattern1::new(client.clone(), _m(&acc, "phs")), phs_min: SeriesPattern1::new(client.clone(), _m(&acc, "phs_min")), - rebound: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rebound")), + rebound: PercentRatioRawPattern::new(client.clone(), _m(&acc, "rebound")), ths: SeriesPattern1::new(client.clone(), _m(&acc, "ths")), ths_min: SeriesPattern1::new(client.clone(), _m(&acc, "ths_min")), } } } -/// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern2 { - pub _1m: BpsPercentRatioPattern, - pub _1w: BpsPercentRatioPattern, - pub _1y: BpsPercentRatioPattern, - pub _24h: BpsPercentRatioPattern, -} - -impl _1m1w1y24hPattern2 { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1m_rate")), - _1w: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1w_rate")), - _1y: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "1y_rate")), - _24h: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "24h_rate")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _1m1w1y24hPattern8 { - pub _1m: BpsPercentRatioPattern4, - pub _1w: BpsPercentRatioPattern4, - pub _1y: BpsPercentRatioPattern4, - pub _24h: BpsPercentRatioPattern4, -} - -impl _1m1w1y24hPattern8 { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _1m: BpsPercentRatioPattern4::new(client.clone(), _m(&acc, "1m")), - _1w: BpsPercentRatioPattern4::new(client.clone(), _m(&acc, "1w")), - _1y: BpsPercentRatioPattern4::new(client.clone(), _m(&acc, "1y")), - _24h: BpsPercentRatioPattern4::new(client.clone(), _m(&acc, "24h")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct _1m1w1y24hPattern4 { pub _1m: BtcCentsSatsUsdPattern, @@ -2528,6 +2488,46 @@ impl _1m1w1y24hPattern6 { } } +/// Pattern struct for repeated tree structure. +pub struct _1m1w1y24hPattern2 { + pub _1m: PercentRatioRawPattern, + pub _1w: PercentRatioRawPattern, + pub _1y: PercentRatioRawPattern, + pub _24h: PercentRatioRawPattern, +} + +impl _1m1w1y24hPattern2 { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: PercentRatioRawPattern::new(client.clone(), _m(&acc, "1m_rate")), + _1w: PercentRatioRawPattern::new(client.clone(), _m(&acc, "1w_rate")), + _1y: PercentRatioRawPattern::new(client.clone(), _m(&acc, "1y_rate")), + _24h: PercentRatioRawPattern::new(client.clone(), _m(&acc, "24h_rate")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1m1w1y24hPattern8 { + pub _1m: PercentRatioRawPattern2, + pub _1w: PercentRatioRawPattern2, + pub _1y: PercentRatioRawPattern2, + pub _24h: PercentRatioRawPattern2, +} + +impl _1m1w1y24hPattern8 { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _1m: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "1m")), + _1w: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "1w")), + _1y: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "1y")), + _24h: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "24h")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _1y2y4yAllPattern { pub _1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern, @@ -2680,7 +2680,7 @@ impl BtcCentsSatsUsdPattern3 { pub struct CentsDeltaToUsdPattern { pub cents: SeriesPattern1, pub delta: AbsoluteRatePattern2, - pub to_own_mcap: BpsPercentRatioPattern4, + pub to_own_mcap: PercentRatioRawPattern2, pub usd: SeriesPattern1, } @@ -2690,7 +2690,7 @@ impl CentsDeltaToUsdPattern { Self { cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), delta: AbsoluteRatePattern2::new(client.clone(), _m(&acc, "delta")), - to_own_mcap: BpsPercentRatioPattern4::new(client.clone(), _m(&acc, "to_own_mcap")), + to_own_mcap: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "to_own_mcap")), usd: SeriesPattern1::new(client.clone(), acc.clone()), } } @@ -2699,8 +2699,8 @@ impl CentsDeltaToUsdPattern { /// Pattern struct for repeated tree structure. pub struct CentsToUsdPattern3 { pub cents: SeriesPattern1, - pub to_own_gross_pnl: BpsPercentRatioPattern, - pub to_own_mcap: BpsPercentRatioPattern, + pub to_own_gross_pnl: PercentRatioRawPattern3, + pub to_own_mcap: PercentRatioRawPattern3, pub usd: SeriesPattern1, } @@ -2709,8 +2709,8 @@ impl CentsToUsdPattern3 { pub fn new(client: Arc, acc: String) -> Self { Self { cents: SeriesPattern1::new(client.clone(), _m(&acc, "cents")), - to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "to_own_gross_pnl")), - to_own_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "to_own_mcap")), + to_own_gross_pnl: PercentRatioRawPattern3::new(client.clone(), _m(&acc, "to_own_gross_pnl")), + to_own_mcap: PercentRatioRawPattern3::new(client.clone(), _m(&acc, "to_own_mcap")), usd: SeriesPattern1::new(client.clone(), acc.clone()), } } @@ -2740,7 +2740,7 @@ impl CoindaysCoinyearsDormancyTransferPattern { pub struct LossNetNuplProfitPattern { pub loss: CentsNegativeUsdPattern, pub net_pnl: CentsUsdPattern, - pub nupl: BpsRatioPattern, + pub nupl: RatioRawPattern, pub profit: CentsUsdPattern3, } @@ -2750,7 +2750,7 @@ impl LossNetNuplProfitPattern { Self { loss: CentsNegativeUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), net_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + nupl: RatioRawPattern::new(client.clone(), _m(&acc, "nupl")), profit: CentsUsdPattern3::new(client.clone(), _m(&acc, "unrealized_profit")), } } @@ -2758,7 +2758,7 @@ impl LossNetNuplProfitPattern { /// Pattern struct for repeated tree structure. pub struct NuplRealizedSupplyUnrealizedPattern { - pub nupl: BpsRatioPattern, + pub nupl: RatioRawPattern, pub realized_cap: AllSthPattern, pub supply: AllSthPattern2, pub unrealized_pnl: AllSthPattern, @@ -2768,7 +2768,7 @@ impl NuplRealizedSupplyUnrealizedPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + nupl: RatioRawPattern::new(client.clone(), _m(&acc, "nupl")), realized_cap: AllSthPattern::new(client.clone(), acc.clone(), "realized_cap".to_string()), supply: AllSthPattern2::new(client.clone(), acc.clone()), unrealized_pnl: AllSthPattern::new(client.clone(), acc.clone(), "unrealized_pnl".to_string()), @@ -2855,7 +2855,7 @@ impl BlockCumulativeSumPattern { /// Pattern struct for repeated tree structure. pub struct BlocksDominanceRewardsPattern { pub blocks_mined: AverageBlockCumulativeSumPattern2, - pub dominance: _1m1w1y24hBpsPercentRatioPattern, + pub dominance: _1m1w1y24hPercentRatioRawPattern, pub rewards: AverageBlockCumulativeSumPattern3, } @@ -2864,102 +2864,12 @@ impl BlocksDominanceRewardsPattern { pub fn new(client: Arc, acc: String) -> Self { Self { blocks_mined: AverageBlockCumulativeSumPattern2::new(client.clone(), _m(&acc, "blocks_mined")), - dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), _m(&acc, "dominance")), + dominance: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), _m(&acc, "dominance")), rewards: AverageBlockCumulativeSumPattern3::new(client.clone(), _m(&acc, "rewards")), } } } -/// Pattern struct for repeated tree structure. -pub struct BpsPercentRatioPattern2 { - pub bps: SeriesPattern1, - pub percent: SeriesPattern1, - pub ratio: SeriesPattern1, -} - -impl BpsPercentRatioPattern2 { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "bps")), - percent: SeriesPattern1::new(client.clone(), acc.clone()), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct BpsPercentRatioPattern4 { - pub bps: SeriesPattern1, - pub percent: SeriesPattern1, - pub ratio: SeriesPattern1, -} - -impl BpsPercentRatioPattern4 { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "bps")), - percent: SeriesPattern1::new(client.clone(), acc.clone()), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct BpsPriceRatioPattern { - pub bps: SeriesPattern1, - pub price: CentsSatsUsdPattern, - pub ratio: SeriesPattern1, -} - -impl BpsPriceRatioPattern { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String, disc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, &format!("ratio_{disc}_bps", disc=disc))), - price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, &disc)), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, &format!("ratio_{disc}", disc=disc))), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct BpsPercentRatioPattern5 { - pub bps: SeriesPattern1, - pub percent: SeriesPattern1, - pub ratio: SeriesPattern1, -} - -impl BpsPercentRatioPattern5 { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "bps")), - percent: SeriesPattern1::new(client.clone(), acc.clone()), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct BpsPercentRatioPattern { - pub bps: SeriesPattern1, - pub percent: SeriesPattern1, - pub ratio: SeriesPattern1, -} - -impl BpsPercentRatioPattern { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "bps")), - percent: SeriesPattern1::new(client.clone(), acc.clone()), - ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct CentsSatsUsdPattern3 { pub cents: SeriesPattern2, @@ -3060,7 +2970,7 @@ impl CumulativeRollingSumPattern { /// Pattern struct for repeated tree structure. pub struct DeltaDominanceTotalPattern { pub delta: AbsoluteRatePattern3, - pub dominance: BpsPercentRatioPattern2, + pub dominance: PercentRatioRawPattern2, pub total: BtcCentsSatsUsdPattern, } @@ -3069,7 +2979,7 @@ impl DeltaDominanceTotalPattern { pub fn new(client: Arc, acc: String) -> Self { Self { delta: AbsoluteRatePattern3::new(client.clone(), _m(&acc, "delta")), - dominance: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "dominance")), + dominance: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "dominance")), total: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()), } } @@ -3096,7 +3006,7 @@ impl GreedNetPainPattern { /// Pattern struct for repeated tree structure. pub struct LossNuplProfitPattern { pub loss: CentsNegativeUsdPattern, - pub nupl: BpsRatioPattern, + pub nupl: RatioRawPattern, pub profit: CentsUsdPattern3, } @@ -3105,12 +3015,84 @@ impl LossNuplProfitPattern { pub fn new(client: Arc, acc: String) -> Self { Self { loss: CentsNegativeUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")), - nupl: BpsRatioPattern::new(client.clone(), _m(&acc, "nupl")), + nupl: RatioRawPattern::new(client.clone(), _m(&acc, "nupl")), profit: CentsUsdPattern3::new(client.clone(), _m(&acc, "unrealized_profit")), } } } +/// Pattern struct for repeated tree structure. +pub struct PercentRatioRawPattern2 { + pub percent: SeriesPattern1, + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, +} + +impl PercentRatioRawPattern2 { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + percent: SeriesPattern1::new(client.clone(), acc.clone()), + ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ppm")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct PercentRatioRawPattern3 { + pub percent: SeriesPattern1, + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, +} + +impl PercentRatioRawPattern3 { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + percent: SeriesPattern1::new(client.clone(), acc.clone()), + ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ppm")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct PercentRatioRawPattern { + pub percent: SeriesPattern1, + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, +} + +impl PercentRatioRawPattern { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + percent: SeriesPattern1::new(client.clone(), acc.clone()), + ratio: SeriesPattern1::new(client.clone(), _m(&acc, "ratio")), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ppm")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct PriceRatioRawPattern { + pub price: CentsSatsUsdPattern, + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, +} + +impl PriceRatioRawPattern { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String, disc: String) -> Self { + Self { + price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, &disc)), + ratio: SeriesPattern1::new(client.clone(), _m(&acc, &format!("ratio_{disc}", disc=disc))), + raw: SeriesPattern1::new(client.clone(), _m(&acc, &format!("ratio_{disc}_ppm", disc=disc))), + } + } +} + /// Pattern struct for repeated tree structure. pub struct RatioTransferValuePattern { pub ratio: _1m1w1y24hPattern, @@ -3131,18 +3113,18 @@ impl RatioTransferValuePattern { /// Pattern struct for repeated tree structure. pub struct RsiStochPattern { - pub rsi: BpsPercentRatioPattern2, - pub stoch_rsi_d: BpsPercentRatioPattern2, - pub stoch_rsi_k: BpsPercentRatioPattern2, + pub rsi: PercentRatioRawPattern2, + pub stoch_rsi_d: PercentRatioRawPattern2, + pub stoch_rsi_k: PercentRatioRawPattern2, } impl RsiStochPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String, disc: String) -> Self { Self { - rsi: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, &disc)), - stoch_rsi_d: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, &format!("stoch_d_{disc}", disc=disc))), - stoch_rsi_k: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, &format!("stoch_k_{disc}", disc=disc))), + rsi: PercentRatioRawPattern2::new(client.clone(), _m(&acc, &disc)), + stoch_rsi_d: PercentRatioRawPattern2::new(client.clone(), _m(&acc, &format!("stoch_d_{disc}", disc=disc))), + stoch_rsi_k: PercentRatioRawPattern2::new(client.clone(), _m(&acc, &format!("stoch_k_{disc}", disc=disc))), } } } @@ -3330,7 +3312,7 @@ impl BlockCumulativePattern { /// Pattern struct for repeated tree structure. pub struct BlocksDominancePattern { pub blocks_mined: AverageBlockCumulativeSumPattern2, - pub dominance: BpsPercentRatioPattern2, + pub dominance: PercentRatioRawPattern2, } impl BlocksDominancePattern { @@ -3338,39 +3320,7 @@ impl BlocksDominancePattern { pub fn new(client: Arc, acc: String) -> Self { Self { blocks_mined: AverageBlockCumulativeSumPattern2::new(client.clone(), _m(&acc, "blocks_mined")), - dominance: BpsPercentRatioPattern2::new(client.clone(), _m(&acc, "dominance")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct BpsRatioPattern2 { - pub bps: SeriesPattern1, - pub ratio: SeriesPattern1, -} - -impl BpsRatioPattern2 { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "bps")), - ratio: SeriesPattern1::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct BpsRatioPattern { - pub bps: SeriesPattern1, - pub ratio: SeriesPattern1, -} - -impl BpsRatioPattern { - /// Create a new pattern node with accumulated series name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bps: SeriesPattern1::new(client.clone(), _m(&acc, "bps")), - ratio: SeriesPattern1::new(client.clone(), acc.clone()), + dominance: PercentRatioRawPattern2::new(client.clone(), _m(&acc, "dominance")), } } } @@ -3551,6 +3501,54 @@ impl PriceRatioPattern { } } +/// Pattern struct for repeated tree structure. +pub struct RatioRawPattern2 { + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, +} + +impl RatioRawPattern2 { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + ratio: SeriesPattern1::new(client.clone(), acc.clone()), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ppm")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RatioRawPattern3 { + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, +} + +impl RatioRawPattern3 { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + ratio: SeriesPattern1::new(client.clone(), acc.clone()), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ppm")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct RatioRawPattern { + pub ratio: SeriesPattern1, + pub raw: SeriesPattern1, +} + +impl RatioRawPattern { + /// Create a new pattern node with accumulated series name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + ratio: SeriesPattern1::new(client.clone(), acc.clone()), + raw: SeriesPattern1::new(client.clone(), _m(&acc, "ppm")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct RatioValuePattern2 { pub ratio: _1m1w1y24hPattern, @@ -3591,16 +3589,16 @@ pub struct SdSmaPattern { /// Pattern struct for repeated tree structure. pub struct ToPattern { - pub to_mcap: BpsPercentRatioPattern, - pub to_rcap: BpsPercentRatioPattern, + pub to_mcap: PercentRatioRawPattern, + pub to_rcap: PercentRatioRawPattern, } impl ToPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - to_mcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "mcap")), - to_rcap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "rcap")), + to_mcap: PercentRatioRawPattern::new(client.clone(), _m(&acc, "mcap")), + to_rcap: PercentRatioRawPattern::new(client.clone(), _m(&acc, "rcap")), } } } @@ -3621,42 +3619,42 @@ impl _24hPattern { /// Pattern struct for repeated tree structure. pub struct NuplPattern { - pub nupl: BpsRatioPattern, + pub nupl: RatioRawPattern, } impl NuplPattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - nupl: BpsRatioPattern::new(client.clone(), acc.clone()), + nupl: RatioRawPattern::new(client.clone(), acc.clone()), } } } /// Pattern struct for repeated tree structure. pub struct PricePattern { - pub price: BpsCentsPercentilesRatioSatsUsdPattern, + pub price: CentsPercentilesRatioRawSatsUsdPattern, } impl PricePattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - price: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), acc.clone()), + price: CentsPercentilesRatioRawSatsUsdPattern::new(client.clone(), acc.clone()), } } } /// Pattern struct for repeated tree structure. pub struct SharePattern { - pub share: BpsPercentRatioPattern2, + pub share: PercentRatioRawPattern2, } impl SharePattern { /// Create a new pattern node with accumulated series name. pub fn new(client: Arc, acc: String) -> Self { Self { - share: BpsPercentRatioPattern2::new(client.clone(), acc.clone()), + share: PercentRatioRawPattern2::new(client.clone(), acc.clone()), } } } @@ -3769,7 +3767,7 @@ impl SeriesTree_Blocks { pub struct SeriesTree_Blocks_Difficulty { pub value: SeriesPattern1, pub hashrate: SeriesPattern1, - pub adjustment: BpsPercentRatioPattern, + pub adjustment: PercentRatioRawPattern3, pub epoch: SeriesPattern1, pub blocks_to_retarget: SeriesPattern1, pub days_to_retarget: SeriesPattern1, @@ -3780,7 +3778,7 @@ impl SeriesTree_Blocks_Difficulty { Self { value: SeriesPattern1::new(client.clone(), "difficulty".to_string()), hashrate: SeriesPattern1::new(client.clone(), "difficulty_hashrate".to_string()), - adjustment: BpsPercentRatioPattern::new(client.clone(), "difficulty_adjustment".to_string()), + adjustment: PercentRatioRawPattern3::new(client.clone(), "difficulty_adjustment".to_string()), epoch: SeriesPattern1::new(client.clone(), "difficulty_epoch".to_string()), blocks_to_retarget: SeriesPattern1::new(client.clone(), "blocks_to_retarget".to_string()), days_to_retarget: SeriesPattern1::new(client.clone(), "days_to_retarget".to_string()), @@ -3969,7 +3967,7 @@ impl SeriesTree_Blocks_Interval { /// Series tree node. pub struct SeriesTree_Blocks_Fullness { - pub bps: SeriesPattern18, + pub raw: SeriesPattern18, pub ratio: SeriesPattern18, pub percent: SeriesPattern18, } @@ -3977,7 +3975,7 @@ pub struct SeriesTree_Blocks_Fullness { impl SeriesTree_Blocks_Fullness { pub fn new(client: Arc, base_path: String) -> Self { Self { - bps: SeriesPattern18::new(client.clone(), "block_fullness_bps".to_string()), + raw: SeriesPattern18::new(client.clone(), "block_fullness_ppm".to_string()), ratio: SeriesPattern18::new(client.clone(), "block_fullness_ratio".to_string()), percent: SeriesPattern18::new(client.clone(), "block_fullness".to_string()), } @@ -4483,33 +4481,33 @@ impl SeriesTree_Inputs_ByType_InputCount { /// Series tree node. pub struct SeriesTree_Inputs_ByType_InputShare { - pub p2pk65: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk33: _1m1w1y24hBpsPercentRatioPattern, - pub p2pkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2ms: _1m1w1y24hBpsPercentRatioPattern, - pub p2sh: _1m1w1y24hBpsPercentRatioPattern, - pub p2wpkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2wsh: _1m1w1y24hBpsPercentRatioPattern, - pub p2tr: _1m1w1y24hBpsPercentRatioPattern, - pub p2a: _1m1w1y24hBpsPercentRatioPattern, - pub unknown: _1m1w1y24hBpsPercentRatioPattern, - pub empty: _1m1w1y24hBpsPercentRatioPattern, + pub p2pk65: _1m1w1y24hPercentRatioRawPattern, + pub p2pk33: _1m1w1y24hPercentRatioRawPattern, + pub p2pkh: _1m1w1y24hPercentRatioRawPattern, + pub p2ms: _1m1w1y24hPercentRatioRawPattern, + pub p2sh: _1m1w1y24hPercentRatioRawPattern, + pub p2wpkh: _1m1w1y24hPercentRatioRawPattern, + pub p2wsh: _1m1w1y24hPercentRatioRawPattern, + pub p2tr: _1m1w1y24hPercentRatioRawPattern, + pub p2a: _1m1w1y24hPercentRatioRawPattern, + pub unknown: _1m1w1y24hPercentRatioRawPattern, + pub empty: _1m1w1y24hPercentRatioRawPattern, } impl SeriesTree_Inputs_ByType_InputShare { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk65: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2pk65_prevout_share".to_string()), - p2pk33: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2pk33_prevout_share".to_string()), - p2pkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2pkh_prevout_share".to_string()), - p2ms: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2ms_prevout_share".to_string()), - p2sh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2sh_prevout_share".to_string()), - p2wpkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2wpkh_prevout_share".to_string()), - p2wsh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2wsh_prevout_share".to_string()), - p2tr: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2tr_prevout_share".to_string()), - p2a: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2a_prevout_share".to_string()), - unknown: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "unknown_outputs_prevout_share".to_string()), - empty: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "empty_outputs_prevout_share".to_string()), + p2pk65: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2pk65_prevout_share".to_string()), + p2pk33: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2pk33_prevout_share".to_string()), + p2pkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2pkh_prevout_share".to_string()), + p2ms: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2ms_prevout_share".to_string()), + p2sh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2sh_prevout_share".to_string()), + p2wpkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2wpkh_prevout_share".to_string()), + p2wsh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2wsh_prevout_share".to_string()), + p2tr: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2tr_prevout_share".to_string()), + p2a: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2a_prevout_share".to_string()), + unknown: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "unknown_outputs_prevout_share".to_string()), + empty: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "empty_outputs_prevout_share".to_string()), } } } @@ -4694,35 +4692,35 @@ impl SeriesTree_Outputs_ByType_OutputCount { /// Series tree node. pub struct SeriesTree_Outputs_ByType_OutputShare { - pub p2pk65: _1m1w1y24hBpsPercentRatioPattern, - pub p2pk33: _1m1w1y24hBpsPercentRatioPattern, - pub p2pkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2ms: _1m1w1y24hBpsPercentRatioPattern, - pub p2sh: _1m1w1y24hBpsPercentRatioPattern, - pub p2wpkh: _1m1w1y24hBpsPercentRatioPattern, - pub p2wsh: _1m1w1y24hBpsPercentRatioPattern, - pub p2tr: _1m1w1y24hBpsPercentRatioPattern, - pub p2a: _1m1w1y24hBpsPercentRatioPattern, - pub unknown: _1m1w1y24hBpsPercentRatioPattern, - pub empty: _1m1w1y24hBpsPercentRatioPattern, - pub op_return: _1m1w1y24hBpsPercentRatioPattern, + pub p2pk65: _1m1w1y24hPercentRatioRawPattern, + pub p2pk33: _1m1w1y24hPercentRatioRawPattern, + pub p2pkh: _1m1w1y24hPercentRatioRawPattern, + pub p2ms: _1m1w1y24hPercentRatioRawPattern, + pub p2sh: _1m1w1y24hPercentRatioRawPattern, + pub p2wpkh: _1m1w1y24hPercentRatioRawPattern, + pub p2wsh: _1m1w1y24hPercentRatioRawPattern, + pub p2tr: _1m1w1y24hPercentRatioRawPattern, + pub p2a: _1m1w1y24hPercentRatioRawPattern, + pub unknown: _1m1w1y24hPercentRatioRawPattern, + pub empty: _1m1w1y24hPercentRatioRawPattern, + pub op_return: _1m1w1y24hPercentRatioRawPattern, } impl SeriesTree_Outputs_ByType_OutputShare { pub fn new(client: Arc, base_path: String) -> Self { Self { - p2pk65: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2pk65_output_share".to_string()), - p2pk33: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2pk33_output_share".to_string()), - p2pkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2pkh_output_share".to_string()), - p2ms: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2ms_output_share".to_string()), - p2sh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2sh_output_share".to_string()), - p2wpkh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2wpkh_output_share".to_string()), - p2wsh: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2wsh_output_share".to_string()), - p2tr: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2tr_output_share".to_string()), - p2a: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "p2a_output_share".to_string()), - unknown: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "unknown_outputs_output_share".to_string()), - empty: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "empty_outputs_output_share".to_string()), - op_return: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "op_return_output_share".to_string()), + p2pk65: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2pk65_output_share".to_string()), + p2pk33: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2pk33_output_share".to_string()), + p2pkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2pkh_output_share".to_string()), + p2ms: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2ms_output_share".to_string()), + p2sh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2sh_output_share".to_string()), + p2wpkh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2wpkh_output_share".to_string()), + p2wsh: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2wsh_output_share".to_string()), + p2tr: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2tr_output_share".to_string()), + p2a: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "p2a_output_share".to_string()), + unknown: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "unknown_outputs_output_share".to_string()), + empty: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "empty_outputs_output_share".to_string()), + op_return: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "op_return_output_share".to_string()), } } } @@ -5041,7 +5039,7 @@ impl SeriesTree_Addrs_Reused { pub struct SeriesTree_Addrs_Reused_Events { pub output_to_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6, pub output_to_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7, - pub spendable_output_to_reused_addr_share: _1m1w1y24hBpsPercentRatioPattern, + pub spendable_output_to_reused_addr_share: _1m1w1y24hPercentRatioRawPattern, pub input_from_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6, pub input_from_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7, pub active_reused_addr_count: _1m1w1y24hBlockPattern, @@ -5053,7 +5051,7 @@ impl SeriesTree_Addrs_Reused_Events { Self { output_to_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6::new(client.clone(), "output_to_reused_addr_count".to_string()), output_to_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7::new(client.clone(), "output_to_reused_addr_share".to_string()), - spendable_output_to_reused_addr_share: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "spendable_output_to_reused_addr_share".to_string()), + spendable_output_to_reused_addr_share: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "spendable_output_to_reused_addr_share".to_string()), input_from_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6::new(client.clone(), "input_from_reused_addr_count".to_string()), input_from_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7::new(client.clone(), "input_from_reused_addr_share".to_string()), active_reused_addr_count: _1m1w1y24hBlockPattern::new(client.clone(), "active_reused_addr_count".to_string()), @@ -5114,7 +5112,7 @@ impl SeriesTree_Addrs_Respent { pub struct SeriesTree_Addrs_Respent_Events { pub output_to_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6, pub output_to_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7, - pub spendable_output_to_reused_addr_share: _1m1w1y24hBpsPercentRatioPattern, + pub spendable_output_to_reused_addr_share: _1m1w1y24hPercentRatioRawPattern, pub input_from_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6, pub input_from_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7, pub active_reused_addr_count: _1m1w1y24hBlockPattern, @@ -5126,7 +5124,7 @@ impl SeriesTree_Addrs_Respent_Events { Self { output_to_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6::new(client.clone(), "output_to_respent_addr_count".to_string()), output_to_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7::new(client.clone(), "output_to_respent_addr_share".to_string()), - spendable_output_to_reused_addr_share: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "spendable_output_to_respent_addr_share".to_string()), + spendable_output_to_reused_addr_share: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "spendable_output_to_respent_addr_share".to_string()), input_from_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6::new(client.clone(), "input_from_respent_addr_count".to_string()), input_from_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7::new(client.clone(), "input_from_respent_addr_share".to_string()), active_reused_addr_count: _1m1w1y24hBlockPattern::new(client.clone(), "active_respent_addr_count".to_string()), @@ -5392,7 +5390,7 @@ pub struct SeriesTree_OpReturn_Total { pub data_bytes: AverageBlockCumulativeSumPattern, pub tx_count: AverageBlockCumulativeSumPattern, pub tx_vsize: AverageBlockCumulativeSumPattern, - pub chain_share: BpsPercentRatioPattern2, + pub chain_share: PercentRatioRawPattern2, } impl SeriesTree_OpReturn_Total { @@ -5401,7 +5399,7 @@ impl SeriesTree_OpReturn_Total { data_bytes: AverageBlockCumulativeSumPattern::new(client.clone(), "op_return_data_bytes".to_string()), tx_count: AverageBlockCumulativeSumPattern::new(client.clone(), "op_return_tx_count".to_string()), tx_vsize: AverageBlockCumulativeSumPattern::new(client.clone(), "op_return_tx_vsize".to_string()), - chain_share: BpsPercentRatioPattern2::new(client.clone(), "op_return_chain_share".to_string()), + chain_share: PercentRatioRawPattern2::new(client.clone(), "op_return_chain_share".to_string()), } } } @@ -5524,7 +5522,7 @@ pub struct SeriesTree_Mining_Rewards_Subsidy { pub cumulative: BtcCentsSatsUsdPattern, pub sum: _1m1w1y24hPattern4, pub average: _1m1w1y24hPattern3, - pub dominance: _1m1w1y24hBpsPercentRatioPattern, + pub dominance: _1m1w1y24hPercentRatioRawPattern, } impl SeriesTree_Mining_Rewards_Subsidy { @@ -5534,7 +5532,7 @@ impl SeriesTree_Mining_Rewards_Subsidy { cumulative: BtcCentsSatsUsdPattern::new(client.clone(), "subsidy_cumulative".to_string()), sum: _1m1w1y24hPattern4::new(client.clone(), "subsidy_sum".to_string()), average: _1m1w1y24hPattern3::new(client.clone(), "subsidy_average".to_string()), - dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "subsidy_dominance".to_string()), + dominance: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "subsidy_dominance".to_string()), } } } @@ -5552,7 +5550,7 @@ pub struct SeriesTree_Mining_Rewards_Fees { pub median: _1m1w1y24hPattern4, pub pct75: _1m1w1y24hPattern4, pub pct90: _1m1w1y24hPattern4, - pub dominance: _1m1w1y24hBpsPercentRatioPattern, + pub dominance: _1m1w1y24hPercentRatioRawPattern, pub to_subsidy_ratio: SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio, } @@ -5570,7 +5568,7 @@ impl SeriesTree_Mining_Rewards_Fees { median: _1m1w1y24hPattern4::new(client.clone(), "fees_median".to_string()), pct75: _1m1w1y24hPattern4::new(client.clone(), "fees_pct75".to_string()), pct90: _1m1w1y24hPattern4::new(client.clone(), "fees_pct90".to_string()), - dominance: _1m1w1y24hBpsPercentRatioPattern::new(client.clone(), "fee_dominance".to_string()), + dominance: _1m1w1y24hPercentRatioRawPattern::new(client.clone(), "fee_dominance".to_string()), to_subsidy_ratio: SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio::new(client.clone(), format!("{base_path}_to_subsidy_ratio")), } } @@ -5578,19 +5576,19 @@ impl SeriesTree_Mining_Rewards_Fees { /// Series tree node. pub struct SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio { - pub _24h: BpsRatioPattern2, - pub _1w: BpsRatioPattern2, - pub _1m: BpsRatioPattern2, - pub _1y: BpsRatioPattern2, + pub _24h: RatioRawPattern3, + pub _1w: RatioRawPattern3, + pub _1m: RatioRawPattern3, + pub _1y: RatioRawPattern3, } impl SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio { pub fn new(client: Arc, base_path: String) -> Self { Self { - _24h: BpsRatioPattern2::new(client.clone(), "fee_to_subsidy_ratio_24h".to_string()), - _1w: BpsRatioPattern2::new(client.clone(), "fee_to_subsidy_ratio_1w".to_string()), - _1m: BpsRatioPattern2::new(client.clone(), "fee_to_subsidy_ratio_1m".to_string()), - _1y: BpsRatioPattern2::new(client.clone(), "fee_to_subsidy_ratio_1y".to_string()), + _24h: RatioRawPattern3::new(client.clone(), "fee_to_subsidy_ratio_24h".to_string()), + _1w: RatioRawPattern3::new(client.clone(), "fee_to_subsidy_ratio_1w".to_string()), + _1m: RatioRawPattern3::new(client.clone(), "fee_to_subsidy_ratio_1m".to_string()), + _1y: RatioRawPattern3::new(client.clone(), "fee_to_subsidy_ratio_1y".to_string()), } } } @@ -5617,7 +5615,7 @@ pub struct SeriesTree_Mining_Hashrate_Rate { pub base: SeriesPattern1, pub sma: SeriesTree_Mining_Hashrate_Rate_Sma, pub ath: SeriesPattern1, - pub drawdown: BpsPercentRatioPattern5, + pub drawdown: PercentRatioRawPattern3, } impl SeriesTree_Mining_Hashrate_Rate { @@ -5626,7 +5624,7 @@ impl SeriesTree_Mining_Hashrate_Rate { base: SeriesPattern1::new(client.clone(), "hash_rate".to_string()), sma: SeriesTree_Mining_Hashrate_Rate_Sma::new(client.clone(), format!("{base_path}_sma")), ath: SeriesPattern1::new(client.clone(), "hash_rate_ath".to_string()), - drawdown: BpsPercentRatioPattern5::new(client.clone(), "hash_rate_drawdown".to_string()), + drawdown: PercentRatioRawPattern3::new(client.clone(), "hash_rate_drawdown".to_string()), } } } @@ -5739,7 +5737,7 @@ pub struct SeriesTree_Cointime_Cap { pub vaulted: CentsUsdPattern3, pub active: CentsUsdPattern3, pub cointime: CentsUsdPattern3, - pub aviv: BpsRatioPattern2, + pub aviv: RatioRawPattern2, } impl SeriesTree_Cointime_Cap { @@ -5750,33 +5748,33 @@ impl SeriesTree_Cointime_Cap { vaulted: CentsUsdPattern3::new(client.clone(), "vaulted_cap".to_string()), active: CentsUsdPattern3::new(client.clone(), "active_cap".to_string()), cointime: CentsUsdPattern3::new(client.clone(), "cointime_cap".to_string()), - aviv: BpsRatioPattern2::new(client.clone(), "aviv_ratio".to_string()), + aviv: RatioRawPattern2::new(client.clone(), "aviv_ratio".to_string()), } } } /// Series tree node. pub struct SeriesTree_Cointime_Prices { - pub vaulted: BpsCentsPercentilesRatioSatsUsdPattern, - pub active: BpsCentsPercentilesRatioSatsUsdPattern, - pub true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern, - pub cointime: BpsCentsPercentilesRatioSatsUsdPattern, + pub vaulted: CentsPercentilesRatioRawSatsUsdPattern, + pub active: CentsPercentilesRatioRawSatsUsdPattern, + pub true_market_mean: CentsPercentilesRatioRawSatsUsdPattern, + pub cointime: CentsPercentilesRatioRawSatsUsdPattern, } impl SeriesTree_Cointime_Prices { pub fn new(client: Arc, base_path: String) -> Self { Self { - vaulted: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "vaulted_price".to_string()), - active: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "active_price".to_string()), - true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "true_market_mean".to_string()), - cointime: BpsCentsPercentilesRatioSatsUsdPattern::new(client.clone(), "cointime_price".to_string()), + vaulted: CentsPercentilesRatioRawSatsUsdPattern::new(client.clone(), "vaulted_price".to_string()), + active: CentsPercentilesRatioRawSatsUsdPattern::new(client.clone(), "active_price".to_string()), + true_market_mean: CentsPercentilesRatioRawSatsUsdPattern::new(client.clone(), "true_market_mean".to_string()), + cointime: CentsPercentilesRatioRawSatsUsdPattern::new(client.clone(), "cointime_price".to_string()), } } } /// Series tree node. pub struct SeriesTree_Cointime_Adjusted { - pub inflation_rate: BpsPercentRatioPattern, + pub inflation_rate: PercentRatioRawPattern, pub tx_velocity_native: SeriesPattern1, pub tx_velocity_fiat: SeriesPattern1, } @@ -5784,7 +5782,7 @@ pub struct SeriesTree_Cointime_Adjusted { impl SeriesTree_Cointime_Adjusted { pub fn new(client: Arc, base_path: String) -> Self { Self { - inflation_rate: BpsPercentRatioPattern::new(client.clone(), "cointime_adj_inflation_rate".to_string()), + inflation_rate: PercentRatioRawPattern::new(client.clone(), "cointime_adj_inflation_rate".to_string()), tx_velocity_native: SeriesPattern1::new(client.clone(), "cointime_adj_tx_velocity_btc".to_string()), tx_velocity_fiat: SeriesPattern1::new(client.clone(), "cointime_adj_tx_velocity_usd".to_string()), } @@ -6429,11 +6427,11 @@ impl SeriesTree_Indexes_Timestamp { /// Series tree node. pub struct SeriesTree_Indicators { - pub puell_multiple: BpsRatioPattern2, - pub nvt: BpsRatioPattern2, - pub gini: BpsPercentRatioPattern2, - pub rhodl_ratio: BpsRatioPattern2, - pub thermo_cap_multiple: BpsRatioPattern2, + pub puell_multiple: RatioRawPattern3, + pub nvt: RatioRawPattern3, + pub gini: PercentRatioRawPattern2, + pub rhodl_ratio: RatioRawPattern3, + pub thermo_cap_multiple: RatioRawPattern3, pub coindays_destroyed_supply_adj: SeriesPattern1, pub coinyears_destroyed_supply_adj: SeriesPattern1, pub dormancy: SeriesTree_Indicators_Dormancy, @@ -6445,11 +6443,11 @@ pub struct SeriesTree_Indicators { impl SeriesTree_Indicators { pub fn new(client: Arc, base_path: String) -> Self { Self { - puell_multiple: BpsRatioPattern2::new(client.clone(), "puell_multiple".to_string()), - nvt: BpsRatioPattern2::new(client.clone(), "nvt".to_string()), - gini: BpsPercentRatioPattern2::new(client.clone(), "gini".to_string()), - rhodl_ratio: BpsRatioPattern2::new(client.clone(), "rhodl_ratio".to_string()), - thermo_cap_multiple: BpsRatioPattern2::new(client.clone(), "thermo_cap_multiple".to_string()), + puell_multiple: RatioRawPattern3::new(client.clone(), "puell_multiple".to_string()), + nvt: RatioRawPattern3::new(client.clone(), "nvt".to_string()), + gini: PercentRatioRawPattern2::new(client.clone(), "gini".to_string()), + rhodl_ratio: RatioRawPattern3::new(client.clone(), "rhodl_ratio".to_string()), + thermo_cap_multiple: RatioRawPattern3::new(client.clone(), "thermo_cap_multiple".to_string()), coindays_destroyed_supply_adj: SeriesPattern1::new(client.clone(), "coindays_destroyed_supply_adj".to_string()), coinyears_destroyed_supply_adj: SeriesPattern1::new(client.clone(), "coinyears_destroyed_supply_adj".to_string()), dormancy: SeriesTree_Indicators_Dormancy::new(client.clone(), format!("{base_path}_dormancy")), @@ -6656,35 +6654,35 @@ impl SeriesTree_Investing_Class_DcaCostBasis { /// Series tree node. pub struct SeriesTree_Investing_Class_DcaReturn { - pub from_2015: BpsPercentRatioPattern, - pub from_2016: BpsPercentRatioPattern, - pub from_2017: BpsPercentRatioPattern, - pub from_2018: BpsPercentRatioPattern, - pub from_2019: BpsPercentRatioPattern, - pub from_2020: BpsPercentRatioPattern, - pub from_2021: BpsPercentRatioPattern, - pub from_2022: BpsPercentRatioPattern, - pub from_2023: BpsPercentRatioPattern, - pub from_2024: BpsPercentRatioPattern, - pub from_2025: BpsPercentRatioPattern, - pub from_2026: BpsPercentRatioPattern, + pub from_2015: PercentRatioRawPattern, + pub from_2016: PercentRatioRawPattern, + pub from_2017: PercentRatioRawPattern, + pub from_2018: PercentRatioRawPattern, + pub from_2019: PercentRatioRawPattern, + pub from_2020: PercentRatioRawPattern, + pub from_2021: PercentRatioRawPattern, + pub from_2022: PercentRatioRawPattern, + pub from_2023: PercentRatioRawPattern, + pub from_2024: PercentRatioRawPattern, + pub from_2025: PercentRatioRawPattern, + pub from_2026: PercentRatioRawPattern, } impl SeriesTree_Investing_Class_DcaReturn { pub fn new(client: Arc, base_path: String) -> Self { Self { - from_2015: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2015".to_string()), - from_2016: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2016".to_string()), - from_2017: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2017".to_string()), - from_2018: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2018".to_string()), - from_2019: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2019".to_string()), - from_2020: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2020".to_string()), - from_2021: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2021".to_string()), - from_2022: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2022".to_string()), - from_2023: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2023".to_string()), - from_2024: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2024".to_string()), - from_2025: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2025".to_string()), - from_2026: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2026".to_string()), + from_2015: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2015".to_string()), + from_2016: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2016".to_string()), + from_2017: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2017".to_string()), + from_2018: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2018".to_string()), + from_2019: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2019".to_string()), + from_2020: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2020".to_string()), + from_2021: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2021".to_string()), + from_2022: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2022".to_string()), + from_2023: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2023".to_string()), + from_2024: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2024".to_string()), + from_2025: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2025".to_string()), + from_2026: PercentRatioRawPattern::new(client.clone(), "dca_return_from_2026".to_string()), } } } @@ -6717,7 +6715,7 @@ impl SeriesTree_Market { /// Series tree node. pub struct SeriesTree_Market_Ath { pub high: CentsSatsUsdPattern, - pub drawdown: BpsPercentRatioPattern5, + pub drawdown: PercentRatioRawPattern3, pub days_since: SeriesPattern1, pub years_since: SeriesPattern1, pub max_days_between: SeriesPattern1, @@ -6728,7 +6726,7 @@ impl SeriesTree_Market_Ath { pub fn new(client: Arc, base_path: String) -> Self { Self { high: CentsSatsUsdPattern::new(client.clone(), "price_ath".to_string()), - drawdown: BpsPercentRatioPattern5::new(client.clone(), "price_drawdown".to_string()), + drawdown: PercentRatioRawPattern3::new(client.clone(), "price_drawdown".to_string()), days_since: SeriesPattern1::new(client.clone(), "days_since_price_ath".to_string()), years_since: SeriesPattern1::new(client.clone(), "years_since_price_ath".to_string()), max_days_between: SeriesPattern1::new(client.clone(), "max_days_between_price_ath".to_string()), @@ -6793,37 +6791,37 @@ impl SeriesTree_Market_Returns { /// Series tree node. pub struct SeriesTree_Market_Returns_Periods { - pub _24h: BpsPercentRatioPattern, - pub _1w: BpsPercentRatioPattern, - pub _1m: BpsPercentRatioPattern, - pub _3m: BpsPercentRatioPattern, - pub _6m: BpsPercentRatioPattern, - pub _1y: BpsPercentRatioPattern, - pub _2y: BpsPercentRatioPattern, - pub _3y: BpsPercentRatioPattern, - pub _4y: BpsPercentRatioPattern, - pub _5y: BpsPercentRatioPattern, - pub _6y: BpsPercentRatioPattern, - pub _8y: BpsPercentRatioPattern, - pub _10y: BpsPercentRatioPattern, + pub _24h: PercentRatioRawPattern, + pub _1w: PercentRatioRawPattern, + pub _1m: PercentRatioRawPattern, + pub _3m: PercentRatioRawPattern, + pub _6m: PercentRatioRawPattern, + pub _1y: PercentRatioRawPattern, + pub _2y: PercentRatioRawPattern, + pub _3y: PercentRatioRawPattern, + pub _4y: PercentRatioRawPattern, + pub _5y: PercentRatioRawPattern, + pub _6y: PercentRatioRawPattern, + pub _8y: PercentRatioRawPattern, + pub _10y: PercentRatioRawPattern, } impl SeriesTree_Market_Returns_Periods { pub fn new(client: Arc, base_path: String) -> Self { Self { - _24h: BpsPercentRatioPattern::new(client.clone(), "price_return_24h".to_string()), - _1w: BpsPercentRatioPattern::new(client.clone(), "price_return_1w".to_string()), - _1m: BpsPercentRatioPattern::new(client.clone(), "price_return_1m".to_string()), - _3m: BpsPercentRatioPattern::new(client.clone(), "price_return_3m".to_string()), - _6m: BpsPercentRatioPattern::new(client.clone(), "price_return_6m".to_string()), - _1y: BpsPercentRatioPattern::new(client.clone(), "price_return_1y".to_string()), - _2y: BpsPercentRatioPattern::new(client.clone(), "price_return_2y".to_string()), - _3y: BpsPercentRatioPattern::new(client.clone(), "price_return_3y".to_string()), - _4y: BpsPercentRatioPattern::new(client.clone(), "price_return_4y".to_string()), - _5y: BpsPercentRatioPattern::new(client.clone(), "price_return_5y".to_string()), - _6y: BpsPercentRatioPattern::new(client.clone(), "price_return_6y".to_string()), - _8y: BpsPercentRatioPattern::new(client.clone(), "price_return_8y".to_string()), - _10y: BpsPercentRatioPattern::new(client.clone(), "price_return_10y".to_string()), + _24h: PercentRatioRawPattern::new(client.clone(), "price_return_24h".to_string()), + _1w: PercentRatioRawPattern::new(client.clone(), "price_return_1w".to_string()), + _1m: PercentRatioRawPattern::new(client.clone(), "price_return_1m".to_string()), + _3m: PercentRatioRawPattern::new(client.clone(), "price_return_3m".to_string()), + _6m: PercentRatioRawPattern::new(client.clone(), "price_return_6m".to_string()), + _1y: PercentRatioRawPattern::new(client.clone(), "price_return_1y".to_string()), + _2y: PercentRatioRawPattern::new(client.clone(), "price_return_2y".to_string()), + _3y: PercentRatioRawPattern::new(client.clone(), "price_return_3y".to_string()), + _4y: PercentRatioRawPattern::new(client.clone(), "price_return_4y".to_string()), + _5y: PercentRatioRawPattern::new(client.clone(), "price_return_5y".to_string()), + _6y: PercentRatioRawPattern::new(client.clone(), "price_return_6y".to_string()), + _8y: PercentRatioRawPattern::new(client.clone(), "price_return_8y".to_string()), + _10y: PercentRatioRawPattern::new(client.clone(), "price_return_10y".to_string()), } } } @@ -6913,7 +6911,7 @@ pub struct SeriesTree_Market_Range { pub max: _1m1w1y2wPattern, pub true_range: SeriesPattern1, pub true_range_sum_2w: SeriesPattern1, - pub choppiness_index_2w: BpsPercentRatioPattern2, + pub choppiness_index_2w: PercentRatioRawPattern2, } impl SeriesTree_Market_Range { @@ -6923,7 +6921,7 @@ impl SeriesTree_Market_Range { max: _1m1w1y2wPattern::new(client.clone(), "price_max".to_string()), true_range: SeriesPattern1::new(client.clone(), "price_true_range".to_string()), true_range_sum_2w: SeriesPattern1::new(client.clone(), "price_true_range_sum_2w".to_string()), - choppiness_index_2w: BpsPercentRatioPattern2::new(client.clone(), "price_choppiness_index_2w".to_string()), + choppiness_index_2w: PercentRatioRawPattern2::new(client.clone(), "price_choppiness_index_2w".to_string()), } } } @@ -6945,43 +6943,43 @@ impl SeriesTree_Market_MovingAverage { /// Series tree node. pub struct SeriesTree_Market_MovingAverage_Sma { - 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 _1w: CentsRatioRawSatsUsdPattern, + pub _8d: CentsRatioRawSatsUsdPattern, + pub _13d: CentsRatioRawSatsUsdPattern, + pub _21d: CentsRatioRawSatsUsdPattern, + pub _1m: CentsRatioRawSatsUsdPattern, + pub _34d: CentsRatioRawSatsUsdPattern, + pub _55d: CentsRatioRawSatsUsdPattern, + pub _89d: CentsRatioRawSatsUsdPattern, + pub _111d: CentsRatioRawSatsUsdPattern, + pub _144d: CentsRatioRawSatsUsdPattern, pub _200d: SeriesTree_Market_MovingAverage_Sma_200d, pub _350d: SeriesTree_Market_MovingAverage_Sma_350d, - pub _1y: BpsCentsRatioSatsUsdPattern, - pub _2y: BpsCentsRatioSatsUsdPattern, - pub _200w: BpsCentsRatioSatsUsdPattern, - pub _4y: BpsCentsRatioSatsUsdPattern, + pub _1y: CentsRatioRawSatsUsdPattern, + pub _2y: CentsRatioRawSatsUsdPattern, + pub _200w: CentsRatioRawSatsUsdPattern, + pub _4y: CentsRatioRawSatsUsdPattern, } impl SeriesTree_Market_MovingAverage_Sma { pub fn new(client: Arc, base_path: String) -> Self { Self { - _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()), + _1w: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_1w".to_string()), + _8d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_8d".to_string()), + _13d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_13d".to_string()), + _21d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_21d".to_string()), + _1m: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_1m".to_string()), + _34d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_34d".to_string()), + _55d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_55d".to_string()), + _89d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_89d".to_string()), + _111d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_111d".to_string()), + _144d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_144d".to_string()), _200d: SeriesTree_Market_MovingAverage_Sma_200d::new(client.clone(), format!("{base_path}_200d")), _350d: SeriesTree_Market_MovingAverage_Sma_350d::new(client.clone(), format!("{base_path}_350d")), - _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()), + _1y: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_1y".to_string()), + _2y: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_2y".to_string()), + _200w: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_200w".to_string()), + _4y: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_sma_4y".to_string()), } } } @@ -6991,7 +6989,7 @@ pub struct SeriesTree_Market_MovingAverage_Sma_200d { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub bps: SeriesPattern1, + pub raw: SeriesPattern1, pub ratio: SeriesPattern1, pub x2_4: CentsSatsUsdPattern, pub x0_8: CentsSatsUsdPattern, @@ -7003,7 +7001,7 @@ impl SeriesTree_Market_MovingAverage_Sma_200d { usd: SeriesPattern1::new(client.clone(), "price_sma_200d".to_string()), cents: SeriesPattern1::new(client.clone(), "price_sma_200d_cents".to_string()), sats: SeriesPattern1::new(client.clone(), "price_sma_200d_sats".to_string()), - bps: SeriesPattern1::new(client.clone(), "price_sma_200d_ratio_bps".to_string()), + raw: SeriesPattern1::new(client.clone(), "price_sma_200d_ratio_ppm".to_string()), ratio: SeriesPattern1::new(client.clone(), "price_sma_200d_ratio".to_string()), x2_4: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x2_4".to_string()), x0_8: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x0_8".to_string()), @@ -7016,7 +7014,7 @@ pub struct SeriesTree_Market_MovingAverage_Sma_350d { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub bps: SeriesPattern1, + pub raw: SeriesPattern1, pub ratio: SeriesPattern1, pub x2: CentsSatsUsdPattern, } @@ -7027,7 +7025,7 @@ impl SeriesTree_Market_MovingAverage_Sma_350d { usd: SeriesPattern1::new(client.clone(), "price_sma_350d".to_string()), cents: SeriesPattern1::new(client.clone(), "price_sma_350d_cents".to_string()), sats: SeriesPattern1::new(client.clone(), "price_sma_350d_sats".to_string()), - bps: SeriesPattern1::new(client.clone(), "price_sma_350d_ratio_bps".to_string()), + raw: SeriesPattern1::new(client.clone(), "price_sma_350d_ratio_ppm".to_string()), ratio: SeriesPattern1::new(client.clone(), "price_sma_350d_ratio".to_string()), x2: CentsSatsUsdPattern::new(client.clone(), "price_sma_350d_x2".to_string()), } @@ -7036,43 +7034,43 @@ impl SeriesTree_Market_MovingAverage_Sma_350d { /// Series tree node. pub struct SeriesTree_Market_MovingAverage_Ema { - 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, + pub _1w: CentsRatioRawSatsUsdPattern, + pub _8d: CentsRatioRawSatsUsdPattern, + pub _12d: CentsRatioRawSatsUsdPattern, + pub _13d: CentsRatioRawSatsUsdPattern, + pub _21d: CentsRatioRawSatsUsdPattern, + pub _26d: CentsRatioRawSatsUsdPattern, + pub _1m: CentsRatioRawSatsUsdPattern, + pub _34d: CentsRatioRawSatsUsdPattern, + pub _55d: CentsRatioRawSatsUsdPattern, + pub _89d: CentsRatioRawSatsUsdPattern, + pub _144d: CentsRatioRawSatsUsdPattern, + pub _200d: CentsRatioRawSatsUsdPattern, + pub _1y: CentsRatioRawSatsUsdPattern, + pub _2y: CentsRatioRawSatsUsdPattern, + pub _200w: CentsRatioRawSatsUsdPattern, + pub _4y: CentsRatioRawSatsUsdPattern, } impl SeriesTree_Market_MovingAverage_Ema { pub fn new(client: Arc, base_path: String) -> Self { Self { - _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()), + _1w: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_1w".to_string()), + _8d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_8d".to_string()), + _12d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_12d".to_string()), + _13d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_13d".to_string()), + _21d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_21d".to_string()), + _26d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_26d".to_string()), + _1m: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_1m".to_string()), + _34d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_34d".to_string()), + _55d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_55d".to_string()), + _89d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_89d".to_string()), + _144d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_144d".to_string()), + _200d: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_200d".to_string()), + _1y: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_1y".to_string()), + _2y: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_2y".to_string()), + _200w: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_200w".to_string()), + _4y: CentsRatioRawSatsUsdPattern::new(client.clone(), "price_ema_4y".to_string()), } } } @@ -7080,7 +7078,7 @@ impl SeriesTree_Market_MovingAverage_Ema { /// Series tree node. pub struct SeriesTree_Market_Technical { pub rsi: SeriesTree_Market_Technical_Rsi, - pub pi_cycle: BpsRatioPattern2, + pub pi_cycle: RatioRawPattern2, pub macd: SeriesTree_Market_Technical_Macd, } @@ -7088,7 +7086,7 @@ impl SeriesTree_Market_Technical { pub fn new(client: Arc, base_path: String) -> Self { Self { rsi: SeriesTree_Market_Technical_Rsi::new(client.clone(), format!("{base_path}_rsi")), - pi_cycle: BpsRatioPattern2::new(client.clone(), "pi_cycle".to_string()), + pi_cycle: RatioRawPattern2::new(client.clone(), "pi_cycle".to_string()), macd: SeriesTree_Market_Technical_Macd::new(client.clone(), format!("{base_path}_macd")), } } @@ -7635,10 +7633,10 @@ pub struct SeriesTree_Supply { pub state: SeriesPattern18, pub circulating: BtcCentsSatsUsdPattern, pub burned: BlockCumulativePattern, - pub inflation_rate: BpsPercentRatioPattern, + pub inflation_rate: PercentRatioRawPattern, pub velocity: SeriesTree_Supply_Velocity, pub market_cap: CentsDeltaUsdPattern, - pub market_minus_realized_cap_growth_rate: _1m1w1y24hPattern, + pub market_minus_realized_cap_growth_rate: _1m1w1y24hPattern, pub hodled_or_lost: BtcCentsSatsUsdPattern, } @@ -7648,7 +7646,7 @@ impl SeriesTree_Supply { state: SeriesPattern18::new(client.clone(), "supply_state".to_string()), circulating: BtcCentsSatsUsdPattern::new(client.clone(), "circulating_supply".to_string()), burned: BlockCumulativePattern::new(client.clone(), "unspendable_supply".to_string()), - inflation_rate: BpsPercentRatioPattern::new(client.clone(), "inflation_rate".to_string()), + inflation_rate: PercentRatioRawPattern::new(client.clone(), "inflation_rate".to_string()), velocity: SeriesTree_Supply_Velocity::new(client.clone(), format!("{base_path}_velocity")), market_cap: CentsDeltaUsdPattern::new(client.clone(), "market_cap".to_string()), market_minus_realized_cap_growth_rate: _1m1w1y24hPattern::new(client.clone(), "market_minus_realized_cap_growth_rate".to_string()), @@ -7829,7 +7827,7 @@ pub struct SeriesTree_Cohorts_Utxo_All_Realized_Price { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub bps: SeriesPattern1, + pub raw: SeriesPattern1, pub ratio: SeriesPattern1, pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, pub sma: _1m1w1y2y4yAllPattern, @@ -7842,7 +7840,7 @@ impl SeriesTree_Cohorts_Utxo_All_Realized_Price { usd: SeriesPattern1::new(client.clone(), "realized_price".to_string()), cents: SeriesPattern1::new(client.clone(), "realized_price_cents".to_string()), sats: SeriesPattern1::new(client.clone(), "realized_price_sats".to_string()), - bps: SeriesPattern1::new(client.clone(), "realized_price_ratio_bps".to_string()), + raw: SeriesPattern1::new(client.clone(), "realized_price_ratio_ppm".to_string()), ratio: SeriesPattern1::new(client.clone(), "realized_price_ratio".to_string()), percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "realized_price".to_string()), sma: _1m1w1y2y4yAllPattern::new(client.clone(), "realized_price_ratio_sma".to_string()), @@ -8076,7 +8074,7 @@ pub struct SeriesTree_Cohorts_Utxo_All_CostBasis { pub max: CentsSatsUsdPattern, pub per_coin: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, pub per_dollar: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern, - pub supply_density: BpsPercentRatioPattern2, + pub supply_density: PercentRatioRawPattern2, } impl SeriesTree_Cohorts_Utxo_All_CostBasis { @@ -8088,14 +8086,14 @@ impl SeriesTree_Cohorts_Utxo_All_CostBasis { max: CentsSatsUsdPattern::new(client.clone(), "cost_basis_max".to_string()), per_coin: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), "cost_basis_per_coin".to_string()), per_dollar: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern::new(client.clone(), "cost_basis_per_dollar".to_string()), - supply_density: BpsPercentRatioPattern2::new(client.clone(), "supply_density".to_string()), + supply_density: PercentRatioRawPattern2::new(client.clone(), "supply_density".to_string()), } } } /// Series tree node. pub struct SeriesTree_Cohorts_Utxo_All_Unrealized { - pub nupl: BpsRatioPattern, + pub nupl: RatioRawPattern, pub profit: SeriesTree_Cohorts_Utxo_All_Unrealized_Profit, pub loss: SeriesTree_Cohorts_Utxo_All_Unrealized_Loss, pub net_pnl: SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl, @@ -8109,7 +8107,7 @@ pub struct SeriesTree_Cohorts_Utxo_All_Unrealized { impl SeriesTree_Cohorts_Utxo_All_Unrealized { pub fn new(client: Arc, base_path: String) -> Self { Self { - nupl: BpsRatioPattern::new(client.clone(), "nupl".to_string()), + nupl: RatioRawPattern::new(client.clone(), "nupl".to_string()), profit: SeriesTree_Cohorts_Utxo_All_Unrealized_Profit::new(client.clone(), format!("{base_path}_profit")), loss: SeriesTree_Cohorts_Utxo_All_Unrealized_Loss::new(client.clone(), format!("{base_path}_loss")), net_pnl: SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl::new(client.clone(), format!("{base_path}_net_pnl")), @@ -8126,8 +8124,8 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized { pub struct SeriesTree_Cohorts_Utxo_All_Unrealized_Profit { pub usd: SeriesPattern1, pub cents: SeriesPattern1, - pub to_mcap: BpsPercentRatioPattern2, - pub to_own_gross_pnl: BpsPercentRatioPattern2, + pub to_mcap: PercentRatioRawPattern2, + pub to_own_gross_pnl: PercentRatioRawPattern2, } impl SeriesTree_Cohorts_Utxo_All_Unrealized_Profit { @@ -8135,8 +8133,8 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized_Profit { Self { usd: SeriesPattern1::new(client.clone(), "unrealized_profit".to_string()), cents: SeriesPattern1::new(client.clone(), "unrealized_profit_cents".to_string()), - to_mcap: BpsPercentRatioPattern2::new(client.clone(), "unrealized_profit_to_mcap".to_string()), - to_own_gross_pnl: BpsPercentRatioPattern2::new(client.clone(), "unrealized_profit_to_own_gross_pnl".to_string()), + to_mcap: PercentRatioRawPattern2::new(client.clone(), "unrealized_profit_to_mcap".to_string()), + to_own_gross_pnl: PercentRatioRawPattern2::new(client.clone(), "unrealized_profit_to_own_gross_pnl".to_string()), } } } @@ -8146,8 +8144,8 @@ pub struct SeriesTree_Cohorts_Utxo_All_Unrealized_Loss { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub negative: SeriesPattern1, - pub to_mcap: BpsPercentRatioPattern2, - pub to_own_gross_pnl: BpsPercentRatioPattern2, + pub to_mcap: PercentRatioRawPattern2, + pub to_own_gross_pnl: PercentRatioRawPattern2, } impl SeriesTree_Cohorts_Utxo_All_Unrealized_Loss { @@ -8156,8 +8154,8 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized_Loss { usd: SeriesPattern1::new(client.clone(), "unrealized_loss".to_string()), cents: SeriesPattern1::new(client.clone(), "unrealized_loss_cents".to_string()), negative: SeriesPattern1::new(client.clone(), "unrealized_loss_neg".to_string()), - to_mcap: BpsPercentRatioPattern2::new(client.clone(), "unrealized_loss_to_mcap".to_string()), - to_own_gross_pnl: BpsPercentRatioPattern2::new(client.clone(), "unrealized_loss_to_own_gross_pnl".to_string()), + to_mcap: PercentRatioRawPattern2::new(client.clone(), "unrealized_loss_to_mcap".to_string()), + to_own_gross_pnl: PercentRatioRawPattern2::new(client.clone(), "unrealized_loss_to_own_gross_pnl".to_string()), } } } @@ -8166,7 +8164,7 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized_Loss { pub struct SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl { pub usd: SeriesPattern1, pub cents: SeriesPattern1, - pub to_own_gross_pnl: BpsPercentRatioPattern, + pub to_own_gross_pnl: PercentRatioRawPattern3, } impl SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl { @@ -8174,7 +8172,7 @@ impl SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl { Self { usd: SeriesPattern1::new(client.clone(), "net_unrealized_pnl".to_string()), cents: SeriesPattern1::new(client.clone(), "net_unrealized_pnl_cents".to_string()), - to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_to_own_gross_pnl".to_string()), + to_own_gross_pnl: PercentRatioRawPattern3::new(client.clone(), "net_unrealized_pnl_to_own_gross_pnl".to_string()), } } } @@ -8261,7 +8259,7 @@ pub struct SeriesTree_Cohorts_Utxo_Sth_Realized_Price { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub bps: SeriesPattern1, + pub raw: SeriesPattern1, pub ratio: SeriesPattern1, pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, pub sma: _1m1w1y2y4yAllPattern, @@ -8274,7 +8272,7 @@ impl SeriesTree_Cohorts_Utxo_Sth_Realized_Price { usd: SeriesPattern1::new(client.clone(), "sth_realized_price".to_string()), cents: SeriesPattern1::new(client.clone(), "sth_realized_price_cents".to_string()), sats: SeriesPattern1::new(client.clone(), "sth_realized_price_sats".to_string()), - bps: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_bps".to_string()), + raw: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio_ppm".to_string()), ratio: SeriesPattern1::new(client.clone(), "sth_realized_price_ratio".to_string()), percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "sth_realized_price".to_string()), sma: _1m1w1y2y4yAllPattern::new(client.clone(), "sth_realized_price_ratio_sma".to_string()), @@ -8531,7 +8529,7 @@ pub struct SeriesTree_Cohorts_Utxo_Lth_Realized_Price { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub bps: SeriesPattern1, + pub raw: SeriesPattern1, pub ratio: SeriesPattern1, pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, pub sma: _1m1w1y2y4yAllPattern, @@ -8544,7 +8542,7 @@ impl SeriesTree_Cohorts_Utxo_Lth_Realized_Price { usd: SeriesPattern1::new(client.clone(), "lth_realized_price".to_string()), cents: SeriesPattern1::new(client.clone(), "lth_realized_price_cents".to_string()), sats: SeriesPattern1::new(client.clone(), "lth_realized_price_sats".to_string()), - bps: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_bps".to_string()), + raw: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio_ppm".to_string()), ratio: SeriesPattern1::new(client.clone(), "lth_realized_price_ratio".to_string()), percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "lth_realized_price".to_string()), sma: _1m1w1y2y4yAllPattern::new(client.clone(), "lth_realized_price_ratio_sma".to_string()), @@ -9031,7 +9029,7 @@ pub struct SeriesTree_Cohorts_Utxo_Entry_Discount_Realized_Price { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub bps: SeriesPattern1, + pub raw: SeriesPattern1, pub ratio: SeriesPattern1, pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, pub sma: _1m1w1y2y4yAllPattern, @@ -9044,7 +9042,7 @@ impl SeriesTree_Cohorts_Utxo_Entry_Discount_Realized_Price { usd: SeriesPattern1::new(client.clone(), "veteran_realized_price".to_string()), cents: SeriesPattern1::new(client.clone(), "veteran_realized_price_cents".to_string()), sats: SeriesPattern1::new(client.clone(), "veteran_realized_price_sats".to_string()), - bps: SeriesPattern1::new(client.clone(), "veteran_realized_price_ratio_bps".to_string()), + raw: SeriesPattern1::new(client.clone(), "veteran_realized_price_ratio_ppm".to_string()), ratio: SeriesPattern1::new(client.clone(), "veteran_realized_price_ratio".to_string()), percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "veteran_realized_price".to_string()), sma: _1m1w1y2y4yAllPattern::new(client.clone(), "veteran_realized_price_ratio_sma".to_string()), @@ -9301,7 +9299,7 @@ pub struct SeriesTree_Cohorts_Utxo_Entry_Premium_Realized_Price { pub usd: SeriesPattern1, pub cents: SeriesPattern1, pub sats: SeriesPattern1, - pub bps: SeriesPattern1, + pub raw: SeriesPattern1, pub ratio: SeriesPattern1, pub percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern, pub sma: _1m1w1y2y4yAllPattern, @@ -9314,7 +9312,7 @@ impl SeriesTree_Cohorts_Utxo_Entry_Premium_Realized_Price { usd: SeriesPattern1::new(client.clone(), "rookie_realized_price".to_string()), cents: SeriesPattern1::new(client.clone(), "rookie_realized_price_cents".to_string()), sats: SeriesPattern1::new(client.clone(), "rookie_realized_price_sats".to_string()), - bps: SeriesPattern1::new(client.clone(), "rookie_realized_price_ratio_bps".to_string()), + raw: SeriesPattern1::new(client.clone(), "rookie_realized_price_ratio_ppm".to_string()), ratio: SeriesPattern1::new(client.clone(), "rookie_realized_price_ratio".to_string()), percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern::new(client.clone(), "rookie_realized_price".to_string()), sma: _1m1w1y2y4yAllPattern::new(client.clone(), "rookie_realized_price_ratio_sma".to_string()), diff --git a/crates/brk_computer/src/blocks/difficulty/compute.rs b/crates/brk_computer/src/blocks/difficulty/compute.rs index 23395d50c..9fdb78c9f 100644 --- a/crates/brk_computer/src/blocks/difficulty/compute.rs +++ b/crates/brk_computer/src/blocks/difficulty/compute.rs @@ -14,7 +14,7 @@ impl Vecs { exit: &Exit, ) -> Result<()> { let starting_height = indexer.safe_lengths().height; - self.adjustment.bps.height.compute_ratio_change( + self.adjustment.raw.height.compute_ratio_change( starting_height, &indexer.vecs.blocks.difficulty, 2016, diff --git a/crates/brk_computer/src/blocks/difficulty/vecs.rs b/crates/brk_computer/src/blocks/difficulty/vecs.rs index 34e35a72a..0da25a7c6 100644 --- a/crates/brk_computer/src/blocks/difficulty/vecs.rs +++ b/crates/brk_computer/src/blocks/difficulty/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Epoch, StoredF32, StoredF64, StoredU32}; +use brk_types::{Epoch, PartsPerMillionSigned32, StoredF32, StoredF64, StoredU32}; use vecdb::{Rw, StorageMode}; use crate::internal::{LazyPerBlock, PerBlock, PercentPerBlock, Resolutions}; @@ -7,7 +7,7 @@ use crate::internal::{LazyPerBlock, PerBlock, PercentPerBlock, Resolutions}; pub struct Vecs { pub value: Resolutions, pub hashrate: LazyPerBlock, - pub adjustment: PercentPerBlock, + pub adjustment: PercentPerBlock, pub epoch: PerBlock, pub blocks_to_retarget: PerBlock, pub days_to_retarget: LazyPerBlock, diff --git a/crates/brk_computer/src/blocks/weight/compute.rs b/crates/brk_computer/src/blocks/weight/compute.rs index e39261c12..ea82b881d 100644 --- a/crates/brk_computer/src/blocks/weight/compute.rs +++ b/crates/brk_computer/src/blocks/weight/compute.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::BasisPoints16; +use brk_types::PartsPerMillion32; use vecdb::Exit; use super::Vecs; @@ -8,10 +8,10 @@ use super::Vecs; impl Vecs { pub(crate) fn compute(&mut self, indexer: &Indexer, exit: &Exit) -> Result<()> { let starting_height = indexer.safe_lengths().height; - self.fullness.bps.compute_transform( + self.fullness.raw.compute_transform( starting_height, &indexer.vecs.blocks.weight, - |(h, weight, ..)| (h, BasisPoints16::from(weight.fullness())), + |(h, weight, ..)| (h, PartsPerMillion32::from(weight.fullness())), exit, )?; diff --git a/crates/brk_computer/src/blocks/weight/vecs.rs b/crates/brk_computer/src/blocks/weight/vecs.rs index 4a962c601..e1c85c13b 100644 --- a/crates/brk_computer/src/blocks/weight/vecs.rs +++ b/crates/brk_computer/src/blocks/weight/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints16, StoredU64, Weight}; +use brk_types::{PartsPerMillion32, StoredU64, Weight}; use vecdb::{Rw, StorageMode}; use crate::internal::{LazyPerBlockRolling, PercentVec}; @@ -7,5 +7,5 @@ use crate::internal::{LazyPerBlockRolling, PercentVec}; #[derive(Traversable)] pub struct Vecs { pub weight: LazyPerBlockRolling, - pub fullness: PercentVec, + pub fullness: PercentVec, } diff --git a/crates/brk_computer/src/cointime/adjusted/compute.rs b/crates/brk_computer/src/cointime/adjusted/compute.rs index 4a5856f9b..625812eb9 100644 --- a/crates/brk_computer/src/cointime/adjusted/compute.rs +++ b/crates/brk_computer/src/cointime/adjusted/compute.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::BasisPointsSigned32; +use brk_types::PartsPerMillionSigned64; use vecdb::Exit; use super::super::activity; @@ -17,14 +17,14 @@ impl Vecs { ) -> Result<()> { let starting_height = indexer.safe_lengths().height; - self.inflation_rate.bps.height.compute_transform2( + self.inflation_rate.raw.height.compute_transform2( starting_height, &activity.ratio.height, - &supply.inflation_rate.bps.height, + &supply.inflation_rate.raw.height, |(h, a2vr, inflation, ..)| { ( h, - BasisPointsSigned32::from(f64::from(a2vr) * f64::from(inflation)), + PartsPerMillionSigned64::from(f64::from(a2vr) * f64::from(inflation)), ) }, exit, diff --git a/crates/brk_computer/src/cointime/adjusted/import.rs b/crates/brk_computer/src/cointime/adjusted/import.rs index c911b6382..2fbdb5388 100644 --- a/crates/brk_computer/src/cointime/adjusted/import.rs +++ b/crates/brk_computer/src/cointime/adjusted/import.rs @@ -18,7 +18,7 @@ impl Vecs { inflation_rate: PercentPerBlock::forced_import( db, "cointime_adj_inflation_rate", - version + Version::ONE, + version + Version::TWO, indexes, )?, tx_velocity_native: PerBlock::forced_import( diff --git a/crates/brk_computer/src/cointime/adjusted/vecs.rs b/crates/brk_computer/src/cointime/adjusted/vecs.rs index 61673664a..935b98da8 100644 --- a/crates/brk_computer/src/cointime/adjusted/vecs.rs +++ b/crates/brk_computer/src/cointime/adjusted/vecs.rs @@ -1,12 +1,12 @@ use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, StoredF64}; +use brk_types::{PartsPerMillionSigned64, StoredF64}; use vecdb::{Rw, StorageMode}; use crate::internal::{PerBlock, PercentPerBlock}; #[derive(Traversable)] pub struct Vecs { - pub inflation_rate: PercentPerBlock, + pub inflation_rate: PercentPerBlock, pub tx_velocity_native: PerBlock, pub tx_velocity_fiat: PerBlock, } diff --git a/crates/brk_computer/src/cointime/cap/vecs.rs b/crates/brk_computer/src/cointime/cap/vecs.rs index 390e49aeb..fbb2c6db5 100644 --- a/crates/brk_computer/src/cointime/cap/vecs.rs +++ b/crates/brk_computer/src/cointime/cap/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Cents}; +use brk_types::{Cents, PartsPerMillion32}; use vecdb::{Rw, StorageMode}; use crate::internal::{FiatPerBlock, RatioPerBlock}; @@ -11,5 +11,5 @@ pub struct Vecs { pub vaulted: FiatPerBlock, pub active: FiatPerBlock, pub cointime: FiatPerBlock, - pub aviv: RatioPerBlock, + pub aviv: RatioPerBlock, } diff --git a/crates/brk_computer/src/distribution/addr/delta.rs b/crates/brk_computer/src/distribution/addr/delta.rs index e5a92f203..54ccb9ec1 100644 --- a/crates/brk_computer/src/distribution/addr/delta.rs +++ b/crates/brk_computer/src/distribution/addr/delta.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, StoredI64, StoredU64, Version}; +use brk_types::{PartsPerMillionSigned64, StoredI64, StoredU64, Version}; use derive_more::{Deref, DerefMut}; use crate::{ @@ -9,7 +9,7 @@ use crate::{ use super::AddrCountsVecs; -type AddrDelta = LazyRollingDeltasFromHeight; +type AddrDelta = LazyRollingDeltasFromHeight; #[derive(Clone, Deref, DerefMut, Traversable)] pub struct DeltaVecs(#[traversable(flatten)] pub WithAddrTypes); @@ -21,7 +21,7 @@ impl DeltaVecs { cached_starts: &Windows<&WindowStartVec>, indexes: &indexes::Vecs, ) -> Self { - let version = version + Version::TWO; + let version = version + Version::new(3); let all = LazyRollingDeltasFromHeight::new( "addr_count", diff --git a/crates/brk_computer/src/distribution/addr/reused/events/vecs.rs b/crates/brk_computer/src/distribution/addr/reused/events/vecs.rs index c48bb04f4..dbd1c7421 100644 --- a/crates/brk_computer/src/distribution/addr/reused/events/vecs.rs +++ b/crates/brk_computer/src/distribution/addr/reused/events/vecs.rs @@ -2,7 +2,7 @@ use brk_cohort::ByAddrType; use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, OutputType, StoredF32, StoredU32, StoredU64, Version}; +use brk_types::{OutputType, PartsPerMillion32, StoredF32, StoredU32, StoredU64, Version}; use rayon::prelude::*; use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec}; @@ -67,11 +67,11 @@ use super::state::AddrTypeToAddrEventCount; pub struct AddrEventsVecs { pub output_to_reused_addr_count: WithAddrTypes>, - pub output_to_reused_addr_share: WithAddrTypes>, - pub spendable_output_to_reused_addr_share: PercentCumulativeRolling, + pub output_to_reused_addr_share: WithAddrTypes>, + pub spendable_output_to_reused_addr_share: PercentCumulativeRolling, pub input_from_reused_addr_count: WithAddrTypes>, - pub input_from_reused_addr_share: WithAddrTypes>, + pub input_from_reused_addr_share: WithAddrTypes>, pub active_reused_addr_count: PerBlockRollingAverage, pub active_reused_addr_share: PerBlockRollingAverage, } @@ -94,7 +94,7 @@ impl AddrEventsVecs { ) }; let import_percent = - |name: &str| -> Result>> { + |name: &str| -> Result>> { Ok(WithAddrTypes { all: PercentCumulativeRolling::forced_import(db, name, version, indexes)?, by_addr_type: ByAddrType::new_with_name(|type_name| { diff --git a/crates/brk_computer/src/distribution/addr/supply/share.rs b/crates/brk_computer/src/distribution/addr/supply/share.rs index d7175294d..f56f88307 100644 --- a/crates/brk_computer/src/distribution/addr/supply/share.rs +++ b/crates/brk_computer/src/distribution/addr/supply/share.rs @@ -1,13 +1,13 @@ use brk_cohort::ByAddrType; use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, Sats, Version}; +use brk_types::{Height, PartsPerMillion32, Sats, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{PercentPerBlock, RatioSatsBp16, WithAddrTypes}, + internal::{PercentPerBlock, RatioSats, WithAddrTypes}, }; use super::vecs::AddrSupplyVecs; @@ -18,7 +18,7 @@ use super::vecs::AddrSupplyVecs; /// - Per-type: type's category supply / type's total supply #[derive(Deref, DerefMut, Traversable)] pub struct AddrSupplyShareVecs( - #[traversable(flatten)] pub WithAddrTypes>, + #[traversable(flatten)] pub WithAddrTypes>, ); impl AddrSupplyShareVecs { @@ -29,7 +29,7 @@ impl AddrSupplyShareVecs { indexes: &indexes::Vecs, ) -> Result { Ok(Self( - WithAddrTypes::>::forced_import( + WithAddrTypes::>::forced_import( db, &format!("{name}_addr_supply_share"), version, @@ -46,7 +46,8 @@ impl AddrSupplyShareVecs { type_supply_sats: &ByAddrType<&impl ReadableVec>, exit: &Exit, ) -> Result<()> { - self.all.compute_binary::( + self.all + .compute_binary::>( max_from, &supply.all.sats.height, all_supply_sats, @@ -57,7 +58,7 @@ impl AddrSupplyShareVecs { .iter_mut() .zip(supply.by_addr_type.iter().zip(type_supply_sats.iter())) { - share.compute_binary::( + share.compute_binary::>( max_from, &cat.sats.height, *denom, diff --git a/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs b/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs index 3ef96a066..5f7c9fd7e 100644 --- a/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/addr/vecs.rs @@ -4,7 +4,7 @@ use brk_cohort::{CohortContext, Filter, Filtered}; use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Cents, Height, Sats, StoredI64, StoredU64, Version}; +use brk_types::{Cents, Height, PartsPerMillionSigned64, Sats, StoredI64, StoredU64, Version}; use rayon::prelude::*; use vecdb::{AnyStoredVec, AnyVec, Database, Exit, ReadableVec, Rw, StorageMode, WritableVec}; @@ -28,7 +28,7 @@ pub struct AddrCohortVecs { #[traversable(flatten)] pub metrics: MinimalCohortMetrics, - pub addr_count: PerBlockWithDeltas, + pub addr_count: PerBlockWithDeltas, } impl AddrCohortVecs { @@ -56,7 +56,7 @@ impl AddrCohortVecs { db, &cfg.name("addr_count"), version, - Version::ONE, + Version::TWO, indexes, cached_starts, )?; diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs b/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs index 41aff35bd..43a856257 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/fenwick.rs @@ -1,5 +1,5 @@ use brk_cohort::{Filter, PROFITABILITY_RANGE_COUNT, compute_profitability_boundaries}; -use brk_types::{Cents, CentsCompact, Sats}; +use brk_types::{Cents, CentsCompact, PartsPerMillion32, Sats}; use crate::{ distribution::state::PendingDelta, @@ -332,10 +332,16 @@ impl CostBasisFenwick { // ----------------------------------------------------------------------- /// 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) { + pub(super) fn density( + &self, + spot_price: Cents, + ) -> (PartsPerMillion32, PartsPerMillion32, PartsPerMillion32) { if self.totals.all_sats <= 0 { - return (0, 0, 0); + return ( + PartsPerMillion32::ZERO, + PartsPerMillion32::ZERO, + PartsPerMillion32::ZERO, + ); } let range = self.density_range(spot_price); @@ -345,16 +351,19 @@ impl CostBasisFenwick { let lth_total = self.totals.all_sats - self.totals.sth_sats; ( - Self::to_bps(all_range, self.totals.all_sats), - Self::to_bps(sth_range, self.totals.sth_sats), - Self::to_bps(lth_range, lth_total), + Self::to_ppm(all_range, self.totals.all_sats), + Self::to_ppm(sth_range, self.totals.sth_sats), + Self::to_ppm(lth_range, lth_total), ) } - /// Compute supply density for entry cohorts: (discount_bps, premium_bps). - pub(super) fn entry_density(&self, spot_price: Cents) -> (u16, u16) { + /// Compute supply density for entry cohorts: (discount, premium). + pub(super) fn entry_density( + &self, + spot_price: Cents, + ) -> (PartsPerMillion32, PartsPerMillion32) { if self.totals.all_sats <= 0 { - return (0, 0); + return (PartsPerMillion32::ZERO, PartsPerMillion32::ZERO); } let range = self.density_range(spot_price); @@ -363,8 +372,8 @@ impl CostBasisFenwick { let premium_total = self.totals.all_sats - self.totals.discount_sats; ( - Self::to_bps(discount_range, self.totals.discount_sats), - Self::to_bps(premium_range, premium_total), + Self::to_ppm(discount_range, self.totals.discount_sats), + Self::to_ppm(premium_range, premium_total), ) } @@ -394,11 +403,11 @@ impl CostBasisFenwick { } #[inline(always)] - fn to_bps(range: i64, total: i64) -> u16 { + fn to_ppm(range: i64, total: i64) -> PartsPerMillion32 { if total <= 0 { - 0 + PartsPerMillion32::ZERO } else { - (range as f64 / total as f64 * 10000.0).round() as u16 + PartsPerMillion32::from(range as f64 / total as f64) } } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/percentiles.rs b/crates/brk_computer/src/distribution/cohorts/utxo/percentiles.rs index a76d0a57a..caa8bc7ee 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::{AGE_RANGE_NAMES, CohortContext, Filtered, PROFITABILITY_RANGE_COUNT, TERM_NAMES}; use brk_error::Result; -use brk_types::{BasisPoints16, Cents, CentsCompact, Date, Dollars, Sats, UrpdRaw}; +use brk_types::{Cents, CentsCompact, Date, Dollars, PartsPerMillion32, Sats, UrpdRaw}; use rayon::prelude::*; use crate::distribution::metrics::{CostBasis, ProfitabilityMetrics}; @@ -139,10 +139,14 @@ impl UTXOCohorts { /// Push percentiles + density to cost basis vecs. #[inline(always)] -fn push_cost_basis(percentiles: &PercentileResult, density_bps: u16, cost_basis: &mut CostBasis) { +fn push_cost_basis( + percentiles: &PercentileResult, + density: PartsPerMillion32, + cost_basis: &mut CostBasis, +) { cost_basis.push_minmax(percentiles.min_price, percentiles.max_price); cost_basis.push_percentiles(&percentiles.sat_prices, &percentiles.usd_prices); - cost_basis.push_density(BasisPoints16::from(density_bps)); + cost_basis.push_density(density); } #[inline(always)] diff --git a/crates/brk_computer/src/distribution/metrics/config.rs b/crates/brk_computer/src/distribution/metrics/config.rs index 56b67318f..7f8789db8 100644 --- a/crates/brk_computer/src/distribution/metrics/config.rs +++ b/crates/brk_computer/src/distribution/metrics/config.rs @@ -1,6 +1,8 @@ use brk_cohort::Filter; use brk_error::Result; -use brk_types::{BasisPoints16, BasisPoints32, BasisPointsSigned32, Cents, Height, Version}; +use brk_types::{ + Cents, Height, PartsPerMillion32, PartsPerMillionSigned32, PartsPerMillionSigned64, Version, +}; use schemars::JsonSchema; use vecdb::{BytesVec, BytesVecValue, Database, ImportableVec}; @@ -39,12 +41,11 @@ impl_config_import!( ValuePerBlockCumulative, PriceWithRatioPerBlock, PriceWithRatioExtendedPerBlock, - RatioPerBlock, - RatioPerBlock, - PercentPerBlock, - PercentPerBlock, - PercentPerBlock, - PercentRollingWindows, + RatioPerBlock, + PercentPerBlock, + PercentPerBlock, + PercentPerBlock, + PercentRollingWindows, Price>, ); 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 4d49110cf..8f0c9aa20 100644 --- a/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; use brk_types::CentsSquaredSats; -use brk_types::{BasisPoints16, Cents, Height, Sats, Version}; +use brk_types::{Cents, Height, PartsPerMillion32, Sats, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; use crate::internal::{PERCENTILES_LEN, PerBlock, PercentPerBlock, PercentilesVecs, Price}; @@ -25,7 +25,7 @@ pub struct CostBasis { pub max: Price>, pub per_coin: PercentilesVecs, pub per_dollar: PercentilesVecs, - pub supply_density: PercentPerBlock, + pub supply_density: PercentPerBlock, } impl CostBasis { @@ -88,7 +88,7 @@ impl CostBasis { .height .len() .min(self.max.cents.height.len()) - .min(self.supply_density.bps.height.len()) + .min(self.supply_density.raw.height.len()) } #[inline(always)] @@ -108,8 +108,8 @@ impl CostBasis { } #[inline(always)] - pub(crate) fn push_density(&mut self, density_bps: BasisPoints16) { - self.supply_density.bps.height.push(density_bps); + pub(crate) fn push_density(&mut self, density: PartsPerMillion32) { + self.supply_density.raw.height.push(density); } pub(crate) fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { @@ -128,7 +128,7 @@ impl CostBasis { &mut self.in_loss.per_dollar.cents.height, &mut self.min.cents.height, &mut self.max.cents.height, - &mut self.supply_density.bps.height, + &mut self.supply_density.raw.height, ]; vecs.extend( self.per_coin diff --git a/crates/brk_computer/src/distribution/metrics/outputs/base.rs b/crates/brk_computer/src/distribution/metrics/outputs/base.rs index bbff4bce1..30f52674d 100644 --- a/crates/brk_computer/src/distribution/metrics/outputs/base.rs +++ b/crates/brk_computer/src/distribution/metrics/outputs/base.rs @@ -1,7 +1,9 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Height, StoredF32, StoredI64, StoredU32, StoredU64, Version}; +use brk_types::{ + Height, PartsPerMillionSigned64, StoredF32, StoredI64, StoredU32, StoredU64, Version, +}; use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; use crate::{ @@ -15,7 +17,7 @@ use crate::{ /// Base output metrics: utxo_count + delta. #[derive(Traversable)] pub struct OutputsBase { - pub unspent_count: PerBlockWithDeltas, + pub unspent_count: PerBlockWithDeltas, pub spent_count: PerBlockCumulativeRolling, pub spending_rate: PerBlock, } @@ -28,7 +30,7 @@ impl OutputsBase { cfg.db, &cfg.name("utxo_count"), cfg.version, - v1, + Version::TWO, cfg.indexes, cfg.cached_starts, )?, diff --git a/crates/brk_computer/src/distribution/metrics/profitability.rs b/crates/brk_computer/src/distribution/metrics/profitability.rs index b4a72a1b2..cdef1297c 100644 --- a/crates/brk_computer/src/distribution/metrics/profitability.rs +++ b/crates/brk_computer/src/distribution/metrics/profitability.rs @@ -2,7 +2,7 @@ use brk_cohort::{Loss, Profit, ProfitabilityRange}; use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Bitcoin, Cents, Dollars, Sats, Version}; +use brk_types::{Bitcoin, Cents, Dollars, PartsPerMillionSigned32, Sats, Version}; use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec}; use crate::{ @@ -24,7 +24,7 @@ pub struct ProfitabilityBucket { pub supply: WithSth, ValuePerBlock>, pub realized_cap: WithSth>, pub unrealized_pnl: WithSth>, - pub nupl: RatioPerBlock, + pub nupl: RatioPerBlock, } impl ProfitabilityBucket { @@ -152,7 +152,7 @@ impl ProfitabilityBucket { exit, )?; - self.nupl.bps.height.compute_transform3( + self.nupl.raw.height.compute_transform3( max_from, &prices.spot.cents.height, &self.realized_cap.all.height, @@ -161,11 +161,11 @@ impl ProfitabilityBucket { let p = spot.as_u128(); let supply = supply_sats.as_u128(); if p == 0 || supply == 0 { - (i, BasisPointsSigned32::ZERO) + (i, PartsPerMillionSigned32::ZERO) } else { let rp = Cents::from(cap_dollars).as_u128() * Sats::ONE_BTC_U128 / supply; - let bps = ((p as i128 - rp as i128) * 10000) / p as i128; - (i, BasisPointsSigned32::from(bps as i32)) + let ratio = (p as f64 - rp as f64) / p as f64; + (i, PartsPerMillionSigned32::from(ratio)) } }, exit, @@ -230,7 +230,7 @@ impl ProfitabilityBucket { &mut self.realized_cap.sth.height, &mut self.unrealized_pnl.all.height, &mut self.unrealized_pnl.sth.height, - &mut self.nupl.bps.height, + &mut self.nupl.raw.height, ] } } diff --git a/crates/brk_computer/src/distribution/metrics/realized/core.rs b/crates/brk_computer/src/distribution/metrics/realized/core.rs index 81455e513..f7c6e1099 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/core.rs @@ -2,7 +2,7 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; use brk_types::{ - BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Dollars, Height, StoredF64, Version, + Bitcoin, Cents, CentsSigned, Dollars, Height, PartsPerMillionSigned64, StoredF64, Version, }; use derive_more::{Deref, DerefMut}; use vecdb::{ @@ -45,8 +45,12 @@ pub struct RealizedCore { #[traversable(wrap = "loss", rename = "negative")] pub neg_loss: NegRealizedLoss, - pub net_pnl: - FiatPerBlockCumulativeWithSumsAndDeltas, + pub net_pnl: FiatPerBlockCumulativeWithSumsAndDeltas< + CentsSigned, + CentsSigned, + PartsPerMillionSigned64, + M, + >, pub sopr: RealizedSoprCore, } @@ -80,7 +84,7 @@ impl RealizedCore { cfg.db, &cfg.name("net_realized_pnl"), cfg.version + v1, - Version::new(4), + Version::new(5), cfg.indexes, cfg.cached_starts, )?; diff --git a/crates/brk_computer/src/distribution/metrics/realized/full.rs b/crates/brk_computer/src/distribution/metrics/realized/full.rs index bc0359c43..85bd9ef84 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -2,8 +2,8 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; use brk_types::{ - BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSats, CentsSigned, CentsSquaredSats, - Dollars, Height, StoredF64, Version, + Bitcoin, Cents, CentsSats, CentsSigned, CentsSquaredSats, Dollars, Height, PartsPerMillion32, + PartsPerMillionSigned64, StoredF64, Version, }; use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, BytesVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; @@ -13,10 +13,9 @@ use crate::{ distribution::state::{CohortState, CostBasisData, RealizedState, WithCapital}, internal::{ FiatPerBlockCumulativeWithSums, PercentPerBlock, PercentRollingWindows, - PriceWithRatioExtendedPerBlock, RatioCents64, RatioCentsBp32, RatioCentsSignedCentsBps32, - RatioCentsSignedDollarsBps32, RatioDollarsBp32, RatioPerBlockPercentiles, - RatioPerBlockStdDevBands, RatioSma, RollingWindows, RollingWindowsFrom1w, - ValuePerBlockCumulativeRolling, + PriceWithRatioExtendedPerBlock, RatioCents, RatioCents64, RatioCentsSignedCents, + RatioCentsSignedDollars, RatioDollars, RatioPerBlockPercentiles, RatioPerBlockStdDevBands, + RatioSma, RollingWindows, RollingWindowsFrom1w, ValuePerBlockCumulativeRolling, }, price, }; @@ -28,9 +27,9 @@ use super::RealizedCore; #[derive(Traversable)] pub struct RealizedNetPnl { #[traversable(wrap = "change_1m", rename = "to_rcap")] - pub change_1m_to_rcap: PercentPerBlock, + pub change_1m_to_rcap: PercentPerBlock, #[traversable(wrap = "change_1m", rename = "to_mcap")] - pub change_1m_to_mcap: PercentPerBlock, + pub change_1m_to_mcap: PercentPerBlock, } #[derive(Traversable)] @@ -60,7 +59,7 @@ pub struct RealizedFull { pub core: RealizedCore, pub gross_pnl: FiatPerBlockCumulativeWithSums, - pub sell_side_risk_ratio: PercentRollingWindows, + pub sell_side_risk_ratio: PercentRollingWindows, pub net_pnl: RealizedNetPnl, pub sopr: RealizedSopr, pub peak_regret: RealizedPeakRegret, @@ -71,7 +70,7 @@ pub struct RealizedFull { #[traversable(hidden)] pub cap_raw: M::Stored>, #[traversable(wrap = "cap", rename = "to_own_mcap")] - pub cap_to_own_mcap: PercentPerBlock, + pub cap_to_own_mcap: PercentPerBlock, #[traversable(wrap = "price", rename = "percentiles")] pub price_ratio_percentiles: RatioPerBlockPercentiles, @@ -95,8 +94,8 @@ impl RealizedFull { // Net PnL let net_pnl = RealizedNetPnl { - change_1m_to_rcap: cfg.import("net_pnl_change_1m_to_rcap", Version::new(4))?, - change_1m_to_mcap: cfg.import("net_pnl_change_1m_to_mcap", Version::new(4))?, + change_1m_to_rcap: cfg.import("net_pnl_change_1m_to_rcap", Version::new(5))?, + change_1m_to_mcap: cfg.import("net_pnl_change_1m_to_mcap", Version::new(5))?, }; // SOPR @@ -286,7 +285,7 @@ impl RealizedFull { // Net PnL 1m change relative to rcap and mcap self.net_pnl .change_1m_to_rcap - .compute_binary::( + .compute_binary::>( starting_lengths.height, &self.core.net_pnl.delta.absolute._1m.cents.height, &self.core.minimal.cap.cents.height, @@ -294,7 +293,11 @@ impl RealizedFull { )?; self.net_pnl .change_1m_to_mcap - .compute_binary::( + .compute_binary::< + CentsSigned, + Dollars, + RatioCentsSignedDollars, + >( starting_lengths.height, &self.core.net_pnl.delta.absolute._1m.cents.height, height_to_market_cap, @@ -313,7 +316,7 @@ impl RealizedFull { .into_iter() .zip(self.gross_pnl.sum.as_array()) { - ssrr.compute_binary::( + ssrr.compute_binary::>( starting_lengths.height, &rv.cents.height, &self.core.minimal.cap.cents.height, @@ -323,7 +326,7 @@ impl RealizedFull { // Realized cap relative to own market cap self.cap_to_own_mcap - .compute_binary::( + .compute_binary::>( starting_lengths.height, &self.core.minimal.cap.usd.height, height_to_market_cap, diff --git a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs index 0f30140c1..156acb2c4 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs @@ -2,8 +2,8 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; use brk_types::{ - BasisPoints32, BasisPointsSigned32, Bitcoin, Cents, CentsSigned, Height, Sats, StoredF32, - Version, + Bitcoin, Cents, CentsSigned, Height, PartsPerMillion64, PartsPerMillionSigned64, Sats, + StoredF32, Version, }; use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; @@ -20,7 +20,7 @@ use crate::distribution::metrics::ImportConfig; #[derive(Traversable)] pub struct RealizedMinimal { - pub cap: FiatPerBlockWithDeltas, + pub cap: FiatPerBlockWithDeltas, pub profit: FiatPerBlockCumulativeWithSums, pub loss: FiatPerBlockCumulativeWithSums, pub price: PriceWithRatioPerBlock, @@ -35,13 +35,13 @@ impl RealizedMinimal { cfg.db, &cfg.name("realized_cap"), cfg.version, - v1, + Version::TWO, cfg.indexes, cfg.cached_starts, )?; let price: PriceWithRatioPerBlock = cfg.import("realized_price", v1)?; - let mvrv = LazyPerBlock::from_lazy::, BasisPoints32>( + let mvrv = LazyPerBlock::from_lazy::, PartsPerMillion64>( &cfg.name("mvrv"), cfg.version, &price.ratio, diff --git a/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs b/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs index 6dd9e1f36..2a90c9a7d 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/extended_own_market_cap.rs @@ -1,9 +1,9 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPoints32, BasisPointsSigned32, Dollars, Height, Version}; +use brk_types::{Dollars, Height, PartsPerMillion32, PartsPerMillionSigned32, Version}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::internal::{PercentPerBlock, RatioDollarsBp16, RatioDollarsBp32, RatioDollarsBps32}; +use crate::internal::{PercentPerBlock, RatioDollars}; use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; @@ -11,11 +11,11 @@ use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; #[derive(Traversable)] pub struct RelativeExtendedOwnMarketCap { #[traversable(wrap = "unrealized/profit", rename = "to_own_mcap")] - pub unrealized_profit_to_own_mcap: PercentPerBlock, + pub unrealized_profit_to_own_mcap: PercentPerBlock, #[traversable(wrap = "unrealized/loss", rename = "to_own_mcap")] - pub unrealized_loss_to_own_mcap: PercentPerBlock, + pub unrealized_loss_to_own_mcap: PercentPerBlock, #[traversable(wrap = "unrealized/net_pnl", rename = "to_own_mcap")] - pub net_unrealized_pnl_to_own_mcap: PercentPerBlock, + pub net_unrealized_pnl_to_own_mcap: PercentPerBlock, } impl RelativeExtendedOwnMarketCap { @@ -39,21 +39,21 @@ impl RelativeExtendedOwnMarketCap { exit: &Exit, ) -> Result<()> { self.unrealized_profit_to_own_mcap - .compute_binary::( + .compute_binary::>( max_from, &unrealized.profit.usd.height, own_market_cap, exit, )?; self.unrealized_loss_to_own_mcap - .compute_binary::( + .compute_binary::>( max_from, &unrealized.loss.usd.height, own_market_cap, exit, )?; self.net_unrealized_pnl_to_own_mcap - .compute_binary::( + .compute_binary::>( max_from, &unrealized.net_pnl.usd.height, own_market_cap, diff --git a/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs b/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs index e89f95a8b..17b9c0186 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/extended_own_pnl.rs @@ -1,9 +1,9 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPointsSigned32, Dollars, Height, Version}; +use brk_types::{Dollars, Height, PartsPerMillion32, PartsPerMillionSigned32, Version}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; -use crate::internal::{PercentPerBlock, RatioDollarsBp16, RatioDollarsBps32}; +use crate::internal::{PercentPerBlock, RatioDollars}; use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; @@ -11,11 +11,11 @@ use crate::distribution::metrics::{ImportConfig, UnrealizedCore}; #[derive(Traversable)] pub struct RelativeExtendedOwnPnl { #[traversable(wrap = "unrealized/profit", rename = "to_own_gross_pnl")] - pub unrealized_profit_to_own_gross_pnl: PercentPerBlock, + pub unrealized_profit_to_own_gross_pnl: PercentPerBlock, #[traversable(wrap = "unrealized/loss", rename = "to_own_gross_pnl")] - pub unrealized_loss_to_own_gross_pnl: PercentPerBlock, + pub unrealized_loss_to_own_gross_pnl: PercentPerBlock, #[traversable(wrap = "unrealized/net_pnl", rename = "to_own_gross_pnl")] - pub net_unrealized_pnl_to_own_gross_pnl: PercentPerBlock, + pub net_unrealized_pnl_to_own_gross_pnl: PercentPerBlock, } impl RelativeExtendedOwnPnl { @@ -39,21 +39,21 @@ impl RelativeExtendedOwnPnl { exit: &Exit, ) -> Result<()> { self.unrealized_profit_to_own_gross_pnl - .compute_binary::( + .compute_binary::>( max_from, &unrealized.profit.usd.height, gross_pnl_usd, exit, )?; self.unrealized_loss_to_own_gross_pnl - .compute_binary::( + .compute_binary::>( max_from, &unrealized.loss.usd.height, gross_pnl_usd, exit, )?; self.net_unrealized_pnl_to_own_gross_pnl - .compute_binary::( + .compute_binary::>( max_from, &unrealized.net_pnl.usd.height, gross_pnl_usd, diff --git a/crates/brk_computer/src/distribution/metrics/relative/full.rs b/crates/brk_computer/src/distribution/metrics/relative/full.rs index bdd7862dd..6115efbb3 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/full.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/full.rs @@ -1,25 +1,25 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Dollars, Height, Sats, Version}; +use brk_types::{Dollars, Height, PartsPerMillion32, Sats, Version}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::{ distribution::metrics::{ImportConfig, SupplyCore, UnrealizedBasic}, - internal::{PercentPerBlock, RatioDollarsBp16, RatioSatsBp16}, + internal::{PercentPerBlock, RatioDollars, RatioSats}, }; /// Full relative metrics (sth/lth/all tier). #[derive(Traversable)] pub struct RelativeFull { #[traversable(wrap = "supply/in_profit", rename = "share")] - pub supply_in_profit_share: PercentPerBlock, + pub supply_in_profit_share: PercentPerBlock, #[traversable(wrap = "supply/in_loss", rename = "share")] - pub supply_in_loss_share: PercentPerBlock, + pub supply_in_loss_share: PercentPerBlock, #[traversable(wrap = "unrealized/profit", rename = "to_mcap")] - pub unrealized_profit_to_mcap: PercentPerBlock, + pub unrealized_profit_to_mcap: PercentPerBlock, #[traversable(wrap = "unrealized/loss", rename = "to_mcap")] - pub unrealized_loss_to_mcap: PercentPerBlock, + pub unrealized_loss_to_mcap: PercentPerBlock, } impl RelativeFull { @@ -44,14 +44,14 @@ impl RelativeFull { exit: &Exit, ) -> Result<()> { self.supply_in_profit_share - .compute_binary::( + .compute_binary::>( max_from, &supply.in_profit.sats.height, &supply.total.sats.height, exit, )?; self.supply_in_loss_share - .compute_binary::( + .compute_binary::>( max_from, &supply.in_loss.sats.height, &supply.total.sats.height, @@ -59,14 +59,14 @@ impl RelativeFull { )?; self.unrealized_profit_to_mcap - .compute_binary::( + .compute_binary::>( max_from, &unrealized.profit.usd.height, market_cap, exit, )?; self.unrealized_loss_to_mcap - .compute_binary::( + .compute_binary::>( max_from, &unrealized.loss.usd.height, market_cap, diff --git a/crates/brk_computer/src/distribution/metrics/relative/invested_capital.rs b/crates/brk_computer/src/distribution/metrics/relative/invested_capital.rs index 9c16c3b1b..5748be598 100644 --- a/crates/brk_computer/src/distribution/metrics/relative/invested_capital.rs +++ b/crates/brk_computer/src/distribution/metrics/relative/invested_capital.rs @@ -1,9 +1,9 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Cents, Height, Version}; +use brk_types::{Cents, Height, PartsPerMillion32, Version}; use vecdb::{Exit, Rw, StorageMode}; -use crate::internal::{PercentPerBlock, RatioCentsBp16}; +use crate::internal::{PercentPerBlock, RatioCents}; use crate::distribution::metrics::{ImportConfig, RealizedFull, UnrealizedFull}; @@ -12,9 +12,9 @@ use crate::distribution::metrics::{ImportConfig, RealizedFull, UnrealizedFull}; #[derive(Traversable)] pub struct RelativeInvestedCapital { #[traversable(wrap = "invested_capital/in_profit", rename = "share")] - pub in_profit_share: PercentPerBlock, + pub in_profit_share: PercentPerBlock, #[traversable(wrap = "invested_capital/in_loss", rename = "share")] - pub in_loss_share: PercentPerBlock, + pub in_loss_share: PercentPerBlock, } impl RelativeInvestedCapital { @@ -35,14 +35,14 @@ impl RelativeInvestedCapital { ) -> Result<()> { let realized_cap = &realized.core.minimal.cap.cents.height; self.in_profit_share - .compute_binary::( + .compute_binary::>( max_from, &unrealized.invested_capital.in_profit.cents.height, realized_cap, exit, )?; self.in_loss_share - .compute_binary::( + .compute_binary::>( max_from, &unrealized.invested_capital.in_loss.cents.height, realized_cap, diff --git a/crates/brk_computer/src/distribution/metrics/supply/base.rs b/crates/brk_computer/src/distribution/metrics/supply/base.rs index 8b8a835ec..42c736747 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/base.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/base.rs @@ -1,7 +1,7 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPointsSigned32, Height, Sats, SatsSigned, Version}; +use brk_types::{Height, PartsPerMillion32, PartsPerMillionSigned64, Sats, SatsSigned, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, Rw, StorageMode, WritableVec}; use crate::{ @@ -10,7 +10,7 @@ use crate::{ }; use crate::internal::{ - LazyRollingDeltasAmountFromHeight, PercentPerBlock, RatioSatsBp16, ValuePerBlock, + LazyRollingDeltasAmountFromHeight, PercentPerBlock, RatioSats, ValuePerBlock, }; use crate::distribution::metrics::ImportConfig; @@ -19,9 +19,9 @@ use crate::distribution::metrics::ImportConfig; #[derive(Traversable)] pub struct SupplyBase { pub total: ValuePerBlock, - pub delta: LazyRollingDeltasAmountFromHeight, + pub delta: LazyRollingDeltasAmountFromHeight, #[traversable(rename = "dominance")] - pub dominance: PercentPerBlock, + pub dominance: PercentPerBlock, } impl SupplyBase { @@ -30,7 +30,7 @@ impl SupplyBase { let delta = LazyRollingDeltasAmountFromHeight::new( &cfg.name("supply_delta"), - cfg.version + Version::ONE, + cfg.version + Version::TWO, &supply.sats.height, cfg.cached_starts, cfg.indexes, @@ -58,7 +58,7 @@ impl SupplyBase { vec![ &mut self.total.sats.height as &mut dyn AnyStoredVec, &mut self.total.cents.height, - &mut self.dominance.bps.height, + &mut self.dominance.raw.height, ] } @@ -77,12 +77,13 @@ impl SupplyBase { all_supply_sats: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.dominance.compute_binary::( - max_from, - &self.total.sats.height, - all_supply_sats, - exit, - ) + self.dominance + .compute_binary::>( + max_from, + &self.total.sats.height, + all_supply_sats, + exit, + ) } pub(crate) fn compute_from_stateful( diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs b/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs index 75d9271fe..14c385746 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/minimal.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Cents, Height, Version}; +use brk_types::{Cents, Height, PartsPerMillionSigned32, Version}; use vecdb::{Exit, ReadableVec, Rw, StorageMode}; use crate::internal::RatioPerBlock; @@ -9,7 +9,7 @@ use crate::distribution::metrics::ImportConfig; #[derive(Traversable)] pub struct UnrealizedMinimal { - pub nupl: RatioPerBlock, + pub nupl: RatioPerBlock, } impl UnrealizedMinimal { @@ -31,18 +31,18 @@ impl UnrealizedMinimal { realized_price: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.nupl.bps.height.compute_transform2( + self.nupl.raw.height.compute_transform2( max_from, spot_price, realized_price, |(i, price, realized_price, ..)| { let p = price.as_u128(); if p == 0 { - (i, BasisPointsSigned32::ZERO) + (i, PartsPerMillionSigned32::ZERO) } else { let rp = realized_price.as_u128(); - let nupl_bps = ((p as i128 - rp as i128) * 10000) / p as i128; - (i, BasisPointsSigned32::from(nupl_bps as i32)) + let ratio = (p as f64 - rp as f64) / p as f64; + (i, PartsPerMillionSigned32::from(ratio)) } }, exit, diff --git a/crates/brk_computer/src/indicators/compute.rs b/crates/brk_computer/src/indicators/compute.rs index 6814f4aee..576d298f6 100644 --- a/crates/brk_computer/src/indicators/compute.rs +++ b/crates/brk_computer/src/indicators/compute.rs @@ -1,10 +1,10 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{Bitcoin, Dollars, StoredF32}; +use brk_types::{Bitcoin, Dollars, PartsPerMillion64, StoredF32}; use vecdb::Exit; use super::{Vecs, gini}; -use crate::{distribution, internal::RatioDollarsBp32, market, mining, transactions}; +use crate::{distribution, internal::RatioDollars, market, mining, transactions}; impl Vecs { #[allow(clippy::too_many_arguments)] @@ -23,8 +23,8 @@ impl Vecs { // Puell Multiple: daily_subsidy_usd / sma_365d_subsidy_usd self.puell_multiple - .bps - .compute_binary::( + .raw + .compute_binary::>( starting_lengths.height, &mining.rewards.subsidy.block.usd, &mining.rewards.subsidy.average._1y.usd.height, @@ -36,8 +36,8 @@ impl Vecs { // RHODL Ratio: 1d-1w realized cap / 1y-2y realized cap self.rhodl_ratio - .bps - .compute_binary::( + .raw + .compute_binary::>( starting_lengths.height, &distribution .utxo_cohorts @@ -70,8 +70,8 @@ impl Vecs { .usd .height; self.nvt - .bps - .compute_binary::( + .raw + .compute_binary::>( starting_lengths.height, market_cap, &transactions.volume.transfer_volume.sum._24h.usd.height, @@ -80,8 +80,8 @@ impl Vecs { // Thermocap Multiple: market_cap / thermo_cap self.thermo_cap_multiple - .bps - .compute_binary::( + .raw + .compute_binary::>( starting_lengths.height, market_cap, &mining.rewards.subsidy.cumulative.usd.height, diff --git a/crates/brk_computer/src/indicators/gini.rs b/crates/brk_computer/src/indicators/gini.rs index 96ebab26b..75fd89bab 100644 --- a/crates/brk_computer/src/indicators/gini.rs +++ b/crates/brk_computer/src/indicators/gini.rs @@ -1,12 +1,12 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{BasisPoints16, Sats, StoredU64, Version}; +use brk_types::{PartsPerMillion32, Sats, StoredU64, Version}; use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, VecIndex, WritableVec}; use crate::{distribution, internal::PercentPerBlock}; pub(super) fn compute( - gini: &mut PercentPerBlock, + gini: &mut PercentPerBlock, distribution: &distribution::Vecs, indexer: &Indexer, exit: &Exit, @@ -34,13 +34,13 @@ pub(super) fn compute( .iter() .fold(Version::ZERO, |acc, v| acc + v.version()); - gini.bps + gini.raw .height .validate_computed_version_or_reset(source_version)?; - let min_len = gini.bps.height.len().min(starting_height.to_usize()); + let min_len = gini.raw.height.len().min(starting_height.to_usize()); - gini.bps.height.truncate_if_needed_at(min_len)?; + gini.raw.height.truncate_if_needed_at(min_len)?; let total_heights = supply_vecs .iter() @@ -49,7 +49,7 @@ pub(super) fn compute( .unwrap_or(0) .min(count_vecs.iter().map(|v| v.len()).min().unwrap_or(0)); - let start_height = gini.bps.height.len(); + let start_height = gini.raw.height.len(); if start_height >= total_heights { return Ok(()); } @@ -73,23 +73,23 @@ pub(super) fn compute( let count: u64 = count_data[c][offset].into(); buckets.push((count, supply)); } - gini.bps.height.push(gini_from_lorenz(&buckets)); + gini.raw.height.push(gini_from_lorenz(&buckets)); } { let _lock = exit.lock(); - gini.bps.height.write()?; + gini.raw.height.write()?; } Ok(()) } -fn gini_from_lorenz(buckets: &[(u64, u64)]) -> BasisPoints16 { +fn gini_from_lorenz(buckets: &[(u64, u64)]) -> PartsPerMillion32 { let total_count: u64 = buckets.iter().map(|(c, _)| c).sum(); let total_supply: u64 = buckets.iter().map(|(_, s)| s).sum(); if total_count == 0 || total_supply == 0 { - return BasisPoints16::ZERO; + return PartsPerMillion32::ZERO; } let (mut cumulative_count, mut cumulative_supply, mut area) = (0u64, 0u64, 0.0f64); @@ -103,5 +103,5 @@ fn gini_from_lorenz(buckets: &[(u64, u64)]) -> BasisPoints16 { area += (p1 - p0) * (w0 + w1) / 2.0; } - BasisPoints16::from(1.0 - 2.0 * area) + PartsPerMillion32::from(1.0 - 2.0 * area) } diff --git a/crates/brk_computer/src/indicators/vecs.rs b/crates/brk_computer/src/indicators/vecs.rs index baf70834f..2868f5470 100644 --- a/crates/brk_computer/src/indicators/vecs.rs +++ b/crates/brk_computer/src/indicators/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPoints32, StoredF32}; +use brk_types::{PartsPerMillion32, PartsPerMillion64, StoredF32}; use vecdb::{Database, Rw, StorageMode}; use super::rarity_meter::RarityMeter; @@ -15,11 +15,11 @@ pub struct DormancyVecs { pub struct Vecs { #[traversable(skip)] pub(crate) db: Database, - pub puell_multiple: RatioPerBlock, - pub nvt: RatioPerBlock, - pub gini: PercentPerBlock, - pub rhodl_ratio: RatioPerBlock, - pub thermo_cap_multiple: RatioPerBlock, + pub puell_multiple: RatioPerBlock, + pub nvt: RatioPerBlock, + pub gini: PercentPerBlock, + pub rhodl_ratio: RatioPerBlock, + pub thermo_cap_multiple: RatioPerBlock, pub coindays_destroyed_supply_adj: PerBlock, pub coinyears_destroyed_supply_adj: PerBlock, pub dormancy: DormancyVecs, diff --git a/crates/brk_computer/src/inputs/by_type/vecs.rs b/crates/brk_computer/src/inputs/by_type/vecs.rs index 6f27e93d9..b3462581d 100644 --- a/crates/brk_computer/src/inputs/by_type/vecs.rs +++ b/crates/brk_computer/src/inputs/by_type/vecs.rs @@ -1,6 +1,6 @@ use brk_cohort::SpendableType; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, StoredU64}; +use brk_types::{PartsPerMillion32, StoredU64}; use vecdb::{Rw, StorageMode}; use super::WithInputTypes; @@ -9,7 +9,7 @@ use crate::internal::{PerBlockCumulativeRolling, PercentCumulativeRolling}; #[derive(Traversable)] pub struct Vecs { pub input_count: WithInputTypes>, - pub input_share: SpendableType>, + pub input_share: SpendableType>, pub tx_count: WithInputTypes>, - pub tx_share: SpendableType>, + pub tx_share: SpendableType>, } diff --git a/crates/brk_computer/src/internal/algo/drawdown.rs b/crates/brk_computer/src/internal/algo/drawdown.rs index acdbd0539..f03f07548 100644 --- a/crates/brk_computer/src/internal/algo/drawdown.rs +++ b/crates/brk_computer/src/internal/algo/drawdown.rs @@ -1,5 +1,5 @@ use brk_error::Result; -use brk_types::BasisPointsSigned16; +use brk_types::PartsPerMillionSigned32; use vecdb::{EagerVec, Exit, PcoVec, ReadableVec, VecIndex, VecValue}; pub trait ComputeDrawdown { @@ -16,7 +16,7 @@ pub trait ComputeDrawdown { f64: From + From; } -impl ComputeDrawdown for EagerVec> +impl ComputeDrawdown for EagerVec> where I: VecIndex, { @@ -39,9 +39,9 @@ where |(i, current, ath, _)| { let ath_f64 = f64::from(ath); let drawdown = if ath_f64 == 0.0 { - BasisPointsSigned16::default() + PartsPerMillionSigned32::default() } else { - BasisPointsSigned16::from((f64::from(current) - ath_f64) / ath_f64) + PartsPerMillionSigned32::from((f64::from(current) - ath_f64) / ath_f64) }; (i, drawdown) }, diff --git a/crates/brk_computer/src/internal/algo/expanding_percentiles.rs b/crates/brk_computer/src/internal/algo/expanding_percentiles.rs index a5b4b441c..d4d7852e2 100644 --- a/crates/brk_computer/src/internal/algo/expanding_percentiles.rs +++ b/crates/brk_computer/src/internal/algo/expanding_percentiles.rs @@ -4,7 +4,7 @@ use super::fenwick::FenwickTree; /// Fast expanding percentile tracker using a Fenwick tree (Binary Indexed Tree). /// -/// Values are discretized to 10 BPS (0.1%) resolution and tracked in +/// Values are discretized to 0.001 ratio resolution and tracked in /// a fixed-size frequency array with Fenwick prefix sums. This gives: /// - O(log N) insert (N = tree size, ~16 ops for 43k buckets) /// - O(log N) percentile query via prefix-sum walk @@ -15,11 +15,9 @@ pub(crate) struct ExpandingPercentiles { count: u32, } -/// Bucket granularity in BPS. 10 BPS = 0.1% = 0.001 ratio. -const BUCKET_BPS: i32 = 10; -/// Max ratio supported: 43.0 = 430,000 BPS. -const MAX_BPS: i32 = 430_000; -const TREE_SIZE: usize = (MAX_BPS / BUCKET_BPS) as usize + 1; +const BUCKET_WIDTH: f64 = 0.001; +const MAX_RATIO: f64 = 43.0; +const TREE_SIZE: usize = (MAX_RATIO / BUCKET_WIDTH) as usize + 1; impl Default for ExpandingPercentiles { fn default() -> Self { @@ -43,8 +41,9 @@ impl ExpandingPercentiles { /// Convert f32 ratio to 0-indexed bucket. #[inline] fn to_bucket(value: f32) -> usize { - let bps = (value as f64 * 10000.0).round() as i32; - (bps / BUCKET_BPS).clamp(0, TREE_SIZE as i32 - 1) as usize + (value as f64 / BUCKET_WIDTH) + .round() + .clamp(0.0, (TREE_SIZE - 1) as f64) as usize } /// Bulk-load values in O(n + N) instead of O(n log N). @@ -73,10 +72,10 @@ impl ExpandingPercentiles { /// Compute 8 percentiles in one call via kth. O(8 × log N) but with /// shared tree traversal across all 8 targets for better cache locality. - /// Quantiles q must be sorted ascending in (0, 1). Output is in BPS. - pub fn quantiles(&self, qs: &[f64; 8], out: &mut [u32; 8]) { + /// Quantiles q must be sorted ascending in (0, 1). Output values are ratios. + pub fn quantiles(&self, qs: &[f64; 8], out: &mut [f64; 8]) { if self.count == 0 { - out.iter_mut().for_each(|o| *o = 0); + out.fill(0.0); return; } let mut targets = [0u32; 8]; @@ -87,7 +86,7 @@ impl ExpandingPercentiles { let mut buckets = [0usize; 8]; self.tree.kth(&targets, &|n: &u32| *n, &mut buckets); for (i, bucket) in buckets.iter().enumerate() { - out[i] = *bucket as u32 * BUCKET_BPS as u32; + out[i] = *bucket as f64 * BUCKET_WIDTH; } } } @@ -96,8 +95,8 @@ impl ExpandingPercentiles { mod tests { use super::*; - fn quantile(ep: &ExpandingPercentiles, q: f64) -> u32 { - let mut out = [0u32; 8]; + fn quantile(ep: &ExpandingPercentiles, q: f64) -> f64 { + let mut out = [0.0; 8]; ep.quantiles(&[q, q, q, q, q, q, q, q], &mut out); out[0] } @@ -111,20 +110,20 @@ mod tests { assert_eq!(ep.count(), 1000); let median = quantile(&ep, 0.5); - assert!((median as i32 - 5000).abs() < 100, "median was {median}"); + assert!((median - 0.5).abs() < 0.01, "median was {median}"); let p99 = quantile(&ep, 0.99); - assert!((p99 as i32 - 9900).abs() < 100, "p99 was {p99}"); + assert!((p99 - 0.99).abs() < 0.01, "p99 was {p99}"); let p01 = quantile(&ep, 0.01); - assert!((p01 as i32 - 100).abs() < 100, "p01 was {p01}"); + assert!((p01 - 0.01).abs() < 0.01, "p01 was {p01}"); } #[test] fn empty() { let ep = ExpandingPercentiles::default(); assert_eq!(ep.count(), 0); - assert_eq!(quantile(&ep, 0.5), 0); + assert_eq!(quantile(&ep, 0.5), 0.0); } #[test] @@ -132,7 +131,7 @@ mod tests { let mut ep = ExpandingPercentiles::default(); ep.add(0.42); let v = quantile(&ep, 0.5); - assert!((v as i32 - 4200).abs() <= BUCKET_BPS, "got {v}"); + assert!((v - 0.42).abs() <= BUCKET_WIDTH, "got {v}"); } #[test] @@ -144,6 +143,6 @@ mod tests { assert_eq!(ep.count(), 100); ep.reset(); assert_eq!(ep.count(), 0); - assert_eq!(quantile(&ep, 0.5), 0); + assert_eq!(quantile(&ep, 0.5), 0.0); } } diff --git a/crates/brk_computer/src/internal/containers/percent.rs b/crates/brk_computer/src/internal/containers/percent.rs index 47b64e826..8537be3c3 100644 --- a/crates/brk_computer/src/internal/containers/percent.rs +++ b/crates/brk_computer/src/internal/containers/percent.rs @@ -2,7 +2,7 @@ use brk_traversable::Traversable; #[derive(Clone, Traversable)] pub struct Percent { - pub bps: A, + pub raw: A, pub ratio: B, pub percent: C, } diff --git a/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs b/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs index 087089ecd..9f1ce7c43 100644 --- a/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs +++ b/crates/brk_computer/src/internal/per_block/computed/with_deltas.rs @@ -8,7 +8,7 @@ use vecdb::{Rw, StorageMode}; use crate::{ indexes, internal::{ - BpsType, LazyRollingDeltasFromHeight, NumericValue, PerBlock, WindowStartVec, Windows, + FixedRatio, LazyRollingDeltasFromHeight, NumericValue, PerBlock, WindowStartVec, Windows, }, }; @@ -17,7 +17,7 @@ pub struct PerBlockWithDeltas where S: NumericValue + JsonSchema + Into, C: NumericValue + JsonSchema + From, - B: BpsType + From, + B: FixedRatio + From, { #[deref] #[deref_mut] @@ -29,7 +29,7 @@ impl PerBlockWithDeltas where S: NumericValue + JsonSchema + Into, C: NumericValue + JsonSchema + From, - B: BpsType + From, + B: FixedRatio + From, { pub(crate) fn forced_import( db: &vecdb::Database, diff --git a/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs index f4bb7b6ab..b347cecf3 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/cumulative_sum_with_deltas.rs @@ -6,7 +6,7 @@ use vecdb::{Database, Rw, StorageMode}; use crate::{ indexes, - internal::{BpsType, LazyRollingDeltasFiatFromHeight, WindowStartVec, Windows}, + internal::{FixedRatio, LazyRollingDeltasFiatFromHeight, WindowStartVec, Windows}, }; use super::{FiatPerBlockCumulativeWithSums, FiatType}; @@ -16,7 +16,7 @@ pub struct FiatPerBlockCumulativeWithSumsAndDeltas, CS: FiatType + From, - B: BpsType + From, + B: FixedRatio + From, { #[deref] #[deref_mut] @@ -29,7 +29,7 @@ impl FiatPerBlockCumulativeWithSumsAndDeltas where C: FiatType + Into, CS: FiatType + From, - B: BpsType + From, + B: FixedRatio + From, { pub(crate) fn forced_import( db: &Database, diff --git a/crates/brk_computer/src/internal/per_block/fiat/with_deltas.rs b/crates/brk_computer/src/internal/per_block/fiat/with_deltas.rs index bdff6b072..189e3edef 100644 --- a/crates/brk_computer/src/internal/per_block/fiat/with_deltas.rs +++ b/crates/brk_computer/src/internal/per_block/fiat/with_deltas.rs @@ -7,7 +7,7 @@ use vecdb::{Database, Rw, StorageMode}; use crate::{ indexes, - internal::{BpsType, LazyRollingDeltasFiatFromHeight, WindowStartVec, Windows}, + internal::{FixedRatio, LazyRollingDeltasFiatFromHeight, WindowStartVec, Windows}, }; use super::{FiatPerBlock, FiatType}; @@ -17,7 +17,7 @@ pub struct FiatPerBlockWithDeltas where C: FiatType + Into, CS: FiatType + From, - B: BpsType + From, + B: FixedRatio + From, { #[deref] #[deref_mut] @@ -30,7 +30,7 @@ impl FiatPerBlockWithDeltas where C: FiatType + JsonSchema + Into, CS: FiatType + From, - B: BpsType + From, + B: FixedRatio + From, { pub(crate) fn forced_import( db: &Database, diff --git a/crates/brk_computer/src/internal/per_block/percent/base.rs b/crates/brk_computer/src/internal/per_block/percent/base.rs index 2a5f58bdd..67706f17f 100644 --- a/crates/brk_computer/src/internal/per_block/percent/base.rs +++ b/crates/brk_computer/src/internal/per_block/percent/base.rs @@ -8,44 +8,39 @@ use vecdb::{ use crate::{ indexes, - internal::{BpsType, Percent, algo::ComputeDrawdown}, + internal::{FixedRatio, Percent, algo::ComputeDrawdown}, }; use crate::internal::{LazyPerBlock, PerBlock}; -/// Basis-point storage with both ratio and percentage float views. -/// -/// Stores integer basis points on disk (Pco-compressed), -/// exposes two lazy StoredF32 views: -/// - `ratio`: bps / 10000 (e.g., 4523 bps -> 0.4523) -/// - `percent`: bps / 100 (e.g., 4523 bps -> 45.23%) +/// Fixed-point storage with lazy ratio and percentage float views. #[derive(Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct PercentPerBlock( +pub struct PercentPerBlock( pub Percent, LazyPerBlock>, ); -impl PercentPerBlock { +impl PercentPerBlock { pub(crate) fn forced_import( db: &Database, name: &str, version: Version, indexes: &indexes::Vecs, ) -> Result { - let bps = PerBlock::forced_import(db, &format!("{name}_bps"), version, indexes)?; - let bps_clone = bps.height.read_only_boxed_clone(); + let raw = PerBlock::forced_import(db, &format!("{name}_{}", B::SUFFIX), version, indexes)?; + let raw_clone = raw.height.read_only_boxed_clone(); let ratio = LazyPerBlock::from_computed::( &format!("{name}_ratio"), version, - bps_clone.clone(), - &bps, + raw_clone.clone(), + &raw, ); - let percent = LazyPerBlock::from_computed::(name, version, bps_clone, &bps); + let percent = LazyPerBlock::from_computed::(name, version, raw_clone, &raw); Ok(Self(Percent { - bps, + raw, ratio, percent, })) @@ -63,7 +58,7 @@ impl PercentPerBlock { S2T: VecValue, F: BinaryTransform, { - self.bps + self.raw .compute_binary::(max_from, source1, source2, exit) } @@ -80,7 +75,7 @@ impl PercentPerBlock { f64: From + From, vecdb::EagerVec>: ComputeDrawdown, { - self.bps + self.raw .height .compute_drawdown(max_from, current, ath, exit) } diff --git a/crates/brk_computer/src/internal/per_block/percent/cumulative_rolling.rs b/crates/brk_computer/src/internal/per_block/percent/cumulative_rolling.rs index c92bca7be..7d72277a6 100644 --- a/crates/brk_computer/src/internal/per_block/percent/cumulative_rolling.rs +++ b/crates/brk_computer/src/internal/per_block/percent/cumulative_rolling.rs @@ -5,25 +5,25 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, StoredU64, Version}; +use brk_types::{Height, PartsPerMillion32, StoredU64, Version}; use vecdb::{BinaryTransform, Database, Exit, ReadableVec, Rw, StorageMode, VecValue}; use crate::{ indexes, internal::{ - BpsType, PerBlockCumulativeRolling, PercentPerBlock, PercentRollingWindows, RatioU64Bp16, + FixedRatio, PerBlockCumulativeRolling, PercentPerBlock, PercentRollingWindows, RatioU64, }, }; #[derive(Traversable)] -pub struct PercentCumulativeRolling { +pub struct PercentCumulativeRolling { #[traversable(flatten)] pub cumulative: PercentPerBlock, #[traversable(flatten)] pub rolling: PercentRollingWindows, } -impl PercentCumulativeRolling { +impl PercentCumulativeRolling { pub(crate) fn forced_import( db: &Database, name: &str, @@ -73,7 +73,7 @@ impl PercentCumulativeRolling { } } -impl PercentCumulativeRolling { +impl PercentCumulativeRolling { /// Derive a percent from two `PerBlockCumulativeRolling` /// sources (numerator and denominator). Both sources must already have /// their cumulative and rolling sums computed. @@ -85,7 +85,15 @@ impl PercentCumulativeRolling { starting_height: Height, exit: &Exit, ) -> Result<()> { - self.compute_binary::( + self.compute_binary::< + StoredU64, + StoredU64, + RatioU64, + _, + _, + _, + _, + >( starting_height, &numerator.cumulative.height, &denominator.cumulative.height, diff --git a/crates/brk_computer/src/internal/per_block/percent/lazy.rs b/crates/brk_computer/src/internal/per_block/percent/lazy.rs index c567dd637..20166146c 100644 --- a/crates/brk_computer/src/internal/per_block/percent/lazy.rs +++ b/crates/brk_computer/src/internal/per_block/percent/lazy.rs @@ -3,39 +3,39 @@ use brk_types::{StoredF32, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{ReadableCloneableVec, UnaryTransform}; -use crate::internal::{BpsType, LazyPerBlock, Percent, PercentPerBlock}; +use crate::internal::{FixedRatio, LazyPerBlock, Percent, PercentPerBlock}; /// Fully lazy variant of `PercentPerBlock` — no stored vecs. /// -/// BPS values are lazily derived from a source `PercentPerBlock` via a unary transform, -/// and ratio/percent float views are chained from the lazy BPS. +/// Raw values are lazily derived from a source `PercentPerBlock` via a unary transform, +/// and ratio/percent float views are chained from them. #[derive(Clone, Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct LazyPercentPerBlock( +pub struct LazyPercentPerBlock( pub Percent, LazyPerBlock>, ); -impl LazyPercentPerBlock { - /// Create from a stored `PercentPerBlock` source via a BPS-to-BPS unary transform. +impl LazyPercentPerBlock { + /// Create from a stored `PercentPerBlock` source via a same-unit unary transform. pub(crate) fn from_percent>( name: &str, version: Version, source: &PercentPerBlock, ) -> Self { - let bps = LazyPerBlock::from_computed::( - &format!("{name}_bps"), + let raw = LazyPerBlock::from_computed::( + &format!("{name}_{}", B::SUFFIX), version, - source.bps.height.read_only_boxed_clone(), - &source.bps, + source.raw.height.read_only_boxed_clone(), + &source.raw, ); let ratio = - LazyPerBlock::from_lazy::(&format!("{name}_ratio"), version, &bps); + LazyPerBlock::from_lazy::(&format!("{name}_ratio"), version, &raw); - let percent = LazyPerBlock::from_lazy::(name, version, &bps); + let percent = LazyPerBlock::from_lazy::(name, version, &raw); Self(Percent { - bps, + raw, ratio, percent, }) diff --git a/crates/brk_computer/src/internal/per_block/percent/lazy_cumulative_rolling.rs b/crates/brk_computer/src/internal/per_block/percent/lazy_cumulative_rolling.rs index 880ce5fc5..f196a229b 100644 --- a/crates/brk_computer/src/internal/per_block/percent/lazy_cumulative_rolling.rs +++ b/crates/brk_computer/src/internal/per_block/percent/lazy_cumulative_rolling.rs @@ -3,25 +3,25 @@ use brk_types::Version; use vecdb::UnaryTransform; use crate::internal::{ - BpsType, LazyPercentPerBlock, LazyPercentRollingWindows, PercentCumulativeRolling, + FixedRatio, LazyPercentPerBlock, LazyPercentRollingWindows, PercentCumulativeRolling, }; /// Fully lazy variant of `PercentCumulativeRolling` — no stored vecs. /// /// Mirrors the flat shape of `PercentCumulativeRolling`: cumulative and /// rolling window fields are both flattened to the same tree level, so -/// consumers see `{ bps, percent, ratio, _24h, _1w, _1m, _1y }`. +/// consumers see `{ raw, percent, ratio, _24h, _1w, _1m, _1y }`. #[derive(Clone, Traversable)] -pub struct LazyPercentCumulativeRolling { +pub struct LazyPercentCumulativeRolling { #[traversable(flatten)] pub cumulative: LazyPercentPerBlock, #[traversable(flatten)] pub rolling: LazyPercentRollingWindows, } -impl LazyPercentCumulativeRolling { +impl LazyPercentCumulativeRolling { /// Derive from a stored `PercentCumulativeRolling` source via a - /// BPS-to-BPS unary transform applied to both cumulative and rolling. + /// same-unit unary transform applied to both cumulative and rolling. pub(crate) fn from_source>( name: &str, version: Version, diff --git a/crates/brk_computer/src/internal/per_block/percent/lazy_windows.rs b/crates/brk_computer/src/internal/per_block/percent/lazy_windows.rs index 33a502f4a..3fa868cb8 100644 --- a/crates/brk_computer/src/internal/per_block/percent/lazy_windows.rs +++ b/crates/brk_computer/src/internal/per_block/percent/lazy_windows.rs @@ -3,20 +3,20 @@ use brk_types::Version; use derive_more::{Deref, DerefMut}; use vecdb::UnaryTransform; -use crate::internal::{BpsType, PercentRollingWindows, Windows}; +use crate::internal::{FixedRatio, PercentRollingWindows, Windows}; use super::LazyPercentPerBlock; /// Fully lazy rolling percent windows — 4 windows (24h, 1w, 1m, 1y), -/// each with lazy BPS + lazy ratio/percent float views. +/// each with lazy raw + lazy ratio/percent float views. /// /// No stored vecs. All values derived from a source `PercentRollingWindows`. #[derive(Clone, Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct LazyPercentRollingWindows(pub Windows>); +pub struct LazyPercentRollingWindows(pub Windows>); -impl LazyPercentRollingWindows { - /// Create from a stored `PercentRollingWindows` source via a BPS-to-BPS unary transform. +impl LazyPercentRollingWindows { + /// Create from a stored source via a same-unit unary transform. pub(crate) fn from_rolling>( name: &str, version: Version, diff --git a/crates/brk_computer/src/internal/per_block/percent/vec.rs b/crates/brk_computer/src/internal/per_block/percent/vec.rs index 2aa190f40..9e50d725c 100644 --- a/crates/brk_computer/src/internal/per_block/percent/vec.rs +++ b/crates/brk_computer/src/internal/per_block/percent/vec.rs @@ -5,37 +5,37 @@ use vecdb::{ Database, EagerVec, ImportableVec, LazyVecFrom1, PcoVec, ReadableCloneableVec, Rw, StorageMode, }; -use crate::internal::{BpsType, Percent}; +use crate::internal::{FixedRatio, Percent}; -/// Lightweight percent container: BPS height vec + lazy ratio + lazy percent. +/// Lightweight percent container: fixed-point height vec + lazy ratio + lazy percent. /// No resolutions, no rolling stats. #[derive(Clone, Deref, DerefMut, Traversable)] #[traversable(transparent)] #[allow(clippy::type_complexity)] -pub struct PercentVec( +pub struct PercentVec( pub Percent>>, LazyVecFrom1>, ); -impl PercentVec { +impl PercentVec { pub(crate) fn forced_import( db: &Database, name: &str, version: Version, ) -> brk_error::Result { - let bps: EagerVec> = - EagerVec::forced_import(db, &format!("{name}_bps"), version)?; - let bps_clone = bps.read_only_boxed_clone(); + let raw: EagerVec> = + EagerVec::forced_import(db, &format!("{name}_{}", B::SUFFIX), version)?; + let raw_clone = raw.read_only_boxed_clone(); let ratio = LazyVecFrom1::transformed::( &format!("{name}_ratio"), version, - bps_clone.clone(), + raw_clone.clone(), ); - let percent = LazyVecFrom1::transformed::(name, version, bps_clone); + let percent = LazyVecFrom1::transformed::(name, version, raw_clone); Ok(Self(Percent { - bps, + raw, ratio, percent, })) diff --git a/crates/brk_computer/src/internal/per_block/percent/windows.rs b/crates/brk_computer/src/internal/per_block/percent/windows.rs index 2c9dd68e9..a6ff5c266 100644 --- a/crates/brk_computer/src/internal/per_block/percent/windows.rs +++ b/crates/brk_computer/src/internal/per_block/percent/windows.rs @@ -6,18 +6,18 @@ use vecdb::{BinaryTransform, Database, Exit, ReadableVec, Rw, StorageMode, VecVa use crate::{ indexes, - internal::{BpsType, PercentPerBlock, Windows}, + internal::{FixedRatio, PercentPerBlock, Windows}, }; -/// 4 rolling window vecs (24h, 1w, 1m, 1y), each storing basis points +/// 4 rolling window vecs (24h, 1w, 1m, 1y), each storing fixed-point values /// with lazy ratio and percent float views. #[derive(Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct PercentRollingWindows( +pub struct PercentRollingWindows( pub Windows>, ); -impl PercentRollingWindows { +impl PercentRollingWindows { pub(crate) fn forced_import( db: &Database, name: &str, diff --git a/crates/brk_computer/src/internal/per_block/ratio/base.rs b/crates/brk_computer/src/internal/per_block/ratio/base.rs index e888ef7f6..9d79d11e6 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/base.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/base.rs @@ -1,23 +1,23 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Cents, Height, StoredF32, Version}; +use brk_types::{Cents, Height, StoredF32, Version}; use vecdb::{Database, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode}; use crate::{ indexes, - internal::{BpsType, LazyPerBlock, PerBlock}, + internal::{FixedRatio, LazyPerBlock, PerBlock}, }; #[derive(Traversable)] -pub struct RatioPerBlock { - pub bps: PerBlock, - pub ratio: LazyPerBlock, +pub struct RatioPerBlock { + pub raw: PerBlock, + pub ratio: LazyPerBlock, } -const VERSION: Version = Version::TWO; +const VERSION: Version = Version::new(3); -impl RatioPerBlock { +impl RatioPerBlock { pub(crate) fn forced_import( db: &Database, name: &str, @@ -35,20 +35,18 @@ impl RatioPerBlock { ) -> Result { let v = version + VERSION; - let bps = PerBlock::forced_import(db, &format!("{name}_bps"), v, indexes)?; + let raw = PerBlock::forced_import(db, &format!("{name}_{}", R::SUFFIX), v, indexes)?; - let ratio = LazyPerBlock::from_computed::( + let ratio = LazyPerBlock::from_computed::( name, v, - bps.height.read_only_boxed_clone(), - &bps, + raw.height.read_only_boxed_clone(), + &raw, ); - Ok(Self { bps, ratio }) + Ok(Self { raw, ratio }) } -} -impl RatioPerBlock { pub(crate) fn compute_ratio( &mut self, starting_lengths: &Lengths, @@ -56,15 +54,15 @@ impl RatioPerBlock { series_price: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.bps.height.compute_transform2( + self.raw.height.compute_transform2( starting_lengths.height, close_price, series_price, |(i, close, price, ..)| { if price == Cents::ZERO { - (i, BasisPoints32::from(1.0)) + (i, R::from(1.0)) } else { - (i, BasisPoints32::from(f64::from(close) / f64::from(price))) + (i, R::from(f64::from(close) / f64::from(price))) } }, exit, 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 3e02d81b0..09486c230 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/percentiles.rs @@ -1,7 +1,7 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Cents, Height, StoredF32, Version}; +use brk_types::{Cents, Height, PartsPerMillion32, StoredF32, Version}; use vecdb::{ AnyStoredVec, AnyVec, Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode, VecIndex, WritableVec, @@ -9,7 +9,7 @@ use vecdb::{ use crate::{ indexes, - internal::{Price, PriceTimesRatioBp32Cents, algo::ExpandingPercentiles}, + internal::{Price, PriceTimesRatio, algo::ExpandingPercentiles}, }; use super::{super::PerBlock, RatioPerBlock}; @@ -17,7 +17,7 @@ use super::{super::PerBlock, RatioPerBlock}; #[derive(Traversable)] pub struct RatioBand { #[traversable(flatten)] - pub ratio: RatioPerBlock, + pub ratio: RatioPerBlock, pub price: Price>, } @@ -119,18 +119,18 @@ impl RatioPerBlockPercentiles { } let new_ratios = ratio_source.collect_range_at(start, ratio_len); - let mut pct_vecs: [&mut EagerVec>; 8] = [ - &mut self.pct0_5.ratio.bps.height, - &mut self.pct1.ratio.bps.height, - &mut self.pct2.ratio.bps.height, - &mut self.pct5.ratio.bps.height, - &mut self.pct95.ratio.bps.height, - &mut self.pct98.ratio.bps.height, - &mut self.pct99.ratio.bps.height, - &mut self.pct99_5.ratio.bps.height, + let mut pct_vecs: [&mut EagerVec>; 8] = [ + &mut self.pct0_5.ratio.raw.height, + &mut self.pct1.ratio.raw.height, + &mut self.pct2.ratio.raw.height, + &mut self.pct5.ratio.raw.height, + &mut self.pct95.ratio.raw.height, + &mut self.pct98.ratio.raw.height, + &mut self.pct99.ratio.raw.height, + &mut self.pct99_5.ratio.raw.height, ]; const PCTS: [f64; 8] = [0.005, 0.01, 0.02, 0.05, 0.95, 0.98, 0.99, 0.995]; - let mut out = [0u32; 8]; + let mut out = [0.0; 8]; for vec in pct_vecs.iter_mut() { vec.truncate_if_needed_at(start)?; @@ -142,7 +142,7 @@ impl RatioPerBlockPercentiles { } self.expanding_pct.quantiles(&PCTS, &mut out); for (vec, &val) in pct_vecs.iter_mut().zip(out.iter()) { - vec.push(BasisPoints32::from(val)); + vec.push(PartsPerMillion32::from(val)); } } } @@ -159,10 +159,14 @@ impl RatioPerBlockPercentiles { self.$band .price .cents - .compute_binary::( + .compute_binary::< + Cents, + PartsPerMillion32, + PriceTimesRatio, + >( starting_lengths.height, series_price, - &self.$band.ratio.bps.height, + &self.$band.ratio.raw.height, exit, )?; }; @@ -182,16 +186,16 @@ impl RatioPerBlockPercentiles { fn mut_pct_vecs( &mut self, - ) -> impl Iterator>> { + ) -> impl Iterator>> { [ - &mut self.pct0_5.ratio.bps.height, - &mut self.pct1.ratio.bps.height, - &mut self.pct2.ratio.bps.height, - &mut self.pct5.ratio.bps.height, - &mut self.pct95.ratio.bps.height, - &mut self.pct98.ratio.bps.height, - &mut self.pct99.ratio.bps.height, - &mut self.pct99_5.ratio.bps.height, + &mut self.pct0_5.ratio.raw.height, + &mut self.pct1.ratio.raw.height, + &mut self.pct2.ratio.raw.height, + &mut self.pct5.ratio.raw.height, + &mut self.pct95.ratio.raw.height, + &mut self.pct98.ratio.raw.height, + &mut self.pct99.ratio.raw.height, + &mut self.pct99_5.ratio.raw.height, ] .into_iter() } diff --git a/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs b/crates/brk_computer/src/internal/per_block/ratio/price_extended.rs index 18f2922a5..0d4b0d2e8 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,7 +1,7 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Cents, Dollars, Height, SatsFract, StoredF32, Version}; +use brk_types::{Cents, Dollars, Height, PartsPerMillion64, SatsFract, StoredF32, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{Database, EagerVec, Exit, PcoVec, ReadableVec, Rw, StorageMode}; @@ -15,8 +15,8 @@ pub struct PriceWithRatioPerBlock { pub usd: LazyPerBlock, pub cents: PerBlock, pub sats: LazyPerBlock, - pub bps: PerBlock, - pub ratio: LazyPerBlock, + pub raw: PerBlock, + pub ratio: LazyPerBlock, } impl PriceWithRatioPerBlock { @@ -32,7 +32,7 @@ impl PriceWithRatioPerBlock { usd: price.usd, cents: price.cents, sats: price.sats, - bps: ratio.bps, + raw: ratio.raw, ratio: ratio.ratio, }) } @@ -44,15 +44,18 @@ impl PriceWithRatioPerBlock { close_price: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - self.bps.height.compute_transform2( + self.raw.height.compute_transform2( starting_lengths.height, close_price, &self.cents.height, |(i, close, price, ..)| { if price == Cents::ZERO { - (i, BasisPoints32::from(1.0)) + (i, PartsPerMillion64::from(1.0)) } else { - (i, BasisPoints32::from(f64::from(close) / f64::from(price))) + ( + i, + PartsPerMillion64::from(f64::from(close) / f64::from(price)), + ) } }, 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 index 287885a5e..4fce459e1 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/sma.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/sma.rs @@ -1,7 +1,7 @@ use brk_error::Result; use brk_indexer::Lengths; use brk_traversable::Traversable; -use brk_types::{BasisPoints32, Height, StoredF32, Version}; +use brk_types::{Height, PartsPerMillion32, StoredF32, Version}; use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode}; use crate::{blocks, indexes}; @@ -10,12 +10,12 @@ 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, + pub all: RatioPerBlock, + pub _1w: RatioPerBlock, + pub _1m: RatioPerBlock, + pub _1y: RatioPerBlock, + pub _2y: RatioPerBlock, + pub _4y: RatioPerBlock, } const VERSION: Version = Version::new(4); @@ -58,7 +58,7 @@ impl RatioSma { ratio_source: &impl ReadableVec, ) -> Result<()> { // Expanding SMA (all history) - self.all.bps.height.compute_sma_( + self.all.raw.height.compute_sma_( starting_lengths.height, ratio_source, usize::MAX, @@ -74,7 +74,7 @@ impl RatioSma { (&mut self._2y, &blocks.lookback._2y), (&mut self._4y, &blocks.lookback._4y), ] { - sma.bps.height.compute_rolling_average( + sma.raw.height.compute_rolling_average( starting_lengths.height, lookback, ratio_source, diff --git a/crates/brk_computer/src/internal/per_block/ratio/windows.rs b/crates/brk_computer/src/internal/per_block/ratio/windows.rs index 63bc6493c..d23afea8c 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/windows.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/windows.rs @@ -6,16 +6,17 @@ use vecdb::{BinaryTransform, Database, Exit, ReadableVec, Rw, StorageMode, VecVa use crate::{ indexes, - internal::{BpsType, RatioPerBlock, Windows}, + internal::{FixedRatio, RatioPerBlock, Windows}, }; -/// 4 rolling window vecs (24h, 1w, 1m, 1y), each storing basis points -/// with a lazy ratio float view. +/// Four rolling-window ratios with fixed-point storage and lazy float views. #[derive(Deref, DerefMut, Traversable)] #[traversable(transparent)] -pub struct RatioRollingWindows(pub Windows>); +pub struct RatioRollingWindows( + pub Windows>, +); -impl RatioRollingWindows { +impl RatioRollingWindows { pub(crate) fn forced_import( db: &Database, name: &str, @@ -49,7 +50,7 @@ impl RatioRollingWindows { .zip(sources2) { target - .bps + .raw .compute_binary::(max_from, s1, s2, exit)?; } Ok(()) diff --git a/crates/brk_computer/src/internal/per_block/rolling/delta.rs b/crates/brk_computer/src/internal/per_block/rolling/delta.rs index 541298656..d2a04abf1 100644 --- a/crates/brk_computer/src/internal/per_block/rolling/delta.rs +++ b/crates/brk_computer/src/internal/per_block/rolling/delta.rs @@ -10,7 +10,7 @@ use vecdb::{ use crate::{ indexes, internal::{ - AmountType, BpsType, DerivedResolutions, FiatType, LazyPerBlock, NumericValue, Percent, + AmountType, DerivedResolutions, FiatType, FixedRatio, LazyPerBlock, NumericValue, Percent, Resolutions, WindowStartVec, Windows, }, }; @@ -19,7 +19,7 @@ use crate::{ /// /// Used as building block for both change and rate deltas. /// - Change: `LazyDeltaFromHeight` -/// - Rate BPS: `LazyDeltaFromHeight` +/// - Rate: `LazyDeltaFromHeight` #[derive(Clone, Traversable)] #[traversable(merge)] pub struct LazyDeltaFromHeight @@ -32,9 +32,9 @@ where pub resolutions: Box>, } -/// Single-slot lazy delta percent: BPS delta + lazy ratio + lazy percent views. +/// Single-slot lazy delta percent: fixed-point delta + lazy ratio + lazy percent views. /// -/// Mirrors `PercentPerBlock` but with lazy delta for the BPS source. +/// Mirrors `PercentPerBlock` but with a lazy delta source. #[derive(Clone, Deref, DerefMut, Traversable)] #[traversable(transparent)] pub struct LazyDeltaPercentFromHeight( @@ -42,7 +42,7 @@ pub struct LazyDeltaPercentFromHeight( ) where S: VecValue, - B: BpsType; + B: FixedRatio; /// Lazy rolling deltas for all 4 window durations (24h, 1w, 1m, 1y). /// @@ -55,7 +55,7 @@ pub struct LazyRollingDeltasFromHeight where S: VecValue, C: NumericValue + JsonSchema, - B: BpsType, + B: FixedRatio, { pub absolute: Windows>, pub rate: Windows>, @@ -65,7 +65,7 @@ impl LazyRollingDeltasFromHeight where S: VecValue + Into, C: NumericValue + JsonSchema + From, - B: BpsType + From, + B: FixedRatio + From, { pub fn new( name: &str, @@ -99,54 +99,52 @@ where resolutions: Box::new(change_resolutions), }; - // Rate BPS: (source[h] - source[ago]) / source[ago] as B (via f64) - let rate_bps_name = format!("{full_name}_rate_bps"); + // Rate: (source[h] - source[ago]) / source[ago] as B (via f64) + let rate_raw_name = format!("{full_name}_rate_{}", B::SUFFIX); let rate_vec = LazyDeltaVec::::new( - &rate_bps_name, + &rate_raw_name, version, src.clone(), starts_version, move || cached.cached(), ); let rate_resolutions = - Resolutions::forced_import(&rate_bps_name, rate_vec.clone(), version, indexes); - let bps = LazyDeltaFromHeight { + Resolutions::forced_import(&rate_raw_name, rate_vec.clone(), version, indexes); + let raw = LazyDeltaFromHeight { height: rate_vec, resolutions: Box::new(rate_resolutions), }; - // Ratio: bps / 10000 let rate_ratio_name = format!("{full_name}_rate_ratio"); let ratio = LazyPerBlock { height: LazyVecFrom1::transformed::( &rate_ratio_name, version, - bps.height.read_only_boxed_clone(), + raw.height.read_only_boxed_clone(), ), resolutions: Box::new(DerivedResolutions::from_derived_computed::( &rate_ratio_name, version, - &bps.resolutions, + &raw.resolutions, )), }; - // Percent: bps / 100 let rate_name = format!("{full_name}_rate"); let percent = LazyPerBlock { height: LazyVecFrom1::transformed::( &rate_name, version, - bps.height.read_only_boxed_clone(), + raw.height.read_only_boxed_clone(), ), resolutions: Box::new(DerivedResolutions::from_derived_computed::( &rate_name, version, - &bps.resolutions, + &raw.resolutions, )), }; let rate = LazyDeltaPercentFromHeight(Percent { - bps, + raw, ratio, percent, }); @@ -186,7 +184,7 @@ pub struct LazyRollingDeltasAmountFromHeight where S: VecValue, C: AmountType, - B: BpsType, + B: FixedRatio, { pub absolute: Windows>, pub rate: Windows>, @@ -196,7 +194,7 @@ impl LazyRollingDeltasAmountFromHeight where S: VecValue + Into, C: AmountType + From, - B: BpsType + From, + B: FixedRatio + From, { pub fn new( name: &str, @@ -247,18 +245,18 @@ where let absolute = LazyDeltaAmountFromHeight { btc, sats }; - // Rate BPS: (source[h] - source[ago]) / source[ago] as B (via f64) - let rate_bps_name = format!("{full_name}_rate_bps"); + // Rate: (source[h] - source[ago]) / source[ago] as B (via f64) + let rate_raw_name = format!("{full_name}_rate_{}", B::SUFFIX); let rate_vec = LazyDeltaVec::::new( - &rate_bps_name, + &rate_raw_name, version, src.clone(), starts_version, move || cached.cached(), ); let rate_resolutions = - Resolutions::forced_import(&rate_bps_name, rate_vec.clone(), version, indexes); - let bps = LazyDeltaFromHeight { + Resolutions::forced_import(&rate_raw_name, rate_vec.clone(), version, indexes); + let raw = LazyDeltaFromHeight { height: rate_vec, resolutions: Box::new(rate_resolutions), }; @@ -268,12 +266,12 @@ where height: LazyVecFrom1::transformed::( &rate_ratio_name, version, - bps.height.read_only_boxed_clone(), + raw.height.read_only_boxed_clone(), ), resolutions: Box::new(DerivedResolutions::from_derived_computed::( &rate_ratio_name, version, - &bps.resolutions, + &raw.resolutions, )), }; @@ -282,17 +280,17 @@ where height: LazyVecFrom1::transformed::( &rate_name, version, - bps.height.read_only_boxed_clone(), + raw.height.read_only_boxed_clone(), ), resolutions: Box::new(DerivedResolutions::from_derived_computed::( &rate_name, version, - &bps.resolutions, + &raw.resolutions, )), }; let rate = LazyDeltaPercentFromHeight(Percent { - bps, + raw, ratio, percent, }); @@ -331,7 +329,7 @@ pub struct LazyRollingDeltasFiatFromHeight where S: VecValue, C: FiatType, - B: BpsType, + B: FixedRatio, { pub absolute: Windows>, pub rate: Windows>, @@ -341,7 +339,7 @@ impl LazyRollingDeltasFiatFromHeight where S: VecValue + Into, C: FiatType + From, - B: BpsType + From, + B: FixedRatio + From, { pub fn new( name: &str, @@ -392,18 +390,18 @@ where let absolute = LazyDeltaFiatFromHeight { usd, cents }; - // Rate BPS: (source[h] - source[ago]) / source[ago] as B (via f64) - let rate_bps_name = format!("{full_name}_rate_bps"); + // Rate: (source[h] - source[ago]) / source[ago] as B (via f64) + let rate_raw_name = format!("{full_name}_rate_{}", B::SUFFIX); let rate_vec = LazyDeltaVec::::new( - &rate_bps_name, + &rate_raw_name, version, src.clone(), starts_version, move || cached.cached(), ); let rate_resolutions = - Resolutions::forced_import(&rate_bps_name, rate_vec.clone(), version, indexes); - let bps = LazyDeltaFromHeight { + Resolutions::forced_import(&rate_raw_name, rate_vec.clone(), version, indexes); + let raw = LazyDeltaFromHeight { height: rate_vec, resolutions: Box::new(rate_resolutions), }; @@ -413,12 +411,12 @@ where height: LazyVecFrom1::transformed::( &rate_ratio_name, version, - bps.height.read_only_boxed_clone(), + raw.height.read_only_boxed_clone(), ), resolutions: Box::new(DerivedResolutions::from_derived_computed::( &rate_ratio_name, version, - &bps.resolutions, + &raw.resolutions, )), }; @@ -427,17 +425,17 @@ where height: LazyVecFrom1::transformed::( &rate_name, version, - bps.height.read_only_boxed_clone(), + raw.height.read_only_boxed_clone(), ), resolutions: Box::new(DerivedResolutions::from_derived_computed::( &rate_name, version, - &bps.resolutions, + &raw.resolutions, )), }; let rate = LazyDeltaPercentFromHeight(Percent { - bps, + raw, ratio, percent, }); diff --git a/crates/brk_computer/src/internal/per_block/value/with_deltas.rs b/crates/brk_computer/src/internal/per_block/value/with_deltas.rs index 9f9ede07e..a99e7e440 100644 --- a/crates/brk_computer/src/internal/per_block/value/with_deltas.rs +++ b/crates/brk_computer/src/internal/per_block/value/with_deltas.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Sats, SatsSigned, Version}; +use brk_types::{PartsPerMillionSigned64, Sats, SatsSigned, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{Database, Rw, StorageMode}; @@ -15,7 +15,7 @@ pub struct ValuePerBlockWithDeltas { #[deref_mut] #[traversable(flatten)] pub inner: ValuePerBlock, - pub delta: LazyRollingDeltasAmountFromHeight, + pub delta: LazyRollingDeltasAmountFromHeight, } impl ValuePerBlockWithDeltas { @@ -30,7 +30,7 @@ impl ValuePerBlockWithDeltas { let delta = LazyRollingDeltasAmountFromHeight::new( &format!("{name}_delta"), - version + Version::ONE, + version + Version::TWO, &inner.sats.height, cached_starts, indexes, diff --git a/crates/brk_computer/src/internal/traits.rs b/crates/brk_computer/src/internal/traits.rs index 173a816d0..15746baa8 100644 --- a/crates/brk_computer/src/internal/traits.rs +++ b/crates/brk_computer/src/internal/traits.rs @@ -1,16 +1,14 @@ use std::ops::{Add, AddAssign, Div}; use brk_types::{ - BasisPoints16, BasisPoints32, BasisPointsSigned16, BasisPointsSigned32, StoredF32, + PartsPerMillion32, PartsPerMillion64, PartsPerMillionSigned32, PartsPerMillionSigned64, + StoredF32, }; use schemars::JsonSchema; use serde::Serialize; use vecdb::{CheckedSub, Formattable, PcoVecValue, UnaryTransform}; -use crate::internal::{ - Bp16ToFloat, Bp16ToPercent, Bp32ToFloat, Bp32ToPercent, Bps16ToFloat, Bps16ToPercent, - Bps32ToFloat, Bps32ToPercent, -}; +use crate::internal::{FixedToPercent, FixedToRatio}; pub trait ComputedVecValue where @@ -40,28 +38,38 @@ pub trait NumericValue: ComputedVecValue + CheckedSub + Default + From + In impl NumericValue for T where T: ComputedVecValue + CheckedSub + Default + From + Into {} -/// Trait that associates a basis-point type with its transforms to ratio and percent. -pub trait BpsType: NumericValue + JsonSchema { +/// A stored fixed-point ratio and its public representations. +pub trait FixedRatio: NumericValue + JsonSchema { + const SUFFIX: &'static str; + type ToRatio: UnaryTransform; type ToPercent: UnaryTransform; } -impl BpsType for BasisPoints16 { - type ToRatio = Bp16ToFloat; - type ToPercent = Bp16ToPercent; +impl FixedRatio for PartsPerMillion32 { + const SUFFIX: &'static str = "ppm"; + + type ToRatio = FixedToRatio; + type ToPercent = FixedToPercent; } -impl BpsType for BasisPoints32 { - type ToRatio = Bp32ToFloat; - type ToPercent = Bp32ToPercent; +impl FixedRatio for PartsPerMillionSigned32 { + const SUFFIX: &'static str = "ppm"; + + type ToRatio = FixedToRatio; + type ToPercent = FixedToPercent; } -impl BpsType for BasisPointsSigned16 { - type ToRatio = Bps16ToFloat; - type ToPercent = Bps16ToPercent; +impl FixedRatio for PartsPerMillion64 { + const SUFFIX: &'static str = "ppm"; + + type ToRatio = FixedToRatio; + type ToPercent = FixedToPercent; } -impl BpsType for BasisPointsSigned32 { - type ToRatio = Bps32ToFloat; - type ToPercent = Bps32ToPercent; +impl FixedRatio for PartsPerMillionSigned64 { + const SUFFIX: &'static str = "ppm"; + + type ToRatio = FixedToRatio; + type ToPercent = FixedToPercent; } diff --git a/crates/brk_computer/src/internal/transform/arithmetic.rs b/crates/brk_computer/src/internal/transform/arithmetic.rs index 508d71944..4eb02d182 100644 --- a/crates/brk_computer/src/internal/transform/arithmetic.rs +++ b/crates/brk_computer/src/internal/transform/arithmetic.rs @@ -1,7 +1,7 @@ use std::marker::PhantomData; use brk_types::{ - BasisPoints16, Bitcoin, Cents, Dollars, Sats, StoredF32, StoredF64, StoredI8, StoredU16, + Bitcoin, Cents, Dollars, PartsPerMillion32, Sats, StoredF32, StoredF64, StoredI8, StoredU16, StoredU32, StoredU64, VSize, Weight, }; use vecdb::{BinaryTransform, UnaryTransform, VecValue}; @@ -128,12 +128,12 @@ impl UnaryTransform for DifficultyToHashF64 { } } -pub struct OneMinusBp16; +pub struct OneMinusPpm; -impl UnaryTransform for OneMinusBp16 { +impl UnaryTransform for OneMinusPpm { #[inline(always)] - fn apply(v: BasisPoints16) -> BasisPoints16 { - BasisPoints16::ONE - v + fn apply(value: PartsPerMillion32) -> PartsPerMillion32 { + PartsPerMillion32::ONE - value } } diff --git a/crates/brk_computer/src/internal/transform/bps.rs b/crates/brk_computer/src/internal/transform/bps.rs deleted file mode 100644 index eb7c236c8..000000000 --- a/crates/brk_computer/src/internal/transform/bps.rs +++ /dev/null @@ -1,76 +0,0 @@ -use brk_types::{ - BasisPoints16, BasisPoints32, BasisPointsSigned16, BasisPointsSigned32, StoredF32, -}; -use vecdb::UnaryTransform; - -pub struct Bp16ToFloat; - -impl UnaryTransform for Bp16ToFloat { - #[inline(always)] - fn apply(bp: BasisPoints16) -> StoredF32 { - StoredF32::from(bp.to_f32()) - } -} - -pub struct Bp32ToFloat; - -impl UnaryTransform for Bp32ToFloat { - #[inline(always)] - fn apply(bp: BasisPoints32) -> StoredF32 { - StoredF32::from(bp.to_f32()) - } -} - -pub struct Bps16ToFloat; - -impl UnaryTransform for Bps16ToFloat { - #[inline(always)] - fn apply(bp: BasisPointsSigned16) -> StoredF32 { - StoredF32::from(bp.to_f32()) - } -} - -pub struct Bps32ToFloat; - -impl UnaryTransform for Bps32ToFloat { - #[inline(always)] - fn apply(bp: BasisPointsSigned32) -> StoredF32 { - StoredF32::from(bp.to_f32()) - } -} - -pub struct Bp16ToPercent; - -impl UnaryTransform for Bp16ToPercent { - #[inline(always)] - fn apply(bp: BasisPoints16) -> StoredF32 { - StoredF32::from(bp.to_f32() * 100.0) - } -} - -pub struct Bp32ToPercent; - -impl UnaryTransform for Bp32ToPercent { - #[inline(always)] - fn apply(bp: BasisPoints32) -> StoredF32 { - StoredF32::from(bp.to_f32() * 100.0) - } -} - -pub struct Bps16ToPercent; - -impl UnaryTransform for Bps16ToPercent { - #[inline(always)] - fn apply(bp: BasisPointsSigned16) -> StoredF32 { - StoredF32::from(bp.to_f32() * 100.0) - } -} - -pub struct Bps32ToPercent; - -impl UnaryTransform for Bps32ToPercent { - #[inline(always)] - fn apply(bp: BasisPointsSigned32) -> StoredF32 { - StoredF32::from(bp.to_f32() * 100.0) - } -} diff --git a/crates/brk_computer/src/internal/transform/derived.rs b/crates/brk_computer/src/internal/transform/derived.rs index 1271c602d..60eec5854 100644 --- a/crates/brk_computer/src/internal/transform/derived.rs +++ b/crates/brk_computer/src/internal/transform/derived.rs @@ -1,8 +1,10 @@ use std::marker::PhantomData; -use brk_types::{BasisPoints32, Cents, StoredF32, StoredF64}; +use brk_types::{Cents, StoredF32, StoredF64}; use vecdb::{BinaryTransform, UnaryTransform}; +use crate::internal::FixedRatio; + pub struct DaysToYears; impl UnaryTransform for DaysToYears { @@ -54,12 +56,12 @@ impl BinaryTransform for PriceTimesRatioCents { } } -pub struct PriceTimesRatioBp32Cents; +pub struct PriceTimesRatio(PhantomData); -impl BinaryTransform for PriceTimesRatioBp32Cents { +impl BinaryTransform for PriceTimesRatio { #[inline(always)] - fn apply(price: Cents, ratio: BasisPoints32) -> Cents { - Cents::from(f64::from(price) * f64::from(ratio)) + fn apply(price: Cents, ratio: R) -> Cents { + Cents::from(f64::from(price) * ratio.into()) } } diff --git a/crates/brk_computer/src/internal/transform/fixed_ratio.rs b/crates/brk_computer/src/internal/transform/fixed_ratio.rs new file mode 100644 index 000000000..8b374d523 --- /dev/null +++ b/crates/brk_computer/src/internal/transform/fixed_ratio.rs @@ -0,0 +1,35 @@ +use brk_types::{ + PartsPerMillion32, PartsPerMillion64, PartsPerMillionSigned32, PartsPerMillionSigned64, + StoredF32, +}; +use vecdb::UnaryTransform; + +pub struct FixedToRatio; +pub struct FixedToPercent; + +macro_rules! impl_fixed_ratio { + ($($type:ty),+ $(,)?) => { + $( + impl UnaryTransform<$type, StoredF32> for FixedToRatio { + #[inline(always)] + fn apply(value: $type) -> StoredF32 { + StoredF32::from(value.to_f32()) + } + } + + impl UnaryTransform<$type, StoredF32> for FixedToPercent { + #[inline(always)] + fn apply(value: $type) -> StoredF32 { + StoredF32::from(value.to_f32() * 100.0) + } + } + )+ + }; +} + +impl_fixed_ratio!( + PartsPerMillion32, + PartsPerMillionSigned32, + PartsPerMillion64, + PartsPerMillionSigned64, +); diff --git a/crates/brk_computer/src/internal/transform/mod.rs b/crates/brk_computer/src/internal/transform/mod.rs index ae2ff420f..fb3cad604 100644 --- a/crates/brk_computer/src/internal/transform/mod.rs +++ b/crates/brk_computer/src/internal/transform/mod.rs @@ -1,32 +1,28 @@ mod arithmetic; -mod bps; mod currency; mod derived; +mod fixed_ratio; mod ratio; mod specialized; pub use arithmetic::{ BlocksToDaysF32, DifficultyToHashF64, HalveCents, HalveDollars, HalveSats, HalveSatsToBitcoin, - Identity, MaskSats, OneMinusBp16, OneMinusF64, ReturnF32Tenths, ReturnI8, ReturnU16, + Identity, MaskSats, OneMinusF64, OneMinusPpm, ReturnF32Tenths, ReturnI8, ReturnU16, ThsToPhsF32, VBytesToWeight, WeightToVSize, }; -pub use bps::{ - Bp16ToFloat, Bp16ToPercent, Bp32ToFloat, Bp32ToPercent, Bps16ToFloat, Bps16ToPercent, - Bps32ToFloat, Bps32ToPercent, -}; pub use currency::{ AvgCentsToUsd, AvgSatsToBtc, CentsSignedToDollars, CentsSubtractToCentsSigned, CentsTimesTenths, CentsUnsignedToDollars, CentsUnsignedToSats, DollarsToSatsFract, NegCentsUnsignedToDollars, SatsSignedToBitcoin, SatsToBitcoin, SatsToCents, }; pub use derived::{ - Days1, Days7, Days30, Days365, DaysToYears, PriceTimesRatioBp32Cents, PriceTimesRatioCents, - RatioCents64, TimesSqrt, + Days1, Days7, Days30, Days365, DaysToYears, PriceTimesRatio, PriceTimesRatioCents, RatioCents64, + TimesSqrt, }; +pub use fixed_ratio::{FixedToPercent, FixedToRatio}; pub use ratio::{ - RatioCentsBp16, RatioCentsBp32, RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32, - RatioDiffCentsBps32, RatioDiffDollarsBps32, RatioDiffF32Bps32, RatioDollarsBp16, - RatioDollarsBp32, RatioDollarsBps32, RatioSatsBp16, RatioU64Bp16, RatioU64F32, + RatioCents, RatioCentsSignedCents, RatioCentsSignedDollars, RatioDiffCents, + RatioDiffDollars, RatioDiffF32, RatioDollars, RatioSats, RatioU64, RatioU64F32, }; pub use specialized::{ BlockCountTarget1m, BlockCountTarget1w, BlockCountTarget1y, BlockCountTarget24h, diff --git a/crates/brk_computer/src/internal/transform/ratio.rs b/crates/brk_computer/src/internal/transform/ratio.rs index 659849908..56fcd9eba 100644 --- a/crates/brk_computer/src/internal/transform/ratio.rs +++ b/crates/brk_computer/src/internal/transform/ratio.rs @@ -1,126 +1,86 @@ -use brk_types::{ - BasisPoints16, BasisPoints32, BasisPointsSigned32, Cents, CentsSigned, Dollars, Sats, - StoredF32, StoredU64, -}; +use std::marker::PhantomData; + +use brk_types::{Cents, CentsSigned, Dollars, Sats, StoredF32, StoredU64}; use vecdb::BinaryTransform; -pub struct RatioU64Bp16; +use crate::internal::FixedRatio; -impl BinaryTransform for RatioU64Bp16 { +pub struct RatioU64

(PhantomData

); + +impl BinaryTransform for RatioU64

{ #[inline(always)] - fn apply(numerator: StoredU64, denominator: StoredU64) -> BasisPoints16 { + fn apply(numerator: StoredU64, denominator: StoredU64) -> P { if *denominator > 0 { - BasisPoints16::from(*numerator as f64 / *denominator as f64) + P::from(*numerator as f64 / *denominator as f64) } else { - BasisPoints16::ZERO + P::default() } } } -pub struct RatioSatsBp16; +pub struct RatioSats

(PhantomData

); -impl BinaryTransform for RatioSatsBp16 { +impl BinaryTransform for RatioSats

{ #[inline(always)] - fn apply(numerator: Sats, denominator: Sats) -> BasisPoints16 { + fn apply(numerator: Sats, denominator: Sats) -> P { if *denominator > 0 { - BasisPoints16::from(*numerator as f64 / *denominator as f64) + P::from(*numerator as f64 / *denominator as f64) } else { - BasisPoints16::ZERO + P::default() } } } -pub struct RatioCentsBp32; +pub struct RatioCents

(PhantomData

); -impl BinaryTransform for RatioCentsBp32 { +impl BinaryTransform for RatioCents

{ #[inline(always)] - fn apply(numerator: Cents, denominator: Cents) -> BasisPoints32 { + fn apply(numerator: Cents, denominator: Cents) -> P { if denominator == Cents::ZERO { - BasisPoints32::ZERO + P::default() } else { - BasisPoints32::from(numerator.inner() as f64 / denominator.inner() as f64) + P::from(numerator.inner() as f64 / denominator.inner() as f64) } } } -pub struct RatioCentsBp16; +pub struct RatioDollars

(PhantomData

); -impl BinaryTransform for RatioCentsBp16 { +impl BinaryTransform for RatioDollars

{ #[inline(always)] - fn apply(numerator: Cents, denominator: Cents) -> BasisPoints16 { - if denominator == Cents::ZERO { - BasisPoints16::ZERO - } else { - BasisPoints16::from(numerator.inner() as f64 / denominator.inner() as f64) - } - } -} - -pub struct RatioDollarsBp16; - -impl BinaryTransform for RatioDollarsBp16 { - #[inline(always)] - fn apply(numerator: Dollars, denominator: Dollars) -> BasisPoints16 { - let ratio = *(numerator / denominator); - if ratio.is_finite() { - BasisPoints16::from(ratio) - } else { - BasisPoints16::ZERO - } - } -} - -pub struct RatioDollarsBps32; - -impl BinaryTransform for RatioDollarsBps32 { - #[inline(always)] - fn apply(numerator: Dollars, denominator: Dollars) -> BasisPointsSigned32 { - let ratio = *(numerator / denominator); - if ratio.is_finite() { - BasisPointsSigned32::from(ratio) - } else { - BasisPointsSigned32::ZERO - } - } -} - -pub struct RatioCentsSignedCentsBps32; - -impl BinaryTransform for RatioCentsSignedCentsBps32 { - #[inline(always)] - fn apply(numerator: CentsSigned, denominator: Cents) -> BasisPointsSigned32 { - if denominator == Cents::ZERO { - BasisPointsSigned32::ZERO - } else { - BasisPointsSigned32::from(numerator.inner() as f64 / denominator.inner() as f64) - } - } -} - -pub struct RatioCentsSignedDollarsBps32; - -impl BinaryTransform for RatioCentsSignedDollarsBps32 { - #[inline(always)] - fn apply(numerator: CentsSigned, denominator: Dollars) -> BasisPointsSigned32 { - let d: f64 = denominator.into(); - if d > 0.0 { - BasisPointsSigned32::from(numerator.inner() as f64 / 100.0 / d) - } else { - BasisPointsSigned32::ZERO - } - } -} - -pub struct RatioDollarsBp32; - -impl BinaryTransform for RatioDollarsBp32 { - #[inline(always)] - fn apply(numerator: Dollars, denominator: Dollars) -> BasisPoints32 { + fn apply(numerator: Dollars, denominator: Dollars) -> P { let ratio = f64::from(numerator) / f64::from(denominator); if ratio.is_finite() { - BasisPoints32::from(ratio) + P::from(ratio) } else { - BasisPoints32::ZERO + P::default() + } + } +} + +pub struct RatioCentsSignedCents

(PhantomData

); + +impl BinaryTransform for RatioCentsSignedCents

{ + #[inline(always)] + fn apply(numerator: CentsSigned, denominator: Cents) -> P { + if denominator == Cents::ZERO { + P::default() + } else { + P::from(numerator.inner() as f64 / denominator.inner() as f64) + } + } +} + +pub struct RatioCentsSignedDollars

(PhantomData

); + +impl BinaryTransform for RatioCentsSignedDollars

{ + #[inline(always)] + fn apply(numerator: CentsSigned, denominator: Dollars) -> P { + let denominator = f64::from(denominator); + if denominator > 0.0 { + P::from(numerator.inner() as f64 / 100.0 / denominator) + } else { + P::default() } } } @@ -138,43 +98,43 @@ impl BinaryTransform for RatioU64F32 { } } -pub struct RatioDiffF32Bps32; +pub struct RatioDiffF32

(PhantomData

); -impl BinaryTransform for RatioDiffF32Bps32 { +impl BinaryTransform for RatioDiffF32

{ #[inline(always)] - fn apply(value: StoredF32, base: StoredF32) -> BasisPointsSigned32 { + fn apply(value: StoredF32, base: StoredF32) -> P { if base.is_nan() || *base == 0.0 { - BasisPointsSigned32::ZERO + P::default() } else { - BasisPointsSigned32::from((*value / *base - 1.0) as f64) + P::from((*value / *base - 1.0) as f64) } } } -pub struct RatioDiffDollarsBps32; +pub struct RatioDiffDollars

(PhantomData

); -impl BinaryTransform for RatioDiffDollarsBps32 { +impl BinaryTransform for RatioDiffDollars

{ #[inline(always)] - fn apply(close: Dollars, base: Dollars) -> BasisPointsSigned32 { - let base_f64: f64 = base.into(); - if base_f64 == 0.0 { - BasisPointsSigned32::ZERO + fn apply(close: Dollars, base: Dollars) -> P { + let base = f64::from(base); + if base == 0.0 { + P::default() } else { - BasisPointsSigned32::from(f64::from(close) / base_f64 - 1.0) + P::from(f64::from(close) / base - 1.0) } } } -pub struct RatioDiffCentsBps32; +pub struct RatioDiffCents

(PhantomData

); -impl BinaryTransform for RatioDiffCentsBps32 { +impl BinaryTransform for RatioDiffCents

{ #[inline(always)] - fn apply(close: Cents, base: Cents) -> BasisPointsSigned32 { - let base_f64 = f64::from(base); - if base_f64 == 0.0 { - BasisPointsSigned32::ZERO + fn apply(close: Cents, base: Cents) -> P { + let base = f64::from(base); + if base == 0.0 { + P::default() } else { - BasisPointsSigned32::from(f64::from(close) / base_f64 - 1.0) + P::from(f64::from(close) / base - 1.0) } } } diff --git a/crates/brk_computer/src/internal/with_addr_types.rs b/crates/brk_computer/src/internal/with_addr_types.rs index ecf4b3a9d..4c22ef2e9 100644 --- a/crates/brk_computer/src/internal/with_addr_types.rs +++ b/crates/brk_computer/src/internal/with_addr_types.rs @@ -14,7 +14,7 @@ use vecdb::{AnyStoredVec, AnyVec, Database, EagerVec, Exit, PcoVec, WritableVec} use crate::{indexes, price}; use super::{ - BpsType, NumericValue, PerBlock, PerBlockCumulativeRolling, PercentPerBlock, ValuePerBlock, + FixedRatio, NumericValue, PerBlock, PerBlockCumulativeRolling, PercentPerBlock, ValuePerBlock, WindowStartVec, Windows, }; @@ -276,7 +276,7 @@ impl WithAddrTypes { } } -impl WithAddrTypes> { +impl WithAddrTypes> { pub(crate) fn forced_import( db: &Database, name: &str, @@ -291,9 +291,9 @@ impl WithAddrTypes> { } pub(crate) fn reset_height(&mut self) -> Result<()> { - self.all.bps.height.reset()?; + self.all.raw.height.reset()?; for v in self.by_addr_type.values_mut() { - v.bps.height.reset()?; + v.raw.height.reset()?; } Ok(()) } diff --git a/crates/brk_computer/src/investing/compute.rs b/crates/brk_computer/src/investing/compute.rs index f07e83f35..6a2848a91 100644 --- a/crates/brk_computer/src/investing/compute.rs +++ b/crates/brk_computer/src/investing/compute.rs @@ -1,10 +1,10 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{BasisPointsSigned32, Bitcoin, Cents, Date, Day1, Dollars, Sats}; +use brk_types::{Bitcoin, Cents, Date, Day1, Dollars, PartsPerMillionSigned64, Sats}; use vecdb::{AnyVec, Exit, ReadableOptionVec, ReadableVec, VecIndex}; use super::{ByDcaPeriod, Vecs}; -use crate::{blocks, indexes, internal::RatioDiffCentsBps32, market, price}; +use crate::{blocks, indexes, internal::RatioDiffCents, market, price}; const DCA_AMOUNT: Dollars = Dollars::mint(100.0); @@ -102,7 +102,7 @@ impl Vecs { .iter_mut() .zip(self.period.dca_cost_basis.iter_with_days()) { - returns.compute_binary::( + returns.compute_binary::>( starting_lengths.height, &prices.spot.cents.height, &average_price.cents.height, @@ -117,13 +117,13 @@ impl Vecs { .zip_mut_with_period(&self.period.dca_return) { let years = days as f64 / 365.0; - cagr.bps.height.compute_transform( + cagr.raw.height.compute_transform( starting_lengths.height, - &returns.bps.height, + &returns.raw.height, |(h, r, ..)| { let ratio = f64::from(r); let v = (ratio + 1.0).powf(1.0 / years) - 1.0; - (h, BasisPointsSigned32::from(v)) + (h, PartsPerMillionSigned64::from(v)) }, exit, )?; @@ -163,7 +163,7 @@ impl Vecs { .iter_mut() .zip(lookback_dca.iter_with_days()) { - returns.compute_binary::( + returns.compute_binary::>( starting_lengths.height, &prices.spot.cents.height, &lookback_price.cents.height, @@ -266,7 +266,7 @@ impl Vecs { .iter_mut() .zip(self.class.dca_cost_basis.iter()) { - returns.compute_binary::( + returns.compute_binary::>( starting_lengths.height, &prices.spot.cents.height, &average_price.cents.height, diff --git a/crates/brk_computer/src/investing/vecs.rs b/crates/brk_computer/src/investing/vecs.rs index cf3ff3f32..618c81769 100644 --- a/crates/brk_computer/src/investing/vecs.rs +++ b/crates/brk_computer/src/investing/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Cents, Height, Sats}; +use brk_types::{Cents, Height, PartsPerMillionSigned64, Sats}; use vecdb::{Database, EagerVec, PcoVec, Rw, StorageMode}; use super::{ByDcaCagr, ByDcaClass, ByDcaPeriod}; @@ -9,17 +9,17 @@ use crate::internal::{PerBlock, PercentPerBlock, Price, ValuePerBlock}; pub struct PeriodVecs { pub dca_stack: ByDcaPeriod>, pub dca_cost_basis: ByDcaPeriod>>, - pub dca_return: ByDcaPeriod>, - pub dca_cagr: ByDcaCagr>, + pub dca_return: ByDcaPeriod>, + pub dca_cagr: ByDcaCagr>, pub lump_sum_stack: ByDcaPeriod>, - pub lump_sum_return: ByDcaPeriod>, + pub lump_sum_return: ByDcaPeriod>, } #[derive(Traversable)] pub struct ClassVecs { pub dca_stack: ByDcaClass>, pub dca_cost_basis: ByDcaClass>>, - pub dca_return: ByDcaClass>, + pub dca_return: ByDcaClass>, } #[derive(Traversable)] diff --git a/crates/brk_computer/src/market/ath/vecs.rs b/crates/brk_computer/src/market/ath/vecs.rs index 6a2c21b4f..10e770abd 100644 --- a/crates/brk_computer/src/market/ath/vecs.rs +++ b/crates/brk_computer/src/market/ath/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned16, Cents, StoredF32}; +use brk_types::{Cents, PartsPerMillionSigned32, StoredF32}; use vecdb::{Rw, StorageMode}; use crate::internal::{LazyPerBlock, PerBlock, PercentPerBlock, Price}; @@ -7,7 +7,7 @@ use crate::internal::{LazyPerBlock, PerBlock, PercentPerBlock, Price}; #[derive(Traversable)] pub struct Vecs { pub high: Price>, - pub drawdown: PercentPerBlock, + pub drawdown: PercentPerBlock, pub days_since: PerBlock, pub years_since: LazyPerBlock, pub max_days_between: PerBlock, diff --git a/crates/brk_computer/src/market/range/compute.rs b/crates/brk_computer/src/market/range/compute.rs index 6f791e620..fd620a9ce 100644 --- a/crates/brk_computer/src/market/range/compute.rs +++ b/crates/brk_computer/src/market/range/compute.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{BasisPoints16, StoredF32}; +use brk_types::{PartsPerMillion32, StoredF32}; use vecdb::{Exit, ReadableVec, VecIndex}; use super::Vecs; @@ -72,7 +72,7 @@ impl Vecs { exit, )?; - self.choppiness_index_2w.bps.height.compute_transform4( + self.choppiness_index_2w.raw.height.compute_transform4( starting_height, &self.true_range_sum_2w.height, &self.max._2w.cents.height, @@ -82,9 +82,11 @@ impl Vecs { let range = f64::from(max) - f64::from(min); let n = (h.to_usize() - window_start.to_usize() + 1) as f32; let ci = if range > 0.0 && n > 1.0 { - BasisPoints16::from((*tr_sum / range as f32).log10() as f64 / n.log10() as f64) + PartsPerMillion32::from( + (*tr_sum / range as f32).log10() as f64 / n.log10() as f64, + ) } else { - BasisPoints16::ZERO + PartsPerMillion32::ZERO }; (h, ci) }, diff --git a/crates/brk_computer/src/market/range/vecs.rs b/crates/brk_computer/src/market/range/vecs.rs index 122148953..fbc9a25c3 100644 --- a/crates/brk_computer/src/market/range/vecs.rs +++ b/crates/brk_computer/src/market/range/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Cents, StoredF32}; +use brk_types::{Cents, PartsPerMillion32, StoredF32}; use vecdb::{Rw, StorageMode}; use crate::internal::{PerBlock, PercentPerBlock, Price}; @@ -18,5 +18,5 @@ pub struct Vecs { pub max: PriceMinMaxVecs, pub true_range: PerBlock, pub true_range_sum_2w: PerBlock, - pub choppiness_index_2w: PercentPerBlock, + pub choppiness_index_2w: PercentPerBlock, } diff --git a/crates/brk_computer/src/market/returns/compute.rs b/crates/brk_computer/src/market/returns/compute.rs index 086a840e0..712eb93c9 100644 --- a/crates/brk_computer/src/market/returns/compute.rs +++ b/crates/brk_computer/src/market/returns/compute.rs @@ -1,12 +1,10 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{BasisPointsSigned32, Dollars}; +use brk_types::{Dollars, PartsPerMillionSigned64}; use vecdb::Exit; use super::Vecs; -use crate::{ - blocks, internal::RatioDiffDollarsBps32, investing::ByDcaPeriod, market::lookback, price, -}; +use crate::{blocks, internal::RatioDiffDollars, investing::ByDcaPeriod, market::lookback, price}; impl Vecs { pub(crate) fn compute( @@ -25,7 +23,7 @@ impl Vecs { .iter_mut_with_days() .zip(lookback.price_past.iter_with_days()) { - returns.compute_binary::( + returns.compute_binary::>( starting_lengths.height, &prices.spot.usd.height, &lookback_price.usd.height, @@ -37,13 +35,13 @@ impl Vecs { let price_return_dca = ByDcaPeriod::from_lookback(&self.periods); for (cagr, returns, days) in self.cagr.zip_mut_with_period(&price_return_dca) { let years = days as f64 / 365.0; - cagr.bps.height.compute_transform( + cagr.raw.height.compute_transform( starting_lengths.height, - &returns.bps.height, + &returns.raw.height, |(h, r, ..)| { let ratio = f64::from(r); let v = (ratio + 1.0).powf(1.0 / years) - 1.0; - (h, BasisPointsSigned32::from(v)) + (h, PartsPerMillionSigned64::from(v)) }, exit, )?; diff --git a/crates/brk_computer/src/market/returns/vecs.rs b/crates/brk_computer/src/market/returns/vecs.rs index 18e3423a3..58a1da512 100644 --- a/crates/brk_computer/src/market/returns/vecs.rs +++ b/crates/brk_computer/src/market/returns/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::BasisPointsSigned32; +use brk_types::PartsPerMillionSigned64; use vecdb::{Rw, StorageMode}; use crate::{ @@ -10,7 +10,7 @@ use crate::{ #[derive(Traversable)] pub struct Vecs { - pub periods: ByLookbackPeriod>, - pub cagr: ByDcaCagr>, + pub periods: ByLookbackPeriod>, + pub cagr: ByDcaCagr>, pub sd_24h: Windows>, } diff --git a/crates/brk_computer/src/market/technical/compute.rs b/crates/brk_computer/src/market/technical/compute.rs index a50178561..d96b6e159 100644 --- a/crates/brk_computer/src/market/technical/compute.rs +++ b/crates/brk_computer/src/market/technical/compute.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::Dollars; +use brk_types::{Dollars, PartsPerMillion32}; use vecdb::Exit; use super::{ @@ -9,7 +9,7 @@ use super::{ }; use crate::{ blocks, - internal::{RatioDollarsBp32, WindowsTo1m}, + internal::{RatioDollars, WindowsTo1m}, price, }; @@ -62,8 +62,8 @@ impl Vecs { } self.pi_cycle - .bps - .compute_binary::( + .raw + .compute_binary::>( starting_height, &moving_average.sma._111d.usd.height, &moving_average.sma._350d_x2.usd.height, diff --git a/crates/brk_computer/src/market/technical/rsi.rs b/crates/brk_computer/src/market/technical/rsi.rs index 9ce45586e..80d85d35d 100644 --- a/crates/brk_computer/src/market/technical/rsi.rs +++ b/crates/brk_computer/src/market/technical/rsi.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{BasisPoints16, Height, StoredF32}; +use brk_types::{Height, PartsPerMillion32, StoredF32}; use vecdb::{Exit, ReadableVec}; use super::RsiChain; @@ -47,60 +47,60 @@ pub(super) fn compute( exit, )?; - chain.rsi.bps.height.compute_transform2( + chain.rsi.raw.height.compute_transform2( starting_height, &chain.average_gain.height, &chain.average_loss.height, |(h, g, l, ..)| { let sum = *g + *l; let rsi = if sum == 0.0 { 0.5 } else { *g / sum }; - (h, BasisPoints16::from(rsi as f64)) + (h, PartsPerMillion32::from(rsi as f64)) }, exit, )?; - chain.rsi_min.bps.height.compute_rolling_min_from_starts( + chain.rsi_min.raw.height.compute_rolling_min_from_starts( starting_height, ws_rma, - &chain.rsi.bps.height, + &chain.rsi.raw.height, exit, )?; - chain.rsi_max.bps.height.compute_rolling_max_from_starts( + chain.rsi_max.raw.height.compute_rolling_max_from_starts( starting_height, ws_rma, - &chain.rsi.bps.height, + &chain.rsi.raw.height, exit, )?; - chain.stoch_rsi.bps.height.compute_transform3( + chain.stoch_rsi.raw.height.compute_transform3( starting_height, - &chain.rsi.bps.height, - &chain.rsi_min.bps.height, - &chain.rsi_max.bps.height, + &chain.rsi.raw.height, + &chain.rsi_min.raw.height, + &chain.rsi_max.raw.height, |(h, r, mn, mx, ..)| { let range = f64::from(*mx) - f64::from(*mn); let stoch = if range == 0.0 { - BasisPoints16::ZERO + PartsPerMillion32::ZERO } else { - BasisPoints16::from((f64::from(*r) - f64::from(*mn)) / range) + PartsPerMillion32::from((f64::from(*r) - f64::from(*mn)) / range) }; (h, stoch) }, exit, )?; - chain.stoch_rsi_k.bps.height.compute_rolling_average( + chain.stoch_rsi_k.raw.height.compute_rolling_average( starting_height, ws_sma, - &chain.stoch_rsi.bps.height, + &chain.stoch_rsi.raw.height, exit, )?; - chain.stoch_rsi_d.bps.height.compute_rolling_average( + chain.stoch_rsi_d.raw.height.compute_rolling_average( starting_height, ws_sma, - &chain.stoch_rsi_k.bps.height, + &chain.stoch_rsi_k.raw.height, exit, )?; diff --git a/crates/brk_computer/src/market/technical/vecs.rs b/crates/brk_computer/src/market/technical/vecs.rs index cc622e974..0ad577284 100644 --- a/crates/brk_computer/src/market/technical/vecs.rs +++ b/crates/brk_computer/src/market/technical/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPoints32, StoredF32}; +use brk_types::{PartsPerMillion32, StoredF32}; use vecdb::{Rw, StorageMode}; use crate::internal::{PerBlock, PercentPerBlock, RatioPerBlock, WindowsTo1m}; @@ -14,15 +14,15 @@ pub struct RsiChain { pub average_gain: PerBlock, #[traversable(hidden)] pub average_loss: PerBlock, - pub rsi: PercentPerBlock, + pub rsi: PercentPerBlock, #[traversable(hidden)] - pub rsi_min: PercentPerBlock, + pub rsi_min: PercentPerBlock, #[traversable(hidden)] - pub rsi_max: PercentPerBlock, + pub rsi_max: PercentPerBlock, #[traversable(hidden)] - pub stoch_rsi: PercentPerBlock, - pub stoch_rsi_k: PercentPerBlock, - pub stoch_rsi_d: PercentPerBlock, + pub stoch_rsi: PercentPerBlock, + pub stoch_rsi_k: PercentPerBlock, + pub stoch_rsi_d: PercentPerBlock, } #[derive(Traversable)] @@ -38,7 +38,7 @@ pub struct MacdChain { pub struct Vecs { pub rsi: WindowsTo1m>, - pub pi_cycle: RatioPerBlock, + pub pi_cycle: RatioPerBlock, pub macd: WindowsTo1m>, } diff --git a/crates/brk_computer/src/mining/hashrate/compute.rs b/crates/brk_computer/src/mining/hashrate/compute.rs index 457ec91fa..f76ce5117 100644 --- a/crates/brk_computer/src/mining/hashrate/compute.rs +++ b/crates/brk_computer/src/mining/hashrate/compute.rs @@ -1,12 +1,12 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{Dollars, Height, Sats, StoredF32, StoredF64}; +use brk_types::{Dollars, Height, PartsPerMillionSigned64, Sats, StoredF32, StoredF64}; use vecdb::{Exit, ReadableVec}; use super::Vecs; use crate::{ blocks::{self, ONE_TERA_HASH, TARGET_BLOCKS_PER_DAY_F64}, - internal::RatioDiffF32Bps32, + internal::RatioDiffF32, }; impl Vecs { @@ -103,7 +103,7 @@ impl Vecs { self.price .rebound - .compute_binary::( + .compute_binary::>( starting_height, &self.price.phs.height, &self.price.phs_min.height, @@ -112,7 +112,7 @@ impl Vecs { self.value .rebound - .compute_binary::( + .compute_binary::>( starting_height, &self.value.phs.height, &self.value.phs_min.height, diff --git a/crates/brk_computer/src/mining/hashrate/import.rs b/crates/brk_computer/src/mining/hashrate/import.rs index d49e1be47..604214aa6 100644 --- a/crates/brk_computer/src/mining/hashrate/import.rs +++ b/crates/brk_computer/src/mining/hashrate/import.rs @@ -77,7 +77,7 @@ impl Vecs { rebound: PercentPerBlock::forced_import( db, "hash_price_rebound", - version + v4, + version + v5, indexes, )?, }, @@ -89,7 +89,7 @@ impl Vecs { rebound: PercentPerBlock::forced_import( db, "hash_value_rebound", - version + v4, + version + v5, indexes, )?, }, diff --git a/crates/brk_computer/src/mining/hashrate/vecs.rs b/crates/brk_computer/src/mining/hashrate/vecs.rs index 8dbb9f59e..dbeda1958 100644 --- a/crates/brk_computer/src/mining/hashrate/vecs.rs +++ b/crates/brk_computer/src/mining/hashrate/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned16, BasisPointsSigned32, StoredF32, StoredF64}; +use brk_types::{PartsPerMillionSigned32, PartsPerMillionSigned64, StoredF32, StoredF64}; use vecdb::{Rw, StorageMode}; use crate::internal::{LazyPerBlock, PerBlock, PercentPerBlock}; @@ -18,7 +18,7 @@ pub struct HashPriceValueVecs { pub ths_min: PerBlock, pub phs: LazyPerBlock, pub phs_min: LazyPerBlock, - pub rebound: PercentPerBlock, + pub rebound: PercentPerBlock, } #[derive(Traversable)] @@ -26,7 +26,7 @@ pub struct RateVecs { pub base: PerBlock, pub sma: HashRateSmaVecs, pub ath: PerBlock, - pub drawdown: PercentPerBlock, + pub drawdown: PercentPerBlock, } #[derive(Traversable)] diff --git a/crates/brk_computer/src/mining/rewards/compute.rs b/crates/brk_computer/src/mining/rewards/compute.rs index 1b7e88721..84d0bfe61 100644 --- a/crates/brk_computer/src/mining/rewards/compute.rs +++ b/crates/brk_computer/src/mining/rewards/compute.rs @@ -1,12 +1,14 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{CheckedSub, Dollars, Halving, Sats}; +use brk_types::{ + CheckedSub, Dollars, Halving, PartsPerMillion32, PartsPerMillion64, Sats, +}; use vecdb::{Exit, ReadableVec, VecIndex}; use super::Vecs; use crate::{ blocks, indexes, - internal::{RatioDollarsBp32, RatioSatsBp16}, + internal::{RatioDollars, RatioSats}, price, transactions, }; @@ -109,7 +111,7 @@ impl Vecs { self.unclaimed.compute(prices, starting_height, exit)?; self.fee_dominance - .compute_binary::( + .compute_binary::, _, _, _, _>( starting_height, &self.fees.cumulative.sats.height, &self.coinbase.cumulative.sats.height, @@ -119,7 +121,7 @@ impl Vecs { )?; self.fee_to_subsidy_ratio - .compute_binary::( + .compute_binary::, _, _>( starting_height, self.coinbase.sum.as_array().map(|w| &w.usd.height), self.fees.sum.as_array().map(|w| &w.usd.height), diff --git a/crates/brk_computer/src/mining/rewards/import.rs b/crates/brk_computer/src/mining/rewards/import.rs index 4c38e7ad5..0147a655b 100644 --- a/crates/brk_computer/src/mining/rewards/import.rs +++ b/crates/brk_computer/src/mining/rewards/import.rs @@ -6,7 +6,7 @@ use super::Vecs; use crate::{ indexes, internal::{ - LazyPercentCumulativeRolling, OneMinusBp16, PercentCumulativeRolling, RatioRollingWindows, + LazyPercentCumulativeRolling, OneMinusPpm, PercentCumulativeRolling, RatioRollingWindows, ValuePerBlockCumulative, ValuePerBlockCumulativeRolling, ValuePerBlockFull, WindowStartVec, Windows, }, @@ -22,7 +22,7 @@ impl Vecs { let fee_dominance = PercentCumulativeRolling::forced_import(db, "fee_dominance", version, indexes)?; - let subsidy_dominance = LazyPercentCumulativeRolling::from_source::( + let subsidy_dominance = LazyPercentCumulativeRolling::from_source::( "subsidy_dominance", version, &fee_dominance, diff --git a/crates/brk_computer/src/mining/rewards/vecs.rs b/crates/brk_computer/src/mining/rewards/vecs.rs index 59d749f50..f4fa0cfd1 100644 --- a/crates/brk_computer/src/mining/rewards/vecs.rs +++ b/crates/brk_computer/src/mining/rewards/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPoints16, BasisPoints32, Height, Sats}; +use brk_types::{Height, PartsPerMillion32, PartsPerMillion64, Sats}; use vecdb::{EagerVec, PcoVec, Rw, StorageMode}; use crate::internal::{ @@ -15,9 +15,9 @@ pub struct Vecs { pub output_volume: M::Stored>>, pub unclaimed: ValuePerBlockCumulative, #[traversable(wrap = "fees", rename = "dominance")] - pub fee_dominance: PercentCumulativeRolling, + pub fee_dominance: PercentCumulativeRolling, #[traversable(wrap = "subsidy", rename = "dominance")] - pub subsidy_dominance: LazyPercentCumulativeRolling, + pub subsidy_dominance: LazyPercentCumulativeRolling, #[traversable(wrap = "fees", rename = "to_subsidy_ratio")] - pub fee_to_subsidy_ratio: RatioRollingWindows, + pub fee_to_subsidy_ratio: RatioRollingWindows, } diff --git a/crates/brk_computer/src/op_return/compute.rs b/crates/brk_computer/src/op_return/compute.rs index 337aaa1ea..738a2443e 100644 --- a/crates/brk_computer/src/op_return/compute.rs +++ b/crates/brk_computer/src/op_return/compute.rs @@ -1,12 +1,12 @@ use brk_error::Result; use brk_indexer::Indexer; -use brk_types::{BasisPoints16, Height, OpReturnKind, StoredU64, VSize}; +use brk_types::{Height, OpReturnKind, PartsPerMillion32, StoredU64, VSize}; use vecdb::{AnyVec, Exit, ReadableVec, VecIndex}; use super::{Breakdown, Vecs, vecs::Totals}; use crate::{ blocks, - internal::{PercentPerBlock, RatioU64Bp16}, + internal::{PercentPerBlock, RatioU64}, }; const KIND_COUNT: usize = OpReturnKind::Unknown as usize + 1; @@ -192,12 +192,17 @@ fn compute_breakdown_data_shares( fn compute_data_share( max_from: Height, - target: &mut PercentPerBlock, + target: &mut PercentPerBlock, data: &impl ReadableVec, block_size: &impl ReadableVec, exit: &Exit, ) -> Result<()> { - target.compute_binary::(max_from, data, block_size, exit) + target.compute_binary::>( + max_from, + data, + block_size, + exit, + ) } fn finalize_transaction( diff --git a/crates/brk_computer/src/op_return/vecs.rs b/crates/brk_computer/src/op_return/vecs.rs index b0a7e1f58..8aa03a136 100644 --- a/crates/brk_computer/src/op_return/vecs.rs +++ b/crates/brk_computer/src/op_return/vecs.rs @@ -1,6 +1,6 @@ use brk_error::Result; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, StoredU64, VSize, Version}; +use brk_types::{Height, PartsPerMillion32, StoredU64, VSize, Version}; use derive_more::{Deref, DerefMut}; use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec}; @@ -111,7 +111,7 @@ pub struct Total { #[deref_mut] #[traversable(flatten)] pub metrics: TotalMetrics, - pub chain_share: PercentPerBlock, + pub chain_share: PercentPerBlock, } impl Total { @@ -203,8 +203,8 @@ pub struct Breakdown { #[deref_mut] #[traversable(flatten)] pub metrics: Metrics, - pub data_share: PercentPerBlock, - pub chain_share: PercentPerBlock, + pub data_share: PercentPerBlock, + pub chain_share: PercentPerBlock, } impl Breakdown { diff --git a/crates/brk_computer/src/outputs/by_type/vecs.rs b/crates/brk_computer/src/outputs/by_type/vecs.rs index ed95c40f0..2e3ae0e70 100644 --- a/crates/brk_computer/src/outputs/by_type/vecs.rs +++ b/crates/brk_computer/src/outputs/by_type/vecs.rs @@ -1,6 +1,6 @@ use brk_cohort::ByType; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, StoredU64}; +use brk_types::{PartsPerMillion32, StoredU64}; use vecdb::{Rw, StorageMode}; use super::WithOutputTypes; @@ -10,7 +10,7 @@ use crate::internal::{PerBlockCumulativeRolling, PercentCumulativeRolling}; pub struct Vecs { pub output_count: WithOutputTypes>, pub spendable_output_count: PerBlockCumulativeRolling, - pub output_share: ByType>, + pub output_share: ByType>, pub tx_count: WithOutputTypes>, - pub tx_share: ByType>, + pub tx_share: ByType>, } diff --git a/crates/brk_computer/src/pools/major.rs b/crates/brk_computer/src/pools/major.rs index c9c478cf1..6c48b830b 100644 --- a/crates/brk_computer/src/pools/major.rs +++ b/crates/brk_computer/src/pools/major.rs @@ -1,14 +1,14 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, PoolSlug, StoredU64}; +use brk_types::{Height, PartsPerMillion32, PoolSlug, StoredU64}; use derive_more::{Deref, DerefMut}; use vecdb::{BinaryTransform, Database, Exit, ReadableVec, Rw, StorageMode, Version}; use crate::{ blocks, indexes, internal::{ - MaskSats, PercentRollingWindows, RatioU64Bp16, ValuePerBlockCumulativeRolling, + MaskSats, PercentRollingWindows, RatioU64, ValuePerBlockCumulativeRolling, WindowStartVec, Windows, }, mining, price, @@ -25,7 +25,7 @@ pub struct Vecs { pub rewards: ValuePerBlockCumulativeRolling, #[traversable(rename = "dominance")] - pub dominance_rolling: PercentRollingWindows, + pub dominance_rolling: PercentRollingWindows, } impl Vecs { @@ -79,7 +79,7 @@ impl Vecs { .into_iter() .zip(blocks.count.total.sum.as_array()), ) { - dom.compute_binary::( + dom.compute_binary::>( starting_height, &mined.height, &total.height, diff --git a/crates/brk_computer/src/pools/minor.rs b/crates/brk_computer/src/pools/minor.rs index 531b6ad49..a3252982e 100644 --- a/crates/brk_computer/src/pools/minor.rs +++ b/crates/brk_computer/src/pools/minor.rs @@ -1,12 +1,12 @@ use brk_error::Result; use brk_indexer::Indexer; use brk_traversable::Traversable; -use brk_types::{BasisPoints16, Height, PoolSlug, StoredU32, StoredU64}; +use brk_types::{Height, PartsPerMillion32, PoolSlug, StoredU32, StoredU64}; use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode, Version}; use crate::{ blocks, indexes, - internal::{PerBlockCumulativeRolling, PercentPerBlock, RatioU64Bp16, WindowStartVec, Windows}, + internal::{PerBlockCumulativeRolling, PercentPerBlock, RatioU64, WindowStartVec, Windows}, }; #[derive(Traversable)] @@ -15,7 +15,7 @@ pub struct Vecs { slug: PoolSlug, pub blocks_mined: PerBlockCumulativeRolling, - pub dominance: PercentPerBlock, + pub dominance: PercentPerBlock, } impl Vecs { @@ -74,7 +74,7 @@ impl Vecs { })?; self.dominance - .compute_binary::( + .compute_binary::>( starting_height, &self.blocks_mined.cumulative.height, &blocks.count.total.cumulative.height, diff --git a/crates/brk_computer/src/supply/compute.rs b/crates/brk_computer/src/supply/compute.rs index e5369df1a..389c09cd9 100644 --- a/crates/brk_computer/src/supply/compute.rs +++ b/crates/brk_computer/src/supply/compute.rs @@ -35,7 +35,7 @@ impl Vecs { // i.e. the lookback points to block 0 or 1 in the genesis era. let circulating_supply = &distribution.utxo_cohorts.all.metrics.supply.total.sats; self.inflation_rate - .bps + .raw .height .compute_rolling_from_window_starts( starting_height, @@ -61,16 +61,16 @@ impl Vecs { let diff_arr = self.market_minus_realized_cap_growth_rate.0.as_mut_array(); let rcr_rates = [ - &all_realized.cap.delta.rate._24h.bps.height, - &all_realized.cap.delta.rate._1w.bps.height, - &all_realized.cap.delta.rate._1m.bps.height, - &all_realized.cap.delta.rate._1y.bps.height, + &all_realized.cap.delta.rate._24h.raw.height, + &all_realized.cap.delta.rate._1w.raw.height, + &all_realized.cap.delta.rate._1m.raw.height, + &all_realized.cap.delta.rate._1y.raw.height, ]; for i in 0..4 { diff_arr[i].height.compute_subtract( starting_height, - &mcr_arr[i].bps.height, + &mcr_arr[i].raw.height, rcr_rates[i], exit, )?; diff --git a/crates/brk_computer/src/supply/import.rs b/crates/brk_computer/src/supply/import.rs index 8beb14118..adb4f46a3 100644 --- a/crates/brk_computer/src/supply/import.rs +++ b/crates/brk_computer/src/supply/import.rs @@ -38,7 +38,7 @@ impl Vecs { // Inflation rate let inflation_rate = - PercentPerBlock::forced_import(&db, "inflation_rate", version + Version::ONE, indexes)?; + PercentPerBlock::forced_import(&db, "inflation_rate", version + Version::TWO, indexes)?; // Velocity let velocity = super::velocity::Vecs::forced_import(&db, version, indexes)?; @@ -50,7 +50,7 @@ impl Vecs { // Market cap delta (change + rate across 4 windows) let market_cap_delta = LazyRollingDeltasFiatFromHeight::new( "market_cap_delta", - version + Version::new(3), + version + Version::new(4), &market_cap.cents.height, cached_starts, indexes, @@ -59,7 +59,7 @@ impl Vecs { let market_minus_realized_cap_growth_rate = RollingWindows::forced_import( &db, "market_minus_realized_cap_growth_rate", - version + Version::TWO, + version + Version::new(3), indexes, )?; diff --git a/crates/brk_computer/src/supply/vecs.rs b/crates/brk_computer/src/supply/vecs.rs index 8345fb1b1..734a5a03c 100644 --- a/crates/brk_computer/src/supply/vecs.rs +++ b/crates/brk_computer/src/supply/vecs.rs @@ -1,5 +1,5 @@ use brk_traversable::Traversable; -use brk_types::{BasisPointsSigned32, Cents, CentsSigned}; +use brk_types::{Cents, CentsSigned, PartsPerMillionSigned64}; use vecdb::{Database, Rw, StorageMode}; use super::{burned, velocity}; @@ -15,11 +15,12 @@ pub struct Vecs { pub circulating: LazyValuePerBlock, pub burned: burned::Vecs, - pub inflation_rate: PercentPerBlock, + pub inflation_rate: PercentPerBlock, pub velocity: velocity::Vecs, pub market_cap: LazyFiatPerBlock, #[traversable(wrap = "market_cap", rename = "delta")] - pub market_cap_delta: LazyRollingDeltasFiatFromHeight, - pub market_minus_realized_cap_growth_rate: RollingWindows, + pub market_cap_delta: + LazyRollingDeltasFiatFromHeight, + pub market_minus_realized_cap_growth_rate: RollingWindows, pub hodled_or_lost: LazyValuePerBlock, } diff --git a/crates/brk_store/Cargo.toml b/crates/brk_store/Cargo.toml index 70d6fe36f..59b945ec7 100644 --- a/crates/brk_store/Cargo.toml +++ b/crates/brk_store/Cargo.toml @@ -16,4 +16,3 @@ brk_types = { workspace = true } byteview = { workspace = true } fjall = { workspace = true } rustc-hash = { workspace = true } -tracing = { workspace = true } diff --git a/crates/brk_store/src/lib.rs b/crates/brk_store/src/lib.rs index bfbe83a05..2e4336094 100644 --- a/crates/brk_store/src/lib.rs +++ b/crates/brk_store/src/lib.rs @@ -19,7 +19,6 @@ use brk_types::{Height, Version}; use byteview::ByteView; use fjall::{Database, Keyspace, KeyspaceCreateOptions, config::*}; use rustc_hash::{FxHashMap, FxHashSet}; -use tracing::info; mod any; mod item; @@ -229,7 +228,6 @@ where for<'a> ByteView: From<&'a K> + From<&'a V>, { self.export_meta_if_needed(height)?; - self.report_db_reads(); let puts = mem::take(&mut self.puts); let dels = mem::take(&mut self.dels); @@ -304,13 +302,6 @@ where Ok(()) } - fn report_db_reads(&self) { - let reads = self.db_reads.swap(0, Relaxed); - if reads != 0 { - info!(store = self.name, reads, "Store DB reads"); - } - } - fn ingest<'a>( keyspace: &Keyspace, puts: impl Iterator, @@ -386,7 +377,6 @@ where fn commit(&mut self, height: Height) -> Result<()> { self.export_meta_if_needed(height)?; - self.report_db_reads(); let puts = mem::take(&mut self.puts); let dels = mem::take(&mut self.dels); diff --git a/crates/brk_traversable_derive/Cargo.toml b/crates/brk_traversable_derive/Cargo.toml index 81407b66d..9ca3d2581 100644 --- a/crates/brk_traversable_derive/Cargo.toml +++ b/crates/brk_traversable_derive/Cargo.toml @@ -11,6 +11,6 @@ repository.workspace = true proc-macro = true [dependencies] -syn = "2.0" +syn = "3.0" quote = "1.0" -proc-macro2 = "1.0.106" +proc-macro2 = "1.0.107" diff --git a/crates/brk_traversable_derive/src/lib.rs b/crates/brk_traversable_derive/src/lib.rs index 67b356d34..e0e4e0967 100644 --- a/crates/brk_traversable_derive/src/lib.rs +++ b/crates/brk_traversable_derive/src/lib.rs @@ -163,7 +163,7 @@ fn type_contains_ident(ty: &Type, ident: &syn::Ident) -> bool { matches!(arg, syn::GenericArgument::Type(inner) if type_contains_ident(inner, ident)) }), syn::PathArguments::Parenthesized(args) => { - args.inputs.iter().any(|inner| type_contains_ident(inner, ident)) + args.inputs.iter().any(|inner| type_contains_ident(&inner.ty, ident)) || matches!(&args.output, syn::ReturnType::Type(_, inner) if type_contains_ident(inner, ident)) } syn::PathArguments::None => false, diff --git a/crates/brk_types/src/basis_points_16.rs b/crates/brk_types/src/basis_points_16.rs deleted file mode 100644 index dc8c93ddb..000000000 --- a/crates/brk_types/src/basis_points_16.rs +++ /dev/null @@ -1,214 +0,0 @@ -use std::ops::{Add, AddAssign, Div, Sub}; - -use derive_more::Deref; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use vecdb::{CheckedSub, Formattable, Pco, unlikely}; - -use super::StoredF32; - -/// Unsigned basis points stored as u16. -/// 1 bp = 0.0001. Range: 0–6.5535. -/// Use for bounded 0–1 ratios (dominance, adoption, liveliness, etc.). -/// `u16::MAX` is reserved as a NaN sentinel. -#[derive( - Debug, - Deref, - Clone, - Default, - Copy, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - Serialize, - Deserialize, - Pco, - JsonSchema, -)] -pub struct BasisPoints16(u16); - -impl BasisPoints16 { - pub const ZERO: Self = Self(0); - pub const ONE: Self = Self(10000); - /// NaN sentinel — uses u16::MAX which is outside the practical range. - pub const NAN: Self = Self(u16::MAX); - - #[inline] - pub const fn new(value: u16) -> Self { - debug_assert!(value != u16::MAX, "u16::MAX is reserved as NaN sentinel"); - Self(value) - } - - #[inline(always)] - pub const fn inner(self) -> u16 { - self.0 - } - - #[inline] - pub fn is_nan(self) -> bool { - self.0 == u16::MAX - } - - /// Convert to f32: divide by 10000. Returns NaN for sentinel value. - #[inline] - pub fn to_f32(self) -> f32 { - if unlikely(self.0 == u16::MAX) { - f32::NAN - } else { - self.0 as f32 / 10000.0 - } - } -} - -impl From for BasisPoints16 { - #[inline] - fn from(value: usize) -> Self { - debug_assert!( - value < u16::MAX as usize, - "usize out of BasisPoints16 range: {value}" - ); - Self(value as u16) - } -} - -impl From for BasisPoints16 { - #[inline] - fn from(value: u16) -> Self { - debug_assert!(value != u16::MAX, "u16::MAX is reserved as NaN sentinel"); - Self(value) - } -} - -impl From for u16 { - #[inline] - fn from(value: BasisPoints16) -> Self { - value.0 - } -} - -/// Convert from f32: multiply by 10000 and round. -/// Input is in ratio form (e.g., 0.4523 for 45.23%). -/// NaN/Inf → NaN sentinel. -impl From for BasisPoints16 { - #[inline] - fn from(value: f32) -> Self { - if unlikely(!value.is_finite()) { - return Self::NAN; - } - let scaled = (value * 10000.0).round().clamp(0.0, u16::MAX as f32 - 1.0); - Self(scaled as u16) - } -} - -/// Convert from f64: multiply by 10000 and round. -/// Input is in ratio form (e.g., 0.4523 for 45.23%). -/// NaN/Inf → NaN sentinel. -impl From for BasisPoints16 { - #[inline] - fn from(value: f64) -> Self { - if unlikely(!value.is_finite()) { - return Self::NAN; - } - let scaled = (value * 10000.0).round().clamp(0.0, u16::MAX as f64 - 1.0); - Self(scaled as u16) - } -} - -impl From for f64 { - #[inline] - fn from(value: BasisPoints16) -> Self { - if unlikely(value.0 == u16::MAX) { - f64::NAN - } else { - value.0 as f64 / 10000.0 - } - } -} - -impl From for StoredF32 { - #[inline] - fn from(value: BasisPoints16) -> Self { - StoredF32::from(value.to_f32()) - } -} - -impl Add for BasisPoints16 { - type Output = Self; - #[inline] - fn add(self, rhs: Self) -> Self::Output { - if unlikely(self.0 == u16::MAX || rhs.0 == u16::MAX) { - Self::NAN - } else { - Self(self.0 + rhs.0) - } - } -} - -impl Sub for BasisPoints16 { - type Output = Self; - #[inline] - fn sub(self, rhs: Self) -> Self::Output { - if unlikely(self.0 == u16::MAX || rhs.0 == u16::MAX) { - Self::NAN - } else { - Self(self.0 - rhs.0) - } - } -} - -impl AddAssign for BasisPoints16 { - #[inline] - fn add_assign(&mut self, rhs: Self) { - *self = *self + rhs; - } -} - -impl Div for BasisPoints16 { - type Output = Self; - #[inline] - fn div(self, rhs: usize) -> Self::Output { - if unlikely(self.0 == u16::MAX) { - Self::NAN - } else { - debug_assert!(rhs <= u16::MAX as usize, "divisor out of u16 range: {rhs}"); - Self(self.0 / rhs as u16) - } - } -} - -impl CheckedSub for BasisPoints16 { - fn checked_sub(self, rhs: Self) -> Option { - if unlikely(self.0 == u16::MAX || rhs.0 == u16::MAX) { - Some(Self::NAN) - } else { - self.0.checked_sub(rhs.0).map(Self) - } - } -} - -impl std::fmt::Display for BasisPoints16 { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mut buf = itoa::Buffer::new(); - let str = buf.format(self.0); - f.write_str(str) - } -} - -impl Formattable for BasisPoints16 { - #[inline(always)] - fn write_to(&self, buf: &mut Vec) { - let mut b = itoa::Buffer::new(); - buf.extend_from_slice(b.format(self.0).as_bytes()); - } - - #[inline(always)] - fn fmt_json(&self, buf: &mut Vec) { - if unlikely(self.0 == u16::MAX) { - buf.extend_from_slice(b"null"); - } else { - self.write_to(buf); - } - } -} diff --git a/crates/brk_types/src/basis_points_signed_16.rs b/crates/brk_types/src/basis_points_signed_16.rs deleted file mode 100644 index 4e20d13f8..000000000 --- a/crates/brk_types/src/basis_points_signed_16.rs +++ /dev/null @@ -1,213 +0,0 @@ -use std::ops::{Add, AddAssign, Div, Sub, SubAssign}; - -use derive_more::Deref; -use schemars::JsonSchema; -use serde::{Deserialize, Serialize}; -use vecdb::{CheckedSub, Formattable, Pco, unlikely}; - -use super::StoredF32; - -/// Signed basis points stored as i16. -/// 1 bp = 0.0001. Range: -3.2767 to +3.2767. -/// Use for signed bounded ratios (NUPL, net PnL ratios, etc.). -/// `i16::MIN` is reserved as a NaN sentinel. -#[derive( - Debug, - Deref, - Clone, - Default, - Copy, - PartialEq, - Eq, - PartialOrd, - Ord, - Hash, - Serialize, - Deserialize, - Pco, - JsonSchema, -)] -pub struct BasisPointsSigned16(i16); - -impl BasisPointsSigned16 { - pub const ZERO: Self = Self(0); - /// NaN sentinel — uses i16::MIN which is outside the documented range. - pub const NAN: Self = Self(i16::MIN); - - #[inline] - pub const fn new(value: i16) -> Self { - debug_assert!(value != i16::MIN, "i16::MIN is reserved as NaN sentinel"); - Self(value) - } - - #[inline(always)] - pub const fn inner(self) -> i16 { - self.0 - } - - #[inline] - pub fn is_nan(self) -> bool { - self.0 == i16::MIN - } - - #[inline] - pub fn is_negative(self) -> bool { - self.0 < 0 && self.0 != i16::MIN - } - - /// Convert to f32: divide by 10000. Returns NaN for sentinel value. - #[inline] - pub fn to_f32(self) -> f32 { - if unlikely(self.0 == i16::MIN) { - f32::NAN - } else { - self.0 as f32 / 10000.0 - } - } -} - -impl From for BasisPointsSigned16 { - #[inline] - fn from(value: usize) -> Self { - debug_assert!( - value <= i16::MAX as usize, - "usize out of BasisPointsSigned16 range: {value}" - ); - Self(value as i16) - } -} - -impl From for BasisPointsSigned16 { - #[inline] - fn from(value: i16) -> Self { - debug_assert!(value != i16::MIN, "i16::MIN is reserved as NaN sentinel"); - Self(value) - } -} - -impl From for i16 { - #[inline] - fn from(value: BasisPointsSigned16) -> Self { - value.0 - } -} - -/// Convert from float: multiply by 10000 and round. -/// Input is in ratio form (e.g., -0.4523 for -45.23%). -/// NaN/Inf → NaN sentinel. -impl From for BasisPointsSigned16 { - #[inline] - fn from(value: f64) -> Self { - if unlikely(!value.is_finite()) { - return Self::NAN; - } - let scaled = (value * 10000.0) - .round() - .clamp(i16::MIN as f64 + 1.0, i16::MAX as f64); - Self(scaled as i16) - } -} - -impl From for f64 { - #[inline] - fn from(value: BasisPointsSigned16) -> Self { - if unlikely(value.0 == i16::MIN) { - f64::NAN - } else { - value.0 as f64 / 10000.0 - } - } -} - -impl From for StoredF32 { - #[inline] - fn from(value: BasisPointsSigned16) -> Self { - StoredF32::from(value.to_f32()) - } -} - -impl Add for BasisPointsSigned16 { - type Output = Self; - #[inline] - fn add(self, rhs: Self) -> Self::Output { - if unlikely(self.0 == i16::MIN || rhs.0 == i16::MIN) { - Self::NAN - } else { - Self(self.0 + rhs.0) - } - } -} - -impl AddAssign for BasisPointsSigned16 { - #[inline] - fn add_assign(&mut self, rhs: Self) { - *self = *self + rhs; - } -} - -impl Sub for BasisPointsSigned16 { - type Output = Self; - #[inline] - fn sub(self, rhs: Self) -> Self::Output { - if unlikely(self.0 == i16::MIN || rhs.0 == i16::MIN) { - Self::NAN - } else { - Self(self.0 - rhs.0) - } - } -} - -impl SubAssign for BasisPointsSigned16 { - #[inline] - fn sub_assign(&mut self, rhs: Self) { - *self = *self - rhs; - } -} - -impl Div for BasisPointsSigned16 { - type Output = Self; - #[inline] - fn div(self, rhs: usize) -> Self::Output { - if unlikely(self.0 == i16::MIN) { - Self::NAN - } else { - debug_assert!(rhs <= i16::MAX as usize, "divisor out of i16 range: {rhs}"); - Self(self.0 / rhs as i16) - } - } -} - -impl CheckedSub for BasisPointsSigned16 { - fn checked_sub(self, rhs: Self) -> Option { - if unlikely(self.0 == i16::MIN || rhs.0 == i16::MIN) { - Some(Self::NAN) - } else { - self.0.checked_sub(rhs.0).map(Self) - } - } -} - -impl std::fmt::Display for BasisPointsSigned16 { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let mut buf = itoa::Buffer::new(); - let str = buf.format(self.0); - f.write_str(str) - } -} - -impl Formattable for BasisPointsSigned16 { - #[inline(always)] - fn write_to(&self, buf: &mut Vec) { - let mut b = itoa::Buffer::new(); - buf.extend_from_slice(b.format(self.0).as_bytes()); - } - - #[inline(always)] - fn fmt_json(&self, buf: &mut Vec) { - if unlikely(self.0 == i16::MIN) { - buf.extend_from_slice(b"null"); - } else { - self.write_to(buf); - } - } -} diff --git a/crates/brk_types/src/lib.rs b/crates/brk_types/src/lib.rs index 0b264d193..d4e6b2035 100644 --- a/crates/brk_types/src/lib.rs +++ b/crates/brk_types/src/lib.rs @@ -14,10 +14,6 @@ mod addr_mempool_stats; mod addr_stats; mod addr_validation; mod age; -mod basis_points_16; -mod basis_points_32; -mod basis_points_signed_16; -mod basis_points_signed_32; mod bitcoin; mod blk_metadata; mod blk_position; @@ -122,6 +118,10 @@ mod p2wpkh_bytes; mod p2wsh_addr_index; mod p2wsh_bytes; mod pagination; +mod parts_per_million_32; +mod parts_per_million_64; +mod parts_per_million_signed_32; +mod parts_per_million_signed_64; mod percentile; mod pool; mod pool_detail; @@ -213,10 +213,6 @@ pub use addr_mempool_stats::*; pub use addr_stats::*; pub use addr_validation::*; pub use age::*; -pub use basis_points_16::*; -pub use basis_points_32::*; -pub use basis_points_signed_16::*; -pub use basis_points_signed_32::*; pub use bitcoin::*; pub use blk_metadata::*; pub use blk_position::*; @@ -321,6 +317,10 @@ pub use p2wpkh_bytes::*; pub use p2wsh_addr_index::*; pub use p2wsh_bytes::*; pub use pagination::*; +pub use parts_per_million_32::*; +pub use parts_per_million_64::*; +pub use parts_per_million_signed_32::*; +pub use parts_per_million_signed_64::*; pub use percentile::*; pub use pool::*; pub use pool_detail::*; diff --git a/crates/brk_types/src/basis_points_32.rs b/crates/brk_types/src/parts_per_million_32.rs similarity index 57% rename from crates/brk_types/src/basis_points_32.rs rename to crates/brk_types/src/parts_per_million_32.rs index b670a0bb2..81bceb2c7 100644 --- a/crates/brk_types/src/basis_points_32.rs +++ b/crates/brk_types/src/parts_per_million_32.rs @@ -1,4 +1,4 @@ -use std::ops::{Add, AddAssign, Div}; +use std::ops::{Add, AddAssign, Div, Sub}; use derive_more::Deref; use schemars::JsonSchema; @@ -7,9 +7,9 @@ use vecdb::{CheckedSub, Formattable, Pco, unlikely}; use super::StoredF32; -/// Unsigned basis points stored as u32. -/// 1 bp = 0.0001. Range: 0–429,496.7295. -/// Use for unbounded unsigned ratios (MVRV, NVT, SOPR, etc.). +/// Unsigned parts per million stored as u32. +/// One unit is 0.000001. Range: 0–4,294.967294. +/// Use for precise bounded ratios and percentages. /// `u32::MAX` is reserved as a NaN sentinel. #[derive( Debug, @@ -27,11 +27,11 @@ use super::StoredF32; Pco, JsonSchema, )] -pub struct BasisPoints32(u32); +pub struct PartsPerMillion32(u32); -impl BasisPoints32 { +impl PartsPerMillion32 { pub const ZERO: Self = Self(0); - /// NaN sentinel — uses u32::MAX which is outside the practical range. + pub const ONE: Self = Self(1_000_000); pub const NAN: Self = Self(u32::MAX); #[inline] @@ -50,29 +50,28 @@ impl BasisPoints32 { self.0 == u32::MAX } - /// Convert to f32: divide by 10000. Returns NaN for sentinel value. #[inline] pub fn to_f32(self) -> f32 { if unlikely(self.0 == u32::MAX) { f32::NAN } else { - self.0 as f32 / 10000.0 + self.0 as f32 / 1_000_000.0 } } } -impl From for BasisPoints32 { +impl From for PartsPerMillion32 { #[inline] fn from(value: usize) -> Self { debug_assert!( value < u32::MAX as usize, - "usize out of BasisPoints32 range: {value}" + "usize out of PartsPerMillion32 range: {value}" ); Self(value as u32) } } -impl From for BasisPoints32 { +impl From for PartsPerMillion32 { #[inline] fn from(value: u32) -> Self { debug_assert!(value != u32::MAX, "u32::MAX is reserved as NaN sentinel"); @@ -80,39 +79,14 @@ impl From for BasisPoints32 { } } -impl From for u32 { +impl From for u32 { #[inline] - fn from(value: BasisPoints32) -> Self { + fn from(value: PartsPerMillion32) -> Self { value.0 } } -/// Convert from float: multiply by 10000 and round. -/// Input is in ratio form (e.g., 2.5 for MVRV of 2.5). -/// NaN/Inf → NaN sentinel. -impl From for BasisPoints32 { - #[inline] - fn from(value: f64) -> Self { - if unlikely(!value.is_finite()) { - return Self::NAN; - } - let scaled = (value * 10000.0).round().clamp(0.0, u32::MAX as f64 - 1.0); - Self(scaled as u32) - } -} - -impl From for f64 { - #[inline] - fn from(value: BasisPoints32) -> Self { - if unlikely(value.0 == u32::MAX) { - f64::NAN - } else { - value.0 as f64 / 10000.0 - } - } -} - -impl From for BasisPoints32 { +impl From for PartsPerMillion32 { #[inline] fn from(value: f32) -> Self { if unlikely(!value.is_finite()) { @@ -122,33 +96,54 @@ impl From for BasisPoints32 { } } -impl From for BasisPoints32 { +impl From for PartsPerMillion32 { #[inline] fn from(value: StoredF32) -> Self { - Self::from(f64::from(*value)) + Self::from(*value) } } -impl From for f32 { +impl From for PartsPerMillion32 { #[inline] - fn from(value: BasisPoints32) -> Self { + fn from(value: f64) -> Self { + if unlikely(!value.is_finite()) { + return Self::NAN; + } + let scaled = (value * 1_000_000.0) + .round() + .clamp(0.0, u32::MAX as f64 - 1.0); + Self(scaled as u32) + } +} + +impl From for f64 { + #[inline] + fn from(value: PartsPerMillion32) -> Self { if unlikely(value.0 == u32::MAX) { - f32::NAN + f64::NAN } else { - value.0 as f32 / 10000.0 + value.0 as f64 / 1_000_000.0 } } } -impl From for StoredF32 { +impl From for f32 { #[inline] - fn from(value: BasisPoints32) -> Self { + fn from(value: PartsPerMillion32) -> Self { + value.to_f32() + } +} + +impl From for StoredF32 { + #[inline] + fn from(value: PartsPerMillion32) -> Self { StoredF32::from(value.to_f32()) } } -impl Add for BasisPoints32 { +impl Add for PartsPerMillion32 { type Output = Self; + #[inline] fn add(self, rhs: Self) -> Self::Output { if unlikely(self.0 == u32::MAX || rhs.0 == u32::MAX) { @@ -159,15 +154,29 @@ impl Add for BasisPoints32 { } } -impl AddAssign for BasisPoints32 { +impl Sub for PartsPerMillion32 { + type Output = Self; + + #[inline] + fn sub(self, rhs: Self) -> Self::Output { + if unlikely(self.0 == u32::MAX || rhs.0 == u32::MAX) { + Self::NAN + } else { + Self(self.0 - rhs.0) + } + } +} + +impl AddAssign for PartsPerMillion32 { #[inline] fn add_assign(&mut self, rhs: Self) { *self = *self + rhs; } } -impl Div for BasisPoints32 { +impl Div for PartsPerMillion32 { type Output = Self; + #[inline] fn div(self, rhs: usize) -> Self::Output { if unlikely(self.0 == u32::MAX) { @@ -179,7 +188,7 @@ impl Div for BasisPoints32 { } } -impl CheckedSub for BasisPoints32 { +impl CheckedSub for PartsPerMillion32 { fn checked_sub(self, rhs: Self) -> Option { if unlikely(self.0 == u32::MAX || rhs.0 == u32::MAX) { Some(Self::NAN) @@ -189,19 +198,18 @@ impl CheckedSub for BasisPoints32 { } } -impl std::fmt::Display for BasisPoints32 { +impl std::fmt::Display for PartsPerMillion32 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut buf = itoa::Buffer::new(); - let str = buf.format(self.0); - f.write_str(str) + f.write_str(buf.format(self.0)) } } -impl Formattable for BasisPoints32 { +impl Formattable for PartsPerMillion32 { #[inline(always)] fn write_to(&self, buf: &mut Vec) { - let mut b = itoa::Buffer::new(); - buf.extend_from_slice(b.format(self.0).as_bytes()); + let mut value = itoa::Buffer::new(); + buf.extend_from_slice(value.format(self.0).as_bytes()); } #[inline(always)] @@ -213,3 +221,21 @@ impl Formattable for BasisPoints32 { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn conversions_and_sentinels() { + assert_eq!(PartsPerMillion32::from(0.123_456_6).inner(), 123_457); + assert_eq!(f64::from(PartsPerMillion32::ONE), 1.0); + assert_eq!(PartsPerMillion32::from(-1.0), PartsPerMillion32::ZERO); + assert_eq!(PartsPerMillion32::from(f64::MAX).inner(), u32::MAX - 1); + assert!(PartsPerMillion32::from(f64::NAN).is_nan()); + + let mut json = Vec::new(); + PartsPerMillion32::NAN.fmt_json(&mut json); + assert_eq!(json, b"null"); + } +} diff --git a/crates/brk_types/src/parts_per_million_64.rs b/crates/brk_types/src/parts_per_million_64.rs new file mode 100644 index 000000000..1d1814543 --- /dev/null +++ b/crates/brk_types/src/parts_per_million_64.rs @@ -0,0 +1,245 @@ +use std::ops::{Add, AddAssign, Div, Sub}; + +use derive_more::Deref; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use vecdb::{CheckedSub, Formattable, Pco, unlikely}; + +use super::StoredF32; + +/// Unsigned parts per million stored as u64. +/// One unit is 0.000001. Range: 0–18,446,744,073,709.551614. +/// Use for precise wide-range ratios. +/// `u64::MAX` is reserved as a NaN sentinel. +#[derive( + Debug, + Deref, + Clone, + Default, + Copy, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + Serialize, + Deserialize, + Pco, + JsonSchema, +)] +pub struct PartsPerMillion64(u64); + +impl PartsPerMillion64 { + pub const ZERO: Self = Self(0); + pub const ONE: Self = Self(1_000_000); + pub const NAN: Self = Self(u64::MAX); + + #[inline] + pub const fn new(value: u64) -> Self { + debug_assert!(value != u64::MAX, "u64::MAX is reserved as NaN sentinel"); + Self(value) + } + + #[inline(always)] + pub const fn inner(self) -> u64 { + self.0 + } + + #[inline] + pub fn is_nan(self) -> bool { + self.0 == u64::MAX + } + + #[inline] + pub fn to_f32(self) -> f32 { + if unlikely(self.0 == u64::MAX) { + f32::NAN + } else { + self.0 as f32 / 1_000_000.0 + } + } +} + +impl From for PartsPerMillion64 { + #[inline] + fn from(value: usize) -> Self { + debug_assert!( + value < u64::MAX as usize, + "usize out of PartsPerMillion64 range: {value}" + ); + Self(value as u64) + } +} + +impl From for PartsPerMillion64 { + #[inline] + fn from(value: u64) -> Self { + debug_assert!(value != u64::MAX, "u64::MAX is reserved as NaN sentinel"); + Self(value) + } +} + +impl From for u64 { + #[inline] + fn from(value: PartsPerMillion64) -> Self { + value.0 + } +} + +impl From for PartsPerMillion64 { + #[inline] + fn from(value: f32) -> Self { + if unlikely(!value.is_finite()) { + return Self::NAN; + } + Self::from(value as f64) + } +} + +impl From for PartsPerMillion64 { + #[inline] + fn from(value: StoredF32) -> Self { + Self::from(*value) + } +} + +impl From for PartsPerMillion64 { + #[inline] + fn from(value: f64) -> Self { + if unlikely(!value.is_finite()) { + return Self::NAN; + } + let scaled = (value * 1_000_000.0).round(); + if scaled <= 0.0 { + Self::ZERO + } else if scaled >= u64::MAX as f64 { + Self(u64::MAX - 1) + } else { + Self(scaled as u64) + } + } +} + +impl From for f64 { + #[inline] + fn from(value: PartsPerMillion64) -> Self { + if unlikely(value.0 == u64::MAX) { + f64::NAN + } else { + value.0 as f64 / 1_000_000.0 + } + } +} + +impl From for f32 { + #[inline] + fn from(value: PartsPerMillion64) -> Self { + value.to_f32() + } +} + +impl From for StoredF32 { + #[inline] + fn from(value: PartsPerMillion64) -> Self { + StoredF32::from(value.to_f32()) + } +} + +impl Add for PartsPerMillion64 { + type Output = Self; + + #[inline] + fn add(self, rhs: Self) -> Self::Output { + if unlikely(self.0 == u64::MAX || rhs.0 == u64::MAX) { + Self::NAN + } else { + Self(self.0 + rhs.0) + } + } +} + +impl Sub for PartsPerMillion64 { + type Output = Self; + + #[inline] + fn sub(self, rhs: Self) -> Self::Output { + if unlikely(self.0 == u64::MAX || rhs.0 == u64::MAX) { + Self::NAN + } else { + Self(self.0 - rhs.0) + } + } +} + +impl AddAssign for PartsPerMillion64 { + #[inline] + fn add_assign(&mut self, rhs: Self) { + *self = *self + rhs; + } +} + +impl Div for PartsPerMillion64 { + type Output = Self; + + #[inline] + fn div(self, rhs: usize) -> Self::Output { + if unlikely(self.0 == u64::MAX) { + Self::NAN + } else { + debug_assert!(rhs <= u64::MAX as usize, "divisor out of u64 range: {rhs}"); + Self(self.0 / rhs as u64) + } + } +} + +impl CheckedSub for PartsPerMillion64 { + fn checked_sub(self, rhs: Self) -> Option { + if unlikely(self.0 == u64::MAX || rhs.0 == u64::MAX) { + Some(Self::NAN) + } else { + self.0.checked_sub(rhs.0).map(Self) + } + } +} + +impl std::fmt::Display for PartsPerMillion64 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut buf = itoa::Buffer::new(); + f.write_str(buf.format(self.0)) + } +} + +impl Formattable for PartsPerMillion64 { + #[inline(always)] + fn write_to(&self, buf: &mut Vec) { + let mut value = itoa::Buffer::new(); + buf.extend_from_slice(value.format(self.0).as_bytes()); + } + + #[inline(always)] + fn fmt_json(&self, buf: &mut Vec) { + if unlikely(self.0 == u64::MAX) { + buf.extend_from_slice(b"null"); + } else { + self.write_to(buf); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn conversions_and_sentinels() { + assert_eq!(PartsPerMillion64::from(0.123_456_6).inner(), 123_457); + assert_eq!(f64::from(PartsPerMillion64::ONE), 1.0); + assert_eq!(PartsPerMillion64::from(-1.0), PartsPerMillion64::ZERO); + assert_eq!(PartsPerMillion64::from(f64::MAX).inner(), u64::MAX - 1); + assert!(PartsPerMillion64::from(f64::INFINITY).is_nan()); + + let mut json = Vec::new(); + PartsPerMillion64::NAN.fmt_json(&mut json); + assert_eq!(json, b"null"); + } +} diff --git a/crates/brk_types/src/basis_points_signed_32.rs b/crates/brk_types/src/parts_per_million_signed_32.rs similarity index 59% rename from crates/brk_types/src/basis_points_signed_32.rs rename to crates/brk_types/src/parts_per_million_signed_32.rs index 68d543286..2f143ea68 100644 --- a/crates/brk_types/src/basis_points_signed_32.rs +++ b/crates/brk_types/src/parts_per_million_signed_32.rs @@ -7,9 +7,9 @@ use vecdb::{CheckedSub, Formattable, Pco, unlikely}; use super::StoredF32; -/// Signed basis points stored as i32. -/// 1 bp = 0.0001. Range: -214,748.3647 to +214,748.3647. -/// Use for unbounded signed values (returns, growth rates, volatility, z-scores, etc.). +/// Signed parts per million stored as i32. +/// One unit is 0.000001. Range: -2,147.483647 to +2,147.483647. +/// Use for precise bounded signed ratios and percentages. /// `i32::MIN` is reserved as a NaN sentinel. #[derive( Debug, @@ -27,11 +27,10 @@ use super::StoredF32; Pco, JsonSchema, )] -pub struct BasisPointsSigned32(i32); +pub struct PartsPerMillionSigned32(i32); -impl BasisPointsSigned32 { +impl PartsPerMillionSigned32 { pub const ZERO: Self = Self(0); - /// NaN sentinel — uses i32::MIN which is outside the documented range. pub const NAN: Self = Self(i32::MIN); #[inline] @@ -55,29 +54,28 @@ impl BasisPointsSigned32 { self.0 < 0 && self.0 != i32::MIN } - /// Convert to f32: divide by 10000. Returns NaN for sentinel value. #[inline] pub fn to_f32(self) -> f32 { if unlikely(self.0 == i32::MIN) { f32::NAN } else { - self.0 as f32 / 10000.0 + self.0 as f32 / 1_000_000.0 } } } -impl From for BasisPointsSigned32 { +impl From for PartsPerMillionSigned32 { #[inline] fn from(value: usize) -> Self { debug_assert!( value <= i32::MAX as usize, - "usize out of BasisPointsSigned32 range: {value}" + "usize out of PartsPerMillionSigned32 range: {value}" ); Self(value as i32) } } -impl From for BasisPointsSigned32 { +impl From for PartsPerMillionSigned32 { #[inline] fn from(value: i32) -> Self { debug_assert!(value != i32::MIN, "i32::MIN is reserved as NaN sentinel"); @@ -85,65 +83,68 @@ impl From for BasisPointsSigned32 { } } -impl From for i32 { +impl From for i32 { #[inline] - fn from(value: BasisPointsSigned32) -> Self { + fn from(value: PartsPerMillionSigned32) -> Self { value.0 } } -/// Convert from float: multiply by 10000 and round. -/// Input is in ratio form (e.g., 50.0 for +5000%). -/// NaN/Inf → NaN sentinel. -impl From for BasisPointsSigned32 { +impl From for PartsPerMillionSigned32 { #[inline] fn from(value: f64) -> Self { if unlikely(!value.is_finite()) { return Self::NAN; } - let scaled = (value * 10000.0) + let scaled = (value * 1_000_000.0) .round() .clamp(i32::MIN as f64 + 1.0, i32::MAX as f64); Self(scaled as i32) } } -/// Convert from f32 ratio form: multiply by 10000 and round. -/// Input is in ratio form (e.g., 0.5 for +50% → 5000 bps). -/// NaN/Inf → NaN sentinel. -impl From for BasisPointsSigned32 { +impl From for PartsPerMillionSigned32 { #[inline] fn from(value: f32) -> Self { - if unlikely(!value.is_finite()) { - return Self::NAN; - } - let scaled = (value * 10000.0) - .round() - .clamp(i32::MIN as f32 + 1.0, i32::MAX as f32); - Self(scaled as i32) + Self::from(value as f64) } } -impl From for f64 { +impl From for PartsPerMillionSigned32 { #[inline] - fn from(value: BasisPointsSigned32) -> Self { + fn from(value: StoredF32) -> Self { + Self::from(*value) + } +} + +impl From for f64 { + #[inline] + fn from(value: PartsPerMillionSigned32) -> Self { if unlikely(value.0 == i32::MIN) { f64::NAN } else { - value.0 as f64 / 10000.0 + value.0 as f64 / 1_000_000.0 } } } -impl From for StoredF32 { +impl From for f32 { #[inline] - fn from(value: BasisPointsSigned32) -> Self { + fn from(value: PartsPerMillionSigned32) -> Self { + value.to_f32() + } +} + +impl From for StoredF32 { + #[inline] + fn from(value: PartsPerMillionSigned32) -> Self { StoredF32::from(value.to_f32()) } } -impl Add for BasisPointsSigned32 { +impl Add for PartsPerMillionSigned32 { type Output = Self; + #[inline] fn add(self, rhs: Self) -> Self::Output { if unlikely(self.0 == i32::MIN || rhs.0 == i32::MIN) { @@ -154,15 +155,16 @@ impl Add for BasisPointsSigned32 { } } -impl AddAssign for BasisPointsSigned32 { +impl AddAssign for PartsPerMillionSigned32 { #[inline] fn add_assign(&mut self, rhs: Self) { *self = *self + rhs; } } -impl Sub for BasisPointsSigned32 { +impl Sub for PartsPerMillionSigned32 { type Output = Self; + #[inline] fn sub(self, rhs: Self) -> Self::Output { if unlikely(self.0 == i32::MIN || rhs.0 == i32::MIN) { @@ -173,15 +175,16 @@ impl Sub for BasisPointsSigned32 { } } -impl SubAssign for BasisPointsSigned32 { +impl SubAssign for PartsPerMillionSigned32 { #[inline] fn sub_assign(&mut self, rhs: Self) { *self = *self - rhs; } } -impl Div for BasisPointsSigned32 { +impl Div for PartsPerMillionSigned32 { type Output = Self; + #[inline] fn div(self, rhs: usize) -> Self::Output { if unlikely(self.0 == i32::MIN) { @@ -193,7 +196,7 @@ impl Div for BasisPointsSigned32 { } } -impl CheckedSub for BasisPointsSigned32 { +impl CheckedSub for PartsPerMillionSigned32 { fn checked_sub(self, rhs: Self) -> Option { if unlikely(self.0 == i32::MIN || rhs.0 == i32::MIN) { Some(Self::NAN) @@ -203,19 +206,18 @@ impl CheckedSub for BasisPointsSigned32 { } } -impl std::fmt::Display for BasisPointsSigned32 { +impl std::fmt::Display for PartsPerMillionSigned32 { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let mut buf = itoa::Buffer::new(); - let str = buf.format(self.0); - f.write_str(str) + f.write_str(buf.format(self.0)) } } -impl Formattable for BasisPointsSigned32 { +impl Formattable for PartsPerMillionSigned32 { #[inline(always)] fn write_to(&self, buf: &mut Vec) { - let mut b = itoa::Buffer::new(); - buf.extend_from_slice(b.format(self.0).as_bytes()); + let mut value = itoa::Buffer::new(); + buf.extend_from_slice(value.format(self.0).as_bytes()); } #[inline(always)] @@ -227,3 +229,27 @@ impl Formattable for BasisPointsSigned32 { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn conversions_and_sentinels() { + assert_eq!( + PartsPerMillionSigned32::from(-0.123_456_6).inner(), + -123_457 + ); + assert_eq!(PartsPerMillionSigned32::from(f64::MAX).inner(), i32::MAX); + assert_eq!( + PartsPerMillionSigned32::from(f64::MIN).inner(), + i32::MIN + 1 + ); + assert!(PartsPerMillionSigned32::from(f64::NAN).is_nan()); + assert!(!PartsPerMillionSigned32::NAN.is_negative()); + + let mut json = Vec::new(); + PartsPerMillionSigned32::NAN.fmt_json(&mut json); + assert_eq!(json, b"null"); + } +} diff --git a/crates/brk_types/src/parts_per_million_signed_64.rs b/crates/brk_types/src/parts_per_million_signed_64.rs new file mode 100644 index 000000000..f6d07a553 --- /dev/null +++ b/crates/brk_types/src/parts_per_million_signed_64.rs @@ -0,0 +1,259 @@ +use std::ops::{Add, AddAssign, Div, Sub, SubAssign}; + +use derive_more::Deref; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use vecdb::{CheckedSub, Formattable, Pco, unlikely}; + +use super::StoredF32; + +/// Signed parts per million stored as i64. +/// One unit is 0.000001. Range: -9,223,372,036,854.775807 to +9,223,372,036,854.775807. +/// Use for precise wide-range signed ratios and percentages. +/// `i64::MIN` is reserved as a NaN sentinel. +#[derive( + Debug, + Deref, + Clone, + Default, + Copy, + PartialEq, + Eq, + PartialOrd, + Ord, + Hash, + Serialize, + Deserialize, + Pco, + JsonSchema, +)] +pub struct PartsPerMillionSigned64(i64); + +impl PartsPerMillionSigned64 { + pub const ZERO: Self = Self(0); + pub const NAN: Self = Self(i64::MIN); + + #[inline] + pub const fn new(value: i64) -> Self { + debug_assert!(value != i64::MIN, "i64::MIN is reserved as NaN sentinel"); + Self(value) + } + + #[inline(always)] + pub const fn inner(self) -> i64 { + self.0 + } + + #[inline] + pub fn is_nan(self) -> bool { + self.0 == i64::MIN + } + + #[inline] + pub fn is_negative(self) -> bool { + self.0 < 0 && self.0 != i64::MIN + } + + #[inline] + pub fn to_f32(self) -> f32 { + if unlikely(self.0 == i64::MIN) { + f32::NAN + } else { + self.0 as f32 / 1_000_000.0 + } + } +} + +impl From for PartsPerMillionSigned64 { + #[inline] + fn from(value: usize) -> Self { + debug_assert!( + value <= i64::MAX as usize, + "usize out of PartsPerMillionSigned64 range: {value}" + ); + Self(value as i64) + } +} + +impl From for PartsPerMillionSigned64 { + #[inline] + fn from(value: i64) -> Self { + debug_assert!(value != i64::MIN, "i64::MIN is reserved as NaN sentinel"); + Self(value) + } +} + +impl From for i64 { + #[inline] + fn from(value: PartsPerMillionSigned64) -> Self { + value.0 + } +} + +impl From for PartsPerMillionSigned64 { + #[inline] + fn from(value: f64) -> Self { + if unlikely(!value.is_finite()) { + return Self::NAN; + } + let scaled = (value * 1_000_000.0).round(); + if scaled <= i64::MIN as f64 { + Self(i64::MIN + 1) + } else if scaled >= i64::MAX as f64 { + Self(i64::MAX) + } else { + Self(scaled as i64) + } + } +} + +impl From for PartsPerMillionSigned64 { + #[inline] + fn from(value: f32) -> Self { + Self::from(value as f64) + } +} + +impl From for PartsPerMillionSigned64 { + #[inline] + fn from(value: StoredF32) -> Self { + Self::from(*value) + } +} + +impl From for f64 { + #[inline] + fn from(value: PartsPerMillionSigned64) -> Self { + if unlikely(value.0 == i64::MIN) { + f64::NAN + } else { + value.0 as f64 / 1_000_000.0 + } + } +} + +impl From for f32 { + #[inline] + fn from(value: PartsPerMillionSigned64) -> Self { + value.to_f32() + } +} + +impl From for StoredF32 { + #[inline] + fn from(value: PartsPerMillionSigned64) -> Self { + StoredF32::from(value.to_f32()) + } +} + +impl Add for PartsPerMillionSigned64 { + type Output = Self; + + #[inline] + fn add(self, rhs: Self) -> Self::Output { + if unlikely(self.0 == i64::MIN || rhs.0 == i64::MIN) { + Self::NAN + } else { + Self(self.0 + rhs.0) + } + } +} + +impl AddAssign for PartsPerMillionSigned64 { + #[inline] + fn add_assign(&mut self, rhs: Self) { + *self = *self + rhs; + } +} + +impl Sub for PartsPerMillionSigned64 { + type Output = Self; + + #[inline] + fn sub(self, rhs: Self) -> Self::Output { + if unlikely(self.0 == i64::MIN || rhs.0 == i64::MIN) { + Self::NAN + } else { + Self(self.0 - rhs.0) + } + } +} + +impl SubAssign for PartsPerMillionSigned64 { + #[inline] + fn sub_assign(&mut self, rhs: Self) { + *self = *self - rhs; + } +} + +impl Div for PartsPerMillionSigned64 { + type Output = Self; + + #[inline] + fn div(self, rhs: usize) -> Self::Output { + if unlikely(self.0 == i64::MIN) { + Self::NAN + } else { + debug_assert!(rhs <= i64::MAX as usize, "divisor out of i64 range: {rhs}"); + Self(self.0 / rhs as i64) + } + } +} + +impl CheckedSub for PartsPerMillionSigned64 { + fn checked_sub(self, rhs: Self) -> Option { + if unlikely(self.0 == i64::MIN || rhs.0 == i64::MIN) { + Some(Self::NAN) + } else { + self.0.checked_sub(rhs.0).map(Self) + } + } +} + +impl std::fmt::Display for PartsPerMillionSigned64 { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let mut buf = itoa::Buffer::new(); + f.write_str(buf.format(self.0)) + } +} + +impl Formattable for PartsPerMillionSigned64 { + #[inline(always)] + fn write_to(&self, buf: &mut Vec) { + let mut value = itoa::Buffer::new(); + buf.extend_from_slice(value.format(self.0).as_bytes()); + } + + #[inline(always)] + fn fmt_json(&self, buf: &mut Vec) { + if unlikely(self.0 == i64::MIN) { + buf.extend_from_slice(b"null"); + } else { + self.write_to(buf); + } + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn conversions_and_sentinels() { + assert_eq!( + PartsPerMillionSigned64::from(-0.123_456_6).inner(), + -123_457 + ); + assert_eq!(PartsPerMillionSigned64::from(f64::MAX).inner(), i64::MAX); + assert_eq!( + PartsPerMillionSigned64::from(f64::MIN).inner(), + i64::MIN + 1 + ); + assert!(PartsPerMillionSigned64::from(f64::NEG_INFINITY).is_nan()); + assert!(!PartsPerMillionSigned64::NAN.is_negative()); + + let mut json = Vec::new(); + PartsPerMillionSigned64::NAN.fmt_json(&mut json); + assert_eq!(json, b"null"); + } +} diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index aca628b1c..7cfcaf293 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -87,38 +87,6 @@ * * @typedef {TypeIndex} AnyAddrIndex */ -/** - * Unsigned basis points stored as u16. - * 1 bp = 0.0001. Range: 0–6.5535. - * Use for bounded 0–1 ratios (dominance, adoption, liveliness, etc.). - * `u16::MAX` is reserved as a NaN sentinel. - * - * @typedef {number} BasisPoints16 - */ -/** - * Unsigned basis points stored as u32. - * 1 bp = 0.0001. Range: 0–429,496.7295. - * Use for unbounded unsigned ratios (MVRV, NVT, SOPR, etc.). - * `u32::MAX` is reserved as a NaN sentinel. - * - * @typedef {number} BasisPoints32 - */ -/** - * Signed basis points stored as i16. - * 1 bp = 0.0001. Range: -3.2767 to +3.2767. - * Use for signed bounded ratios (NUPL, net PnL ratios, etc.). - * `i16::MIN` is reserved as a NaN sentinel. - * - * @typedef {number} BasisPointsSigned16 - */ -/** - * Signed basis points stored as i32. - * 1 bp = 0.0001. Range: -214,748.3647 to +214,748.3647. - * Use for unbounded signed values (returns, growth rates, volatility, z-scores, etc.). - * `i32::MIN` is reserved as a NaN sentinel. - * - * @typedef {number} BasisPointsSigned32 - */ /** * Bitcoin amount as floating point (1 BTC = 100,000,000 satoshis) * @@ -875,6 +843,38 @@ ancestors and no descendants (matches mempool.space). * @property {?number=} page - Pagination index * @property {?number=} perPage - Results per page (default: 1000, max: 1000) */ +/** + * Unsigned parts per million stored as u32. + * One unit is 0.000001. Range: 0–4,294.967294. + * Use for precise bounded ratios and percentages. + * `u32::MAX` is reserved as a NaN sentinel. + * + * @typedef {number} PartsPerMillion32 + */ +/** + * Unsigned parts per million stored as u64. + * One unit is 0.000001. Range: 0–18,446,744,073,709.551614. + * Use for precise wide-range ratios. + * `u64::MAX` is reserved as a NaN sentinel. + * + * @typedef {number} PartsPerMillion64 + */ +/** + * Signed parts per million stored as i32. + * One unit is 0.000001. Range: -2,147.483647 to +2,147.483647. + * Use for precise bounded signed ratios and percentages. + * `i32::MIN` is reserved as a NaN sentinel. + * + * @typedef {number} PartsPerMillionSigned32 + */ +/** + * Signed parts per million stored as i64. + * One unit is 0.000001. Range: -9,223,372,036,854.775807 to +9,223,372,036,854.775807. + * Use for precise wide-range signed ratios and percentages. + * `i64::MIN` is reserved as a NaN sentinel. + * + * @typedef {number} PartsPerMillionSigned64 + */ /** * Block counts for different time periods * @@ -2590,45 +2590,6 @@ function createAllEmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPatte }; } -/** - * @typedef {Object} _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 - * @property {BpsPercentRatioPattern} _10y - * @property {BpsPercentRatioPattern} _1m - * @property {BpsPercentRatioPattern} _1w - * @property {BpsPercentRatioPattern} _1y - * @property {BpsPercentRatioPattern} _2y - * @property {BpsPercentRatioPattern} _3m - * @property {BpsPercentRatioPattern} _3y - * @property {BpsPercentRatioPattern} _4y - * @property {BpsPercentRatioPattern} _5y - * @property {BpsPercentRatioPattern} _6m - * @property {BpsPercentRatioPattern} _6y - * @property {BpsPercentRatioPattern} _8y - */ - -/** - * Create a _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} - */ -function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, acc) { - return { - _10y: createBpsPercentRatioPattern(client, _m(acc, '10y')), - _1m: createBpsPercentRatioPattern(client, _m(acc, '1m')), - _1w: createBpsPercentRatioPattern(client, _m(acc, '1w')), - _1y: createBpsPercentRatioPattern(client, _m(acc, '1y')), - _2y: createBpsPercentRatioPattern(client, _m(acc, '2y')), - _3m: createBpsPercentRatioPattern(client, _m(acc, '3m')), - _3y: createBpsPercentRatioPattern(client, _m(acc, '3y')), - _4y: createBpsPercentRatioPattern(client, _m(acc, '4y')), - _5y: createBpsPercentRatioPattern(client, _m(acc, '5y')), - _6m: createBpsPercentRatioPattern(client, _m(acc, '6m')), - _6y: createBpsPercentRatioPattern(client, _m(acc, '6y')), - _8y: createBpsPercentRatioPattern(client, _m(acc, '8y')), - }; -} - /** * @typedef {Object} _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 * @property {BtcCentsSatsUsdPattern} _10y @@ -2668,6 +2629,45 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { }; } +/** + * @typedef {Object} _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 + * @property {PercentRatioRawPattern} _10y + * @property {PercentRatioRawPattern} _1m + * @property {PercentRatioRawPattern} _1w + * @property {PercentRatioRawPattern} _1y + * @property {PercentRatioRawPattern} _2y + * @property {PercentRatioRawPattern} _3m + * @property {PercentRatioRawPattern} _3y + * @property {PercentRatioRawPattern} _4y + * @property {PercentRatioRawPattern} _5y + * @property {PercentRatioRawPattern} _6m + * @property {PercentRatioRawPattern} _6y + * @property {PercentRatioRawPattern} _8y + */ + +/** + * Create a _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} + */ +function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, acc) { + return { + _10y: createPercentRatioRawPattern(client, _m(acc, '10y')), + _1m: createPercentRatioRawPattern(client, _m(acc, '1m')), + _1w: createPercentRatioRawPattern(client, _m(acc, '1w')), + _1y: createPercentRatioRawPattern(client, _m(acc, '1y')), + _2y: createPercentRatioRawPattern(client, _m(acc, '2y')), + _3m: createPercentRatioRawPattern(client, _m(acc, '3m')), + _3y: createPercentRatioRawPattern(client, _m(acc, '3y')), + _4y: createPercentRatioRawPattern(client, _m(acc, '4y')), + _5y: createPercentRatioRawPattern(client, _m(acc, '5y')), + _6m: createPercentRatioRawPattern(client, _m(acc, '6m')), + _6y: createPercentRatioRawPattern(client, _m(acc, '6y')), + _8y: createPercentRatioRawPattern(client, _m(acc, '8y')), + }; +} + /** * @typedef {Object} AllEmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern * @property {AverageBlockCumulativeSumPattern} all @@ -2693,7 +2693,7 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { * @property {SeriesPattern1} mvrv * @property {BlockChangeCumulativeDeltaSumPattern} netPnl * @property {BlockCumulativeSumPattern} peakRegret - * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price + * @property {CentsPercentilesRatioRawSatsSmaStdUsdPattern} price * @property {BlockCumulativeSumPattern} profit * @property {_1m1w1y24hPattern} profitToLossRatio * @property {_1m1w1y24hPattern8} sellSideRiskRatio @@ -2709,7 +2709,7 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { * @property {SeriesPattern1} mvrv * @property {BlockChangeCumulativeDeltaSumPattern} netPnl * @property {BlockCumulativeSumPattern} peakRegret - * @property {BpsCentsPercentilesRatioSatsSmaStdUsdPattern} price + * @property {CentsPercentilesRatioRawSatsSmaStdUsdPattern} price * @property {BlockCumulativeSumPattern} profit * @property {_1m1w1y24hPattern} profitToLossRatio * @property {_1m1w1y24hPattern8} sellSideRiskRatio @@ -2718,18 +2718,18 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { /** * @typedef {Object} EmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2 - * @property {_1m1w1y24hBpsPercentRatioPattern} empty - * @property {_1m1w1y24hBpsPercentRatioPattern} opReturn - * @property {_1m1w1y24hBpsPercentRatioPattern} p2a - * @property {_1m1w1y24hBpsPercentRatioPattern} p2ms - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk33 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk65 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2sh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2tr - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wpkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wsh - * @property {_1m1w1y24hBpsPercentRatioPattern} unknown + * @property {_1m1w1y24hPercentRatioRawPattern} empty + * @property {_1m1w1y24hPercentRatioRawPattern} opReturn + * @property {_1m1w1y24hPercentRatioRawPattern} p2a + * @property {_1m1w1y24hPercentRatioRawPattern} p2ms + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk33 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk65 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2sh + * @property {_1m1w1y24hPercentRatioRawPattern} p2tr + * @property {_1m1w1y24hPercentRatioRawPattern} p2wpkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2wsh + * @property {_1m1w1y24hPercentRatioRawPattern} unknown */ /** @@ -2740,18 +2740,18 @@ function create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, acc) { */ function createEmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2(client, acc) { return { - empty: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'empty_outputs_output')), - opReturn: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'op_return_output')), - p2a: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2a_output')), - p2ms: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2ms_output')), - p2pk33: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk33_output')), - p2pk65: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk65_output')), - p2pkh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pkh_output')), - p2sh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2sh_output')), - p2tr: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2tr_output')), - p2wpkh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wpkh_output')), - p2wsh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wsh_output')), - unknown: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'unknown_outputs_output')), + empty: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'empty_outputs_output')), + opReturn: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'op_return_output')), + p2a: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2a_output')), + p2ms: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2ms_output')), + p2pk33: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk33_output')), + p2pk65: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk65_output')), + p2pkh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pkh_output')), + p2sh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2sh_output')), + p2tr: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2tr_output')), + p2wpkh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wpkh_output')), + p2wsh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wsh_output')), + unknown: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'unknown_outputs_output')), }; } @@ -2794,17 +2794,17 @@ function createAverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern( /** * @typedef {Object} EmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2 - * @property {_1m1w1y24hBpsPercentRatioPattern} empty - * @property {_1m1w1y24hBpsPercentRatioPattern} p2a - * @property {_1m1w1y24hBpsPercentRatioPattern} p2ms - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk33 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk65 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2sh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2tr - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wpkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wsh - * @property {_1m1w1y24hBpsPercentRatioPattern} unknown + * @property {_1m1w1y24hPercentRatioRawPattern} empty + * @property {_1m1w1y24hPercentRatioRawPattern} p2a + * @property {_1m1w1y24hPercentRatioRawPattern} p2ms + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk33 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk65 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2sh + * @property {_1m1w1y24hPercentRatioRawPattern} p2tr + * @property {_1m1w1y24hPercentRatioRawPattern} p2wpkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2wsh + * @property {_1m1w1y24hPercentRatioRawPattern} unknown */ /** @@ -2815,17 +2815,17 @@ function createAverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern( */ function createEmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2(client, acc) { return { - empty: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'empty_outputs_prevout')), - p2a: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2a_prevout')), - p2ms: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2ms_prevout')), - p2pk33: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk33_prevout')), - p2pk65: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk65_prevout')), - p2pkh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pkh_prevout')), - p2sh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2sh_prevout')), - p2tr: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2tr_prevout')), - p2wpkh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wpkh_prevout')), - p2wsh: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wsh_prevout')), - unknown: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'unknown_outputs_prevout')), + empty: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'empty_outputs_prevout')), + p2a: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2a_prevout')), + p2ms: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2ms_prevout')), + p2pk33: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk33_prevout')), + p2pk65: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk65_prevout')), + p2pkh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pkh_prevout')), + p2sh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2sh_prevout')), + p2tr: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2tr_prevout')), + p2wpkh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wpkh_prevout')), + p2wsh: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wsh_prevout')), + unknown: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'unknown_outputs_prevout')), }; } @@ -2952,15 +2952,15 @@ function createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(client, acc) { /** * @typedef {Object} AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern5 - * @property {BpsPercentRatioPattern2} all - * @property {BpsPercentRatioPattern2} p2a - * @property {BpsPercentRatioPattern2} p2pk33 - * @property {BpsPercentRatioPattern2} p2pk65 - * @property {BpsPercentRatioPattern2} p2pkh - * @property {BpsPercentRatioPattern2} p2sh - * @property {BpsPercentRatioPattern2} p2tr - * @property {BpsPercentRatioPattern2} p2wpkh - * @property {BpsPercentRatioPattern2} p2wsh + * @property {PercentRatioRawPattern2} all + * @property {PercentRatioRawPattern2} p2a + * @property {PercentRatioRawPattern2} p2pk33 + * @property {PercentRatioRawPattern2} p2pk65 + * @property {PercentRatioRawPattern2} p2pkh + * @property {PercentRatioRawPattern2} p2sh + * @property {PercentRatioRawPattern2} p2tr + * @property {PercentRatioRawPattern2} p2wpkh + * @property {PercentRatioRawPattern2} p2wsh */ /** @@ -2971,15 +2971,15 @@ function createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(client, acc) { */ function createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern5(client, acc) { return { - all: createBpsPercentRatioPattern2(client, acc), - p2a: createBpsPercentRatioPattern2(client, _p('p2a', acc)), - p2pk33: createBpsPercentRatioPattern2(client, _p('p2pk33', acc)), - p2pk65: createBpsPercentRatioPattern2(client, _p('p2pk65', acc)), - p2pkh: createBpsPercentRatioPattern2(client, _p('p2pkh', acc)), - p2sh: createBpsPercentRatioPattern2(client, _p('p2sh', acc)), - p2tr: createBpsPercentRatioPattern2(client, _p('p2tr', acc)), - p2wpkh: createBpsPercentRatioPattern2(client, _p('p2wpkh', acc)), - p2wsh: createBpsPercentRatioPattern2(client, _p('p2wsh', acc)), + all: createPercentRatioRawPattern2(client, acc), + p2a: createPercentRatioRawPattern2(client, _p('p2a', acc)), + p2pk33: createPercentRatioRawPattern2(client, _p('p2pk33', acc)), + p2pk65: createPercentRatioRawPattern2(client, _p('p2pk65', acc)), + p2pkh: createPercentRatioRawPattern2(client, _p('p2pkh', acc)), + p2sh: createPercentRatioRawPattern2(client, _p('p2sh', acc)), + p2tr: createPercentRatioRawPattern2(client, _p('p2tr', acc)), + p2wpkh: createPercentRatioRawPattern2(client, _p('p2wpkh', acc)), + p2wsh: createPercentRatioRawPattern2(client, _p('p2wsh', acc)), }; } @@ -3018,15 +3018,15 @@ function createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern4(client, acc) { /** * @typedef {Object} AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7 - * @property {_1m1w1y24hBpsPercentRatioPattern} all - * @property {_1m1w1y24hBpsPercentRatioPattern} p2a - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk33 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk65 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2sh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2tr - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wpkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wsh + * @property {_1m1w1y24hPercentRatioRawPattern} all + * @property {_1m1w1y24hPercentRatioRawPattern} p2a + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk33 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk65 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2sh + * @property {_1m1w1y24hPercentRatioRawPattern} p2tr + * @property {_1m1w1y24hPercentRatioRawPattern} p2wpkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2wsh */ /** @@ -3037,15 +3037,15 @@ function createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern4(client, acc) { */ function createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(client, acc) { return { - all: create_1m1w1y24hBpsPercentRatioPattern(client, acc), - p2a: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2a', acc)), - p2pk33: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2pk33', acc)), - p2pk65: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2pk65', acc)), - p2pkh: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2pkh', acc)), - p2sh: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2sh', acc)), - p2tr: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2tr', acc)), - p2wpkh: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2wpkh', acc)), - p2wsh: create_1m1w1y24hBpsPercentRatioPattern(client, _p('p2wsh', acc)), + all: create_1m1w1y24hPercentRatioRawPattern(client, acc), + p2a: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2a', acc)), + p2pk33: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2pk33', acc)), + p2pk65: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2pk65', acc)), + p2pkh: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2pkh', acc)), + p2sh: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2sh', acc)), + p2tr: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2tr', acc)), + p2wpkh: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2wpkh', acc)), + p2wsh: create_1m1w1y24hPercentRatioRawPattern(client, _p('p2wsh', acc)), }; } @@ -3090,7 +3090,7 @@ function createAverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern(client, acc) { * @property {InPattern2} investedCapital * @property {CentsNegativeToUsdPattern2} loss * @property {CentsToUsdPattern3} netPnl - * @property {BpsRatioPattern} nupl + * @property {RatioRawPattern} nupl * @property {CentsToUsdPattern4} profit * @property {GreedNetPainPattern} sentiment */ @@ -3109,18 +3109,18 @@ function createCapitalizedGrossInvestedLossNetNuplProfitSentimentPattern2(client investedCapital: createInPattern2(client, _m(acc, 'invested_capital_in')), loss: createCentsNegativeToUsdPattern2(client, _m(acc, 'unrealized_loss')), netPnl: createCentsToUsdPattern3(client, _m(acc, 'net_unrealized_pnl')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + nupl: createRatioRawPattern(client, _m(acc, 'nupl')), profit: createCentsToUsdPattern4(client, _m(acc, 'unrealized_profit')), sentiment: createGreedNetPainPattern(client, acc), }; } /** - * @typedef {Object} BpsCentsPercentilesRatioSatsSmaStdUsdPattern - * @property {SeriesPattern1} bps + * @typedef {Object} CentsPercentilesRatioRawSatsSmaStdUsdPattern * @property {SeriesPattern1} cents * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw * @property {SeriesPattern1} sats * @property {_1m1w1y2y4yAllPattern} sma * @property {_1y2y4yAllPattern} stdDev @@ -3129,14 +3129,14 @@ function createCapitalizedGrossInvestedLossNetNuplProfitSentimentPattern2(client /** * @typedef {Object} Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern - * @property {BpsPriceRatioPattern} pct05 - * @property {BpsPriceRatioPattern} pct1 - * @property {BpsPriceRatioPattern} pct2 - * @property {BpsPriceRatioPattern} pct5 - * @property {BpsPriceRatioPattern} pct95 - * @property {BpsPriceRatioPattern} pct98 - * @property {BpsPriceRatioPattern} pct99 - * @property {BpsPriceRatioPattern} pct995 + * @property {PriceRatioRawPattern} pct05 + * @property {PriceRatioRawPattern} pct1 + * @property {PriceRatioRawPattern} pct2 + * @property {PriceRatioRawPattern} pct5 + * @property {PriceRatioRawPattern} pct95 + * @property {PriceRatioRawPattern} pct98 + * @property {PriceRatioRawPattern} pct99 + * @property {PriceRatioRawPattern} pct995 */ /** @@ -3147,26 +3147,26 @@ function createCapitalizedGrossInvestedLossNetNuplProfitSentimentPattern2(client */ function createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, acc) { return { - pct05: createBpsPriceRatioPattern(client, acc, 'pct0_5'), - pct1: createBpsPriceRatioPattern(client, acc, 'pct1'), - pct2: createBpsPriceRatioPattern(client, acc, 'pct2'), - pct5: createBpsPriceRatioPattern(client, acc, 'pct5'), - pct95: createBpsPriceRatioPattern(client, acc, 'pct95'), - pct98: createBpsPriceRatioPattern(client, acc, 'pct98'), - pct99: createBpsPriceRatioPattern(client, acc, 'pct99'), - pct995: createBpsPriceRatioPattern(client, acc, 'pct99_5'), + pct05: createPriceRatioRawPattern(client, acc, 'pct0_5'), + pct1: createPriceRatioRawPattern(client, acc, 'pct1'), + pct2: createPriceRatioRawPattern(client, acc, 'pct2'), + pct5: createPriceRatioRawPattern(client, acc, 'pct5'), + pct95: createPriceRatioRawPattern(client, acc, 'pct95'), + pct98: createPriceRatioRawPattern(client, acc, 'pct98'), + pct99: createPriceRatioRawPattern(client, acc, 'pct99'), + pct995: createPriceRatioRawPattern(client, acc, 'pct99_5'), }; } /** * @typedef {Object} _10y2y3y4y5y6y8yPattern - * @property {BpsPercentRatioPattern} _10y - * @property {BpsPercentRatioPattern} _2y - * @property {BpsPercentRatioPattern} _3y - * @property {BpsPercentRatioPattern} _4y - * @property {BpsPercentRatioPattern} _5y - * @property {BpsPercentRatioPattern} _6y - * @property {BpsPercentRatioPattern} _8y + * @property {PercentRatioRawPattern} _10y + * @property {PercentRatioRawPattern} _2y + * @property {PercentRatioRawPattern} _3y + * @property {PercentRatioRawPattern} _4y + * @property {PercentRatioRawPattern} _5y + * @property {PercentRatioRawPattern} _6y + * @property {PercentRatioRawPattern} _8y */ /** @@ -3177,42 +3177,42 @@ function createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, acc) { */ function create_10y2y3y4y5y6y8yPattern(client, acc) { return { - _10y: createBpsPercentRatioPattern(client, _m(acc, '10y')), - _2y: createBpsPercentRatioPattern(client, _m(acc, '2y')), - _3y: createBpsPercentRatioPattern(client, _m(acc, '3y')), - _4y: createBpsPercentRatioPattern(client, _m(acc, '4y')), - _5y: createBpsPercentRatioPattern(client, _m(acc, '5y')), - _6y: createBpsPercentRatioPattern(client, _m(acc, '6y')), - _8y: createBpsPercentRatioPattern(client, _m(acc, '8y')), + _10y: createPercentRatioRawPattern(client, _m(acc, '10y')), + _2y: createPercentRatioRawPattern(client, _m(acc, '2y')), + _3y: createPercentRatioRawPattern(client, _m(acc, '3y')), + _4y: createPercentRatioRawPattern(client, _m(acc, '4y')), + _5y: createPercentRatioRawPattern(client, _m(acc, '5y')), + _6y: createPercentRatioRawPattern(client, _m(acc, '6y')), + _8y: createPercentRatioRawPattern(client, _m(acc, '8y')), }; } /** - * @typedef {Object} _1m1w1y24hBpsPercentRatioPattern - * @property {BpsPercentRatioPattern2} _1m - * @property {BpsPercentRatioPattern2} _1w - * @property {BpsPercentRatioPattern2} _1y - * @property {BpsPercentRatioPattern2} _24h - * @property {SeriesPattern1} bps + * @typedef {Object} _1m1w1y24hPercentRatioRawPattern + * @property {PercentRatioRawPattern2} _1m + * @property {PercentRatioRawPattern2} _1w + * @property {PercentRatioRawPattern2} _1y + * @property {PercentRatioRawPattern2} _24h * @property {SeriesPattern1} percent * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw */ /** - * Create a _1m1w1y24hBpsPercentRatioPattern pattern node + * Create a _1m1w1y24hPercentRatioRawPattern pattern node * @param {BrkClient} client * @param {string} acc - Accumulated series name - * @returns {_1m1w1y24hBpsPercentRatioPattern} + * @returns {_1m1w1y24hPercentRatioRawPattern} */ -function create_1m1w1y24hBpsPercentRatioPattern(client, acc) { +function create_1m1w1y24hPercentRatioRawPattern(client, acc) { return { - _1m: createBpsPercentRatioPattern2(client, _m(acc, '1m')), - _1w: createBpsPercentRatioPattern2(client, _m(acc, '1w')), - _1y: createBpsPercentRatioPattern2(client, _m(acc, '1y')), - _24h: createBpsPercentRatioPattern2(client, _m(acc, '24h')), - bps: createSeriesPattern1(client, _m(acc, 'bps')), + _1m: createPercentRatioRawPattern2(client, _m(acc, '1m')), + _1w: createPercentRatioRawPattern2(client, _m(acc, '1w')), + _1y: createPercentRatioRawPattern2(client, _m(acc, '1y')), + _24h: createPercentRatioRawPattern2(client, _m(acc, '24h')), percent: createSeriesPattern1(client, acc), ratio: createSeriesPattern1(client, _m(acc, 'ratio')), + raw: createSeriesPattern1(client, _m(acc, 'ppm')), }; } @@ -3224,7 +3224,7 @@ function create_1m1w1y24hBpsPercentRatioPattern(client, acc) { * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7} inputFromReusedAddrShare * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6} outputToReusedAddrCount * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7} outputToReusedAddrShare - * @property {_1m1w1y24hBpsPercentRatioPattern} spendableOutputToReusedAddrShare + * @property {_1m1w1y24hPercentRatioRawPattern} spendableOutputToReusedAddrShare */ /** @@ -3244,7 +3244,7 @@ function create_1m1w1y24hBpsPercentRatioPattern(client, acc) { * @property {BlockCumulativeNegativeSumPattern} loss * @property {SeriesPattern1} mvrv * @property {BlockCumulativeDeltaSumPattern} netPnl - * @property {BpsCentsRatioSatsUsdPattern} price + * @property {CentsRatioRawSatsUsdPattern} price * @property {BlockCumulativeSumPattern} profit * @property {RatioValuePattern} sopr */ @@ -3261,7 +3261,7 @@ function createCapLossMvrvNetPriceProfitSoprPattern(client, acc) { loss: createBlockCumulativeNegativeSumPattern(client, _m(acc, 'realized_loss')), mvrv: createSeriesPattern1(client, _m(acc, 'mvrv')), netPnl: createBlockCumulativeDeltaSumPattern(client, _m(acc, 'net_realized_pnl')), - price: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), + price: createCentsRatioRawSatsUsdPattern(client, _m(acc, 'realized_price')), profit: createBlockCumulativeSumPattern(client, _m(acc, 'realized_profit')), sopr: createRatioValuePattern(client, acc), }; @@ -3275,7 +3275,7 @@ function createCapLossMvrvNetPriceProfitSoprPattern(client, acc) { * @property {CentsSatsUsdPattern} min * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} perCoin * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} perDollar - * @property {BpsPercentRatioPattern2} supplyDensity + * @property {PercentRatioRawPattern2} supplyDensity */ /** @@ -3292,7 +3292,7 @@ function createInMaxMinPerSupplyPattern(client, acc) { min: createCentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')), perCoin: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis_per_coin')), perDollar: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis_per_dollar')), - supplyDensity: createBpsPercentRatioPattern2(client, _m(acc, 'supply_density')), + supplyDensity: createPercentRatioRawPattern2(client, _m(acc, 'supply_density')), }; } @@ -3358,12 +3358,12 @@ function createMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, acc) { /** * @typedef {Object} _1m1w1y2y4yAllPattern - * @property {BpsRatioPattern2} _1m - * @property {BpsRatioPattern2} _1w - * @property {BpsRatioPattern2} _1y - * @property {BpsRatioPattern2} _2y - * @property {BpsRatioPattern2} _4y - * @property {BpsRatioPattern2} all + * @property {RatioRawPattern2} _1m + * @property {RatioRawPattern2} _1w + * @property {RatioRawPattern2} _1y + * @property {RatioRawPattern2} _2y + * @property {RatioRawPattern2} _4y + * @property {RatioRawPattern2} all */ /** @@ -3374,12 +3374,12 @@ function createMaxMedianMinPct10Pct25Pct75Pct90Pattern(client, acc) { */ function create_1m1w1y2y4yAllPattern(client, acc) { return { - _1m: createBpsRatioPattern2(client, _m(acc, '1m')), - _1w: createBpsRatioPattern2(client, _m(acc, '1w')), - _1y: createBpsRatioPattern2(client, _m(acc, '1y')), - _2y: createBpsRatioPattern2(client, _m(acc, '2y')), - _4y: createBpsRatioPattern2(client, _m(acc, '4y')), - all: createBpsRatioPattern2(client, _m(acc, 'all')), + _1m: createRatioRawPattern2(client, _m(acc, '1m')), + _1w: createRatioRawPattern2(client, _m(acc, '1w')), + _1y: createRatioRawPattern2(client, _m(acc, '1y')), + _2y: createRatioRawPattern2(client, _m(acc, '2y')), + _4y: createRatioRawPattern2(client, _m(acc, '4y')), + all: createRatioRawPattern2(client, _m(acc, 'all')), }; } @@ -3437,40 +3437,13 @@ function createAverageBlockCumulativeInSumPattern(client, acc) { }; } -/** - * @typedef {Object} BpsCentsPercentilesRatioSatsUsdPattern - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} cents - * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles - * @property {SeriesPattern1} ratio - * @property {SeriesPattern1} sats - * @property {SeriesPattern1} usd - */ - -/** - * Create a BpsCentsPercentilesRatioSatsUsdPattern pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsCentsPercentilesRatioSatsUsdPattern} - */ -function createBpsCentsPercentilesRatioSatsUsdPattern(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'ratio_bps')), - cents: createSeriesPattern1(client, _m(acc, 'cents')), - percentiles: createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, acc), - ratio: createSeriesPattern1(client, _m(acc, 'ratio')), - sats: createSeriesPattern1(client, _m(acc, 'sats')), - usd: createSeriesPattern1(client, acc), - }; -} - /** * @typedef {Object} CentsNegativeToUsdPattern2 * @property {SeriesPattern1} cents * @property {SeriesPattern1} negative - * @property {BpsPercentRatioPattern2} toMcap - * @property {BpsPercentRatioPattern2} toOwnGrossPnl - * @property {BpsPercentRatioPattern4} toOwnMcap + * @property {PercentRatioRawPattern2} toMcap + * @property {PercentRatioRawPattern2} toOwnGrossPnl + * @property {PercentRatioRawPattern2} toOwnMcap * @property {SeriesPattern1} usd */ @@ -3484,18 +3457,45 @@ function createCentsNegativeToUsdPattern2(client, acc) { return { cents: createSeriesPattern1(client, _m(acc, 'cents')), negative: createSeriesPattern1(client, _m(acc, 'neg')), - toMcap: createBpsPercentRatioPattern2(client, _m(acc, 'to_mcap')), - toOwnGrossPnl: createBpsPercentRatioPattern2(client, _m(acc, 'to_own_gross_pnl')), - toOwnMcap: createBpsPercentRatioPattern4(client, _m(acc, 'to_own_mcap')), + toMcap: createPercentRatioRawPattern2(client, _m(acc, 'to_mcap')), + toOwnGrossPnl: createPercentRatioRawPattern2(client, _m(acc, 'to_own_gross_pnl')), + toOwnMcap: createPercentRatioRawPattern2(client, _m(acc, 'to_own_mcap')), + usd: createSeriesPattern1(client, acc), + }; +} + +/** + * @typedef {Object} CentsPercentilesRatioRawSatsUsdPattern + * @property {SeriesPattern1} cents + * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + * @property {SeriesPattern1} sats + * @property {SeriesPattern1} usd + */ + +/** + * Create a CentsPercentilesRatioRawSatsUsdPattern pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {CentsPercentilesRatioRawSatsUsdPattern} + */ +function createCentsPercentilesRatioRawSatsUsdPattern(client, acc) { + return { + cents: createSeriesPattern1(client, _m(acc, 'cents')), + percentiles: createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, acc), + ratio: createSeriesPattern1(client, _m(acc, 'ratio')), + raw: createSeriesPattern1(client, _m(acc, 'ratio_ppm')), + sats: createSeriesPattern1(client, _m(acc, 'sats')), usd: createSeriesPattern1(client, acc), }; } /** * @typedef {Object} ChainDataOutputTxPattern - * @property {BpsPercentRatioPattern2} chainShare + * @property {PercentRatioRawPattern2} chainShare * @property {AverageBlockCumulativeSumPattern} dataBytes - * @property {BpsPercentRatioPattern2} dataShare + * @property {PercentRatioRawPattern2} dataShare * @property {AverageBlockCumulativeSumPattern} outputCount * @property {AverageBlockCumulativeSumPattern} txCount * @property {AverageBlockCumulativeSumPattern} txVsize @@ -3509,9 +3509,9 @@ function createCentsNegativeToUsdPattern2(client, acc) { */ function createChainDataOutputTxPattern(client, acc) { return { - chainShare: createBpsPercentRatioPattern2(client, _m(acc, 'chain_share')), + chainShare: createPercentRatioRawPattern2(client, _m(acc, 'chain_share')), dataBytes: createAverageBlockCumulativeSumPattern(client, _m(acc, 'data_bytes')), - dataShare: createBpsPercentRatioPattern2(client, _m(acc, 'data_share')), + dataShare: createPercentRatioRawPattern2(client, _m(acc, 'data_share')), outputCount: createAverageBlockCumulativeSumPattern(client, _m(acc, 'output_count')), txCount: createAverageBlockCumulativeSumPattern(client, _m(acc, 'tx_count')), txVsize: createAverageBlockCumulativeSumPattern(client, _m(acc, 'tx_vsize')), @@ -3521,7 +3521,7 @@ function createChainDataOutputTxPattern(client, acc) { /** * @typedef {Object} DeltaDominanceHalfInTotalPattern2 * @property {AbsoluteRatePattern3} delta - * @property {BpsPercentRatioPattern2} dominance + * @property {PercentRatioRawPattern2} dominance * @property {BtcCentsSatsUsdPattern} half * @property {BtcCentsSatsShareUsdPattern} inLoss * @property {BtcCentsSatsShareUsdPattern} inProfit @@ -3537,7 +3537,7 @@ function createChainDataOutputTxPattern(client, acc) { function createDeltaDominanceHalfInTotalPattern2(client, acc) { return { delta: createAbsoluteRatePattern3(client, _m(acc, 'delta')), - dominance: createBpsPercentRatioPattern2(client, _m(acc, 'dominance')), + dominance: createPercentRatioRawPattern2(client, _m(acc, 'dominance')), half: createBtcCentsSatsUsdPattern(client, _m(acc, 'half')), inLoss: createBtcCentsSatsShareUsdPattern(client, _m(acc, 'in_loss')), inProfit: createBtcCentsSatsShareUsdPattern(client, _m(acc, 'in_profit')), @@ -3548,7 +3548,7 @@ function createDeltaDominanceHalfInTotalPattern2(client, acc) { /** * @typedef {Object} DeltaDominanceHalfInTotalPattern * @property {AbsoluteRatePattern3} delta - * @property {BpsPercentRatioPattern2} dominance + * @property {PercentRatioRawPattern2} dominance * @property {BtcCentsSatsUsdPattern} half * @property {BtcCentsSatsUsdPattern} inLoss * @property {BtcCentsSatsUsdPattern} inProfit @@ -3564,7 +3564,7 @@ function createDeltaDominanceHalfInTotalPattern2(client, acc) { function createDeltaDominanceHalfInTotalPattern(client, acc) { return { delta: createAbsoluteRatePattern3(client, _m(acc, 'delta')), - dominance: createBpsPercentRatioPattern2(client, _m(acc, 'dominance')), + dominance: createPercentRatioRawPattern2(client, _m(acc, 'dominance')), half: createBtcCentsSatsUsdPattern(client, _m(acc, 'half')), inLoss: createBtcCentsSatsUsdPattern(client, _m(acc, 'in_loss')), inProfit: createBtcCentsSatsUsdPattern(client, _m(acc, 'in_profit')), @@ -3747,31 +3747,6 @@ function createBlockChangeCumulativeDeltaSumPattern(client, acc) { }; } -/** - * @typedef {Object} BpsCentsRatioSatsUsdPattern - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} cents - * @property {SeriesPattern1} ratio - * @property {SeriesPattern1} sats - * @property {SeriesPattern1} usd - */ - -/** - * Create a BpsCentsRatioSatsUsdPattern pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsCentsRatioSatsUsdPattern} - */ -function createBpsCentsRatioSatsUsdPattern(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'ratio_bps')), - cents: createSeriesPattern1(client, _m(acc, 'cents')), - ratio: createSeriesPattern1(client, _m(acc, 'ratio')), - sats: createSeriesPattern1(client, _m(acc, 'sats')), - usd: createSeriesPattern1(client, acc), - }; -} - /** * @typedef {Object} BtcCentsDeltaSatsUsdPattern * @property {SeriesPattern1} btc @@ -3802,7 +3777,7 @@ function createBtcCentsDeltaSatsUsdPattern(client, acc) { * @property {SeriesPattern1} btc * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {BpsPercentRatioPattern2} share + * @property {PercentRatioRawPattern2} share * @property {SeriesPattern1} usd */ @@ -3817,7 +3792,7 @@ function createBtcCentsSatsShareUsdPattern(client, acc) { btc: createSeriesPattern1(client, acc), cents: createSeriesPattern1(client, _m(acc, 'cents')), sats: createSeriesPattern1(client, _m(acc, 'sats')), - share: createBpsPercentRatioPattern2(client, _m(acc, 'share')), + share: createPercentRatioRawPattern2(client, _m(acc, 'share')), usd: createSeriesPattern1(client, _m(acc, 'usd')), }; } @@ -3827,7 +3802,7 @@ function createBtcCentsSatsShareUsdPattern(client, acc) { * @property {CentsDeltaUsdPattern} cap * @property {BlockCumulativeSumPattern} loss * @property {SeriesPattern1} mvrv - * @property {BpsCentsRatioSatsUsdPattern} price + * @property {CentsRatioRawSatsUsdPattern} price * @property {BlockCumulativeSumPattern} profit */ @@ -3842,17 +3817,42 @@ function createCapLossMvrvPriceProfitPattern(client, acc) { cap: createCentsDeltaUsdPattern(client, _m(acc, 'realized_cap')), loss: createBlockCumulativeSumPattern(client, _m(acc, 'realized_loss')), mvrv: createSeriesPattern1(client, _m(acc, 'mvrv')), - price: createBpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')), + price: createCentsRatioRawSatsUsdPattern(client, _m(acc, 'realized_price')), profit: createBlockCumulativeSumPattern(client, _m(acc, 'realized_profit')), }; } +/** + * @typedef {Object} CentsRatioRawSatsUsdPattern + * @property {SeriesPattern1} cents + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + * @property {SeriesPattern1} sats + * @property {SeriesPattern1} usd + */ + +/** + * Create a CentsRatioRawSatsUsdPattern pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {CentsRatioRawSatsUsdPattern} + */ +function createCentsRatioRawSatsUsdPattern(client, acc) { + return { + cents: createSeriesPattern1(client, _m(acc, 'cents')), + ratio: createSeriesPattern1(client, _m(acc, 'ratio')), + raw: createSeriesPattern1(client, _m(acc, 'ratio_ppm')), + sats: createSeriesPattern1(client, _m(acc, 'sats')), + usd: createSeriesPattern1(client, acc), + }; +} + /** * @typedef {Object} CentsToUsdPattern4 * @property {SeriesPattern1} cents - * @property {BpsPercentRatioPattern2} toMcap - * @property {BpsPercentRatioPattern2} toOwnGrossPnl - * @property {BpsPercentRatioPattern2} toOwnMcap + * @property {PercentRatioRawPattern2} toMcap + * @property {PercentRatioRawPattern2} toOwnGrossPnl + * @property {PercentRatioRawPattern2} toOwnMcap * @property {SeriesPattern1} usd */ @@ -3865,9 +3865,9 @@ function createCapLossMvrvPriceProfitPattern(client, acc) { function createCentsToUsdPattern4(client, acc) { return { cents: createSeriesPattern1(client, _m(acc, 'cents')), - toMcap: createBpsPercentRatioPattern2(client, _m(acc, 'to_mcap')), - toOwnGrossPnl: createBpsPercentRatioPattern2(client, _m(acc, 'to_own_gross_pnl')), - toOwnMcap: createBpsPercentRatioPattern2(client, _m(acc, 'to_own_mcap')), + toMcap: createPercentRatioRawPattern2(client, _m(acc, 'to_mcap')), + toOwnGrossPnl: createPercentRatioRawPattern2(client, _m(acc, 'to_own_gross_pnl')), + toOwnMcap: createPercentRatioRawPattern2(client, _m(acc, 'to_own_mcap')), usd: createSeriesPattern1(client, acc), }; } @@ -3885,7 +3885,7 @@ function createCentsToUsdPattern4(client, acc) { * @typedef {Object} PhsReboundThsPattern * @property {SeriesPattern1} phs * @property {SeriesPattern1} phsMin - * @property {BpsPercentRatioPattern} rebound + * @property {PercentRatioRawPattern} rebound * @property {SeriesPattern1} ths * @property {SeriesPattern1} thsMin */ @@ -3900,58 +3900,12 @@ function createPhsReboundThsPattern(client, acc) { return { phs: createSeriesPattern1(client, _m(acc, 'phs')), phsMin: createSeriesPattern1(client, _m(acc, 'phs_min')), - rebound: createBpsPercentRatioPattern(client, _m(acc, 'rebound')), + rebound: createPercentRatioRawPattern(client, _m(acc, 'rebound')), ths: createSeriesPattern1(client, _m(acc, 'ths')), thsMin: createSeriesPattern1(client, _m(acc, 'ths_min')), }; } -/** - * @typedef {Object} _1m1w1y24hPattern2 - * @property {BpsPercentRatioPattern} _1m - * @property {BpsPercentRatioPattern} _1w - * @property {BpsPercentRatioPattern} _1y - * @property {BpsPercentRatioPattern} _24h - */ - -/** - * Create a _1m1w1y24hPattern2 pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {_1m1w1y24hPattern2} - */ -function create_1m1w1y24hPattern2(client, acc) { - return { - _1m: createBpsPercentRatioPattern(client, _m(acc, '1m_rate')), - _1w: createBpsPercentRatioPattern(client, _m(acc, '1w_rate')), - _1y: createBpsPercentRatioPattern(client, _m(acc, '1y_rate')), - _24h: createBpsPercentRatioPattern(client, _m(acc, '24h_rate')), - }; -} - -/** - * @typedef {Object} _1m1w1y24hPattern8 - * @property {BpsPercentRatioPattern4} _1m - * @property {BpsPercentRatioPattern4} _1w - * @property {BpsPercentRatioPattern4} _1y - * @property {BpsPercentRatioPattern4} _24h - */ - -/** - * Create a _1m1w1y24hPattern8 pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {_1m1w1y24hPattern8} - */ -function create_1m1w1y24hPattern8(client, acc) { - return { - _1m: createBpsPercentRatioPattern4(client, _m(acc, '1m')), - _1w: createBpsPercentRatioPattern4(client, _m(acc, '1w')), - _1y: createBpsPercentRatioPattern4(client, _m(acc, '1y')), - _24h: createBpsPercentRatioPattern4(client, _m(acc, '24h')), - }; -} - /** * @typedef {Object} _1m1w1y24hPattern4 * @property {BtcCentsSatsUsdPattern} _1m @@ -4090,6 +4044,52 @@ function create_1m1w1y24hPattern6(client, acc) { }; } +/** + * @typedef {Object} _1m1w1y24hPattern2 + * @property {PercentRatioRawPattern} _1m + * @property {PercentRatioRawPattern} _1w + * @property {PercentRatioRawPattern} _1y + * @property {PercentRatioRawPattern} _24h + */ + +/** + * Create a _1m1w1y24hPattern2 pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {_1m1w1y24hPattern2} + */ +function create_1m1w1y24hPattern2(client, acc) { + return { + _1m: createPercentRatioRawPattern(client, _m(acc, '1m_rate')), + _1w: createPercentRatioRawPattern(client, _m(acc, '1w_rate')), + _1y: createPercentRatioRawPattern(client, _m(acc, '1y_rate')), + _24h: createPercentRatioRawPattern(client, _m(acc, '24h_rate')), + }; +} + +/** + * @typedef {Object} _1m1w1y24hPattern8 + * @property {PercentRatioRawPattern2} _1m + * @property {PercentRatioRawPattern2} _1w + * @property {PercentRatioRawPattern2} _1y + * @property {PercentRatioRawPattern2} _24h + */ + +/** + * Create a _1m1w1y24hPattern8 pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {_1m1w1y24hPattern8} + */ +function create_1m1w1y24hPattern8(client, acc) { + return { + _1m: createPercentRatioRawPattern2(client, _m(acc, '1m')), + _1w: createPercentRatioRawPattern2(client, _m(acc, '1w')), + _1y: createPercentRatioRawPattern2(client, _m(acc, '1y')), + _24h: createPercentRatioRawPattern2(client, _m(acc, '24h')), + }; +} + /** * @typedef {Object} _1y2y4yAllPattern * @property {_0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdZscorePattern} _1y @@ -4263,7 +4263,7 @@ function createBtcCentsSatsUsdPattern3(client, acc) { * @typedef {Object} CentsDeltaToUsdPattern * @property {SeriesPattern1} cents * @property {AbsoluteRatePattern2} delta - * @property {BpsPercentRatioPattern4} toOwnMcap + * @property {PercentRatioRawPattern2} toOwnMcap * @property {SeriesPattern1} usd */ @@ -4277,7 +4277,7 @@ function createCentsDeltaToUsdPattern(client, acc) { return { cents: createSeriesPattern1(client, _m(acc, 'cents')), delta: createAbsoluteRatePattern2(client, _m(acc, 'delta')), - toOwnMcap: createBpsPercentRatioPattern4(client, _m(acc, 'to_own_mcap')), + toOwnMcap: createPercentRatioRawPattern2(client, _m(acc, 'to_own_mcap')), usd: createSeriesPattern1(client, acc), }; } @@ -4285,8 +4285,8 @@ function createCentsDeltaToUsdPattern(client, acc) { /** * @typedef {Object} CentsToUsdPattern3 * @property {SeriesPattern1} cents - * @property {BpsPercentRatioPattern} toOwnGrossPnl - * @property {BpsPercentRatioPattern} toOwnMcap + * @property {PercentRatioRawPattern3} toOwnGrossPnl + * @property {PercentRatioRawPattern3} toOwnMcap * @property {SeriesPattern1} usd */ @@ -4299,8 +4299,8 @@ function createCentsDeltaToUsdPattern(client, acc) { function createCentsToUsdPattern3(client, acc) { return { cents: createSeriesPattern1(client, _m(acc, 'cents')), - toOwnGrossPnl: createBpsPercentRatioPattern(client, _m(acc, 'to_own_gross_pnl')), - toOwnMcap: createBpsPercentRatioPattern(client, _m(acc, 'to_own_mcap')), + toOwnGrossPnl: createPercentRatioRawPattern3(client, _m(acc, 'to_own_gross_pnl')), + toOwnMcap: createPercentRatioRawPattern3(client, _m(acc, 'to_own_mcap')), usd: createSeriesPattern1(client, acc), }; } @@ -4332,7 +4332,7 @@ function createCoindaysCoinyearsDormancyTransferPattern(client, acc) { * @typedef {Object} LossNetNuplProfitPattern * @property {CentsNegativeUsdPattern} loss * @property {CentsUsdPattern} netPnl - * @property {BpsRatioPattern} nupl + * @property {RatioRawPattern} nupl * @property {CentsUsdPattern3} profit */ @@ -4346,14 +4346,14 @@ function createLossNetNuplProfitPattern(client, acc) { return { loss: createCentsNegativeUsdPattern(client, _m(acc, 'unrealized_loss')), netPnl: createCentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + nupl: createRatioRawPattern(client, _m(acc, 'nupl')), profit: createCentsUsdPattern3(client, _m(acc, 'unrealized_profit')), }; } /** * @typedef {Object} NuplRealizedSupplyUnrealizedPattern - * @property {BpsRatioPattern} nupl + * @property {RatioRawPattern} nupl * @property {AllSthPattern} realizedCap * @property {AllSthPattern2} supply * @property {AllSthPattern} unrealizedPnl @@ -4367,7 +4367,7 @@ function createLossNetNuplProfitPattern(client, acc) { */ function createNuplRealizedSupplyUnrealizedPattern(client, acc) { return { - nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + nupl: createRatioRawPattern(client, _m(acc, 'nupl')), realizedCap: createAllSthPattern(client, acc, 'realized_cap'), supply: createAllSthPattern2(client, acc), unrealizedPnl: createAllSthPattern(client, acc, 'unrealized_pnl'), @@ -4469,7 +4469,7 @@ function createBlockCumulativeSumPattern(client, acc) { /** * @typedef {Object} BlocksDominanceRewardsPattern * @property {AverageBlockCumulativeSumPattern2} blocksMined - * @property {_1m1w1y24hBpsPercentRatioPattern} dominance + * @property {_1m1w1y24hPercentRatioRawPattern} dominance * @property {AverageBlockCumulativeSumPattern3} rewards */ @@ -4482,117 +4482,11 @@ function createBlockCumulativeSumPattern(client, acc) { function createBlocksDominanceRewardsPattern(client, acc) { return { blocksMined: createAverageBlockCumulativeSumPattern2(client, _m(acc, 'blocks_mined')), - dominance: create_1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'dominance')), + dominance: create_1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'dominance')), rewards: createAverageBlockCumulativeSumPattern3(client, _m(acc, 'rewards')), }; } -/** - * @typedef {Object} BpsPercentRatioPattern2 - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} percent - * @property {SeriesPattern1} ratio - */ - -/** - * Create a BpsPercentRatioPattern2 pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsPercentRatioPattern2} - */ -function createBpsPercentRatioPattern2(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'bps')), - percent: createSeriesPattern1(client, acc), - ratio: createSeriesPattern1(client, _m(acc, 'ratio')), - }; -} - -/** - * @typedef {Object} BpsPercentRatioPattern4 - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} percent - * @property {SeriesPattern1} ratio - */ - -/** - * Create a BpsPercentRatioPattern4 pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsPercentRatioPattern4} - */ -function createBpsPercentRatioPattern4(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'bps')), - percent: createSeriesPattern1(client, acc), - ratio: createSeriesPattern1(client, _m(acc, 'ratio')), - }; -} - -/** - * @typedef {Object} BpsPriceRatioPattern - * @property {SeriesPattern1} bps - * @property {CentsSatsUsdPattern} price - * @property {SeriesPattern1} ratio - */ - -/** - * Create a BpsPriceRatioPattern pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @param {string} disc - Discriminator suffix - * @returns {BpsPriceRatioPattern} - */ -function createBpsPriceRatioPattern(client, acc, disc) { - return { - bps: createSeriesPattern1(client, _m(acc, `ratio_${disc}_bps`)), - price: createCentsSatsUsdPattern(client, _m(acc, disc)), - ratio: createSeriesPattern1(client, _m(_m(acc, 'ratio'), disc)), - }; -} - -/** - * @typedef {Object} BpsPercentRatioPattern5 - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} percent - * @property {SeriesPattern1} ratio - */ - -/** - * Create a BpsPercentRatioPattern5 pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsPercentRatioPattern5} - */ -function createBpsPercentRatioPattern5(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'bps')), - percent: createSeriesPattern1(client, acc), - ratio: createSeriesPattern1(client, _m(acc, 'ratio')), - }; -} - -/** - * @typedef {Object} BpsPercentRatioPattern - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} percent - * @property {SeriesPattern1} ratio - */ - -/** - * Create a BpsPercentRatioPattern pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsPercentRatioPattern} - */ -function createBpsPercentRatioPattern(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'bps')), - percent: createSeriesPattern1(client, acc), - ratio: createSeriesPattern1(client, _m(acc, 'ratio')), - }; -} - /** * @typedef {Object} CentsSatsUsdPattern3 * @property {SeriesPattern2} cents @@ -4708,7 +4602,7 @@ function createCumulativeRollingSumPattern(client, acc) { /** * @typedef {Object} DeltaDominanceTotalPattern * @property {AbsoluteRatePattern3} delta - * @property {BpsPercentRatioPattern2} dominance + * @property {PercentRatioRawPattern2} dominance * @property {BtcCentsSatsUsdPattern} total */ @@ -4721,7 +4615,7 @@ function createCumulativeRollingSumPattern(client, acc) { function createDeltaDominanceTotalPattern(client, acc) { return { delta: createAbsoluteRatePattern3(client, _m(acc, 'delta')), - dominance: createBpsPercentRatioPattern2(client, _m(acc, 'dominance')), + dominance: createPercentRatioRawPattern2(client, _m(acc, 'dominance')), total: createBtcCentsSatsUsdPattern(client, acc), }; } @@ -4750,7 +4644,7 @@ function createGreedNetPainPattern(client, acc) { /** * @typedef {Object} LossNuplProfitPattern * @property {CentsNegativeUsdPattern} loss - * @property {BpsRatioPattern} nupl + * @property {RatioRawPattern} nupl * @property {CentsUsdPattern3} profit */ @@ -4763,11 +4657,96 @@ function createGreedNetPainPattern(client, acc) { function createLossNuplProfitPattern(client, acc) { return { loss: createCentsNegativeUsdPattern(client, _m(acc, 'unrealized_loss')), - nupl: createBpsRatioPattern(client, _m(acc, 'nupl')), + nupl: createRatioRawPattern(client, _m(acc, 'nupl')), profit: createCentsUsdPattern3(client, _m(acc, 'unrealized_profit')), }; } +/** + * @typedef {Object} PercentRatioRawPattern2 + * @property {SeriesPattern1} percent + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + */ + +/** + * Create a PercentRatioRawPattern2 pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {PercentRatioRawPattern2} + */ +function createPercentRatioRawPattern2(client, acc) { + return { + percent: createSeriesPattern1(client, acc), + ratio: createSeriesPattern1(client, _m(acc, 'ratio')), + raw: createSeriesPattern1(client, _m(acc, 'ppm')), + }; +} + +/** + * @typedef {Object} PercentRatioRawPattern3 + * @property {SeriesPattern1} percent + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + */ + +/** + * Create a PercentRatioRawPattern3 pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {PercentRatioRawPattern3} + */ +function createPercentRatioRawPattern3(client, acc) { + return { + percent: createSeriesPattern1(client, acc), + ratio: createSeriesPattern1(client, _m(acc, 'ratio')), + raw: createSeriesPattern1(client, _m(acc, 'ppm')), + }; +} + +/** + * @typedef {Object} PercentRatioRawPattern + * @property {SeriesPattern1} percent + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + */ + +/** + * Create a PercentRatioRawPattern pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {PercentRatioRawPattern} + */ +function createPercentRatioRawPattern(client, acc) { + return { + percent: createSeriesPattern1(client, acc), + ratio: createSeriesPattern1(client, _m(acc, 'ratio')), + raw: createSeriesPattern1(client, _m(acc, 'ppm')), + }; +} + +/** + * @typedef {Object} PriceRatioRawPattern + * @property {CentsSatsUsdPattern} price + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + */ + +/** + * Create a PriceRatioRawPattern pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @param {string} disc - Discriminator suffix + * @returns {PriceRatioRawPattern} + */ +function createPriceRatioRawPattern(client, acc, disc) { + return { + price: createCentsSatsUsdPattern(client, _m(acc, disc)), + ratio: createSeriesPattern1(client, _m(_m(acc, 'ratio'), disc)), + raw: createSeriesPattern1(client, _m(acc, `ratio_${disc}_ppm`)), + }; +} + /** * @typedef {Object} RatioTransferValuePattern * @property {_1m1w1y24hPattern} ratio @@ -4791,9 +4770,9 @@ function createRatioTransferValuePattern(client, acc) { /** * @typedef {Object} RsiStochPattern - * @property {BpsPercentRatioPattern2} rsi - * @property {BpsPercentRatioPattern2} stochRsiD - * @property {BpsPercentRatioPattern2} stochRsiK + * @property {PercentRatioRawPattern2} rsi + * @property {PercentRatioRawPattern2} stochRsiD + * @property {PercentRatioRawPattern2} stochRsiK */ /** @@ -4805,9 +4784,9 @@ function createRatioTransferValuePattern(client, acc) { */ function createRsiStochPattern(client, acc, disc) { return { - rsi: createBpsPercentRatioPattern2(client, _m(acc, disc)), - stochRsiD: createBpsPercentRatioPattern2(client, _m(_m(acc, 'stoch_d'), disc)), - stochRsiK: createBpsPercentRatioPattern2(client, _m(_m(acc, 'stoch_k'), disc)), + rsi: createPercentRatioRawPattern2(client, _m(acc, disc)), + stochRsiD: createPercentRatioRawPattern2(client, _m(_m(acc, 'stoch_d'), disc)), + stochRsiK: createPercentRatioRawPattern2(client, _m(_m(acc, 'stoch_k'), disc)), }; } @@ -5030,7 +5009,7 @@ function createBlockCumulativePattern(client, acc) { /** * @typedef {Object} BlocksDominancePattern * @property {AverageBlockCumulativeSumPattern2} blocksMined - * @property {BpsPercentRatioPattern2} dominance + * @property {PercentRatioRawPattern2} dominance */ /** @@ -5042,45 +5021,7 @@ function createBlockCumulativePattern(client, acc) { function createBlocksDominancePattern(client, acc) { return { blocksMined: createAverageBlockCumulativeSumPattern2(client, _m(acc, 'blocks_mined')), - dominance: createBpsPercentRatioPattern2(client, _m(acc, 'dominance')), - }; -} - -/** - * @typedef {Object} BpsRatioPattern2 - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} ratio - */ - -/** - * Create a BpsRatioPattern2 pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsRatioPattern2} - */ -function createBpsRatioPattern2(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'bps')), - ratio: createSeriesPattern1(client, acc), - }; -} - -/** - * @typedef {Object} BpsRatioPattern - * @property {SeriesPattern1} bps - * @property {SeriesPattern1} ratio - */ - -/** - * Create a BpsRatioPattern pattern node - * @param {BrkClient} client - * @param {string} acc - Accumulated series name - * @returns {BpsRatioPattern} - */ -function createBpsRatioPattern(client, acc) { - return { - bps: createSeriesPattern1(client, _m(acc, 'bps')), - ratio: createSeriesPattern1(client, acc), + dominance: createPercentRatioRawPattern2(client, _m(acc, 'dominance')), }; } @@ -5294,6 +5235,63 @@ function createPriceRatioPattern(client, acc, disc) { }; } +/** + * @typedef {Object} RatioRawPattern2 + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + */ + +/** + * Create a RatioRawPattern2 pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {RatioRawPattern2} + */ +function createRatioRawPattern2(client, acc) { + return { + ratio: createSeriesPattern1(client, acc), + raw: createSeriesPattern1(client, _m(acc, 'ppm')), + }; +} + +/** + * @typedef {Object} RatioRawPattern3 + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + */ + +/** + * Create a RatioRawPattern3 pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {RatioRawPattern3} + */ +function createRatioRawPattern3(client, acc) { + return { + ratio: createSeriesPattern1(client, acc), + raw: createSeriesPattern1(client, _m(acc, 'ppm')), + }; +} + +/** + * @typedef {Object} RatioRawPattern + * @property {SeriesPattern1} ratio + * @property {SeriesPattern1} raw + */ + +/** + * Create a RatioRawPattern pattern node + * @param {BrkClient} client + * @param {string} acc - Accumulated series name + * @returns {RatioRawPattern} + */ +function createRatioRawPattern(client, acc) { + return { + ratio: createSeriesPattern1(client, acc), + raw: createSeriesPattern1(client, _m(acc, 'ppm')), + }; +} + /** * @typedef {Object} RatioValuePattern2 * @property {_1m1w1y24hPattern} ratio @@ -5340,8 +5338,8 @@ function createRatioValuePattern(client, acc) { /** * @typedef {Object} ToPattern - * @property {BpsPercentRatioPattern} toMcap - * @property {BpsPercentRatioPattern} toRcap + * @property {PercentRatioRawPattern} toMcap + * @property {PercentRatioRawPattern} toRcap */ /** @@ -5352,8 +5350,8 @@ function createRatioValuePattern(client, acc) { */ function createToPattern(client, acc) { return { - toMcap: createBpsPercentRatioPattern(client, _m(acc, 'mcap')), - toRcap: createBpsPercentRatioPattern(client, _m(acc, 'rcap')), + toMcap: createPercentRatioRawPattern(client, _m(acc, 'mcap')), + toRcap: createPercentRatioRawPattern(client, _m(acc, 'rcap')), }; } @@ -5376,7 +5374,7 @@ function create_24hPattern(client, acc) { /** * @typedef {Object} NuplPattern - * @property {BpsRatioPattern} nupl + * @property {RatioRawPattern} nupl */ /** @@ -5387,13 +5385,13 @@ function create_24hPattern(client, acc) { */ function createNuplPattern(client, acc) { return { - nupl: createBpsRatioPattern(client, acc), + nupl: createRatioRawPattern(client, acc), }; } /** * @typedef {Object} PricePattern - * @property {BpsCentsPercentilesRatioSatsUsdPattern} price + * @property {CentsPercentilesRatioRawSatsUsdPattern} price */ /** @@ -5404,13 +5402,13 @@ function createNuplPattern(client, acc) { */ function createPricePattern(client, acc) { return { - price: createBpsCentsPercentilesRatioSatsUsdPattern(client, acc), + price: createCentsPercentilesRatioRawSatsUsdPattern(client, acc), }; } /** * @typedef {Object} SharePattern - * @property {BpsPercentRatioPattern2} share + * @property {PercentRatioRawPattern2} share */ /** @@ -5421,7 +5419,7 @@ function createPricePattern(client, acc) { */ function createSharePattern(client, acc) { return { - share: createBpsPercentRatioPattern2(client, acc), + share: createPercentRatioRawPattern2(client, acc), }; } @@ -5489,7 +5487,7 @@ function createTransferPattern(client, acc) { * @typedef {Object} SeriesTree_Blocks_Difficulty * @property {SeriesPattern1} value * @property {SeriesPattern1} hashrate - * @property {BpsPercentRatioPattern} adjustment + * @property {PercentRatioRawPattern3} adjustment * @property {SeriesPattern1} epoch * @property {SeriesPattern1} blocksToRetarget * @property {SeriesPattern1} daysToRetarget @@ -5579,7 +5577,7 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Blocks_Fullness - * @property {SeriesPattern18} bps + * @property {SeriesPattern18} raw * @property {SeriesPattern18} ratio * @property {SeriesPattern18} percent */ @@ -5803,17 +5801,17 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Inputs_ByType_InputShare - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk65 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk33 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2ms - * @property {_1m1w1y24hBpsPercentRatioPattern} p2sh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wpkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wsh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2tr - * @property {_1m1w1y24hBpsPercentRatioPattern} p2a - * @property {_1m1w1y24hBpsPercentRatioPattern} unknown - * @property {_1m1w1y24hBpsPercentRatioPattern} empty + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk65 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk33 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2ms + * @property {_1m1w1y24hPercentRatioRawPattern} p2sh + * @property {_1m1w1y24hPercentRatioRawPattern} p2wpkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2wsh + * @property {_1m1w1y24hPercentRatioRawPattern} p2tr + * @property {_1m1w1y24hPercentRatioRawPattern} p2a + * @property {_1m1w1y24hPercentRatioRawPattern} unknown + * @property {_1m1w1y24hPercentRatioRawPattern} empty */ /** @@ -5895,18 +5893,18 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Outputs_ByType_OutputShare - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk65 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pk33 - * @property {_1m1w1y24hBpsPercentRatioPattern} p2pkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2ms - * @property {_1m1w1y24hBpsPercentRatioPattern} p2sh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wpkh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2wsh - * @property {_1m1w1y24hBpsPercentRatioPattern} p2tr - * @property {_1m1w1y24hBpsPercentRatioPattern} p2a - * @property {_1m1w1y24hBpsPercentRatioPattern} unknown - * @property {_1m1w1y24hBpsPercentRatioPattern} empty - * @property {_1m1w1y24hBpsPercentRatioPattern} opReturn + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk65 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pk33 + * @property {_1m1w1y24hPercentRatioRawPattern} p2pkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2ms + * @property {_1m1w1y24hPercentRatioRawPattern} p2sh + * @property {_1m1w1y24hPercentRatioRawPattern} p2wpkh + * @property {_1m1w1y24hPercentRatioRawPattern} p2wsh + * @property {_1m1w1y24hPercentRatioRawPattern} p2tr + * @property {_1m1w1y24hPercentRatioRawPattern} p2a + * @property {_1m1w1y24hPercentRatioRawPattern} unknown + * @property {_1m1w1y24hPercentRatioRawPattern} empty + * @property {_1m1w1y24hPercentRatioRawPattern} opReturn */ /** @@ -6044,7 +6042,7 @@ function createTransferPattern(client, acc) { * @typedef {Object} SeriesTree_Addrs_Reused_Events * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6} outputToReusedAddrCount * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7} outputToReusedAddrShare - * @property {_1m1w1y24hBpsPercentRatioPattern} spendableOutputToReusedAddrShare + * @property {_1m1w1y24hPercentRatioRawPattern} spendableOutputToReusedAddrShare * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6} inputFromReusedAddrCount * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7} inputFromReusedAddrShare * @property {_1m1w1y24hBlockPattern} activeReusedAddrCount @@ -6076,7 +6074,7 @@ function createTransferPattern(client, acc) { * @typedef {Object} SeriesTree_Addrs_Respent_Events * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6} outputToReusedAddrCount * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7} outputToReusedAddrShare - * @property {_1m1w1y24hBpsPercentRatioPattern} spendableOutputToReusedAddrShare + * @property {_1m1w1y24hPercentRatioRawPattern} spendableOutputToReusedAddrShare * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6} inputFromReusedAddrCount * @property {AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7} inputFromReusedAddrShare * @property {_1m1w1y24hBlockPattern} activeReusedAddrCount @@ -6196,7 +6194,7 @@ function createTransferPattern(client, acc) { * @property {AverageBlockCumulativeSumPattern} dataBytes * @property {AverageBlockCumulativeSumPattern} txCount * @property {AverageBlockCumulativeSumPattern} txVsize - * @property {BpsPercentRatioPattern2} chainShare + * @property {PercentRatioRawPattern2} chainShare */ /** @@ -6255,7 +6253,7 @@ function createTransferPattern(client, acc) { * @property {BtcCentsSatsUsdPattern} cumulative * @property {_1m1w1y24hPattern4} sum * @property {_1m1w1y24hPattern3} average - * @property {_1m1w1y24hBpsPercentRatioPattern} dominance + * @property {_1m1w1y24hPercentRatioRawPattern} dominance */ /** @@ -6271,16 +6269,16 @@ function createTransferPattern(client, acc) { * @property {_1m1w1y24hPattern4} median * @property {_1m1w1y24hPattern4} pct75 * @property {_1m1w1y24hPattern4} pct90 - * @property {_1m1w1y24hBpsPercentRatioPattern} dominance + * @property {_1m1w1y24hPercentRatioRawPattern} dominance * @property {SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio} toSubsidyRatio */ /** * @typedef {Object} SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio - * @property {BpsRatioPattern2} _24h - * @property {BpsRatioPattern2} _1w - * @property {BpsRatioPattern2} _1m - * @property {BpsRatioPattern2} _1y + * @property {RatioRawPattern3} _24h + * @property {RatioRawPattern3} _1w + * @property {RatioRawPattern3} _1m + * @property {RatioRawPattern3} _1y */ /** @@ -6295,7 +6293,7 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} base * @property {SeriesTree_Mining_Hashrate_Rate_Sma} sma * @property {SeriesPattern1} ath - * @property {BpsPercentRatioPattern5} drawdown + * @property {PercentRatioRawPattern3} drawdown */ /** @@ -6348,20 +6346,20 @@ function createTransferPattern(client, acc) { * @property {CentsUsdPattern3} vaulted * @property {CentsUsdPattern3} active * @property {CentsUsdPattern3} cointime - * @property {BpsRatioPattern2} aviv + * @property {RatioRawPattern2} aviv */ /** * @typedef {Object} SeriesTree_Cointime_Prices - * @property {BpsCentsPercentilesRatioSatsUsdPattern} vaulted - * @property {BpsCentsPercentilesRatioSatsUsdPattern} active - * @property {BpsCentsPercentilesRatioSatsUsdPattern} trueMarketMean - * @property {BpsCentsPercentilesRatioSatsUsdPattern} cointime + * @property {CentsPercentilesRatioRawSatsUsdPattern} vaulted + * @property {CentsPercentilesRatioRawSatsUsdPattern} active + * @property {CentsPercentilesRatioRawSatsUsdPattern} trueMarketMean + * @property {CentsPercentilesRatioRawSatsUsdPattern} cointime */ /** * @typedef {Object} SeriesTree_Cointime_Adjusted - * @property {BpsPercentRatioPattern} inflationRate + * @property {PercentRatioRawPattern} inflationRate * @property {SeriesPattern1} txVelocityNative * @property {SeriesPattern1} txVelocityFiat */ @@ -6632,11 +6630,11 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Indicators - * @property {BpsRatioPattern2} puellMultiple - * @property {BpsRatioPattern2} nvt - * @property {BpsPercentRatioPattern2} gini - * @property {BpsRatioPattern2} rhodlRatio - * @property {BpsRatioPattern2} thermoCapMultiple + * @property {RatioRawPattern3} puellMultiple + * @property {RatioRawPattern3} nvt + * @property {PercentRatioRawPattern2} gini + * @property {RatioRawPattern3} rhodlRatio + * @property {RatioRawPattern3} thermoCapMultiple * @property {SeriesPattern1} coindaysDestroyedSupplyAdj * @property {SeriesPattern1} coinyearsDestroyedSupplyAdj * @property {SeriesTree_Indicators_Dormancy} dormancy @@ -6732,18 +6730,18 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Investing_Class_DcaReturn - * @property {BpsPercentRatioPattern} from2015 - * @property {BpsPercentRatioPattern} from2016 - * @property {BpsPercentRatioPattern} from2017 - * @property {BpsPercentRatioPattern} from2018 - * @property {BpsPercentRatioPattern} from2019 - * @property {BpsPercentRatioPattern} from2020 - * @property {BpsPercentRatioPattern} from2021 - * @property {BpsPercentRatioPattern} from2022 - * @property {BpsPercentRatioPattern} from2023 - * @property {BpsPercentRatioPattern} from2024 - * @property {BpsPercentRatioPattern} from2025 - * @property {BpsPercentRatioPattern} from2026 + * @property {PercentRatioRawPattern} from2015 + * @property {PercentRatioRawPattern} from2016 + * @property {PercentRatioRawPattern} from2017 + * @property {PercentRatioRawPattern} from2018 + * @property {PercentRatioRawPattern} from2019 + * @property {PercentRatioRawPattern} from2020 + * @property {PercentRatioRawPattern} from2021 + * @property {PercentRatioRawPattern} from2022 + * @property {PercentRatioRawPattern} from2023 + * @property {PercentRatioRawPattern} from2024 + * @property {PercentRatioRawPattern} from2025 + * @property {PercentRatioRawPattern} from2026 */ /** @@ -6760,7 +6758,7 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Market_Ath * @property {CentsSatsUsdPattern} high - * @property {BpsPercentRatioPattern5} drawdown + * @property {PercentRatioRawPattern3} drawdown * @property {SeriesPattern1} daysSince * @property {SeriesPattern1} yearsSince * @property {SeriesPattern1} maxDaysBetween @@ -6793,19 +6791,19 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Market_Returns_Periods - * @property {BpsPercentRatioPattern} _24h - * @property {BpsPercentRatioPattern} _1w - * @property {BpsPercentRatioPattern} _1m - * @property {BpsPercentRatioPattern} _3m - * @property {BpsPercentRatioPattern} _6m - * @property {BpsPercentRatioPattern} _1y - * @property {BpsPercentRatioPattern} _2y - * @property {BpsPercentRatioPattern} _3y - * @property {BpsPercentRatioPattern} _4y - * @property {BpsPercentRatioPattern} _5y - * @property {BpsPercentRatioPattern} _6y - * @property {BpsPercentRatioPattern} _8y - * @property {BpsPercentRatioPattern} _10y + * @property {PercentRatioRawPattern} _24h + * @property {PercentRatioRawPattern} _1w + * @property {PercentRatioRawPattern} _1m + * @property {PercentRatioRawPattern} _3m + * @property {PercentRatioRawPattern} _6m + * @property {PercentRatioRawPattern} _1y + * @property {PercentRatioRawPattern} _2y + * @property {PercentRatioRawPattern} _3y + * @property {PercentRatioRawPattern} _4y + * @property {PercentRatioRawPattern} _5y + * @property {PercentRatioRawPattern} _6y + * @property {PercentRatioRawPattern} _8y + * @property {PercentRatioRawPattern} _10y */ /** @@ -6846,7 +6844,7 @@ function createTransferPattern(client, acc) { * @property {_1m1w1y2wPattern} max * @property {SeriesPattern1} trueRange * @property {SeriesPattern1} trueRangeSum2w - * @property {BpsPercentRatioPattern2} choppinessIndex2w + * @property {PercentRatioRawPattern2} choppinessIndex2w */ /** @@ -6857,22 +6855,22 @@ function createTransferPattern(client, acc) { /** * @typedef {Object} SeriesTree_Market_MovingAverage_Sma - * @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 {CentsRatioRawSatsUsdPattern} _1w + * @property {CentsRatioRawSatsUsdPattern} _8d + * @property {CentsRatioRawSatsUsdPattern} _13d + * @property {CentsRatioRawSatsUsdPattern} _21d + * @property {CentsRatioRawSatsUsdPattern} _1m + * @property {CentsRatioRawSatsUsdPattern} _34d + * @property {CentsRatioRawSatsUsdPattern} _55d + * @property {CentsRatioRawSatsUsdPattern} _89d + * @property {CentsRatioRawSatsUsdPattern} _111d + * @property {CentsRatioRawSatsUsdPattern} _144d * @property {SeriesTree_Market_MovingAverage_Sma_200d} _200d * @property {SeriesTree_Market_MovingAverage_Sma_350d} _350d - * @property {BpsCentsRatioSatsUsdPattern} _1y - * @property {BpsCentsRatioSatsUsdPattern} _2y - * @property {BpsCentsRatioSatsUsdPattern} _200w - * @property {BpsCentsRatioSatsUsdPattern} _4y + * @property {CentsRatioRawSatsUsdPattern} _1y + * @property {CentsRatioRawSatsUsdPattern} _2y + * @property {CentsRatioRawSatsUsdPattern} _200w + * @property {CentsRatioRawSatsUsdPattern} _4y */ /** @@ -6880,7 +6878,7 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {SeriesPattern1} bps + * @property {SeriesPattern1} raw * @property {SeriesPattern1} ratio * @property {CentsSatsUsdPattern} x24 * @property {CentsSatsUsdPattern} x08 @@ -6891,35 +6889,35 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {SeriesPattern1} bps + * @property {SeriesPattern1} raw * @property {SeriesPattern1} ratio * @property {CentsSatsUsdPattern} x2 */ /** * @typedef {Object} SeriesTree_Market_MovingAverage_Ema - * @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 + * @property {CentsRatioRawSatsUsdPattern} _1w + * @property {CentsRatioRawSatsUsdPattern} _8d + * @property {CentsRatioRawSatsUsdPattern} _12d + * @property {CentsRatioRawSatsUsdPattern} _13d + * @property {CentsRatioRawSatsUsdPattern} _21d + * @property {CentsRatioRawSatsUsdPattern} _26d + * @property {CentsRatioRawSatsUsdPattern} _1m + * @property {CentsRatioRawSatsUsdPattern} _34d + * @property {CentsRatioRawSatsUsdPattern} _55d + * @property {CentsRatioRawSatsUsdPattern} _89d + * @property {CentsRatioRawSatsUsdPattern} _144d + * @property {CentsRatioRawSatsUsdPattern} _200d + * @property {CentsRatioRawSatsUsdPattern} _1y + * @property {CentsRatioRawSatsUsdPattern} _2y + * @property {CentsRatioRawSatsUsdPattern} _200w + * @property {CentsRatioRawSatsUsdPattern} _4y */ /** * @typedef {Object} SeriesTree_Market_Technical * @property {SeriesTree_Market_Technical_Rsi} rsi - * @property {BpsRatioPattern2} piCycle + * @property {RatioRawPattern2} piCycle * @property {SeriesTree_Market_Technical_Macd} macd */ @@ -7178,10 +7176,10 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern18} state * @property {BtcCentsSatsUsdPattern} circulating * @property {BlockCumulativePattern} burned - * @property {BpsPercentRatioPattern} inflationRate + * @property {PercentRatioRawPattern} inflationRate * @property {SeriesTree_Supply_Velocity} velocity * @property {CentsDeltaUsdPattern} marketCap - * @property {_1m1w1y24hPattern} marketMinusRealizedCapGrowthRate + * @property {_1m1w1y24hPattern} marketMinusRealizedCapGrowthRate * @property {BtcCentsSatsUsdPattern} hodledOrLost */ @@ -7263,7 +7261,7 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {SeriesPattern1} bps + * @property {SeriesPattern1} raw * @property {SeriesPattern1} ratio * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles * @property {_1m1w1y2y4yAllPattern} sma @@ -7376,12 +7374,12 @@ function createTransferPattern(client, acc) { * @property {CentsSatsUsdPattern} max * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} perCoin * @property {Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern} perDollar - * @property {BpsPercentRatioPattern2} supplyDensity + * @property {PercentRatioRawPattern2} supplyDensity */ /** * @typedef {Object} SeriesTree_Cohorts_Utxo_All_Unrealized - * @property {BpsRatioPattern} nupl + * @property {RatioRawPattern} nupl * @property {SeriesTree_Cohorts_Utxo_All_Unrealized_Profit} profit * @property {SeriesTree_Cohorts_Utxo_All_Unrealized_Loss} loss * @property {SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl} netPnl @@ -7396,8 +7394,8 @@ function createTransferPattern(client, acc) { * @typedef {Object} SeriesTree_Cohorts_Utxo_All_Unrealized_Profit * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents - * @property {BpsPercentRatioPattern2} toMcap - * @property {BpsPercentRatioPattern2} toOwnGrossPnl + * @property {PercentRatioRawPattern2} toMcap + * @property {PercentRatioRawPattern2} toOwnGrossPnl */ /** @@ -7405,15 +7403,15 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} negative - * @property {BpsPercentRatioPattern2} toMcap - * @property {BpsPercentRatioPattern2} toOwnGrossPnl + * @property {PercentRatioRawPattern2} toMcap + * @property {PercentRatioRawPattern2} toOwnGrossPnl */ /** * @typedef {Object} SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents - * @property {BpsPercentRatioPattern} toOwnGrossPnl + * @property {PercentRatioRawPattern3} toOwnGrossPnl */ /** @@ -7455,7 +7453,7 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {SeriesPattern1} bps + * @property {SeriesPattern1} raw * @property {SeriesPattern1} ratio * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles * @property {_1m1w1y2y4yAllPattern} sma @@ -7578,7 +7576,7 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {SeriesPattern1} bps + * @property {SeriesPattern1} raw * @property {SeriesPattern1} ratio * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles * @property {_1m1w1y2y4yAllPattern} sma @@ -7807,7 +7805,7 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {SeriesPattern1} bps + * @property {SeriesPattern1} raw * @property {SeriesPattern1} ratio * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles * @property {_1m1w1y2y4yAllPattern} sma @@ -7930,7 +7928,7 @@ function createTransferPattern(client, acc) { * @property {SeriesPattern1} usd * @property {SeriesPattern1} cents * @property {SeriesPattern1} sats - * @property {SeriesPattern1} bps + * @property {SeriesPattern1} raw * @property {SeriesPattern1} ratio * @property {Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern} percentiles * @property {_1m1w1y2y4yAllPattern} sma @@ -9480,7 +9478,7 @@ class BrkClient extends BrkClientBase { difficulty: { value: createSeriesPattern1(this, 'difficulty'), hashrate: createSeriesPattern1(this, 'difficulty_hashrate'), - adjustment: createBpsPercentRatioPattern(this, 'difficulty_adjustment'), + adjustment: createPercentRatioRawPattern3(this, 'difficulty_adjustment'), epoch: createSeriesPattern1(this, 'difficulty_epoch'), blocksToRetarget: createSeriesPattern1(this, 'blocks_to_retarget'), daysToRetarget: createSeriesPattern1(this, 'days_to_retarget'), @@ -9563,7 +9561,7 @@ class BrkClient extends BrkClientBase { }, vbytes: createAverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern(this, 'block_vbytes'), fullness: { - bps: createSeriesPattern18(this, 'block_fullness_bps'), + raw: createSeriesPattern18(this, 'block_fullness_ppm'), ratio: createSeriesPattern18(this, 'block_fullness_ratio'), percent: createSeriesPattern18(this, 'block_fullness'), }, @@ -9721,17 +9719,17 @@ class BrkClient extends BrkClientBase { empty: createAverageBlockCumulativeSumPattern(this, 'empty_outputs_prevout_count'), }, inputShare: { - p2pk65: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2pk65_prevout_share'), - p2pk33: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2pk33_prevout_share'), - p2pkh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2pkh_prevout_share'), - p2ms: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2ms_prevout_share'), - p2sh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2sh_prevout_share'), - p2wpkh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2wpkh_prevout_share'), - p2wsh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2wsh_prevout_share'), - p2tr: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2tr_prevout_share'), - p2a: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2a_prevout_share'), - unknown: create_1m1w1y24hBpsPercentRatioPattern(this, 'unknown_outputs_prevout_share'), - empty: create_1m1w1y24hBpsPercentRatioPattern(this, 'empty_outputs_prevout_share'), + p2pk65: create_1m1w1y24hPercentRatioRawPattern(this, 'p2pk65_prevout_share'), + p2pk33: create_1m1w1y24hPercentRatioRawPattern(this, 'p2pk33_prevout_share'), + p2pkh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2pkh_prevout_share'), + p2ms: create_1m1w1y24hPercentRatioRawPattern(this, 'p2ms_prevout_share'), + p2sh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2sh_prevout_share'), + p2wpkh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2wpkh_prevout_share'), + p2wsh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2wsh_prevout_share'), + p2tr: create_1m1w1y24hPercentRatioRawPattern(this, 'p2tr_prevout_share'), + p2a: create_1m1w1y24hPercentRatioRawPattern(this, 'p2a_prevout_share'), + unknown: create_1m1w1y24hPercentRatioRawPattern(this, 'unknown_outputs_prevout_share'), + empty: create_1m1w1y24hPercentRatioRawPattern(this, 'empty_outputs_prevout_share'), }, txCount: { all: createAverageBlockCumulativeSumPattern(this, 'non_coinbase_tx_count'), @@ -9786,18 +9784,18 @@ class BrkClient extends BrkClientBase { }, spendableOutputCount: createAverageBlockCumulativeSumPattern(this, 'spendable_output_count'), outputShare: { - p2pk65: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2pk65_output_share'), - p2pk33: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2pk33_output_share'), - p2pkh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2pkh_output_share'), - p2ms: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2ms_output_share'), - p2sh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2sh_output_share'), - p2wpkh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2wpkh_output_share'), - p2wsh: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2wsh_output_share'), - p2tr: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2tr_output_share'), - p2a: create_1m1w1y24hBpsPercentRatioPattern(this, 'p2a_output_share'), - unknown: create_1m1w1y24hBpsPercentRatioPattern(this, 'unknown_outputs_output_share'), - empty: create_1m1w1y24hBpsPercentRatioPattern(this, 'empty_outputs_output_share'), - opReturn: create_1m1w1y24hBpsPercentRatioPattern(this, 'op_return_output_share'), + p2pk65: create_1m1w1y24hPercentRatioRawPattern(this, 'p2pk65_output_share'), + p2pk33: create_1m1w1y24hPercentRatioRawPattern(this, 'p2pk33_output_share'), + p2pkh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2pkh_output_share'), + p2ms: create_1m1w1y24hPercentRatioRawPattern(this, 'p2ms_output_share'), + p2sh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2sh_output_share'), + p2wpkh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2wpkh_output_share'), + p2wsh: create_1m1w1y24hPercentRatioRawPattern(this, 'p2wsh_output_share'), + p2tr: create_1m1w1y24hPercentRatioRawPattern(this, 'p2tr_output_share'), + p2a: create_1m1w1y24hPercentRatioRawPattern(this, 'p2a_output_share'), + unknown: create_1m1w1y24hPercentRatioRawPattern(this, 'unknown_outputs_output_share'), + empty: create_1m1w1y24hPercentRatioRawPattern(this, 'empty_outputs_output_share'), + opReturn: create_1m1w1y24hPercentRatioRawPattern(this, 'op_return_output_share'), }, txCount: createAllEmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern(this, 'tx_count'), txShare: createEmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2(this, 'tx_share_with'), @@ -9883,7 +9881,7 @@ class BrkClient extends BrkClientBase { events: { outputToReusedAddrCount: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(this, 'output_to_reused_addr_count'), outputToReusedAddrShare: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(this, 'output_to_reused_addr_share'), - spendableOutputToReusedAddrShare: create_1m1w1y24hBpsPercentRatioPattern(this, 'spendable_output_to_reused_addr_share'), + spendableOutputToReusedAddrShare: create_1m1w1y24hPercentRatioRawPattern(this, 'spendable_output_to_reused_addr_share'), inputFromReusedAddrCount: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(this, 'input_from_reused_addr_count'), inputFromReusedAddrShare: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(this, 'input_from_reused_addr_share'), activeReusedAddrCount: create_1m1w1y24hBlockPattern(this, 'active_reused_addr_count'), @@ -9907,7 +9905,7 @@ class BrkClient extends BrkClientBase { events: { outputToReusedAddrCount: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(this, 'output_to_respent_addr_count'), outputToReusedAddrShare: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(this, 'output_to_respent_addr_share'), - spendableOutputToReusedAddrShare: create_1m1w1y24hBpsPercentRatioPattern(this, 'spendable_output_to_respent_addr_share'), + spendableOutputToReusedAddrShare: create_1m1w1y24hPercentRatioRawPattern(this, 'spendable_output_to_respent_addr_share'), inputFromReusedAddrCount: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(this, 'input_from_respent_addr_count'), inputFromReusedAddrShare: createAllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(this, 'input_from_respent_addr_share'), activeReusedAddrCount: create_1m1w1y24hBlockPattern(this, 'active_respent_addr_count'), @@ -9993,7 +9991,7 @@ class BrkClient extends BrkClientBase { dataBytes: createAverageBlockCumulativeSumPattern(this, 'op_return_data_bytes'), txCount: createAverageBlockCumulativeSumPattern(this, 'op_return_tx_count'), txVsize: createAverageBlockCumulativeSumPattern(this, 'op_return_tx_vsize'), - chainShare: createBpsPercentRatioPattern2(this, 'op_return_chain_share'), + chainShare: createPercentRatioRawPattern2(this, 'op_return_chain_share'), }, byKind: { runes: createChainDataOutputTxPattern(this, 'op_return_runes'), @@ -10035,7 +10033,7 @@ class BrkClient extends BrkClientBase { cumulative: createBtcCentsSatsUsdPattern(this, 'subsidy_cumulative'), sum: create_1m1w1y24hPattern4(this, 'subsidy_sum'), average: create_1m1w1y24hPattern3(this, 'subsidy_average'), - dominance: create_1m1w1y24hBpsPercentRatioPattern(this, 'subsidy_dominance'), + dominance: create_1m1w1y24hPercentRatioRawPattern(this, 'subsidy_dominance'), }, fees: { block: createBtcCentsSatsUsdPattern3(this, 'fees'), @@ -10049,12 +10047,12 @@ class BrkClient extends BrkClientBase { median: create_1m1w1y24hPattern4(this, 'fees_median'), pct75: create_1m1w1y24hPattern4(this, 'fees_pct75'), pct90: create_1m1w1y24hPattern4(this, 'fees_pct90'), - dominance: create_1m1w1y24hBpsPercentRatioPattern(this, 'fee_dominance'), + dominance: create_1m1w1y24hPercentRatioRawPattern(this, 'fee_dominance'), toSubsidyRatio: { - _24h: createBpsRatioPattern2(this, 'fee_to_subsidy_ratio_24h'), - _1w: createBpsRatioPattern2(this, 'fee_to_subsidy_ratio_1w'), - _1m: createBpsRatioPattern2(this, 'fee_to_subsidy_ratio_1m'), - _1y: createBpsRatioPattern2(this, 'fee_to_subsidy_ratio_1y'), + _24h: createRatioRawPattern3(this, 'fee_to_subsidy_ratio_24h'), + _1w: createRatioRawPattern3(this, 'fee_to_subsidy_ratio_1w'), + _1m: createRatioRawPattern3(this, 'fee_to_subsidy_ratio_1m'), + _1y: createRatioRawPattern3(this, 'fee_to_subsidy_ratio_1y'), }, }, outputVolume: createSeriesPattern18(this, 'output_volume'), @@ -10070,7 +10068,7 @@ class BrkClient extends BrkClientBase { _1y: createSeriesPattern1(this, 'hash_rate_sma_1y'), }, ath: createSeriesPattern1(this, 'hash_rate_ath'), - drawdown: createBpsPercentRatioPattern5(this, 'hash_rate_drawdown'), + drawdown: createPercentRatioRawPattern3(this, 'hash_rate_drawdown'), }, price: createPhsReboundThsPattern(this, 'hash_price'), value: createPhsReboundThsPattern(this, 'hash_value'), @@ -10101,16 +10099,16 @@ class BrkClient extends BrkClientBase { vaulted: createCentsUsdPattern3(this, 'vaulted_cap'), active: createCentsUsdPattern3(this, 'active_cap'), cointime: createCentsUsdPattern3(this, 'cointime_cap'), - aviv: createBpsRatioPattern2(this, 'aviv_ratio'), + aviv: createRatioRawPattern2(this, 'aviv_ratio'), }, prices: { - vaulted: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'vaulted_price'), - active: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'active_price'), - trueMarketMean: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'true_market_mean'), - cointime: createBpsCentsPercentilesRatioSatsUsdPattern(this, 'cointime_price'), + vaulted: createCentsPercentilesRatioRawSatsUsdPattern(this, 'vaulted_price'), + active: createCentsPercentilesRatioRawSatsUsdPattern(this, 'active_price'), + trueMarketMean: createCentsPercentilesRatioRawSatsUsdPattern(this, 'true_market_mean'), + cointime: createCentsPercentilesRatioRawSatsUsdPattern(this, 'cointime_price'), }, adjusted: { - inflationRate: createBpsPercentRatioPattern(this, 'cointime_adj_inflation_rate'), + inflationRate: createPercentRatioRawPattern(this, 'cointime_adj_inflation_rate'), txVelocityNative: createSeriesPattern1(this, 'cointime_adj_tx_velocity_btc'), txVelocityFiat: createSeriesPattern1(this, 'cointime_adj_tx_velocity_usd'), }, @@ -10275,11 +10273,11 @@ class BrkClient extends BrkClientBase { }, }, indicators: { - puellMultiple: createBpsRatioPattern2(this, 'puell_multiple'), - nvt: createBpsRatioPattern2(this, 'nvt'), - gini: createBpsPercentRatioPattern2(this, 'gini'), - rhodlRatio: createBpsRatioPattern2(this, 'rhodl_ratio'), - thermoCapMultiple: createBpsRatioPattern2(this, 'thermo_cap_multiple'), + puellMultiple: createRatioRawPattern3(this, 'puell_multiple'), + nvt: createRatioRawPattern3(this, 'nvt'), + gini: createPercentRatioRawPattern2(this, 'gini'), + rhodlRatio: createRatioRawPattern3(this, 'rhodl_ratio'), + thermoCapMultiple: createRatioRawPattern3(this, 'thermo_cap_multiple'), coindaysDestroyedSupplyAdj: createSeriesPattern1(this, 'coindays_destroyed_supply_adj'), coinyearsDestroyedSupplyAdj: createSeriesPattern1(this, 'coinyears_destroyed_supply_adj'), dormancy: { @@ -10347,25 +10345,25 @@ class BrkClient extends BrkClientBase { from2026: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2026'), }, dcaReturn: { - from2015: createBpsPercentRatioPattern(this, 'dca_return_from_2015'), - from2016: createBpsPercentRatioPattern(this, 'dca_return_from_2016'), - from2017: createBpsPercentRatioPattern(this, 'dca_return_from_2017'), - from2018: createBpsPercentRatioPattern(this, 'dca_return_from_2018'), - from2019: createBpsPercentRatioPattern(this, 'dca_return_from_2019'), - from2020: createBpsPercentRatioPattern(this, 'dca_return_from_2020'), - from2021: createBpsPercentRatioPattern(this, 'dca_return_from_2021'), - from2022: createBpsPercentRatioPattern(this, 'dca_return_from_2022'), - from2023: createBpsPercentRatioPattern(this, 'dca_return_from_2023'), - from2024: createBpsPercentRatioPattern(this, 'dca_return_from_2024'), - from2025: createBpsPercentRatioPattern(this, 'dca_return_from_2025'), - from2026: createBpsPercentRatioPattern(this, 'dca_return_from_2026'), + from2015: createPercentRatioRawPattern(this, 'dca_return_from_2015'), + from2016: createPercentRatioRawPattern(this, 'dca_return_from_2016'), + from2017: createPercentRatioRawPattern(this, 'dca_return_from_2017'), + from2018: createPercentRatioRawPattern(this, 'dca_return_from_2018'), + from2019: createPercentRatioRawPattern(this, 'dca_return_from_2019'), + from2020: createPercentRatioRawPattern(this, 'dca_return_from_2020'), + from2021: createPercentRatioRawPattern(this, 'dca_return_from_2021'), + from2022: createPercentRatioRawPattern(this, 'dca_return_from_2022'), + from2023: createPercentRatioRawPattern(this, 'dca_return_from_2023'), + from2024: createPercentRatioRawPattern(this, 'dca_return_from_2024'), + from2025: createPercentRatioRawPattern(this, 'dca_return_from_2025'), + from2026: createPercentRatioRawPattern(this, 'dca_return_from_2026'), }, }, }, market: { ath: { high: createCentsSatsUsdPattern(this, 'price_ath'), - drawdown: createBpsPercentRatioPattern5(this, 'price_drawdown'), + drawdown: createPercentRatioRawPattern3(this, 'price_drawdown'), daysSince: createSeriesPattern1(this, 'days_since_price_ath'), yearsSince: createSeriesPattern1(this, 'years_since_price_ath'), maxDaysBetween: createSeriesPattern1(this, 'max_days_between_price_ath'), @@ -10388,19 +10386,19 @@ class BrkClient extends BrkClientBase { }, returns: { periods: { - _24h: createBpsPercentRatioPattern(this, 'price_return_24h'), - _1w: createBpsPercentRatioPattern(this, 'price_return_1w'), - _1m: createBpsPercentRatioPattern(this, 'price_return_1m'), - _3m: createBpsPercentRatioPattern(this, 'price_return_3m'), - _6m: createBpsPercentRatioPattern(this, 'price_return_6m'), - _1y: createBpsPercentRatioPattern(this, 'price_return_1y'), - _2y: createBpsPercentRatioPattern(this, 'price_return_2y'), - _3y: createBpsPercentRatioPattern(this, 'price_return_3y'), - _4y: createBpsPercentRatioPattern(this, 'price_return_4y'), - _5y: createBpsPercentRatioPattern(this, 'price_return_5y'), - _6y: createBpsPercentRatioPattern(this, 'price_return_6y'), - _8y: createBpsPercentRatioPattern(this, 'price_return_8y'), - _10y: createBpsPercentRatioPattern(this, 'price_return_10y'), + _24h: createPercentRatioRawPattern(this, 'price_return_24h'), + _1w: createPercentRatioRawPattern(this, 'price_return_1w'), + _1m: createPercentRatioRawPattern(this, 'price_return_1m'), + _3m: createPercentRatioRawPattern(this, 'price_return_3m'), + _6m: createPercentRatioRawPattern(this, 'price_return_6m'), + _1y: createPercentRatioRawPattern(this, 'price_return_1y'), + _2y: createPercentRatioRawPattern(this, 'price_return_2y'), + _3y: createPercentRatioRawPattern(this, 'price_return_3y'), + _4y: createPercentRatioRawPattern(this, 'price_return_4y'), + _5y: createPercentRatioRawPattern(this, 'price_return_5y'), + _6y: createPercentRatioRawPattern(this, 'price_return_6y'), + _8y: createPercentRatioRawPattern(this, 'price_return_8y'), + _10y: createPercentRatioRawPattern(this, 'price_return_10y'), }, cagr: create_10y2y3y4y5y6y8yPattern(this, 'price_cagr'), sd24h: { @@ -10428,25 +10426,25 @@ class BrkClient extends BrkClientBase { max: create_1m1w1y2wPattern(this, 'price_max'), trueRange: createSeriesPattern1(this, 'price_true_range'), trueRangeSum2w: createSeriesPattern1(this, 'price_true_range_sum_2w'), - choppinessIndex2w: createBpsPercentRatioPattern2(this, 'price_choppiness_index_2w'), + choppinessIndex2w: createPercentRatioRawPattern2(this, 'price_choppiness_index_2w'), }, movingAverage: { sma: { - _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'), + _1w: createCentsRatioRawSatsUsdPattern(this, 'price_sma_1w'), + _8d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_8d'), + _13d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_13d'), + _21d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_21d'), + _1m: createCentsRatioRawSatsUsdPattern(this, 'price_sma_1m'), + _34d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_34d'), + _55d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_55d'), + _89d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_89d'), + _111d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_111d'), + _144d: createCentsRatioRawSatsUsdPattern(this, 'price_sma_144d'), _200d: { usd: createSeriesPattern1(this, 'price_sma_200d'), cents: createSeriesPattern1(this, 'price_sma_200d_cents'), sats: createSeriesPattern1(this, 'price_sma_200d_sats'), - bps: createSeriesPattern1(this, 'price_sma_200d_ratio_bps'), + raw: createSeriesPattern1(this, 'price_sma_200d_ratio_ppm'), ratio: createSeriesPattern1(this, 'price_sma_200d_ratio'), x24: createCentsSatsUsdPattern(this, 'price_sma_200d_x2_4'), x08: createCentsSatsUsdPattern(this, 'price_sma_200d_x0_8'), @@ -10455,32 +10453,32 @@ class BrkClient extends BrkClientBase { usd: createSeriesPattern1(this, 'price_sma_350d'), cents: createSeriesPattern1(this, 'price_sma_350d_cents'), sats: createSeriesPattern1(this, 'price_sma_350d_sats'), - bps: createSeriesPattern1(this, 'price_sma_350d_ratio_bps'), + raw: createSeriesPattern1(this, 'price_sma_350d_ratio_ppm'), ratio: createSeriesPattern1(this, 'price_sma_350d_ratio'), x2: createCentsSatsUsdPattern(this, 'price_sma_350d_x2'), }, - _1y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_1y'), - _2y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_2y'), - _200w: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_200w'), - _4y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_4y'), + _1y: createCentsRatioRawSatsUsdPattern(this, 'price_sma_1y'), + _2y: createCentsRatioRawSatsUsdPattern(this, 'price_sma_2y'), + _200w: createCentsRatioRawSatsUsdPattern(this, 'price_sma_200w'), + _4y: createCentsRatioRawSatsUsdPattern(this, 'price_sma_4y'), }, ema: { - _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'), + _1w: createCentsRatioRawSatsUsdPattern(this, 'price_ema_1w'), + _8d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_8d'), + _12d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_12d'), + _13d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_13d'), + _21d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_21d'), + _26d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_26d'), + _1m: createCentsRatioRawSatsUsdPattern(this, 'price_ema_1m'), + _34d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_34d'), + _55d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_55d'), + _89d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_89d'), + _144d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_144d'), + _200d: createCentsRatioRawSatsUsdPattern(this, 'price_ema_200d'), + _1y: createCentsRatioRawSatsUsdPattern(this, 'price_ema_1y'), + _2y: createCentsRatioRawSatsUsdPattern(this, 'price_ema_2y'), + _200w: createCentsRatioRawSatsUsdPattern(this, 'price_ema_200w'), + _4y: createCentsRatioRawSatsUsdPattern(this, 'price_ema_4y'), }, }, technical: { @@ -10489,7 +10487,7 @@ class BrkClient extends BrkClientBase { _1w: createRsiStochPattern(this, 'rsi', '1w'), _1m: createRsiStochPattern(this, 'rsi', '1m'), }, - piCycle: createBpsRatioPattern2(this, 'pi_cycle'), + piCycle: createRatioRawPattern2(this, 'pi_cycle'), macd: { _24h: { emaFast: createSeriesPattern1(this, 'macd_ema_fast_24h'), @@ -10709,7 +10707,7 @@ class BrkClient extends BrkClientBase { state: createSeriesPattern18(this, 'supply_state'), circulating: createBtcCentsSatsUsdPattern(this, 'circulating_supply'), burned: createBlockCumulativePattern(this, 'unspendable_supply'), - inflationRate: createBpsPercentRatioPattern(this, 'inflation_rate'), + inflationRate: createPercentRatioRawPattern(this, 'inflation_rate'), velocity: { native: createSeriesPattern1(this, 'velocity_btc'), fiat: createSeriesPattern1(this, 'velocity_usd'), @@ -10741,7 +10739,7 @@ class BrkClient extends BrkClientBase { usd: createSeriesPattern1(this, 'realized_price'), cents: createSeriesPattern1(this, 'realized_price_cents'), sats: createSeriesPattern1(this, 'realized_price_sats'), - bps: createSeriesPattern1(this, 'realized_price_ratio_bps'), + raw: createSeriesPattern1(this, 'realized_price_ratio_ppm'), ratio: createSeriesPattern1(this, 'realized_price_ratio'), percentiles: createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(this, 'realized_price'), sma: create_1m1w1y2y4yAllPattern(this, 'realized_price_ratio_sma'), @@ -10840,27 +10838,27 @@ class BrkClient extends BrkClientBase { max: createCentsSatsUsdPattern(this, 'cost_basis_max'), perCoin: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(this, 'cost_basis_per_coin'), perDollar: createPct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(this, 'cost_basis_per_dollar'), - supplyDensity: createBpsPercentRatioPattern2(this, 'supply_density'), + supplyDensity: createPercentRatioRawPattern2(this, 'supply_density'), }, unrealized: { - nupl: createBpsRatioPattern(this, 'nupl'), + nupl: createRatioRawPattern(this, 'nupl'), profit: { usd: createSeriesPattern1(this, 'unrealized_profit'), cents: createSeriesPattern1(this, 'unrealized_profit_cents'), - toMcap: createBpsPercentRatioPattern2(this, 'unrealized_profit_to_mcap'), - toOwnGrossPnl: createBpsPercentRatioPattern2(this, 'unrealized_profit_to_own_gross_pnl'), + toMcap: createPercentRatioRawPattern2(this, 'unrealized_profit_to_mcap'), + toOwnGrossPnl: createPercentRatioRawPattern2(this, 'unrealized_profit_to_own_gross_pnl'), }, loss: { usd: createSeriesPattern1(this, 'unrealized_loss'), cents: createSeriesPattern1(this, 'unrealized_loss_cents'), negative: createSeriesPattern1(this, 'unrealized_loss_neg'), - toMcap: createBpsPercentRatioPattern2(this, 'unrealized_loss_to_mcap'), - toOwnGrossPnl: createBpsPercentRatioPattern2(this, 'unrealized_loss_to_own_gross_pnl'), + toMcap: createPercentRatioRawPattern2(this, 'unrealized_loss_to_mcap'), + toOwnGrossPnl: createPercentRatioRawPattern2(this, 'unrealized_loss_to_own_gross_pnl'), }, netPnl: { usd: createSeriesPattern1(this, 'net_unrealized_pnl'), cents: createSeriesPattern1(this, 'net_unrealized_pnl_cents'), - toOwnGrossPnl: createBpsPercentRatioPattern(this, 'net_unrealized_pnl_to_own_gross_pnl'), + toOwnGrossPnl: createPercentRatioRawPattern3(this, 'net_unrealized_pnl_to_own_gross_pnl'), }, grossPnl: createCentsUsdPattern3(this, 'unrealized_gross_pnl'), investedCapital: createInPattern2(this, 'invested_capital_in'), @@ -10886,7 +10884,7 @@ class BrkClient extends BrkClientBase { usd: createSeriesPattern1(this, 'sth_realized_price'), cents: createSeriesPattern1(this, 'sth_realized_price_cents'), sats: createSeriesPattern1(this, 'sth_realized_price_sats'), - bps: createSeriesPattern1(this, 'sth_realized_price_ratio_bps'), + raw: createSeriesPattern1(this, 'sth_realized_price_ratio_ppm'), ratio: createSeriesPattern1(this, 'sth_realized_price_ratio'), percentiles: createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(this, 'sth_realized_price'), sma: create_1m1w1y2y4yAllPattern(this, 'sth_realized_price_ratio_sma'), @@ -10986,7 +10984,7 @@ class BrkClient extends BrkClientBase { usd: createSeriesPattern1(this, 'lth_realized_price'), cents: createSeriesPattern1(this, 'lth_realized_price_cents'), sats: createSeriesPattern1(this, 'lth_realized_price_sats'), - bps: createSeriesPattern1(this, 'lth_realized_price_ratio_bps'), + raw: createSeriesPattern1(this, 'lth_realized_price_ratio_ppm'), ratio: createSeriesPattern1(this, 'lth_realized_price_ratio'), percentiles: createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(this, 'lth_realized_price'), sma: create_1m1w1y2y4yAllPattern(this, 'lth_realized_price_ratio_sma'), @@ -11177,7 +11175,7 @@ class BrkClient extends BrkClientBase { usd: createSeriesPattern1(this, 'veteran_realized_price'), cents: createSeriesPattern1(this, 'veteran_realized_price_cents'), sats: createSeriesPattern1(this, 'veteran_realized_price_sats'), - bps: createSeriesPattern1(this, 'veteran_realized_price_ratio_bps'), + raw: createSeriesPattern1(this, 'veteran_realized_price_ratio_ppm'), ratio: createSeriesPattern1(this, 'veteran_realized_price_ratio'), percentiles: createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(this, 'veteran_realized_price'), sma: create_1m1w1y2y4yAllPattern(this, 'veteran_realized_price_ratio_sma'), @@ -11277,7 +11275,7 @@ class BrkClient extends BrkClientBase { usd: createSeriesPattern1(this, 'rookie_realized_price'), cents: createSeriesPattern1(this, 'rookie_realized_price_cents'), sats: createSeriesPattern1(this, 'rookie_realized_price_sats'), - bps: createSeriesPattern1(this, 'rookie_realized_price_ratio_bps'), + raw: createSeriesPattern1(this, 'rookie_realized_price_ratio_ppm'), ratio: createSeriesPattern1(this, 'rookie_realized_price_ratio'), percentiles: createPct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(this, 'rookie_realized_price'), sma: create_1m1w1y2y4yAllPattern(this, 'rookie_realized_price_ratio_sma'), diff --git a/modules/brk-client/package.json b/modules/brk-client/package.json index 5e3364fd7..4746d4e68 100644 --- a/modules/brk-client/package.json +++ b/modules/brk-client/package.json @@ -3,9 +3,10 @@ "url": "https://github.com/bitcoinresearchkit/brk/issues" }, "scripts": { - "test": "node tests/basic.js && node tests/tree.js", + "test": "node tests/hash_prefix.js && node tests/basic.js && node tests/metric_data.js && node tests/tree.js", "test:basic": "node tests/basic.js", "test:hash-prefix": "node tests/hash_prefix.js", + "test:metric-data": "node tests/metric_data.js", "test:tree": "node tests/tree.js" }, "description": "Bitcoin on-chain analytics client — thousands of metrics, block explorer, and address index", diff --git a/modules/brk-client/tests/basic.js b/modules/brk-client/tests/basic.js index 3dbe83b4a..54f361af7 100644 --- a/modules/brk-client/tests/basic.js +++ b/modules/brk-client/tests/basic.js @@ -6,50 +6,50 @@ console.log("Testing idiomatic API...\n"); // Test getter access (property) console.log("1. Getter access (.by.dateindex):"); -const all = await client.series.prices.split.close.usd.by.day1; +const all = await client.series.price.split.close.usd.by.day1; console.log(` Got: ${all.data.length} items\n`); // Test dynamic access (bracket notation) console.log("2. Dynamic access (.by['dateindex']):"); -const allDynamic = await client.series.prices.split.close.usd.by.day1; +const allDynamic = await client.series.price.split.close.usd.by.day1; console.log(` Got: ${allDynamic.data.length} items\n`); // Test fetch all (explicit .fetch()) console.log("3. Explicit .fetch():"); -const allExplicit = await client.series.prices.split.close.usd.by.day1.fetch(); +const allExplicit = await client.series.price.split.close.usd.by.day1.fetch(); console.log(` Got: ${allExplicit.data.length} items\n`); // Test first(n) console.log("4. First 5 items (.first(5)):"); -const first5 = await client.series.prices.split.close.usd.by.day1.first(5); +const first5 = await client.series.price.split.close.usd.by.day1.first(5); console.log( ` Start: ${first5.start}, End: ${first5.end}, Got: ${first5.data.length} items\n`, ); // Test last(n) console.log("5. Last 5 items (.last(5)):"); -const last5 = await client.series.prices.split.close.usd.by.day1.last(5); +const last5 = await client.series.price.split.close.usd.by.day1.last(5); console.log( ` Start: ${last5.start}, End: ${last5.end}, Got: ${last5.data.length} items\n`, ); // Test slice(start, end) console.log("6. Slice 10-20 (.slice(10, 20)):"); -const sliced = await client.series.prices.split.close.usd.by.day1.slice(10, 20); +const sliced = await client.series.price.split.close.usd.by.day1.slice(10, 20); console.log( ` Start: ${sliced.start}, End: ${sliced.end}, Got: ${sliced.data.length} items\n`, ); // Test get(index) - single item console.log("7. Single item (.get(100)):"); -const single = await client.series.prices.split.close.usd.by.day1.get(100); +const single = await client.series.price.split.close.usd.by.day1.get(100); console.log( ` Start: ${single.start}, End: ${single.end}, Got: ${single.data.length} item(s)\n`, ); // Test skip(n).take(m) chaining console.log("8. Skip and take (.skip(100).take(10)):"); -const skipTake = await client.series.prices.split.close.usd.by.day1 +const skipTake = await client.series.price.split.close.usd.by.day1 .skip(100) .take(10); console.log( @@ -58,7 +58,7 @@ console.log( // Test fetchCsv console.log("9. Fetch as CSV (.last(3).fetchCsv()):"); -const csv = await client.series.prices.split.close.usd.by.day1 +const csv = await client.series.price.split.close.usd.by.day1 .last(3) .fetchCsv(); console.log(` CSV preview: ${csv.substring(0, 100)}...\n`); diff --git a/modules/brk-client/tests/metric_data.js b/modules/brk-client/tests/metric_data.js index d8497af5a..31d72fb43 100644 --- a/modules/brk-client/tests/metric_data.js +++ b/modules/brk-client/tests/metric_data.js @@ -11,7 +11,7 @@ console.log("Testing MetricData helpers...\n"); // Fetch a date-based metric console.log("1. Fetching price data (day1):"); -const price = await client.series.prices.split.close.usd.by.day1.first(5); +const price = await client.series.price.split.close.usd.by.day1.first(5); console.log(` Start: ${price.start}, End: ${price.end}`); // Test isDateBased @@ -95,7 +95,7 @@ if (count !== 5) throw new Error("Expected 5 iterations"); // Test with non-date-based index (height) console.log("\n11. Testing height-based metric:"); -const heightMetric = await client.series.prices.spot.usd.by.height.last(3); +const heightMetric = await client.series.price.spot.usd.by.height.last(3); console.log(` Start: ${heightMetric.start}, End: ${heightMetric.end}`); if (heightMetric.isDateBased) throw new Error("height should not be date-based"); @@ -133,7 +133,7 @@ console.log(` Iterated ${heightCount} items`); // Test different date indexes console.log("\n13. Testing month1:"); const monthMetric = - await client.series.prices.split.close.usd.by.month1.first(3); + await client.series.price.split.close.usd.by.month1.first(3); const monthDates = monthMetric.dates(); console.log(` First month: ${monthDates[0].toISOString()}`); // MonthIndex 0 = Jan 1, 2009 @@ -236,7 +236,7 @@ console.log(` Roundtrip day1 100: ${testDate.toISOString()} -> ${roundtrip}`); // Test slice with Date console.log("\n16. Testing slice with Date:"); -const dateSlice = await client.series.prices.split.close.usd.by.day1 +const dateSlice = await client.series.price.split.close.usd.by.day1 .slice(new Date(Date.UTC(2020, 0, 1)), new Date(Date.UTC(2020, 0, 4))) .fetch(); console.log( diff --git a/modules/brk-client/tests/tree.js b/modules/brk-client/tests/tree.js index 03914f71a..55ea5e5a0 100644 --- a/modules/brk-client/tests/tree.js +++ b/modules/brk-client/tests/tree.js @@ -42,6 +42,7 @@ function getAllMetrics(obj, path = "") { // Check if this is a metric pattern using the indexes() method if (isMetricPattern(attr)) { metrics.push({ path: currentPath, metric: attr }); + continue; } // Recurse into nested tree nodes @@ -90,7 +91,7 @@ async function testAllEndpoints() { console.log( `FAIL: ${fullPath} -> ${e instanceof Error ? e.message : e}`, ); - return; + throw e; } } } diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index a072c7b7a..20a605e5d 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -31,26 +31,6 @@ TypeIndex = int OutputType = Literal["p2pk", "p2pk", "p2pkh", "multisig", "p2sh", "op_return", "v0_p2wpkh", "v0_p2wsh", "v1_p2tr", "p2a", "empty", "unknown"] # Unified index for any address type (funded or empty) AnyAddrIndex = TypeIndex -# Unsigned basis points stored as u16. -# 1 bp = 0.0001. Range: 0–6.5535. -# Use for bounded 0–1 ratios (dominance, adoption, liveliness, etc.). -# `u16::MAX` is reserved as a NaN sentinel. -BasisPoints16 = int -# Unsigned basis points stored as u32. -# 1 bp = 0.0001. Range: 0–429,496.7295. -# Use for unbounded unsigned ratios (MVRV, NVT, SOPR, etc.). -# `u32::MAX` is reserved as a NaN sentinel. -BasisPoints32 = int -# Signed basis points stored as i16. -# 1 bp = 0.0001. Range: -3.2767 to +3.2767. -# Use for signed bounded ratios (NUPL, net PnL ratios, etc.). -# `i16::MIN` is reserved as a NaN sentinel. -BasisPointsSigned16 = int -# Signed basis points stored as i32. -# 1 bp = 0.0001. Range: -214,748.3647 to +214,748.3647. -# Use for unbounded signed values (returns, growth rates, volatility, z-scores, etc.). -# `i32::MIN` is reserved as a NaN sentinel. -BasisPointsSigned32 = int # Bitcoin amount as floating point (1 BTC = 100,000,000 satoshis) Bitcoin = float # URL-friendly mining pool identifier @@ -216,6 +196,26 @@ P2WPKHAddrIndex = TypeIndex P2WPKHBytes = U8x20 P2WSHAddrIndex = TypeIndex P2WSHBytes = U8x32 +# Unsigned parts per million stored as u32. +# One unit is 0.000001. Range: 0–4,294.967294. +# Use for precise bounded ratios and percentages. +# `u32::MAX` is reserved as a NaN sentinel. +PartsPerMillion32 = int +# Unsigned parts per million stored as u64. +# One unit is 0.000001. Range: 0–18,446,744,073,709.551614. +# Use for precise wide-range ratios. +# `u64::MAX` is reserved as a NaN sentinel. +PartsPerMillion64 = int +# Signed parts per million stored as i32. +# One unit is 0.000001. Range: -2,147.483647 to +2,147.483647. +# Use for precise bounded signed ratios and percentages. +# `i32::MIN` is reserved as a NaN sentinel. +PartsPerMillionSigned32 = int +# Signed parts per million stored as i64. +# One unit is 0.000001. Range: -9,223,372,036,854.775807 to +9,223,372,036,854.775807. +# Use for precise wide-range signed ratios and percentages. +# `i64::MIN` is reserved as a NaN sentinel. +PartsPerMillionSigned64 = int # Fractional satoshis (f64) - for representing USD prices in sats # # Formula: `sats_fract = usd_value * 100_000_000 / btc_price` @@ -3041,24 +3041,6 @@ class AllEmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern: self.p2wsh: AverageBlockCumulativeSumPattern[StoredU64] = AverageBlockCumulativeSumPattern(client, _m(acc, 'with_p2wsh_output')) self.unknown: AverageBlockCumulativeSumPattern[StoredU64] = AverageBlockCumulativeSumPattern(client, _m(acc, 'with_unknown_outputs_output')) -class _10y1m1w1y2y3m3y4y5y6m6y8yPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self._10y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '10y')) - self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1m')) - self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1w')) - self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1y')) - self._2y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '2y')) - self._3m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '3m')) - self._3y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '3y')) - self._4y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '4y')) - self._5y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '5y')) - self._6m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '6m')) - self._6y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '6y')) - self._8y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '8y')) - class _10y1m1w1y2y3m3y4y5y6m6y8yPattern3: """Pattern struct for repeated tree structure.""" @@ -3077,6 +3059,24 @@ class _10y1m1w1y2y3m3y4y5y6m6y8yPattern3: self._6y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '6y')) self._8y: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, '8y')) +class _10y1m1w1y2y3m3y4y5y6m6y8yPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self._10y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '10y')) + self._1m: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '1m')) + self._1w: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '1w')) + self._1y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '1y')) + self._2y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '2y')) + self._3m: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '3m')) + self._3y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '3y')) + self._4y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '4y')) + self._5y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '5y')) + self._6m: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '6m')) + self._6y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '6y')) + self._8y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '8y')) + class AllEmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern: """Pattern struct for repeated tree structure.""" pass @@ -3094,18 +3094,18 @@ class EmptyOpP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.empty: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'empty_outputs_output')) - self.op_return: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'op_return_output')) - self.p2a: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2a_output')) - self.p2ms: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2ms_output')) - self.p2pk33: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk33_output')) - self.p2pk65: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk65_output')) - self.p2pkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pkh_output')) - self.p2sh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2sh_output')) - self.p2tr: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2tr_output')) - self.p2wpkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wpkh_output')) - self.p2wsh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wsh_output')) - self.unknown: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'unknown_outputs_output')) + self.empty: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'empty_outputs_output')) + self.op_return: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'op_return_output')) + self.p2a: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2a_output')) + self.p2ms: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2ms_output')) + self.p2pk33: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk33_output')) + self.p2pk65: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk65_output')) + self.p2pkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pkh_output')) + self.p2sh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2sh_output')) + self.p2tr: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2tr_output')) + self.p2wpkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wpkh_output')) + self.p2wsh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wsh_output')) + self.unknown: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'unknown_outputs_output')) class AverageBlockCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern: """Pattern struct for repeated tree structure.""" @@ -3129,17 +3129,17 @@ class EmptyP2aP2msP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshUnknownPattern2: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.empty: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'empty_outputs_prevout')) - self.p2a: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2a_prevout')) - self.p2ms: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2ms_prevout')) - self.p2pk33: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk33_prevout')) - self.p2pk65: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pk65_prevout')) - self.p2pkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2pkh_prevout')) - self.p2sh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2sh_prevout')) - self.p2tr: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2tr_prevout')) - self.p2wpkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wpkh_prevout')) - self.p2wsh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'p2wsh_prevout')) - self.unknown: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'unknown_outputs_prevout')) + self.empty: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'empty_outputs_prevout')) + self.p2a: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2a_prevout')) + self.p2ms: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2ms_prevout')) + self.p2pk33: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk33_prevout')) + self.p2pk65: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pk65_prevout')) + self.p2pkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2pkh_prevout')) + self.p2sh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2sh_prevout')) + self.p2tr: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2tr_prevout')) + self.p2wpkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wpkh_prevout')) + self.p2wsh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'p2wsh_prevout')) + self.unknown: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'unknown_outputs_prevout')) class AverageBaseCumulativeMaxMedianMinPct10Pct25Pct75Pct90SumPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -3198,15 +3198,15 @@ class AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern5: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.all: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, acc) - self.p2a: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2a', acc)) - self.p2pk33: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2pk33', acc)) - self.p2pk65: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2pk65', acc)) - self.p2pkh: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2pkh', acc)) - self.p2sh: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2sh', acc)) - self.p2tr: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2tr', acc)) - self.p2wpkh: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2wpkh', acc)) - self.p2wsh: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _p('p2wsh', acc)) + self.all: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, acc) + self.p2a: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2a', acc)) + self.p2pk33: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2pk33', acc)) + self.p2pk65: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2pk65', acc)) + self.p2pkh: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2pkh', acc)) + self.p2sh: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2sh', acc)) + self.p2tr: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2tr', acc)) + self.p2wpkh: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2wpkh', acc)) + self.p2wsh: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _p('p2wsh', acc)) class AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern4: """Pattern struct for repeated tree structure.""" @@ -3228,15 +3228,15 @@ class AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.all: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, acc) - self.p2a: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2a', acc)) - self.p2pk33: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2pk33', acc)) - self.p2pk65: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2pk65', acc)) - self.p2pkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2pkh', acc)) - self.p2sh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2sh', acc)) - self.p2tr: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2tr', acc)) - self.p2wpkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2wpkh', acc)) - self.p2wsh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _p('p2wsh', acc)) + self.all: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, acc) + self.p2a: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2a', acc)) + self.p2pk33: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2pk33', acc)) + self.p2pk65: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2pk65', acc)) + self.p2pkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2pkh', acc)) + self.p2sh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2sh', acc)) + self.p2tr: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2tr', acc)) + self.p2wpkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2wpkh', acc)) + self.p2wsh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _p('p2wsh', acc)) class AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern: """Pattern struct for repeated tree structure.""" @@ -3264,11 +3264,11 @@ class CapitalizedGrossInvestedLossNetNuplProfitSentimentPattern2: self.invested_capital: InPattern2 = InPattern2(client, _m(acc, 'invested_capital_in')) self.loss: CentsNegativeToUsdPattern2 = CentsNegativeToUsdPattern2(client, _m(acc, 'unrealized_loss')) self.net_pnl: CentsToUsdPattern3 = CentsToUsdPattern3(client, _m(acc, 'net_unrealized_pnl')) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.nupl: RatioRawPattern = RatioRawPattern(client, _m(acc, 'nupl')) self.profit: CentsToUsdPattern4 = CentsToUsdPattern4(client, _m(acc, 'unrealized_profit')) self.sentiment: GreedNetPainPattern = GreedNetPainPattern(client, acc) -class BpsCentsPercentilesRatioSatsSmaStdUsdPattern: +class CentsPercentilesRatioRawSatsSmaStdUsdPattern: """Pattern struct for repeated tree structure.""" pass @@ -3277,40 +3277,40 @@ class Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.pct0_5: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct0_5') - self.pct1: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct1') - self.pct2: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct2') - self.pct5: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct5') - self.pct95: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct95') - self.pct98: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct98') - self.pct99: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct99') - self.pct99_5: BpsPriceRatioPattern = BpsPriceRatioPattern(client, acc, 'pct99_5') + self.pct0_5: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct0_5') + self.pct1: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct1') + self.pct2: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct2') + self.pct5: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct5') + self.pct95: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct95') + self.pct98: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct98') + self.pct99: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct99') + self.pct99_5: PriceRatioRawPattern = PriceRatioRawPattern(client, acc, 'pct99_5') class _10y2y3y4y5y6y8yPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self._10y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '10y')) - self._2y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '2y')) - self._3y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '3y')) - self._4y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '4y')) - self._5y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '5y')) - self._6y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '6y')) - self._8y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '8y')) + self._10y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '10y')) + self._2y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '2y')) + self._3y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '3y')) + self._4y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '4y')) + self._5y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '5y')) + self._6y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '6y')) + self._8y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '8y')) -class _1m1w1y24hBpsPercentRatioPattern: +class _1m1w1y24hPercentRatioRawPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self._1m: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, '1m')) - self._1w: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, '1w')) - self._1y: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, '1y')) - self._24h: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, '24h')) - self.bps: SeriesPattern1[BasisPoints16] = SeriesPattern1(client, _m(acc, 'bps')) + self._1m: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '1m')) + self._1w: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '1w')) + self._1y: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '1y')) + self._24h: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '24h')) self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) + self.raw: SeriesPattern1[PartsPerMillion32] = SeriesPattern1(client, _m(acc, 'ppm')) class ActiveInputOutputSpendablePattern: """Pattern struct for repeated tree structure.""" @@ -3329,7 +3329,7 @@ class CapLossMvrvNetPriceProfitSoprPattern: self.loss: BlockCumulativeNegativeSumPattern = BlockCumulativeNegativeSumPattern(client, _m(acc, 'realized_loss')) self.mvrv: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'mvrv')) self.net_pnl: BlockCumulativeDeltaSumPattern = BlockCumulativeDeltaSumPattern(client, _m(acc, 'net_realized_pnl')) - self.price: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) + self.price: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, _m(acc, 'realized_price')) self.profit: BlockCumulativeSumPattern = BlockCumulativeSumPattern(client, _m(acc, 'realized_profit')) self.sopr: RatioValuePattern = RatioValuePattern(client, acc) @@ -3344,7 +3344,7 @@ class InMaxMinPerSupplyPattern: self.min: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, 'cost_basis_min')) self.per_coin: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis_per_coin')) self.per_dollar: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, _m(acc, 'cost_basis_per_dollar')) - self.supply_density: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'supply_density')) + self.supply_density: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'supply_density')) class MaxMedianMinPct10Pct25Pct75Pct90Pattern2: """Pattern struct for repeated tree structure.""" @@ -3377,12 +3377,12 @@ class _1m1w1y2y4yAllPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self._1m: BpsRatioPattern2 = BpsRatioPattern2(client, _m(acc, '1m')) - self._1w: BpsRatioPattern2 = BpsRatioPattern2(client, _m(acc, '1w')) - self._1y: BpsRatioPattern2 = BpsRatioPattern2(client, _m(acc, '1y')) - self._2y: BpsRatioPattern2 = BpsRatioPattern2(client, _m(acc, '2y')) - self._4y: BpsRatioPattern2 = BpsRatioPattern2(client, _m(acc, '4y')) - self.all: BpsRatioPattern2 = BpsRatioPattern2(client, _m(acc, 'all')) + self._1m: RatioRawPattern2 = RatioRawPattern2(client, _m(acc, '1m')) + self._1w: RatioRawPattern2 = RatioRawPattern2(client, _m(acc, '1w')) + self._1y: RatioRawPattern2 = RatioRawPattern2(client, _m(acc, '1y')) + self._2y: RatioRawPattern2 = RatioRawPattern2(client, _m(acc, '2y')) + self._4y: RatioRawPattern2 = RatioRawPattern2(client, _m(acc, '4y')) + self.all: RatioRawPattern2 = RatioRawPattern2(client, _m(acc, 'all')) class ActivityAddrOutputsRealizedSupplyUnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -3408,18 +3408,6 @@ class AverageBlockCumulativeInSumPattern: self.in_profit: AverageBlockCumulativeSumPattern3 = AverageBlockCumulativeSumPattern3(client, _m(acc, 'in_profit')) self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, _m(acc, 'sum')) -class BpsCentsPercentilesRatioSatsUsdPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, _m(acc, 'ratio_bps')) - self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) - self.percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, acc) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) - self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, _m(acc, 'sats')) - self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) - class CentsNegativeToUsdPattern2: """Pattern struct for repeated tree structure.""" @@ -3427,9 +3415,21 @@ class CentsNegativeToUsdPattern2: """Create pattern node with accumulated series name.""" self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) self.negative: SeriesPattern1[Dollars] = SeriesPattern1(client, _m(acc, 'neg')) - self.to_mcap: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'to_mcap')) - self.to_own_gross_pnl: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'to_own_gross_pnl')) - self.to_own_mcap: BpsPercentRatioPattern4 = BpsPercentRatioPattern4(client, _m(acc, 'to_own_mcap')) + self.to_mcap: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'to_mcap')) + self.to_own_gross_pnl: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'to_own_gross_pnl')) + self.to_own_mcap: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'to_own_mcap')) + self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) + +class CentsPercentilesRatioRawSatsUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) + self.percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, acc) + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, _m(acc, 'ratio_ppm')) + self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, _m(acc, 'sats')) self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) class ChainDataOutputTxPattern: @@ -3437,9 +3437,9 @@ class ChainDataOutputTxPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.chain_share: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'chain_share')) + self.chain_share: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'chain_share')) self.data_bytes: AverageBlockCumulativeSumPattern[StoredU64] = AverageBlockCumulativeSumPattern(client, _m(acc, 'data_bytes')) - self.data_share: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'data_share')) + self.data_share: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'data_share')) self.output_count: AverageBlockCumulativeSumPattern[StoredU64] = AverageBlockCumulativeSumPattern(client, _m(acc, 'output_count')) self.tx_count: AverageBlockCumulativeSumPattern[StoredU64] = AverageBlockCumulativeSumPattern(client, _m(acc, 'tx_count')) self.tx_vsize: AverageBlockCumulativeSumPattern[VSize] = AverageBlockCumulativeSumPattern(client, _m(acc, 'tx_vsize')) @@ -3450,7 +3450,7 @@ class DeltaDominanceHalfInTotalPattern2: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.delta: AbsoluteRatePattern3 = AbsoluteRatePattern3(client, _m(acc, 'delta')) - self.dominance: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'dominance')) + self.dominance: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'dominance')) self.half: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'half')) self.in_loss: BtcCentsSatsShareUsdPattern = BtcCentsSatsShareUsdPattern(client, _m(acc, 'in_loss')) self.in_profit: BtcCentsSatsShareUsdPattern = BtcCentsSatsShareUsdPattern(client, _m(acc, 'in_profit')) @@ -3462,7 +3462,7 @@ class DeltaDominanceHalfInTotalPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.delta: AbsoluteRatePattern3 = AbsoluteRatePattern3(client, _m(acc, 'delta')) - self.dominance: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'dominance')) + self.dominance: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'dominance')) self.half: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'half')) self.in_loss: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'in_loss')) self.in_profit: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, _m(acc, 'in_profit')) @@ -3545,17 +3545,6 @@ class BlockChangeCumulativeDeltaSumPattern: self.delta: AbsoluteRatePattern2 = AbsoluteRatePattern2(client, _m(acc, 'realized_pnl_delta')) self.sum: _1m1w1y24hPattern5 = _1m1w1y24hPattern5(client, _m(acc, 'realized_pnl_sum')) -class BpsCentsRatioSatsUsdPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, _m(acc, 'ratio_bps')) - self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) - self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, _m(acc, 'sats')) - self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) - class BtcCentsDeltaSatsUsdPattern: """Pattern struct for repeated tree structure.""" @@ -3575,7 +3564,7 @@ class BtcCentsSatsShareUsdPattern: self.btc: SeriesPattern1[Bitcoin] = SeriesPattern1(client, acc) self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) self.sats: SeriesPattern1[Sats] = SeriesPattern1(client, _m(acc, 'sats')) - self.share: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'share')) + self.share: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'share')) self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, _m(acc, 'usd')) class CapLossMvrvPriceProfitPattern: @@ -3586,18 +3575,29 @@ class CapLossMvrvPriceProfitPattern: self.cap: CentsDeltaUsdPattern = CentsDeltaUsdPattern(client, _m(acc, 'realized_cap')) self.loss: BlockCumulativeSumPattern = BlockCumulativeSumPattern(client, _m(acc, 'realized_loss')) self.mvrv: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'mvrv')) - self.price: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, _m(acc, 'realized_price')) + self.price: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, _m(acc, 'realized_price')) self.profit: BlockCumulativeSumPattern = BlockCumulativeSumPattern(client, _m(acc, 'realized_profit')) +class CentsRatioRawSatsUsdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, _m(acc, 'ratio_ppm')) + self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, _m(acc, 'sats')) + self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) + class CentsToUsdPattern4: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) - self.to_mcap: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'to_mcap')) - self.to_own_gross_pnl: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'to_own_gross_pnl')) - self.to_own_mcap: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'to_own_mcap')) + self.to_mcap: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'to_mcap')) + self.to_own_gross_pnl: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'to_own_gross_pnl')) + self.to_own_mcap: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'to_own_mcap')) self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) class EmaHistogramLineSignalPattern: @@ -3611,30 +3611,10 @@ class PhsReboundThsPattern: """Create pattern node with accumulated series name.""" self.phs: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'phs')) self.phs_min: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'phs_min')) - self.rebound: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rebound')) + self.rebound: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, 'rebound')) self.ths: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ths')) self.ths_min: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ths_min')) -class _1m1w1y24hPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1m_rate')) - self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1w_rate')) - self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '1y_rate')) - self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, '24h_rate')) - -class _1m1w1y24hPattern8: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self._1m: BpsPercentRatioPattern4 = BpsPercentRatioPattern4(client, _m(acc, '1m')) - self._1w: BpsPercentRatioPattern4 = BpsPercentRatioPattern4(client, _m(acc, '1w')) - self._1y: BpsPercentRatioPattern4 = BpsPercentRatioPattern4(client, _m(acc, '1y')) - self._24h: BpsPercentRatioPattern4 = BpsPercentRatioPattern4(client, _m(acc, '24h')) - class _1m1w1y24hPattern4: """Pattern struct for repeated tree structure.""" @@ -3695,6 +3675,26 @@ class _1m1w1y24hPattern6: self._1y: CentsUsdPattern3 = CentsUsdPattern3(client, _m(acc, '1y')) self._24h: CentsUsdPattern3 = CentsUsdPattern3(client, _m(acc, '24h')) +class _1m1w1y24hPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self._1m: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '1m_rate')) + self._1w: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '1w_rate')) + self._1y: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '1y_rate')) + self._24h: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, '24h_rate')) + +class _1m1w1y24hPattern8: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self._1m: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '1m')) + self._1w: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '1w')) + self._1y: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '1y')) + self._24h: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, '24h')) + class _1y2y4yAllPattern: """Pattern struct for repeated tree structure.""" pass @@ -3776,7 +3776,7 @@ class CentsDeltaToUsdPattern: """Create pattern node with accumulated series name.""" self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, _m(acc, 'cents')) self.delta: AbsoluteRatePattern2 = AbsoluteRatePattern2(client, _m(acc, 'delta')) - self.to_own_mcap: BpsPercentRatioPattern4 = BpsPercentRatioPattern4(client, _m(acc, 'to_own_mcap')) + self.to_own_mcap: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'to_own_mcap')) self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) class CentsToUsdPattern3: @@ -3785,8 +3785,8 @@ class CentsToUsdPattern3: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.cents: SeriesPattern1[CentsSigned] = SeriesPattern1(client, _m(acc, 'cents')) - self.to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'to_own_gross_pnl')) - self.to_own_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'to_own_mcap')) + self.to_own_gross_pnl: PercentRatioRawPattern3 = PercentRatioRawPattern3(client, _m(acc, 'to_own_gross_pnl')) + self.to_own_mcap: PercentRatioRawPattern3 = PercentRatioRawPattern3(client, _m(acc, 'to_own_mcap')) self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, acc) class CoindaysCoinyearsDormancyTransferPattern: @@ -3806,7 +3806,7 @@ class LossNetNuplProfitPattern: """Create pattern node with accumulated series name.""" self.loss: CentsNegativeUsdPattern = CentsNegativeUsdPattern(client, _m(acc, 'unrealized_loss')) self.net_pnl: CentsUsdPattern = CentsUsdPattern(client, _m(acc, 'net_unrealized_pnl')) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.nupl: RatioRawPattern = RatioRawPattern(client, _m(acc, 'nupl')) self.profit: CentsUsdPattern3 = CentsUsdPattern3(client, _m(acc, 'unrealized_profit')) class NuplRealizedSupplyUnrealizedPattern: @@ -3814,7 +3814,7 @@ class NuplRealizedSupplyUnrealizedPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.nupl: RatioRawPattern = RatioRawPattern(client, _m(acc, 'nupl')) self.realized_cap: AllSthPattern = AllSthPattern(client, acc, 'realized_cap') self.supply: AllSthPattern2 = AllSthPattern2(client, acc) self.unrealized_pnl: AllSthPattern = AllSthPattern(client, acc, 'unrealized_pnl') @@ -3863,54 +3863,9 @@ class BlocksDominanceRewardsPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.blocks_mined: AverageBlockCumulativeSumPattern2 = AverageBlockCumulativeSumPattern2(client, _m(acc, 'blocks_mined')) - self.dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, _m(acc, 'dominance')) + self.dominance: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, _m(acc, 'dominance')) self.rewards: AverageBlockCumulativeSumPattern3 = AverageBlockCumulativeSumPattern3(client, _m(acc, 'rewards')) -class BpsPercentRatioPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPoints16] = SeriesPattern1(client, _m(acc, 'bps')) - self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) - -class BpsPercentRatioPattern4: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, _m(acc, 'bps')) - self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) - -class BpsPriceRatioPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str, disc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, _m(acc, f'ratio_{disc}_bps')) - self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, disc)) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, f'ratio_{disc}')) - -class BpsPercentRatioPattern5: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPointsSigned16] = SeriesPattern1(client, _m(acc, 'bps')) - self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) - -class BpsPercentRatioPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPointsSigned32] = SeriesPattern1(client, _m(acc, 'bps')) - self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) - class CentsSatsUsdPattern3: """Pattern struct for repeated tree structure.""" @@ -3966,7 +3921,7 @@ class DeltaDominanceTotalPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.delta: AbsoluteRatePattern3 = AbsoluteRatePattern3(client, _m(acc, 'delta')) - self.dominance: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'dominance')) + self.dominance: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'dominance')) self.total: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, acc) class GreedNetPainPattern: @@ -3984,9 +3939,45 @@ class LossNuplProfitPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.loss: CentsNegativeUsdPattern = CentsNegativeUsdPattern(client, _m(acc, 'unrealized_loss')) - self.nupl: BpsRatioPattern = BpsRatioPattern(client, _m(acc, 'nupl')) + self.nupl: RatioRawPattern = RatioRawPattern(client, _m(acc, 'nupl')) self.profit: CentsUsdPattern3 = CentsUsdPattern3(client, _m(acc, 'unrealized_profit')) +class PercentRatioRawPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) + self.raw: SeriesPattern1[PartsPerMillion32] = SeriesPattern1(client, _m(acc, 'ppm')) + +class PercentRatioRawPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) + self.raw: SeriesPattern1[PartsPerMillionSigned32] = SeriesPattern1(client, _m(acc, 'ppm')) + +class PercentRatioRawPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.percent: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, 'ratio')) + self.raw: SeriesPattern1[PartsPerMillionSigned64] = SeriesPattern1(client, _m(acc, 'ppm')) + +class PriceRatioRawPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str, disc: str): + """Create pattern node with accumulated series name.""" + self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, disc)) + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, f'ratio_{disc}')) + self.raw: SeriesPattern1[PartsPerMillion32] = SeriesPattern1(client, _m(acc, f'ratio_{disc}_ppm')) + class RatioTransferValuePattern: """Pattern struct for repeated tree structure.""" @@ -4001,9 +3992,9 @@ class RsiStochPattern: def __init__(self, client: BrkClient, acc: str, disc: str): """Create pattern node with accumulated series name.""" - self.rsi: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, disc)) - self.stoch_rsi_d: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, f'stoch_d_{disc}')) - self.stoch_rsi_k: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, f'stoch_k_{disc}')) + self.rsi: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, disc)) + self.stoch_rsi_d: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, f'stoch_d_{disc}')) + self.stoch_rsi_k: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, f'stoch_k_{disc}')) class SpendingSpentUnspentPattern: """Pattern struct for repeated tree structure.""" @@ -4101,23 +4092,7 @@ class BlocksDominancePattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" self.blocks_mined: AverageBlockCumulativeSumPattern2 = AverageBlockCumulativeSumPattern2(client, _m(acc, 'blocks_mined')) - self.dominance: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, _m(acc, 'dominance')) - -class BpsRatioPattern2: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, _m(acc, 'bps')) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) - -class BpsRatioPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClient, acc: str): - """Create pattern node with accumulated series name.""" - self.bps: SeriesPattern1[BasisPointsSigned32] = SeriesPattern1(client, _m(acc, 'bps')) - self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) + self.dominance: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, _m(acc, 'dominance')) class BtcSatsPattern: """Pattern struct for repeated tree structure.""" @@ -4207,6 +4182,30 @@ class PriceRatioPattern: self.price: CentsSatsUsdPattern = CentsSatsUsdPattern(client, _m(acc, disc)) self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, _m(acc, f'ratio_{disc}')) +class RatioRawPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) + self.raw: SeriesPattern1[PartsPerMillion32] = SeriesPattern1(client, _m(acc, 'ppm')) + +class RatioRawPattern3: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, _m(acc, 'ppm')) + +class RatioRawPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClient, acc: str): + """Create pattern node with accumulated series name.""" + self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, acc) + self.raw: SeriesPattern1[PartsPerMillionSigned32] = SeriesPattern1(client, _m(acc, 'ppm')) + class RatioValuePattern2: """Pattern struct for repeated tree structure.""" @@ -4232,8 +4231,8 @@ class ToPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.to_mcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'mcap')) - self.to_rcap: BpsPercentRatioPattern = BpsPercentRatioPattern(client, _m(acc, 'rcap')) + self.to_mcap: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, 'mcap')) + self.to_rcap: PercentRatioRawPattern = PercentRatioRawPattern(client, _m(acc, 'rcap')) class _24hPattern: """Pattern struct for repeated tree structure.""" @@ -4247,21 +4246,21 @@ class NuplPattern: def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.nupl: BpsRatioPattern = BpsRatioPattern(client, acc) + self.nupl: RatioRawPattern = RatioRawPattern(client, acc) class PricePattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.price: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, acc) + self.price: CentsPercentilesRatioRawSatsUsdPattern = CentsPercentilesRatioRawSatsUsdPattern(client, acc) class SharePattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClient, acc: str): """Create pattern node with accumulated series name.""" - self.share: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, acc) + self.share: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, acc) class TransferPattern: """Pattern struct for repeated tree structure.""" @@ -4278,7 +4277,7 @@ class SeriesTree_Blocks_Difficulty: def __init__(self, client: BrkClient, base_path: str = ''): self.value: SeriesPattern1[StoredF64] = SeriesPattern1(client, 'difficulty') self.hashrate: SeriesPattern1[StoredF64] = SeriesPattern1(client, 'difficulty_hashrate') - self.adjustment: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'difficulty_adjustment') + self.adjustment: PercentRatioRawPattern3 = PercentRatioRawPattern3(client, 'difficulty_adjustment') self.epoch: SeriesPattern1[Epoch] = SeriesPattern1(client, 'difficulty_epoch') self.blocks_to_retarget: SeriesPattern1[StoredU32] = SeriesPattern1(client, 'blocks_to_retarget') self.days_to_retarget: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'days_to_retarget') @@ -4374,7 +4373,7 @@ class SeriesTree_Blocks_Fullness: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.bps: SeriesPattern18[BasisPoints16] = SeriesPattern18(client, 'block_fullness_bps') + self.raw: SeriesPattern18[PartsPerMillion32] = SeriesPattern18(client, 'block_fullness_ppm') self.ratio: SeriesPattern18[StoredF32] = SeriesPattern18(client, 'block_fullness_ratio') self.percent: SeriesPattern18[StoredF32] = SeriesPattern18(client, 'block_fullness') @@ -4621,17 +4620,17 @@ class SeriesTree_Inputs_ByType_InputShare: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.p2pk65: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2pk65_prevout_share') - self.p2pk33: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2pk33_prevout_share') - self.p2pkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2pkh_prevout_share') - self.p2ms: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2ms_prevout_share') - self.p2sh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2sh_prevout_share') - self.p2wpkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2wpkh_prevout_share') - self.p2wsh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2wsh_prevout_share') - self.p2tr: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2tr_prevout_share') - self.p2a: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2a_prevout_share') - self.unknown: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'unknown_outputs_prevout_share') - self.empty: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'empty_outputs_prevout_share') + self.p2pk65: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2pk65_prevout_share') + self.p2pk33: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2pk33_prevout_share') + self.p2pkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2pkh_prevout_share') + self.p2ms: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2ms_prevout_share') + self.p2sh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2sh_prevout_share') + self.p2wpkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2wpkh_prevout_share') + self.p2wsh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2wsh_prevout_share') + self.p2tr: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2tr_prevout_share') + self.p2a: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2a_prevout_share') + self.unknown: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'unknown_outputs_prevout_share') + self.empty: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'empty_outputs_prevout_share') class SeriesTree_Inputs_ByType_TxCount: """Series tree node.""" @@ -4719,18 +4718,18 @@ class SeriesTree_Outputs_ByType_OutputShare: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.p2pk65: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2pk65_output_share') - self.p2pk33: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2pk33_output_share') - self.p2pkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2pkh_output_share') - self.p2ms: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2ms_output_share') - self.p2sh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2sh_output_share') - self.p2wpkh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2wpkh_output_share') - self.p2wsh: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2wsh_output_share') - self.p2tr: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2tr_output_share') - self.p2a: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'p2a_output_share') - self.unknown: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'unknown_outputs_output_share') - self.empty: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'empty_outputs_output_share') - self.op_return: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'op_return_output_share') + self.p2pk65: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2pk65_output_share') + self.p2pk33: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2pk33_output_share') + self.p2pkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2pkh_output_share') + self.p2ms: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2ms_output_share') + self.p2sh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2sh_output_share') + self.p2wpkh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2wpkh_output_share') + self.p2wsh: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2wsh_output_share') + self.p2tr: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2tr_output_share') + self.p2a: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'p2a_output_share') + self.unknown: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'unknown_outputs_output_share') + self.empty: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'empty_outputs_output_share') + self.op_return: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'op_return_output_share') class SeriesTree_Outputs_ByType: """Series tree node.""" @@ -4881,7 +4880,7 @@ class SeriesTree_Addrs_Reused_Events: def __init__(self, client: BrkClient, base_path: str = ''): self.output_to_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(client, 'output_to_reused_addr_count') self.output_to_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(client, 'output_to_reused_addr_share') - self.spendable_output_to_reused_addr_share: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'spendable_output_to_reused_addr_share') + self.spendable_output_to_reused_addr_share: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'spendable_output_to_reused_addr_share') self.input_from_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(client, 'input_from_reused_addr_count') self.input_from_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(client, 'input_from_reused_addr_share') self.active_reused_addr_count: _1m1w1y24hBlockPattern = _1m1w1y24hBlockPattern(client, 'active_reused_addr_count') @@ -4916,7 +4915,7 @@ class SeriesTree_Addrs_Respent_Events: def __init__(self, client: BrkClient, base_path: str = ''): self.output_to_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(client, 'output_to_respent_addr_count') self.output_to_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(client, 'output_to_respent_addr_share') - self.spendable_output_to_reused_addr_share: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'spendable_output_to_respent_addr_share') + self.spendable_output_to_reused_addr_share: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'spendable_output_to_respent_addr_share') self.input_from_reused_addr_count: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern6(client, 'input_from_respent_addr_count') self.input_from_reused_addr_share: AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7 = AllP2aP2pk33P2pk65P2pkhP2shP2trP2wpkhP2wshPattern7(client, 'input_from_respent_addr_share') self.active_reused_addr_count: _1m1w1y24hBlockPattern = _1m1w1y24hBlockPattern(client, 'active_respent_addr_count') @@ -5066,7 +5065,7 @@ class SeriesTree_OpReturn_Total: self.data_bytes: AverageBlockCumulativeSumPattern[StoredU64] = AverageBlockCumulativeSumPattern(client, 'op_return_data_bytes') self.tx_count: AverageBlockCumulativeSumPattern[StoredU64] = AverageBlockCumulativeSumPattern(client, 'op_return_tx_count') self.tx_vsize: AverageBlockCumulativeSumPattern[VSize] = AverageBlockCumulativeSumPattern(client, 'op_return_tx_vsize') - self.chain_share: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'op_return_chain_share') + self.chain_share: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'op_return_chain_share') class SeriesTree_OpReturn_ByKind: """Series tree node.""" @@ -5122,16 +5121,16 @@ class SeriesTree_Mining_Rewards_Subsidy: self.cumulative: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'subsidy_cumulative') self.sum: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, 'subsidy_sum') self.average: _1m1w1y24hPattern3 = _1m1w1y24hPattern3(client, 'subsidy_average') - self.dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'subsidy_dominance') + self.dominance: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'subsidy_dominance') class SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self._24h: BpsRatioPattern2 = BpsRatioPattern2(client, 'fee_to_subsidy_ratio_24h') - self._1w: BpsRatioPattern2 = BpsRatioPattern2(client, 'fee_to_subsidy_ratio_1w') - self._1m: BpsRatioPattern2 = BpsRatioPattern2(client, 'fee_to_subsidy_ratio_1m') - self._1y: BpsRatioPattern2 = BpsRatioPattern2(client, 'fee_to_subsidy_ratio_1y') + self._24h: RatioRawPattern3 = RatioRawPattern3(client, 'fee_to_subsidy_ratio_24h') + self._1w: RatioRawPattern3 = RatioRawPattern3(client, 'fee_to_subsidy_ratio_1w') + self._1m: RatioRawPattern3 = RatioRawPattern3(client, 'fee_to_subsidy_ratio_1m') + self._1y: RatioRawPattern3 = RatioRawPattern3(client, 'fee_to_subsidy_ratio_1y') class SeriesTree_Mining_Rewards_Fees: """Series tree node.""" @@ -5148,7 +5147,7 @@ class SeriesTree_Mining_Rewards_Fees: self.median: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, 'fees_median') self.pct75: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, 'fees_pct75') self.pct90: _1m1w1y24hPattern4 = _1m1w1y24hPattern4(client, 'fees_pct90') - self.dominance: _1m1w1y24hBpsPercentRatioPattern = _1m1w1y24hBpsPercentRatioPattern(client, 'fee_dominance') + self.dominance: _1m1w1y24hPercentRatioRawPattern = _1m1w1y24hPercentRatioRawPattern(client, 'fee_dominance') self.to_subsidy_ratio: SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio = SeriesTree_Mining_Rewards_Fees_ToSubsidyRatio(client) class SeriesTree_Mining_Rewards: @@ -5177,7 +5176,7 @@ class SeriesTree_Mining_Hashrate_Rate: self.base: SeriesPattern1[StoredF64] = SeriesPattern1(client, 'hash_rate') self.sma: SeriesTree_Mining_Hashrate_Rate_Sma = SeriesTree_Mining_Hashrate_Rate_Sma(client) self.ath: SeriesPattern1[StoredF64] = SeriesPattern1(client, 'hash_rate_ath') - self.drawdown: BpsPercentRatioPattern5 = BpsPercentRatioPattern5(client, 'hash_rate_drawdown') + self.drawdown: PercentRatioRawPattern3 = PercentRatioRawPattern3(client, 'hash_rate_drawdown') class SeriesTree_Mining_Hashrate: """Series tree node.""" @@ -5230,22 +5229,22 @@ class SeriesTree_Cointime_Cap: self.vaulted: CentsUsdPattern3 = CentsUsdPattern3(client, 'vaulted_cap') self.active: CentsUsdPattern3 = CentsUsdPattern3(client, 'active_cap') self.cointime: CentsUsdPattern3 = CentsUsdPattern3(client, 'cointime_cap') - self.aviv: BpsRatioPattern2 = BpsRatioPattern2(client, 'aviv_ratio') + self.aviv: RatioRawPattern2 = RatioRawPattern2(client, 'aviv_ratio') class SeriesTree_Cointime_Prices: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.vaulted: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'vaulted_price') - self.active: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'active_price') - self.true_market_mean: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'true_market_mean') - self.cointime: BpsCentsPercentilesRatioSatsUsdPattern = BpsCentsPercentilesRatioSatsUsdPattern(client, 'cointime_price') + self.vaulted: CentsPercentilesRatioRawSatsUsdPattern = CentsPercentilesRatioRawSatsUsdPattern(client, 'vaulted_price') + self.active: CentsPercentilesRatioRawSatsUsdPattern = CentsPercentilesRatioRawSatsUsdPattern(client, 'active_price') + self.true_market_mean: CentsPercentilesRatioRawSatsUsdPattern = CentsPercentilesRatioRawSatsUsdPattern(client, 'true_market_mean') + self.cointime: CentsPercentilesRatioRawSatsUsdPattern = CentsPercentilesRatioRawSatsUsdPattern(client, 'cointime_price') class SeriesTree_Cointime_Adjusted: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'cointime_adj_inflation_rate') + self.inflation_rate: PercentRatioRawPattern = PercentRatioRawPattern(client, 'cointime_adj_inflation_rate') self.tx_velocity_native: SeriesPattern1[StoredF64] = SeriesPattern1(client, 'cointime_adj_tx_velocity_btc') self.tx_velocity_fiat: SeriesPattern1[StoredF64] = SeriesPattern1(client, 'cointime_adj_tx_velocity_usd') @@ -5580,11 +5579,11 @@ class SeriesTree_Indicators: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.puell_multiple: BpsRatioPattern2 = BpsRatioPattern2(client, 'puell_multiple') - self.nvt: BpsRatioPattern2 = BpsRatioPattern2(client, 'nvt') - self.gini: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'gini') - self.rhodl_ratio: BpsRatioPattern2 = BpsRatioPattern2(client, 'rhodl_ratio') - self.thermo_cap_multiple: BpsRatioPattern2 = BpsRatioPattern2(client, 'thermo_cap_multiple') + self.puell_multiple: RatioRawPattern3 = RatioRawPattern3(client, 'puell_multiple') + self.nvt: RatioRawPattern3 = RatioRawPattern3(client, 'nvt') + self.gini: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'gini') + self.rhodl_ratio: RatioRawPattern3 = RatioRawPattern3(client, 'rhodl_ratio') + self.thermo_cap_multiple: RatioRawPattern3 = RatioRawPattern3(client, 'thermo_cap_multiple') self.coindays_destroyed_supply_adj: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'coindays_destroyed_supply_adj') self.coinyears_destroyed_supply_adj: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'coinyears_destroyed_supply_adj') self.dormancy: SeriesTree_Indicators_Dormancy = SeriesTree_Indicators_Dormancy(client) @@ -5658,18 +5657,18 @@ class SeriesTree_Investing_Class_DcaReturn: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.from_2015: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2015') - self.from_2016: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2016') - self.from_2017: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2017') - self.from_2018: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2018') - self.from_2019: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2019') - self.from_2020: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2020') - self.from_2021: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2021') - self.from_2022: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2022') - self.from_2023: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2023') - self.from_2024: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2024') - self.from_2025: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2025') - self.from_2026: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2026') + self.from_2015: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2015') + self.from_2016: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2016') + self.from_2017: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2017') + self.from_2018: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2018') + self.from_2019: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2019') + self.from_2020: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2020') + self.from_2021: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2021') + self.from_2022: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2022') + self.from_2023: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2023') + self.from_2024: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2024') + self.from_2025: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2025') + self.from_2026: PercentRatioRawPattern = PercentRatioRawPattern(client, 'dca_return_from_2026') class SeriesTree_Investing_Class: """Series tree node.""" @@ -5692,7 +5691,7 @@ class SeriesTree_Market_Ath: def __init__(self, client: BrkClient, base_path: str = ''): self.high: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_ath') - self.drawdown: BpsPercentRatioPattern5 = BpsPercentRatioPattern5(client, 'price_drawdown') + self.drawdown: PercentRatioRawPattern3 = PercentRatioRawPattern3(client, 'price_drawdown') self.days_since: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'days_since_price_ath') self.years_since: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'years_since_price_ath') self.max_days_between: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'max_days_between_price_ath') @@ -5720,19 +5719,19 @@ class SeriesTree_Market_Returns_Periods: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self._24h: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_24h') - self._1w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_1w') - self._1m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_1m') - self._3m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_3m') - self._6m: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_6m') - self._1y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_1y') - self._2y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_2y') - self._3y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_3y') - self._4y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_4y') - self._5y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_5y') - self._6y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_6y') - self._8y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_8y') - self._10y: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_return_10y') + self._24h: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_24h') + self._1w: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_1w') + self._1m: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_1m') + self._3m: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_3m') + self._6m: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_6m') + self._1y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_1y') + self._2y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_2y') + self._3y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_3y') + self._4y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_4y') + self._5y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_5y') + self._6y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_6y') + self._8y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_8y') + self._10y: PercentRatioRawPattern = PercentRatioRawPattern(client, 'price_return_10y') class SeriesTree_Market_Returns_Sd24h_24h: """Series tree node.""" @@ -5787,7 +5786,7 @@ class SeriesTree_Market_Range: self.max: _1m1w1y2wPattern = _1m1w1y2wPattern(client, 'price_max') self.true_range: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'price_true_range') self.true_range_sum_2w: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'price_true_range_sum_2w') - self.choppiness_index_2w: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'price_choppiness_index_2w') + self.choppiness_index_2w: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'price_choppiness_index_2w') class SeriesTree_Market_MovingAverage_Sma_200d: """Series tree node.""" @@ -5796,7 +5795,7 @@ class SeriesTree_Market_MovingAverage_Sma_200d: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'price_sma_200d') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'price_sma_200d_cents') self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, 'price_sma_200d_sats') - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, 'price_sma_200d_ratio_bps') + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, 'price_sma_200d_ratio_ppm') self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'price_sma_200d_ratio') self.x2_4: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x2_4') self.x0_8: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x0_8') @@ -5808,7 +5807,7 @@ class SeriesTree_Market_MovingAverage_Sma_350d: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'price_sma_350d') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'price_sma_350d_cents') self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, 'price_sma_350d_sats') - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, 'price_sma_350d_ratio_bps') + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, 'price_sma_350d_ratio_ppm') self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'price_sma_350d_ratio') self.x2: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_350d_x2') @@ -5816,43 +5815,43 @@ class SeriesTree_Market_MovingAverage_Sma: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - 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._1w: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_1w') + self._8d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_8d') + self._13d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_13d') + self._21d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_21d') + self._1m: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_1m') + self._34d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_34d') + self._55d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_55d') + self._89d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_89d') + self._111d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_111d') + self._144d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_144d') self._200d: SeriesTree_Market_MovingAverage_Sma_200d = SeriesTree_Market_MovingAverage_Sma_200d(client) self._350d: SeriesTree_Market_MovingAverage_Sma_350d = SeriesTree_Market_MovingAverage_Sma_350d(client) - 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._1y: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_1y') + self._2y: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_2y') + self._200w: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_200w') + self._4y: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_sma_4y') class SeriesTree_Market_MovingAverage_Ema: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - 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') + self._1w: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_1w') + self._8d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_8d') + self._12d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_12d') + self._13d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_13d') + self._21d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_21d') + self._26d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_26d') + self._1m: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_1m') + self._34d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_34d') + self._55d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_55d') + self._89d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_89d') + self._144d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_144d') + self._200d: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_200d') + self._1y: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_1y') + self._2y: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_2y') + self._200w: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_200w') + self._4y: CentsRatioRawSatsUsdPattern = CentsRatioRawSatsUsdPattern(client, 'price_ema_4y') class SeriesTree_Market_MovingAverage: """Series tree node.""" @@ -5912,7 +5911,7 @@ class SeriesTree_Market_Technical: def __init__(self, client: BrkClient, base_path: str = ''): self.rsi: SeriesTree_Market_Technical_Rsi = SeriesTree_Market_Technical_Rsi(client) - self.pi_cycle: BpsRatioPattern2 = BpsRatioPattern2(client, 'pi_cycle') + self.pi_cycle: RatioRawPattern2 = RatioRawPattern2(client, 'pi_cycle') self.macd: SeriesTree_Market_Technical_Macd = SeriesTree_Market_Technical_Macd(client) class SeriesTree_Market: @@ -6157,10 +6156,10 @@ class SeriesTree_Supply: self.state: SeriesPattern18[SupplyState] = SeriesPattern18(client, 'supply_state') self.circulating: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'circulating_supply') self.burned: BlockCumulativePattern = BlockCumulativePattern(client, 'unspendable_supply') - self.inflation_rate: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'inflation_rate') + self.inflation_rate: PercentRatioRawPattern = PercentRatioRawPattern(client, 'inflation_rate') self.velocity: SeriesTree_Supply_Velocity = SeriesTree_Supply_Velocity(client) self.market_cap: CentsDeltaUsdPattern = CentsDeltaUsdPattern(client, 'market_cap') - self.market_minus_realized_cap_growth_rate: _1m1w1y24hPattern[BasisPointsSigned32] = _1m1w1y24hPattern(client, 'market_minus_realized_cap_growth_rate') + self.market_minus_realized_cap_growth_rate: _1m1w1y24hPattern[PartsPerMillionSigned64] = _1m1w1y24hPattern(client, 'market_minus_realized_cap_growth_rate') self.hodled_or_lost: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'hodled_or_lost_supply') class SeriesTree_Cohorts_Utxo_All_Outputs: @@ -6276,7 +6275,7 @@ class SeriesTree_Cohorts_Utxo_All_Realized_Price: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'realized_price') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'realized_price_cents') self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, 'realized_price_sats') - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, 'realized_price_ratio_bps') + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, 'realized_price_ratio_ppm') self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'realized_price_ratio') self.percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, 'realized_price') self.sma: _1m1w1y2y4yAllPattern = _1m1w1y2y4yAllPattern(client, 'realized_price_ratio_sma') @@ -6325,7 +6324,7 @@ class SeriesTree_Cohorts_Utxo_All_CostBasis: self.max: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'cost_basis_max') self.per_coin: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, 'cost_basis_per_coin') self.per_dollar: Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern = Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern(client, 'cost_basis_per_dollar') - self.supply_density: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'supply_density') + self.supply_density: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'supply_density') class SeriesTree_Cohorts_Utxo_All_Unrealized_Profit: """Series tree node.""" @@ -6333,8 +6332,8 @@ class SeriesTree_Cohorts_Utxo_All_Unrealized_Profit: def __init__(self, client: BrkClient, base_path: str = ''): self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'unrealized_profit') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'unrealized_profit_cents') - self.to_mcap: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'unrealized_profit_to_mcap') - self.to_own_gross_pnl: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'unrealized_profit_to_own_gross_pnl') + self.to_mcap: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'unrealized_profit_to_mcap') + self.to_own_gross_pnl: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'unrealized_profit_to_own_gross_pnl') class SeriesTree_Cohorts_Utxo_All_Unrealized_Loss: """Series tree node.""" @@ -6343,8 +6342,8 @@ class SeriesTree_Cohorts_Utxo_All_Unrealized_Loss: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'unrealized_loss') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'unrealized_loss_cents') self.negative: SeriesPattern1[Dollars] = SeriesPattern1(client, 'unrealized_loss_neg') - self.to_mcap: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'unrealized_loss_to_mcap') - self.to_own_gross_pnl: BpsPercentRatioPattern2 = BpsPercentRatioPattern2(client, 'unrealized_loss_to_own_gross_pnl') + self.to_mcap: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'unrealized_loss_to_mcap') + self.to_own_gross_pnl: PercentRatioRawPattern2 = PercentRatioRawPattern2(client, 'unrealized_loss_to_own_gross_pnl') class SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl: """Series tree node.""" @@ -6352,7 +6351,7 @@ class SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl: def __init__(self, client: BrkClient, base_path: str = ''): self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'net_unrealized_pnl') self.cents: SeriesPattern1[CentsSigned] = SeriesPattern1(client, 'net_unrealized_pnl_cents') - self.to_own_gross_pnl: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'net_unrealized_pnl_to_own_gross_pnl') + self.to_own_gross_pnl: PercentRatioRawPattern3 = PercentRatioRawPattern3(client, 'net_unrealized_pnl_to_own_gross_pnl') class SeriesTree_Cohorts_Utxo_All_Unrealized_Sentiment: """Series tree node.""" @@ -6366,7 +6365,7 @@ class SeriesTree_Cohorts_Utxo_All_Unrealized: """Series tree node.""" def __init__(self, client: BrkClient, base_path: str = ''): - self.nupl: BpsRatioPattern = BpsRatioPattern(client, 'nupl') + self.nupl: RatioRawPattern = RatioRawPattern(client, 'nupl') self.profit: SeriesTree_Cohorts_Utxo_All_Unrealized_Profit = SeriesTree_Cohorts_Utxo_All_Unrealized_Profit(client) self.loss: SeriesTree_Cohorts_Utxo_All_Unrealized_Loss = SeriesTree_Cohorts_Utxo_All_Unrealized_Loss(client) self.net_pnl: SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl = SeriesTree_Cohorts_Utxo_All_Unrealized_NetPnl(client) @@ -6484,7 +6483,7 @@ class SeriesTree_Cohorts_Utxo_Sth_Realized_Price: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'sth_realized_price') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'sth_realized_price_cents') self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, 'sth_realized_price_sats') - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, 'sth_realized_price_ratio_bps') + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, 'sth_realized_price_ratio_ppm') self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'sth_realized_price_ratio') self.percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, 'sth_realized_price') self.sma: _1m1w1y2y4yAllPattern = _1m1w1y2y4yAllPattern(client, 'sth_realized_price_ratio_sma') @@ -6615,7 +6614,7 @@ class SeriesTree_Cohorts_Utxo_Lth_Realized_Price: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'lth_realized_price') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'lth_realized_price_cents') self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, 'lth_realized_price_sats') - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, 'lth_realized_price_ratio_bps') + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, 'lth_realized_price_ratio_ppm') self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'lth_realized_price_ratio') self.percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, 'lth_realized_price') self.sma: _1m1w1y2y4yAllPattern = _1m1w1y2y4yAllPattern(client, 'lth_realized_price_ratio_sma') @@ -6851,7 +6850,7 @@ class SeriesTree_Cohorts_Utxo_Entry_Discount_Realized_Price: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'veteran_realized_price') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'veteran_realized_price_cents') self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, 'veteran_realized_price_sats') - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, 'veteran_realized_price_ratio_bps') + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, 'veteran_realized_price_ratio_ppm') self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'veteran_realized_price_ratio') self.percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, 'veteran_realized_price') self.sma: _1m1w1y2y4yAllPattern = _1m1w1y2y4yAllPattern(client, 'veteran_realized_price_ratio_sma') @@ -6982,7 +6981,7 @@ class SeriesTree_Cohorts_Utxo_Entry_Premium_Realized_Price: self.usd: SeriesPattern1[Dollars] = SeriesPattern1(client, 'rookie_realized_price') self.cents: SeriesPattern1[Cents] = SeriesPattern1(client, 'rookie_realized_price_cents') self.sats: SeriesPattern1[SatsFract] = SeriesPattern1(client, 'rookie_realized_price_sats') - self.bps: SeriesPattern1[BasisPoints32] = SeriesPattern1(client, 'rookie_realized_price_ratio_bps') + self.raw: SeriesPattern1[PartsPerMillion64] = SeriesPattern1(client, 'rookie_realized_price_ratio_ppm') self.ratio: SeriesPattern1[StoredF32] = SeriesPattern1(client, 'rookie_realized_price_ratio') self.percentiles: Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern = Pct0Pct1Pct2Pct5Pct95Pct98Pct99Pattern(client, 'rookie_realized_price') self.sma: _1m1w1y2y4yAllPattern = _1m1w1y2y4yAllPattern(client, 'rookie_realized_price_ratio_sma') diff --git a/website_next/explore/block/format.js b/website_next/explore/block/format.js index 27cdc64b8..82edda599 100644 --- a/website_next/explore/block/format.js +++ b/website_next/explore/block/format.js @@ -43,7 +43,7 @@ export function formatDateAndAge(unixSeconds) { const [unit, seconds] = RELATIVE_UNITS.find(([, duration]) => { return absolute >= duration; - }) ?? RELATIVE_UNITS.at(-1); + }) ?? RELATIVE_UNITS[RELATIVE_UNITS.length - 1]; return `${date} · ${RELATIVE_TIME.format(Math.trunc(difference / seconds), unit)}`; } diff --git a/website_next/explore/block/preview/heatmap/geometry.js b/website_next/explore/block/preview/heatmap/geometry.js index 22955b361..2596cd49e 100644 --- a/website_next/explore/block/preview/heatmap/geometry.js +++ b/website_next/explore/block/preview/heatmap/geometry.js @@ -124,8 +124,8 @@ export function hitTest(geometry, x, y) { /** * @typedef {Object} SquareLayout * @property {number} columns - * @property {SquareCell[]} resolvedCells - * @property {SquareCellLayout[]} layouts + * @property {readonly SquareCell[]} resolvedCells + * @property {readonly SquareCellLayout[]} layouts */ /**