diff --git a/Cargo.lock b/Cargo.lock index e659ecf59..065753c10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1405,9 +1405,9 @@ checksum = "b35204fbdc0b3f4446b89fc1ac2cf84a8a68971995d0bf2e925ec7cd960f9cb3" [[package]] name = "byteview" -version = "0.9.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6e3a2110d267b9881afe689e6eebcc7635534a827928bd69bef59a8f9db644a" +checksum = "dda4398f387cc6395a3e93b3867cd9abda914c97a0b344d1eefb2e5c51785fca" [[package]] name = "castaway" @@ -2154,8 +2154,9 @@ checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" [[package]] name = "fjall" -version = "3.0.0-rc.9" -source = "git+https://github.com/fjall-rs/fjall#ef220cd8502ff1f41bf00f7a01162040148b57fb" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4986f550347ed1666561f36e8bf1be3c97df72850ecef0140129da6e2d0aa911" dependencies = [ "byteorder-lite", "byteview", @@ -3034,9 +3035,9 @@ checksum = "5e5032e24019045c762d3c0f28f5b6b8bbf38563a65908389bf7978758920897" [[package]] name = "lsm-tree" -version = "3.0.0-rc.9" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b24b4f8669054ca480aeedf97c19157f94736a1bf87ab688aaea66e8f2d54d" +checksum = "3a206e87e8bc38114045060ec1fc6bc4e4559748a37e9622b910d80e48863e87" dependencies = [ "byteorder-lite", "byteview", @@ -4772,9 +4773,9 @@ dependencies = [ [[package]] name = "sfa" -version = "0.1.0" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86cc3fab8d5eb0e19832083e29d69607305b01ae6a16d5790b3e5374c5da3d91" +checksum = "a1296838937cab56cd6c4eeeb8718ec777383700c33f060e2869867bd01d1175" dependencies = [ "byteorder-lite", "log", diff --git a/Cargo.toml b/Cargo.toml index cc21cd8ec..0330e2e6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -63,12 +63,11 @@ brk_store = { version = "0.1.0-alpha.1", path = "crates/brk_store" } brk_types = { version = "0.1.0-alpha.1", path = "crates/brk_types" } brk_traversable = { version = "0.1.0-alpha.1", path = "crates/brk_traversable", features = ["pco", "derive"] } brk_traversable_derive = { version = "0.1.0-alpha.1", path = "crates/brk_traversable_derive" } -byteview = "0.9.1" +byteview = "0.10.0" color-eyre = "0.6.5" derive_deref = "1.1.1" env_logger = "0.11.8" -# fjall = "3.0.0-rc.6" -fjall = { git = "https://github.com/fjall-rs/fjall" } +fjall = "3.0.0" jiff = "0.2.17" log = "0.4.29" minreq = { version = "2.14.1", features = ["https", "serde_json"] } diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 3f48a5a3e..aba12c569 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -3826,32 +3826,32 @@ impl RelativePattern { /// Pattern struct for repeated tree structure. pub struct BlockSizePattern { - pub average: MetricPattern1, + pub average: MetricPattern2, pub cumulative: MetricPattern1, - pub max: MetricPattern1, - pub median: MetricPattern25, - pub min: MetricPattern1, - pub pct10: MetricPattern25, - pub pct25: MetricPattern25, - pub pct75: MetricPattern25, - pub pct90: MetricPattern25, - pub sum: MetricPattern1, + pub max: MetricPattern2, + pub median: MetricPattern21, + pub min: MetricPattern2, + pub pct10: MetricPattern21, + pub pct25: MetricPattern21, + pub pct75: MetricPattern21, + pub pct90: MetricPattern21, + pub sum: MetricPattern2, } impl BlockSizePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - average: MetricPattern1::new(client.clone(), _m(&acc, "avg")), + average: MetricPattern2::new(client.clone(), _m(&acc, "avg")), cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - max: MetricPattern1::new(client.clone(), _m(&acc, "max")), - median: MetricPattern25::new(client.clone(), _m(&acc, "median")), - min: MetricPattern1::new(client.clone(), _m(&acc, "min")), - pct10: MetricPattern25::new(client.clone(), _m(&acc, "pct10")), - pct25: MetricPattern25::new(client.clone(), _m(&acc, "pct25")), - pct75: MetricPattern25::new(client.clone(), _m(&acc, "pct75")), - pct90: MetricPattern25::new(client.clone(), _m(&acc, "pct90")), - sum: MetricPattern1::new(client.clone(), _m(&acc, "sum")), + max: MetricPattern2::new(client.clone(), _m(&acc, "max")), + median: MetricPattern21::new(client.clone(), _m(&acc, "median")), + min: MetricPattern2::new(client.clone(), _m(&acc, "min")), + pct10: MetricPattern21::new(client.clone(), _m(&acc, "pct10")), + pct25: MetricPattern21::new(client.clone(), _m(&acc, "pct25")), + pct75: MetricPattern21::new(client.clone(), _m(&acc, "pct75")), + pct90: MetricPattern21::new(client.clone(), _m(&acc, "pct90")), + sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), } } } @@ -3886,58 +3886,30 @@ impl UnrealizedPattern { } } -/// Pattern struct for repeated tree structure. -pub struct Constant0Pattern { - pub dateindex: MetricPattern21, - pub decadeindex: MetricPattern22, - pub height: MetricPattern25, - pub monthindex: MetricPattern27, - pub quarterindex: MetricPattern39, - pub semesterindex: MetricPattern40, - pub weekindex: MetricPattern43, - pub yearindex: MetricPattern44, -} - -impl Constant0Pattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - dateindex: MetricPattern21::new(client.clone(), acc.clone()), - decadeindex: MetricPattern22::new(client.clone(), acc.clone()), - height: MetricPattern25::new(client.clone(), acc.clone()), - monthindex: MetricPattern27::new(client.clone(), acc.clone()), - quarterindex: MetricPattern39::new(client.clone(), acc.clone()), - semesterindex: MetricPattern40::new(client.clone(), acc.clone()), - weekindex: MetricPattern43::new(client.clone(), acc.clone()), - yearindex: MetricPattern44::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct AddresstypeToHeightToAddrCountPattern { - pub p2a: MetricPattern25, - pub p2pk33: MetricPattern25, - pub p2pk65: MetricPattern25, - pub p2pkh: MetricPattern25, - pub p2sh: MetricPattern25, - pub p2tr: MetricPattern25, - pub p2wpkh: MetricPattern25, - pub p2wsh: MetricPattern25, + pub p2a: MetricPattern30, + pub p2pk33: MetricPattern32, + pub p2pk65: MetricPattern33, + pub p2pkh: MetricPattern34, + pub p2sh: MetricPattern35, + pub p2tr: MetricPattern36, + pub p2wpkh: MetricPattern37, + pub p2wsh: MetricPattern38, } impl AddresstypeToHeightToAddrCountPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - p2a: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2a".to_string() } else { format!("p2a_{acc}") }), - p2pk33: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2pk33".to_string() } else { format!("p2pk33_{acc}") }), - p2pk65: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2pk65".to_string() } else { format!("p2pk65_{acc}") }), - p2pkh: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2pkh".to_string() } else { format!("p2pkh_{acc}") }), - p2sh: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2sh".to_string() } else { format!("p2sh_{acc}") }), - p2tr: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2tr".to_string() } else { format!("p2tr_{acc}") }), - p2wpkh: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2wpkh".to_string() } else { format!("p2wpkh_{acc}") }), - p2wsh: MetricPattern25::new(client.clone(), if acc.is_empty() { "p2wsh".to_string() } else { format!("p2wsh_{acc}") }), + p2a: MetricPattern30::new(client.clone(), if acc.is_empty() { "p2a".to_string() } else { format!("p2a_{acc}") }), + p2pk33: MetricPattern32::new(client.clone(), if acc.is_empty() { "p2pk33".to_string() } else { format!("p2pk33_{acc}") }), + p2pk65: MetricPattern33::new(client.clone(), if acc.is_empty() { "p2pk65".to_string() } else { format!("p2pk65_{acc}") }), + p2pkh: MetricPattern34::new(client.clone(), if acc.is_empty() { "p2pkh".to_string() } else { format!("p2pkh_{acc}") }), + p2sh: MetricPattern35::new(client.clone(), if acc.is_empty() { "p2sh".to_string() } else { format!("p2sh_{acc}") }), + p2tr: MetricPattern36::new(client.clone(), if acc.is_empty() { "p2tr".to_string() } else { format!("p2tr_{acc}") }), + p2wpkh: MetricPattern37::new(client.clone(), if acc.is_empty() { "p2wpkh".to_string() } else { format!("p2wpkh_{acc}") }), + p2wsh: MetricPattern38::new(client.clone(), if acc.is_empty() { "p2wsh".to_string() } else { format!("p2wsh_{acc}") }), } } } @@ -3970,6 +3942,34 @@ impl BlockIntervalPattern { } } +/// Pattern struct for repeated tree structure. +pub struct Constant0Pattern { + pub dateindex: MetricPattern21, + pub decadeindex: MetricPattern22, + pub height: MetricPattern25, + pub monthindex: MetricPattern27, + pub quarterindex: MetricPattern39, + pub semesterindex: MetricPattern40, + pub weekindex: MetricPattern43, + pub yearindex: MetricPattern44, +} + +impl Constant0Pattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + dateindex: MetricPattern21::new(client.clone(), acc.clone()), + decadeindex: MetricPattern22::new(client.clone(), acc.clone()), + height: MetricPattern25::new(client.clone(), acc.clone()), + monthindex: MetricPattern27::new(client.clone(), acc.clone()), + quarterindex: MetricPattern39::new(client.clone(), acc.clone()), + semesterindex: MetricPattern40::new(client.clone(), acc.clone()), + weekindex: MetricPattern43::new(client.clone(), acc.clone()), + yearindex: MetricPattern44::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _0satsPattern { pub activity: ActivityPattern2, @@ -3996,6 +3996,30 @@ impl _0satsPattern { } } +/// Pattern struct for repeated tree structure. +pub struct UpTo1dPattern { + pub activity: ActivityPattern2, + pub cost_basis: CostBasisPattern2, + pub realized: RealizedPattern3, + pub relative: RelativePattern2, + pub supply: SupplyPattern3, + pub unrealized: UnrealizedPattern, +} + +impl UpTo1dPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + activity: ActivityPattern2::new(client.clone(), acc.clone()), + cost_basis: CostBasisPattern2::new(client.clone(), acc.clone()), + realized: RealizedPattern3::new(client.clone(), acc.clone()), + relative: RelativePattern2::new(client.clone(), acc.clone()), + supply: SupplyPattern3::new(client.clone(), acc.clone()), + unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _0satsPattern2 { pub activity: ActivityPattern2, @@ -4044,30 +4068,6 @@ impl _10yTo12yPattern { } } -/// Pattern struct for repeated tree structure. -pub struct UpTo1dPattern { - pub activity: ActivityPattern2, - pub cost_basis: CostBasisPattern2, - pub realized: RealizedPattern3, - pub relative: RelativePattern2, - pub supply: SupplyPattern3, - pub unrealized: UnrealizedPattern, -} - -impl UpTo1dPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - activity: ActivityPattern2::new(client.clone(), acc.clone()), - cost_basis: CostBasisPattern2::new(client.clone(), acc.clone()), - realized: RealizedPattern3::new(client.clone(), acc.clone()), - relative: RelativePattern2::new(client.clone(), acc.clone()), - supply: SupplyPattern3::new(client.clone(), acc.clone()), - unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct SegwitAdoptionPattern { pub average: MetricPattern2, @@ -4156,26 +4156,6 @@ impl SentPattern { } } -/// Pattern struct for repeated tree structure. -pub struct OpreturnPattern { - pub base: MetricPattern25, - pub bitcoin: BitcoinPattern2, - pub dollars: BitcoinPattern2, - pub sats: SatsPattern4, -} - -impl OpreturnPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - base: MetricPattern25::new(client.clone(), acc.clone()), - bitcoin: BitcoinPattern2::new(client.clone(), _m(&acc, "btc")), - dollars: BitcoinPattern2::new(client.clone(), _m(&acc, "usd")), - sats: SatsPattern4::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct SupplyPattern2 { pub base: MetricPattern25, @@ -4197,19 +4177,21 @@ impl SupplyPattern2 { } /// Pattern struct for repeated tree structure. -pub struct UnclaimedRewardsPattern { - pub bitcoin: BlockCountPattern, - pub dollars: BlockCountPattern, - pub sats: BlockCountPattern, +pub struct OpreturnPattern { + pub base: MetricPattern25, + pub bitcoin: BitcoinPattern2, + pub dollars: BitcoinPattern2, + pub sats: SatsPattern4, } -impl UnclaimedRewardsPattern { +impl OpreturnPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - bitcoin: BlockCountPattern::new(client.clone(), _m(&acc, "btc")), - dollars: BlockCountPattern::new(client.clone(), _m(&acc, "usd")), - sats: BlockCountPattern::new(client.clone(), acc.clone()), + base: MetricPattern25::new(client.clone(), acc.clone()), + bitcoin: BitcoinPattern2::new(client.clone(), _m(&acc, "btc")), + dollars: BitcoinPattern2::new(client.clone(), _m(&acc, "usd")), + sats: SatsPattern4::new(client.clone(), acc.clone()), } } } @@ -4232,24 +4214,6 @@ impl CoinbasePattern { } } -/// Pattern struct for repeated tree structure. -pub struct ActiveSupplyPattern { - pub bitcoin: MetricPattern1, - pub dollars: MetricPattern1, - pub sats: MetricPattern1, -} - -impl ActiveSupplyPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bitcoin: MetricPattern1::new(client.clone(), _m(&acc, "btc")), - dollars: MetricPattern1::new(client.clone(), _m(&acc, "usd")), - sats: MetricPattern1::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct CostBasisPattern2 { pub max_cost_basis: MetricPattern1, @@ -4269,19 +4233,37 @@ impl CostBasisPattern2 { } /// Pattern struct for repeated tree structure. -pub struct BlockCountPattern { - pub base: MetricPattern25, - pub cumulative: MetricPattern1, - pub sum: MetricPattern2, +pub struct UnclaimedRewardsPattern { + pub bitcoin: BlockCountPattern, + pub dollars: BlockCountPattern, + pub sats: BlockCountPattern, } -impl BlockCountPattern { +impl UnclaimedRewardsPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - base: MetricPattern25::new(client.clone(), acc.clone()), - cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), + bitcoin: BlockCountPattern::new(client.clone(), _m(&acc, "btc")), + dollars: BlockCountPattern::new(client.clone(), _m(&acc, "usd")), + sats: BlockCountPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct ActiveSupplyPattern { + pub bitcoin: MetricPattern1, + pub dollars: MetricPattern1, + pub sats: MetricPattern1, +} + +impl ActiveSupplyPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + bitcoin: MetricPattern1::new(client.clone(), _m(&acc, "btc")), + dollars: MetricPattern1::new(client.clone(), _m(&acc, "usd")), + sats: MetricPattern1::new(client.clone(), acc.clone()), } } } @@ -4305,49 +4287,19 @@ impl BitcoinPattern2 { } /// Pattern struct for repeated tree structure. -pub struct SatsPattern4 { - pub cumulative: MetricPattern1, - pub last: MetricPattern2, +pub struct BlockCountPattern { + pub base: MetricPattern25, + pub cumulative: MetricPattern1, + pub sum: MetricPattern2, } -impl SatsPattern4 { +impl BlockCountPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { + base: MetricPattern25::new(client.clone(), acc.clone()), cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - last: MetricPattern2::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct CostBasisPattern { - pub max_cost_basis: MetricPattern1, - pub min_cost_basis: MetricPattern1, -} - -impl CostBasisPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - max_cost_basis: MetricPattern1::new(client.clone(), _m(&acc, "max_cost_basis")), - min_cost_basis: MetricPattern1::new(client.clone(), _m(&acc, "min_cost_basis")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct SatsPattern { - pub cumulative: MetricPattern1, - pub sum: MetricPattern2, -} - -impl SatsPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - sum: MetricPattern2::new(client.clone(), acc.clone()), + sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), } } } @@ -4368,6 +4320,38 @@ impl _1dReturns1mSdPattern { } } +/// Pattern struct for repeated tree structure. +pub struct SatsPattern { + pub cumulative: MetricPattern1, + pub sum: MetricPattern2, +} + +impl SatsPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + sum: MetricPattern2::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CostBasisPattern { + pub max_cost_basis: MetricPattern1, + pub min_cost_basis: MetricPattern1, +} + +impl CostBasisPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + max_cost_basis: MetricPattern1::new(client.clone(), _m(&acc, "max_cost_basis")), + min_cost_basis: MetricPattern1::new(client.clone(), _m(&acc, "min_cost_basis")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct SupplyValuePattern { pub bitcoin: MetricPattern25, @@ -4384,6 +4368,22 @@ impl SupplyValuePattern { } } +/// Pattern struct for repeated tree structure. +pub struct SatsPattern4 { + pub cumulative: MetricPattern1, + pub last: MetricPattern2, +} + +impl SatsPattern4 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + last: MetricPattern2::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct TotalRealizedPnlPattern { pub base: MetricPattern25, diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index a7f356356..fa369ff37 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -2653,16 +2653,16 @@ function createRelativePattern(client, acc) { /** * @template T * @typedef {Object} BlockSizePattern - * @property {MetricPattern1} average + * @property {MetricPattern2} average * @property {MetricPattern1} cumulative - * @property {MetricPattern1} max - * @property {MetricPattern25} median - * @property {MetricPattern1} min - * @property {MetricPattern25} pct10 - * @property {MetricPattern25} pct25 - * @property {MetricPattern25} pct75 - * @property {MetricPattern25} pct90 - * @property {MetricPattern1} sum + * @property {MetricPattern2} max + * @property {MetricPattern21} median + * @property {MetricPattern2} min + * @property {MetricPattern21} pct10 + * @property {MetricPattern21} pct25 + * @property {MetricPattern21} pct75 + * @property {MetricPattern21} pct90 + * @property {MetricPattern2} sum */ /** @@ -2674,16 +2674,16 @@ function createRelativePattern(client, acc) { */ function createBlockSizePattern(client, acc) { return { - average: createMetricPattern1(client, _m(acc, 'avg')), + average: createMetricPattern2(client, _m(acc, 'avg')), cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), - max: createMetricPattern1(client, _m(acc, 'max')), - median: createMetricPattern25(client, _m(acc, 'median')), - min: createMetricPattern1(client, _m(acc, 'min')), - pct10: createMetricPattern25(client, _m(acc, 'pct10')), - pct25: createMetricPattern25(client, _m(acc, 'pct25')), - pct75: createMetricPattern25(client, _m(acc, 'pct75')), - pct90: createMetricPattern25(client, _m(acc, 'pct90')), - sum: createMetricPattern1(client, _m(acc, 'sum')), + max: createMetricPattern2(client, _m(acc, 'max')), + median: createMetricPattern21(client, _m(acc, 'median')), + min: createMetricPattern2(client, _m(acc, 'min')), + pct10: createMetricPattern21(client, _m(acc, 'pct10')), + pct25: createMetricPattern21(client, _m(acc, 'pct25')), + pct75: createMetricPattern21(client, _m(acc, 'pct75')), + pct90: createMetricPattern21(client, _m(acc, 'pct90')), + sum: createMetricPattern2(client, _m(acc, 'sum')), }; } @@ -2720,50 +2720,17 @@ function createUnrealizedPattern(client, acc) { }; } -/** - * @template T - * @typedef {Object} Constant0Pattern - * @property {MetricPattern21} dateindex - * @property {MetricPattern22} decadeindex - * @property {MetricPattern25} height - * @property {MetricPattern27} monthindex - * @property {MetricPattern39} quarterindex - * @property {MetricPattern40} semesterindex - * @property {MetricPattern43} weekindex - * @property {MetricPattern44} yearindex - */ - -/** - * Create a Constant0Pattern pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {Constant0Pattern} - */ -function createConstant0Pattern(client, acc) { - return { - dateindex: createMetricPattern21(client, acc), - decadeindex: createMetricPattern22(client, acc), - height: createMetricPattern25(client, acc), - monthindex: createMetricPattern27(client, acc), - quarterindex: createMetricPattern39(client, acc), - semesterindex: createMetricPattern40(client, acc), - weekindex: createMetricPattern43(client, acc), - yearindex: createMetricPattern44(client, acc), - }; -} - /** * @template T * @typedef {Object} AddresstypeToHeightToAddrCountPattern - * @property {MetricPattern25} p2a - * @property {MetricPattern25} p2pk33 - * @property {MetricPattern25} p2pk65 - * @property {MetricPattern25} p2pkh - * @property {MetricPattern25} p2sh - * @property {MetricPattern25} p2tr - * @property {MetricPattern25} p2wpkh - * @property {MetricPattern25} p2wsh + * @property {MetricPattern30} p2a + * @property {MetricPattern32} p2pk33 + * @property {MetricPattern33} p2pk65 + * @property {MetricPattern34} p2pkh + * @property {MetricPattern35} p2sh + * @property {MetricPattern36} p2tr + * @property {MetricPattern37} p2wpkh + * @property {MetricPattern38} p2wsh */ /** @@ -2775,14 +2742,14 @@ function createConstant0Pattern(client, acc) { */ function createAddresstypeToHeightToAddrCountPattern(client, acc) { return { - p2a: createMetricPattern25(client, (acc ? `p2a_${acc}` : 'p2a')), - p2pk33: createMetricPattern25(client, (acc ? `p2pk33_${acc}` : 'p2pk33')), - p2pk65: createMetricPattern25(client, (acc ? `p2pk65_${acc}` : 'p2pk65')), - p2pkh: createMetricPattern25(client, (acc ? `p2pkh_${acc}` : 'p2pkh')), - p2sh: createMetricPattern25(client, (acc ? `p2sh_${acc}` : 'p2sh')), - p2tr: createMetricPattern25(client, (acc ? `p2tr_${acc}` : 'p2tr')), - p2wpkh: createMetricPattern25(client, (acc ? `p2wpkh_${acc}` : 'p2wpkh')), - p2wsh: createMetricPattern25(client, (acc ? `p2wsh_${acc}` : 'p2wsh')), + p2a: createMetricPattern30(client, (acc ? `p2a_${acc}` : 'p2a')), + p2pk33: createMetricPattern32(client, (acc ? `p2pk33_${acc}` : 'p2pk33')), + p2pk65: createMetricPattern33(client, (acc ? `p2pk65_${acc}` : 'p2pk65')), + p2pkh: createMetricPattern34(client, (acc ? `p2pkh_${acc}` : 'p2pkh')), + p2sh: createMetricPattern35(client, (acc ? `p2sh_${acc}` : 'p2sh')), + p2tr: createMetricPattern36(client, (acc ? `p2tr_${acc}` : 'p2tr')), + p2wpkh: createMetricPattern37(client, (acc ? `p2wpkh_${acc}` : 'p2wpkh')), + p2wsh: createMetricPattern38(client, (acc ? `p2wsh_${acc}` : 'p2wsh')), }; } @@ -2819,6 +2786,39 @@ function createBlockIntervalPattern(client, acc) { }; } +/** + * @template T + * @typedef {Object} Constant0Pattern + * @property {MetricPattern21} dateindex + * @property {MetricPattern22} decadeindex + * @property {MetricPattern25} height + * @property {MetricPattern27} monthindex + * @property {MetricPattern39} quarterindex + * @property {MetricPattern40} semesterindex + * @property {MetricPattern43} weekindex + * @property {MetricPattern44} yearindex + */ + +/** + * Create a Constant0Pattern pattern node + * @template T + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {Constant0Pattern} + */ +function createConstant0Pattern(client, acc) { + return { + dateindex: createMetricPattern21(client, acc), + decadeindex: createMetricPattern22(client, acc), + height: createMetricPattern25(client, acc), + monthindex: createMetricPattern27(client, acc), + quarterindex: createMetricPattern39(client, acc), + semesterindex: createMetricPattern40(client, acc), + weekindex: createMetricPattern43(client, acc), + yearindex: createMetricPattern44(client, acc), + }; +} + /** * @typedef {Object} _0satsPattern * @property {ActivityPattern2} activity @@ -2848,6 +2848,33 @@ function create_0satsPattern(client, acc) { }; } +/** + * @typedef {Object} UpTo1dPattern + * @property {ActivityPattern2} activity + * @property {CostBasisPattern2} costBasis + * @property {RealizedPattern3} realized + * @property {RelativePattern2} relative + * @property {SupplyPattern3} supply + * @property {UnrealizedPattern} unrealized + */ + +/** + * Create a UpTo1dPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {UpTo1dPattern} + */ +function createUpTo1dPattern(client, acc) { + return { + activity: createActivityPattern2(client, acc), + costBasis: createCostBasisPattern2(client, acc), + realized: createRealizedPattern3(client, acc), + relative: createRelativePattern2(client, acc), + supply: createSupplyPattern3(client, acc), + unrealized: createUnrealizedPattern(client, acc), + }; +} + /** * @typedef {Object} _0satsPattern2 * @property {ActivityPattern2} activity @@ -2902,33 +2929,6 @@ function create_10yTo12yPattern(client, acc) { }; } -/** - * @typedef {Object} UpTo1dPattern - * @property {ActivityPattern2} activity - * @property {CostBasisPattern2} costBasis - * @property {RealizedPattern3} realized - * @property {RelativePattern2} relative - * @property {SupplyPattern3} supply - * @property {UnrealizedPattern} unrealized - */ - -/** - * Create a UpTo1dPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {UpTo1dPattern} - */ -function createUpTo1dPattern(client, acc) { - return { - activity: createActivityPattern2(client, acc), - costBasis: createCostBasisPattern2(client, acc), - realized: createRealizedPattern3(client, acc), - relative: createRelativePattern2(client, acc), - supply: createSupplyPattern3(client, acc), - unrealized: createUnrealizedPattern(client, acc), - }; -} - /** * @template T * @typedef {Object} SegwitAdoptionPattern @@ -3031,29 +3031,6 @@ function createSentPattern(client, acc) { }; } -/** - * @typedef {Object} OpreturnPattern - * @property {MetricPattern25} base - * @property {BitcoinPattern2} bitcoin - * @property {BitcoinPattern2} dollars - * @property {SatsPattern4} sats - */ - -/** - * Create a OpreturnPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {OpreturnPattern} - */ -function createOpreturnPattern(client, acc) { - return { - base: createMetricPattern25(client, acc), - bitcoin: createBitcoinPattern2(client, _m(acc, 'btc')), - dollars: createBitcoinPattern2(client, _m(acc, 'usd')), - sats: createSatsPattern4(client, acc), - }; -} - /** * @typedef {Object} SupplyPattern2 * @property {MetricPattern25} base @@ -3078,23 +3055,25 @@ function createSupplyPattern2(client, acc) { } /** - * @typedef {Object} UnclaimedRewardsPattern - * @property {BlockCountPattern} bitcoin - * @property {BlockCountPattern} dollars - * @property {BlockCountPattern} sats + * @typedef {Object} OpreturnPattern + * @property {MetricPattern25} base + * @property {BitcoinPattern2} bitcoin + * @property {BitcoinPattern2} dollars + * @property {SatsPattern4} sats */ /** - * Create a UnclaimedRewardsPattern pattern node + * Create a OpreturnPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {UnclaimedRewardsPattern} + * @returns {OpreturnPattern} */ -function createUnclaimedRewardsPattern(client, acc) { +function createOpreturnPattern(client, acc) { return { - bitcoin: createBlockCountPattern(client, _m(acc, 'btc')), - dollars: createBlockCountPattern(client, _m(acc, 'usd')), - sats: createBlockCountPattern(client, acc), + base: createMetricPattern25(client, acc), + bitcoin: createBitcoinPattern2(client, _m(acc, 'btc')), + dollars: createBitcoinPattern2(client, _m(acc, 'usd')), + sats: createSatsPattern4(client, acc), }; } @@ -3119,27 +3098,6 @@ function createCoinbasePattern(client, acc) { }; } -/** - * @typedef {Object} ActiveSupplyPattern - * @property {MetricPattern1} bitcoin - * @property {MetricPattern1} dollars - * @property {MetricPattern1} sats - */ - -/** - * Create a ActiveSupplyPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {ActiveSupplyPattern} - */ -function createActiveSupplyPattern(client, acc) { - return { - bitcoin: createMetricPattern1(client, _m(acc, 'btc')), - dollars: createMetricPattern1(client, _m(acc, 'usd')), - sats: createMetricPattern1(client, acc), - }; -} - /** * @typedef {Object} CostBasisPattern2 * @property {MetricPattern1} maxCostBasis @@ -3162,25 +3120,44 @@ function createCostBasisPattern2(client, acc) { } /** - * @template T - * @typedef {Object} BlockCountPattern - * @property {MetricPattern25} base - * @property {MetricPattern1} cumulative - * @property {MetricPattern2} sum + * @typedef {Object} UnclaimedRewardsPattern + * @property {BlockCountPattern} bitcoin + * @property {BlockCountPattern} dollars + * @property {BlockCountPattern} sats */ /** - * Create a BlockCountPattern pattern node - * @template T + * Create a UnclaimedRewardsPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {BlockCountPattern} + * @returns {UnclaimedRewardsPattern} */ -function createBlockCountPattern(client, acc) { +function createUnclaimedRewardsPattern(client, acc) { return { - base: createMetricPattern25(client, acc), - cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), - sum: createMetricPattern2(client, _m(acc, 'sum')), + bitcoin: createBlockCountPattern(client, _m(acc, 'btc')), + dollars: createBlockCountPattern(client, _m(acc, 'usd')), + sats: createBlockCountPattern(client, acc), + }; +} + +/** + * @typedef {Object} ActiveSupplyPattern + * @property {MetricPattern1} bitcoin + * @property {MetricPattern1} dollars + * @property {MetricPattern1} sats + */ + +/** + * Create a ActiveSupplyPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {ActiveSupplyPattern} + */ +function createActiveSupplyPattern(client, acc) { + return { + bitcoin: createMetricPattern1(client, _m(acc, 'btc')), + dollars: createMetricPattern1(client, _m(acc, 'usd')), + sats: createMetricPattern1(client, acc), }; } @@ -3208,59 +3185,25 @@ function createBitcoinPattern2(client, acc) { } /** - * @typedef {Object} SatsPattern4 - * @property {MetricPattern1} cumulative - * @property {MetricPattern2} last + * @template T + * @typedef {Object} BlockCountPattern + * @property {MetricPattern25} base + * @property {MetricPattern1} cumulative + * @property {MetricPattern2} sum */ /** - * Create a SatsPattern4 pattern node + * Create a BlockCountPattern pattern node + * @template T * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {SatsPattern4} + * @returns {BlockCountPattern} */ -function createSatsPattern4(client, acc) { +function createBlockCountPattern(client, acc) { return { + base: createMetricPattern25(client, acc), cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), - last: createMetricPattern2(client, acc), - }; -} - -/** - * @typedef {Object} CostBasisPattern - * @property {MetricPattern1} maxCostBasis - * @property {MetricPattern1} minCostBasis - */ - -/** - * Create a CostBasisPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CostBasisPattern} - */ -function createCostBasisPattern(client, acc) { - return { - maxCostBasis: createMetricPattern1(client, _m(acc, 'max_cost_basis')), - minCostBasis: createMetricPattern1(client, _m(acc, 'min_cost_basis')), - }; -} - -/** - * @typedef {Object} SatsPattern - * @property {MetricPattern1} cumulative - * @property {MetricPattern2} sum - */ - -/** - * Create a SatsPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {SatsPattern} - */ -function createSatsPattern(client, acc) { - return { - cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), - sum: createMetricPattern2(client, acc), + sum: createMetricPattern2(client, _m(acc, 'sum')), }; } @@ -3283,6 +3226,44 @@ function create_1dReturns1mSdPattern(client, acc) { }; } +/** + * @typedef {Object} SatsPattern + * @property {MetricPattern1} cumulative + * @property {MetricPattern2} sum + */ + +/** + * Create a SatsPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {SatsPattern} + */ +function createSatsPattern(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + sum: createMetricPattern2(client, acc), + }; +} + +/** + * @typedef {Object} CostBasisPattern + * @property {MetricPattern1} maxCostBasis + * @property {MetricPattern1} minCostBasis + */ + +/** + * Create a CostBasisPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CostBasisPattern} + */ +function createCostBasisPattern(client, acc) { + return { + maxCostBasis: createMetricPattern1(client, _m(acc, 'max_cost_basis')), + minCostBasis: createMetricPattern1(client, _m(acc, 'min_cost_basis')), + }; +} + /** * @typedef {Object} SupplyValuePattern * @property {MetricPattern25} bitcoin @@ -3302,6 +3283,25 @@ function createSupplyValuePattern(client, acc) { }; } +/** + * @typedef {Object} SatsPattern4 + * @property {MetricPattern1} cumulative + * @property {MetricPattern2} last + */ + +/** + * Create a SatsPattern4 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {SatsPattern4} + */ +function createSatsPattern4(client, acc) { + return { + cumulative: createMetricPattern1(client, _m(acc, 'cumulative')), + last: createMetricPattern2(client, acc), + }; +} + /** * @template T * @typedef {Object} TotalRealizedPnlPattern diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index 1d1952808..45b114b82 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -2539,16 +2539,16 @@ class BlockSizePattern(Generic[T]): def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.average: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'avg')) + self.average: MetricPattern2[T] = MetricPattern2(client, _m(acc, 'avg')) self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) - self.max: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'max')) - self.median: MetricPattern25[T] = MetricPattern25(client, _m(acc, 'median')) - self.min: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'min')) - self.pct10: MetricPattern25[T] = MetricPattern25(client, _m(acc, 'pct10')) - self.pct25: MetricPattern25[T] = MetricPattern25(client, _m(acc, 'pct25')) - self.pct75: MetricPattern25[T] = MetricPattern25(client, _m(acc, 'pct75')) - self.pct90: MetricPattern25[T] = MetricPattern25(client, _m(acc, 'pct90')) - self.sum: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'sum')) + self.max: MetricPattern2[T] = MetricPattern2(client, _m(acc, 'max')) + self.median: MetricPattern21[T] = MetricPattern21(client, _m(acc, 'median')) + self.min: MetricPattern2[T] = MetricPattern2(client, _m(acc, 'min')) + self.pct10: MetricPattern21[T] = MetricPattern21(client, _m(acc, 'pct10')) + self.pct25: MetricPattern21[T] = MetricPattern21(client, _m(acc, 'pct25')) + self.pct75: MetricPattern21[T] = MetricPattern21(client, _m(acc, 'pct75')) + self.pct90: MetricPattern21[T] = MetricPattern21(client, _m(acc, 'pct90')) + self.sum: MetricPattern2[T] = MetricPattern2(client, _m(acc, 'sum')) class UnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -2565,33 +2565,19 @@ class UnrealizedPattern: self.unrealized_loss: MetricPattern3[Dollars] = MetricPattern3(client, _m(acc, 'unrealized_loss')) self.unrealized_profit: MetricPattern3[Dollars] = MetricPattern3(client, _m(acc, 'unrealized_profit')) -class Constant0Pattern(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.dateindex: MetricPattern21[T] = MetricPattern21(client, acc) - self.decadeindex: MetricPattern22[T] = MetricPattern22(client, acc) - self.height: MetricPattern25[T] = MetricPattern25(client, acc) - self.monthindex: MetricPattern27[T] = MetricPattern27(client, acc) - self.quarterindex: MetricPattern39[T] = MetricPattern39(client, acc) - self.semesterindex: MetricPattern40[T] = MetricPattern40(client, acc) - self.weekindex: MetricPattern43[T] = MetricPattern43(client, acc) - self.yearindex: MetricPattern44[T] = MetricPattern44(client, acc) - class AddresstypeToHeightToAddrCountPattern(Generic[T]): """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.p2a: MetricPattern25[T] = MetricPattern25(client, (f'p2a_{{acc}}' if acc else 'p2a')) - self.p2pk33: MetricPattern25[T] = MetricPattern25(client, (f'p2pk33_{{acc}}' if acc else 'p2pk33')) - self.p2pk65: MetricPattern25[T] = MetricPattern25(client, (f'p2pk65_{{acc}}' if acc else 'p2pk65')) - self.p2pkh: MetricPattern25[T] = MetricPattern25(client, (f'p2pkh_{{acc}}' if acc else 'p2pkh')) - self.p2sh: MetricPattern25[T] = MetricPattern25(client, (f'p2sh_{{acc}}' if acc else 'p2sh')) - self.p2tr: MetricPattern25[T] = MetricPattern25(client, (f'p2tr_{{acc}}' if acc else 'p2tr')) - self.p2wpkh: MetricPattern25[T] = MetricPattern25(client, (f'p2wpkh_{{acc}}' if acc else 'p2wpkh')) - self.p2wsh: MetricPattern25[T] = MetricPattern25(client, (f'p2wsh_{{acc}}' if acc else 'p2wsh')) + self.p2a: MetricPattern30[T] = MetricPattern30(client, (f'p2a_{{acc}}' if acc else 'p2a')) + self.p2pk33: MetricPattern32[T] = MetricPattern32(client, (f'p2pk33_{{acc}}' if acc else 'p2pk33')) + self.p2pk65: MetricPattern33[T] = MetricPattern33(client, (f'p2pk65_{{acc}}' if acc else 'p2pk65')) + self.p2pkh: MetricPattern34[T] = MetricPattern34(client, (f'p2pkh_{{acc}}' if acc else 'p2pkh')) + self.p2sh: MetricPattern35[T] = MetricPattern35(client, (f'p2sh_{{acc}}' if acc else 'p2sh')) + self.p2tr: MetricPattern36[T] = MetricPattern36(client, (f'p2tr_{{acc}}' if acc else 'p2tr')) + self.p2wpkh: MetricPattern37[T] = MetricPattern37(client, (f'p2wpkh_{{acc}}' if acc else 'p2wpkh')) + self.p2wsh: MetricPattern38[T] = MetricPattern38(client, (f'p2wsh_{{acc}}' if acc else 'p2wsh')) class BlockIntervalPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2607,6 +2593,20 @@ class BlockIntervalPattern(Generic[T]): self.pct75: MetricPattern25[T] = MetricPattern25(client, _m(acc, 'pct75')) self.pct90: MetricPattern25[T] = MetricPattern25(client, _m(acc, 'pct90')) +class Constant0Pattern(Generic[T]): + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.dateindex: MetricPattern21[T] = MetricPattern21(client, acc) + self.decadeindex: MetricPattern22[T] = MetricPattern22(client, acc) + self.height: MetricPattern25[T] = MetricPattern25(client, acc) + self.monthindex: MetricPattern27[T] = MetricPattern27(client, acc) + self.quarterindex: MetricPattern39[T] = MetricPattern39(client, acc) + self.semesterindex: MetricPattern40[T] = MetricPattern40(client, acc) + self.weekindex: MetricPattern43[T] = MetricPattern43(client, acc) + self.yearindex: MetricPattern44[T] = MetricPattern44(client, acc) + class _0satsPattern: """Pattern struct for repeated tree structure.""" @@ -2620,6 +2620,18 @@ class _0satsPattern: self.supply: SupplyPattern3 = SupplyPattern3(client, acc) self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) +class UpTo1dPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.activity: ActivityPattern2 = ActivityPattern2(client, acc) + self.cost_basis: CostBasisPattern2 = CostBasisPattern2(client, acc) + self.realized: RealizedPattern3 = RealizedPattern3(client, acc) + self.relative: RelativePattern2 = RelativePattern2(client, acc) + self.supply: SupplyPattern3 = SupplyPattern3(client, acc) + self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) + class _0satsPattern2: """Pattern struct for repeated tree structure.""" @@ -2644,18 +2656,6 @@ class _10yTo12yPattern: self.supply: SupplyPattern3 = SupplyPattern3(client, acc) self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) -class UpTo1dPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.activity: ActivityPattern2 = ActivityPattern2(client, acc) - self.cost_basis: CostBasisPattern2 = CostBasisPattern2(client, acc) - self.realized: RealizedPattern3 = RealizedPattern3(client, acc) - self.relative: RelativePattern2 = RelativePattern2(client, acc) - self.supply: SupplyPattern3 = SupplyPattern3(client, acc) - self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) - class SegwitAdoptionPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2700,16 +2700,6 @@ class SentPattern: self.dollars: BlockCountPattern[Dollars] = BlockCountPattern(client, _m(acc, 'usd')) self.sats: SatsPattern = SatsPattern(client, acc) -class OpreturnPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.base: MetricPattern25[Sats] = MetricPattern25(client, acc) - self.bitcoin: BitcoinPattern2[Bitcoin] = BitcoinPattern2(client, _m(acc, 'btc')) - self.dollars: BitcoinPattern2[Dollars] = BitcoinPattern2(client, _m(acc, 'usd')) - self.sats: SatsPattern4 = SatsPattern4(client, acc) - class SupplyPattern2: """Pattern struct for repeated tree structure.""" @@ -2720,14 +2710,15 @@ class SupplyPattern2: self.dollars: MetricPattern4[Dollars] = MetricPattern4(client, _m(acc, 'usd')) self.sats: MetricPattern4[Sats] = MetricPattern4(client, acc) -class UnclaimedRewardsPattern: +class OpreturnPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.bitcoin: BlockCountPattern[Bitcoin] = BlockCountPattern(client, _m(acc, 'btc')) - self.dollars: BlockCountPattern[Dollars] = BlockCountPattern(client, _m(acc, 'usd')) - self.sats: BlockCountPattern[Sats] = BlockCountPattern(client, acc) + self.base: MetricPattern25[Sats] = MetricPattern25(client, acc) + self.bitcoin: BitcoinPattern2[Bitcoin] = BitcoinPattern2(client, _m(acc, 'btc')) + self.dollars: BitcoinPattern2[Dollars] = BitcoinPattern2(client, _m(acc, 'usd')) + self.sats: SatsPattern4 = SatsPattern4(client, acc) class CoinbasePattern: """Pattern struct for repeated tree structure.""" @@ -2738,15 +2729,6 @@ class CoinbasePattern: self.dollars: BitcoinPattern[Dollars] = BitcoinPattern(client, _m(acc, 'usd')) self.sats: BitcoinPattern[Sats] = BitcoinPattern(client, acc) -class ActiveSupplyPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.bitcoin: MetricPattern1[Bitcoin] = MetricPattern1(client, _m(acc, 'btc')) - self.dollars: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) - self.sats: MetricPattern1[Sats] = MetricPattern1(client, acc) - class CostBasisPattern2: """Pattern struct for repeated tree structure.""" @@ -2756,14 +2738,23 @@ class CostBasisPattern2: self.min_cost_basis: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'min_cost_basis')) self.percentiles: PercentilesPattern = PercentilesPattern(client, _m(acc, 'cost_basis')) -class BlockCountPattern(Generic[T]): +class UnclaimedRewardsPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.base: MetricPattern25[T] = MetricPattern25(client, acc) - self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) - self.sum: MetricPattern2[T] = MetricPattern2(client, _m(acc, 'sum')) + self.bitcoin: BlockCountPattern[Bitcoin] = BlockCountPattern(client, _m(acc, 'btc')) + self.dollars: BlockCountPattern[Dollars] = BlockCountPattern(client, _m(acc, 'usd')) + self.sats: BlockCountPattern[Sats] = BlockCountPattern(client, acc) + +class ActiveSupplyPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.bitcoin: MetricPattern1[Bitcoin] = MetricPattern1(client, _m(acc, 'btc')) + self.dollars: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'usd')) + self.sats: MetricPattern1[Sats] = MetricPattern1(client, acc) class BitcoinPattern2(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -2774,29 +2765,14 @@ class BitcoinPattern2(Generic[T]): self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) self.last: MetricPattern2[T] = MetricPattern2(client, acc) -class SatsPattern4: +class BlockCountPattern(Generic[T]): """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.cumulative: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'cumulative')) - self.last: MetricPattern2[Sats] = MetricPattern2(client, acc) - -class CostBasisPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.max_cost_basis: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'max_cost_basis')) - self.min_cost_basis: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'min_cost_basis')) - -class SatsPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.cumulative: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'cumulative')) - self.sum: MetricPattern2[Sats] = MetricPattern2(client, acc) + self.base: MetricPattern25[T] = MetricPattern25(client, acc) + self.cumulative: MetricPattern1[T] = MetricPattern1(client, _m(acc, 'cumulative')) + self.sum: MetricPattern2[T] = MetricPattern2(client, _m(acc, 'sum')) class _1dReturns1mSdPattern: """Pattern struct for repeated tree structure.""" @@ -2806,6 +2782,22 @@ class _1dReturns1mSdPattern: self.sd: MetricPattern4[StoredF32] = MetricPattern4(client, _m(acc, 'sd')) self.sma: MetricPattern4[StoredF32] = MetricPattern4(client, _m(acc, 'sma')) +class SatsPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'cumulative')) + self.sum: MetricPattern2[Sats] = MetricPattern2(client, acc) + +class CostBasisPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.max_cost_basis: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'max_cost_basis')) + self.min_cost_basis: MetricPattern1[Dollars] = MetricPattern1(client, _m(acc, 'min_cost_basis')) + class SupplyValuePattern: """Pattern struct for repeated tree structure.""" @@ -2814,6 +2806,14 @@ class SupplyValuePattern: self.bitcoin: MetricPattern25[Bitcoin] = MetricPattern25(client, _m(acc, 'btc')) self.dollars: MetricPattern25[Dollars] = MetricPattern25(client, _m(acc, 'usd')) +class SatsPattern4: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.cumulative: MetricPattern1[Sats] = MetricPattern1(client, _m(acc, 'cumulative')) + self.last: MetricPattern2[Sats] = MetricPattern2(client, acc) + class TotalRealizedPnlPattern(Generic[T]): """Pattern struct for repeated tree structure.""" diff --git a/websites/bitview/scripts/entry.js b/websites/bitview/scripts/entry.js index bde283312..ffcb5fe71 100644 --- a/websites/bitview/scripts/entry.js +++ b/websites/bitview/scripts/entry.js @@ -40,17 +40,17 @@ * @typedef {AllUtxoPattern | MinAgePattern | UtxoAmountPattern} PatternWithRealizedPrice * @typedef {AllUtxoPattern} PatternWithFullRealized * @typedef {AllUtxoPattern | MinAgePattern | UtxoAmountPattern} PatternWithNupl - * @typedef {AllUtxoPattern | MinAgePattern | UtxoAmountPattern} PatternWithPricePaidStats + * @typedef {AllUtxoPattern | MinAgePattern | UtxoAmountPattern} PatternWithCostBasis * @typedef {AllUtxoPattern | MinAgePattern | UtxoAmountPattern} PatternWithActivity - * @typedef {AllUtxoPattern | MaxAgePattern | MinAgePattern} PatternWithPricePercentiles + * @typedef {AllUtxoPattern | MaxAgePattern | MinAgePattern} PatternWithCostBasisPercentiles * * Cohort objects with specific pattern capabilities * @typedef {{ name: string, title: string, color: Color, tree: PatternWithRealizedPrice }} CohortWithRealizedPrice * @typedef {{ name: string, title: string, color: Color, tree: PatternWithFullRealized }} CohortWithFullRealized * @typedef {{ name: string, title: string, color: Color, tree: PatternWithNupl }} CohortWithNupl - * @typedef {{ name: string, title: string, color: Color, tree: PatternWithPricePaidStats }} CohortWithPricePaidStats + * @typedef {{ name: string, title: string, color: Color, tree: PatternWithCostBasis }} CohortWithCostBasis * @typedef {{ name: string, title: string, color: Color, tree: PatternWithActivity }} CohortWithActivity - * @typedef {{ name: string, title: string, color: Color, tree: PatternWithPricePercentiles }} CohortWithPricePercentiles + * @typedef {{ name: string, title: string, color: Color, tree: PatternWithCostBasisPercentiles }} CohortWithCostBasisPercentiles * * Tree branch types * @typedef {InstanceType["tree"]["computed"]["market"]} Market diff --git a/websites/bitview/scripts/options/partial.js b/websites/bitview/scripts/options/partial.js index 8052f135c..b1d68f51a 100644 --- a/websites/bitview/scripts/options/partial.js +++ b/websites/bitview/scripts/options/partial.js @@ -2500,7 +2500,7 @@ export function createPartialOptions({ colors, brk }) { top: list.flatMap(({ color, name, tree }) => { return /** @type {const} */ ([ s({ - metric: tree.pricePaid.minPricePaid, + metric: tree.costBasis.minCostBasis, name, color: color, }), @@ -2513,7 +2513,7 @@ export function createPartialOptions({ colors, brk }) { top: list.flatMap(({ color, name, tree }) => { return /** @type {const} */ ([ s({ - metric: tree.pricePaid.maxPricePaid, + metric: tree.costBasis.maxCostBasis, name, color: color, }), @@ -2526,7 +2526,7 @@ export function createPartialOptions({ colors, brk }) { : [ { name: "Cost Basis", - title: `Costs Basis ${title}`, + title: `Cost Basis ${title}`, top: [ s({ metric: args.tree.realizedPrice, @@ -2534,13 +2534,13 @@ export function createPartialOptions({ colors, brk }) { color: args.color, }), s({ - metric: args.tree.pricePaid.minPricePaid, + metric: args.tree.costBasis.minCostBasis, name: "Min", color: colors.green, defaultActive: false, }), s({ - metric: args.tree.pricePaid.maxPricePaid, + metric: args.tree.costBasis.maxCostBasis, name: "Max", color: colors.red, }), diff --git a/websites/bitview/scripts/options/partial/cohorts/address.js b/websites/bitview/scripts/options/partial/cohorts/address.js index f23f62e70..71a71ebd9 100644 --- a/websites/bitview/scripts/options/partial/cohorts/address.js +++ b/websites/bitview/scripts/options/partial/cohorts/address.js @@ -1,7 +1,7 @@ /** * Address cohort folder builder * Creates option trees for address-based cohorts (has addrCount) - * Address cohorts use _0satsPattern which has PricePaidPattern (no percentiles) + * Address cohorts use _0satsPattern which has CostBasisPattern (no percentiles) */ import { @@ -104,8 +104,8 @@ export function createAddressCohortFolder(ctx, args) { // Unrealized section ...createUnrealizedSection(ctx, list, useGroupName, title), - // Price paid section (no percentiles for address cohorts) - ...createPricePaidSection(ctx, list, useGroupName, title), + // Cost basis section (no percentiles for address cohorts) + ...createCostBasisSection(ctx, list, useGroupName, title), // Activity section ...createActivitySection(ctx, list, useGroupName, title), @@ -237,32 +237,32 @@ function createUnrealizedSection(ctx, list, useGroupName, title) { } /** - * Create price paid section (no percentiles for address cohorts) + * Create cost basis section (no percentiles for address cohorts) * @param {PartialContext} ctx * @param {readonly AddressCohortObject[]} list * @param {boolean} useGroupName * @param {string} title * @returns {PartialOptionsTree} */ -function createPricePaidSection(ctx, list, useGroupName, title) { +function createCostBasisSection(ctx, list, useGroupName, title) { const { s } = ctx; return [ { - name: "Price Paid", + name: "Cost Basis", tree: [ { name: "min", - title: `Min Price Paid ${title}`, + title: `Min Cost Basis ${title}`, top: list.map(({ color, name, tree }) => - s({ metric: tree.pricePaid.minPricePaid, name: useGroupName ? name : "Min", color }), + s({ metric: tree.costBasis.minCostBasis, name: useGroupName ? name : "Min", color }), ), }, { name: "max", - title: `Max Price Paid ${title}`, + title: `Max Cost Basis ${title}`, top: list.map(({ color, name, tree }) => - s({ metric: tree.pricePaid.maxPricePaid, name: useGroupName ? name : "Max", color }), + s({ metric: tree.costBasis.maxCostBasis, name: useGroupName ? name : "Max", color }), ), }, ], diff --git a/websites/bitview/scripts/options/partial/cohorts/index.js b/websites/bitview/scripts/options/partial/cohorts/index.js index 6437b415f..bcefac5e9 100644 --- a/websites/bitview/scripts/options/partial/cohorts/index.js +++ b/websites/bitview/scripts/options/partial/cohorts/index.js @@ -20,6 +20,6 @@ export { createRealizedPriceSeries, createRealizedPriceRatioSeries, createRealizedCapSeries, - createPricePaidMinMaxSeries, - createPricePercentilesSeries, + createCostBasisMinMaxSeries, + createCostBasisPercentilesSeries, } from "./shared.js"; diff --git a/websites/bitview/scripts/options/partial/cohorts/shared.js b/websites/bitview/scripts/options/partial/cohorts/shared.js index 365a02c14..4e8c1a525 100644 --- a/websites/bitview/scripts/options/partial/cohorts/shared.js +++ b/websites/bitview/scripts/options/partial/cohorts/shared.js @@ -178,39 +178,39 @@ export function createRealizedCapSeries(ctx, list, useGroupName) { } /** - * Create price paid min/max series (available on all cohorts) + * Create cost basis min/max series (available on all cohorts) * @param {PartialContext} ctx * @param {readonly CohortObject[]} list * @param {boolean} useGroupName * @returns {AnyFetchedSeriesBlueprint[]} */ -export function createPricePaidMinMaxSeries(ctx, list, useGroupName) { +export function createCostBasisMinMaxSeries(ctx, list, useGroupName) { const { s } = ctx; return list.flatMap(({ color, name, tree }) => [ - s({ metric: tree.pricePaid.minPricePaid, name: useGroupName ? `${name} min` : "Min", color }), - s({ metric: tree.pricePaid.maxPricePaid, name: useGroupName ? `${name} max` : "Max", color }), + s({ metric: tree.costBasis.minCostBasis, name: useGroupName ? `${name} min` : "Min", color }), + s({ metric: tree.costBasis.maxCostBasis, name: useGroupName ? `${name} max` : "Max", color }), ]); } /** - * Create price percentile series (only for cohorts with PricePaidPattern2) + * Create cost basis percentile series (only for cohorts with CostBasisPattern2) * @param {PartialContext} ctx - * @param {readonly CohortWithPricePercentiles[]} list + * @param {readonly CohortWithCostBasisPercentiles[]} list * @param {boolean} useGroupName * @returns {AnyFetchedSeriesBlueprint[]} */ -export function createPricePercentilesSeries(ctx, list, useGroupName) { +export function createCostBasisPercentilesSeries(ctx, list, useGroupName) { const { s, colors } = ctx; return list.flatMap(({ color, name, tree }) => { - const pp = tree.pricePaid.pricePercentiles; + const percentiles = tree.costBasis.percentiles; return [ - s({ metric: pp.pct10, name: useGroupName ? `${name} p10` : "p10", color, defaultActive: false }), - s({ metric: pp.pct25, name: useGroupName ? `${name} p25` : "p25", color, defaultActive: false }), - s({ metric: pp.pct50, name: useGroupName ? `${name} p50` : "p50", color }), - s({ metric: pp.pct75, name: useGroupName ? `${name} p75` : "p75", color, defaultActive: false }), - s({ metric: pp.pct90, name: useGroupName ? `${name} p90` : "p90", color, defaultActive: false }), + s({ metric: percentiles.pct10, name: useGroupName ? `${name} p10` : "p10", color, defaultActive: false }), + s({ metric: percentiles.pct25, name: useGroupName ? `${name} p25` : "p25", color, defaultActive: false }), + s({ metric: percentiles.pct50, name: useGroupName ? `${name} p50` : "p50", color }), + s({ metric: percentiles.pct75, name: useGroupName ? `${name} p75` : "p75", color, defaultActive: false }), + s({ metric: percentiles.pct90, name: useGroupName ? `${name} p90` : "p90", color, defaultActive: false }), ]; }); } diff --git a/websites/bitview/scripts/options/partial/cohorts/utxo.js b/websites/bitview/scripts/options/partial/cohorts/utxo.js index e67be375d..1ae8cbfaa 100644 --- a/websites/bitview/scripts/options/partial/cohorts/utxo.js +++ b/websites/bitview/scripts/options/partial/cohorts/utxo.js @@ -3,8 +3,8 @@ * Creates option trees for UTXO-based cohorts (no addrCount) * * Two main builders: - * - createAgeCohortFolder: For term, maxAge, minAge, ageRange, epoch (has price percentiles) - * - createAmountCohortFolder: For geAmount, ltAmount, amountRange, type (no price percentiles) + * - createAgeCohortFolder: For term, maxAge, minAge, ageRange, epoch (has cost basis percentiles) + * - createAmountCohortFolder: For geAmount, ltAmount, amountRange, type (no cost basis percentiles) */ import { @@ -16,13 +16,13 @@ import { createRealizedPriceSeries, createRealizedPriceRatioSeries, createRealizedCapSeries, - createPricePaidMinMaxSeries, - createPricePercentilesSeries, + createCostBasisMinMaxSeries, + createCostBasisPercentilesSeries, } from "./shared.js"; /** * Create a cohort folder for age-based UTXO cohorts (term, maxAge, minAge, ageRange, epoch) - * These cohorts have price percentiles via PricePaidPattern2 + * These cohorts have cost basis percentiles via CostBasisPattern2 * @param {PartialContext} ctx * @param {AgeCohortObject | AgeCohortGroupObject} args * @returns {PartialOptionsGroup} @@ -40,7 +40,7 @@ export function createAgeCohortFolder(ctx, args) { createUtxoCountSection(ctx, list, useGroupName, title), createRealizedSection(ctx, list, args, useGroupName, isSingle, title), ...createUnrealizedSection(ctx, list, useGroupName, title), - ...createPricePaidSectionWithPercentiles(ctx, list, useGroupName, title), + ...createCostBasisSectionWithPercentiles(ctx, list, useGroupName, title), ...createActivitySection(ctx, list, useGroupName, title), ], }; @@ -48,7 +48,7 @@ export function createAgeCohortFolder(ctx, args) { /** * Create a cohort folder for amount-based UTXO cohorts (geAmount, ltAmount, amountRange, type) - * These cohorts have only min/max price paid via PricePaidPattern + * These cohorts have only min/max cost basis via CostBasisPattern * @param {PartialContext} ctx * @param {AmountCohortObject | AmountCohortGroupObject} args * @returns {PartialOptionsGroup} @@ -66,7 +66,7 @@ export function createAmountCohortFolder(ctx, args) { createUtxoCountSection(ctx, list, useGroupName, title), createRealizedSection(ctx, list, args, useGroupName, isSingle, title), ...createUnrealizedSection(ctx, list, useGroupName, title), - ...createPricePaidSectionBasic(ctx, list, useGroupName, title), + ...createCostBasisSectionBasic(ctx, list, useGroupName, title), ...createActivitySection(ctx, list, useGroupName, title), ], }; @@ -87,7 +87,7 @@ export function createUtxoCohortFolder(ctx, args) { const title = args.title ? `${useGroupName ? "by" : "of"} ${args.title}` : ""; // Runtime check for percentiles - const hasPercentiles = "pricePercentiles" in list[0].tree.pricePaid; + const hasPercentiles = "percentiles" in list[0].tree.costBasis; return { name: args.name || "all", @@ -97,8 +97,8 @@ export function createUtxoCohortFolder(ctx, args) { createRealizedSection(ctx, list, args, useGroupName, isSingle, title), ...createUnrealizedSection(ctx, list, useGroupName, title), ...(hasPercentiles - ? createPricePaidSectionWithPercentiles(ctx, /** @type {readonly AgeCohortObject[]} */ (list), useGroupName, title) - : createPricePaidSectionBasic(ctx, list, useGroupName, title)), + ? createCostBasisSectionWithPercentiles(ctx, /** @type {readonly AgeCohortObject[]} */ (list), useGroupName, title) + : createCostBasisSectionBasic(ctx, list, useGroupName, title)), ...createActivitySection(ctx, list, useGroupName, title), ], }; @@ -372,38 +372,38 @@ function createUnrealizedSection(ctx, list, useGroupName, title) { } /** - * Create price paid section for cohorts WITH percentiles (age cohorts) + * Create cost basis section for cohorts WITH percentiles (age cohorts) * @param {PartialContext} ctx * @param {readonly AgeCohortObject[]} list * @param {boolean} useGroupName * @param {string} title * @returns {PartialOptionsTree} */ -function createPricePaidSectionWithPercentiles(ctx, list, useGroupName, title) { +function createCostBasisSectionWithPercentiles(ctx, list, useGroupName, title) { const { s } = ctx; return [ { - name: "Price Paid", + name: "Cost Basis", tree: [ { name: "min", - title: `Min Price Paid ${title}`, + title: `Min Cost Basis ${title}`, top: list.map(({ color, name, tree }) => - s({ metric: tree.pricePaid.minPricePaid, name: useGroupName ? name : "Min", color }), + s({ metric: tree.costBasis.minCostBasis, name: useGroupName ? name : "Min", color }), ), }, { name: "max", - title: `Max Price Paid ${title}`, + title: `Max Cost Basis ${title}`, top: list.map(({ color, name, tree }) => - s({ metric: tree.pricePaid.maxPricePaid, name: useGroupName ? name : "Max", color }), + s({ metric: tree.costBasis.maxCostBasis, name: useGroupName ? name : "Max", color }), ), }, { name: "percentiles", - title: `Price Paid Percentiles ${title}`, - top: createPricePercentilesSeries(ctx, list, useGroupName), + title: `Cost Basis Percentiles ${title}`, + top: createCostBasisPercentilesSeries(ctx, list, useGroupName), }, ], }, @@ -411,32 +411,32 @@ function createPricePaidSectionWithPercentiles(ctx, list, useGroupName, title) { } /** - * Create price paid section for cohorts WITHOUT percentiles (amount cohorts) + * Create cost basis section for cohorts WITHOUT percentiles (amount cohorts) * @param {PartialContext} ctx * @param {readonly UtxoCohortObject[]} list * @param {boolean} useGroupName * @param {string} title * @returns {PartialOptionsTree} */ -function createPricePaidSectionBasic(ctx, list, useGroupName, title) { +function createCostBasisSectionBasic(ctx, list, useGroupName, title) { const { s } = ctx; return [ { - name: "Price Paid", + name: "Cost Basis", tree: [ { name: "min", - title: `Min Price Paid ${title}`, + title: `Min Cost Basis ${title}`, top: list.map(({ color, name, tree }) => - s({ metric: tree.pricePaid.minPricePaid, name: useGroupName ? name : "Min", color }), + s({ metric: tree.costBasis.minCostBasis, name: useGroupName ? name : "Min", color }), ), }, { name: "max", - title: `Max Price Paid ${title}`, + title: `Max Cost Basis ${title}`, top: list.map(({ color, name, tree }) => - s({ metric: tree.pricePaid.maxPricePaid, name: useGroupName ? name : "Max", color }), + s({ metric: tree.costBasis.maxCostBasis, name: useGroupName ? name : "Max", color }), ), }, ], diff --git a/websites/bitview/scripts/options/partial/types.js b/websites/bitview/scripts/options/partial/types.js index bf1535cf3..53abb8c59 100644 --- a/websites/bitview/scripts/options/partial/types.js +++ b/websites/bitview/scripts/options/partial/types.js @@ -121,14 +121,14 @@ * @property {Color} color * @property {UtxoCohortPattern} tree * - * Age cohorts (term, maxAge, minAge, ageRange, epoch) - have price percentiles + * Age cohorts (term, maxAge, minAge, ageRange, epoch) - have cost basis percentiles * @typedef {Object} AgeCohortObject * @property {string} name * @property {string} title * @property {Color} color - * @property {PatternWithPricePercentiles} tree + * @property {PatternWithCostBasisPercentiles} tree * - * Amount cohorts (geAmount, ltAmount, amountRange, type) - no price percentiles + * Amount cohorts (geAmount, ltAmount, amountRange, type) - no cost basis percentiles * @typedef {Object} AmountCohortObject * @property {string} name * @property {string} title diff --git a/websites/bitview/scripts/panes/simulation.js b/websites/bitview/scripts/panes/simulation.js index 79597f1c1..f9934f6a4 100644 --- a/websites/bitview/scripts/panes/simulation.js +++ b/websites/bitview/scripts/panes/simulation.js @@ -644,7 +644,7 @@ export function init({ colors, createChartElement, signals, resources }) { equals: false, }, ); - const averagePricePaidData = signals.createSignal( + const averageCostBasisData = signals.createSignal( /** @type {LineData[]} */ ([]), { equals: false, @@ -772,7 +772,7 @@ export function init({ colors, createChartElement, signals, resources }) { title: "Average Cost Basis", type: "Line", color: colors.lime, - data: averagePricePaidData, + data: averageCostBasisData, }, ], }, @@ -873,7 +873,7 @@ export function init({ colors, createChartElement, signals, resources }) { totalValueData().length = 0; investmentData().length = 0; bitcoinAddedData().length = 0; - averagePricePaidData().length = 0; + averageCostBasisData().length = 0; bitcoinPriceData().length = 0; buyCountData().length = 0; totalFeesPaidData().length = 0; @@ -887,7 +887,7 @@ export function init({ colors, createChartElement, signals, resources }) { let investedAmount = 0; let postFeesInvestedAmount = 0; let buyCount = 0; - let averagePricePaid = 0; + let averageCostBasis = 0; let bitcoinValue = 0; let roi = 0; let totalValue = 0; @@ -951,7 +951,7 @@ export function init({ colors, createChartElement, signals, resources }) { totalValue = dollars + bitcoinValue; - averagePricePaid = postFeesInvestedAmount / bitcoin; + averageCostBasis = postFeesInvestedAmount / bitcoin; roi = (bitcoinValue / postFeesInvestedAmount - 1) * 100; @@ -1010,9 +1010,9 @@ export function init({ colors, createChartElement, signals, resources }) { value: bitcoinAdded, }); - averagePricePaidData().push({ + averageCostBasisData().push({ time, - value: averagePricePaid, + value: averageCostBasis, }); buyCountData().push({ @@ -1057,12 +1057,12 @@ export function init({ colors, createChartElement, signals, resources }) { const serSats = c("orange", f(sats)); const serBitcoin = c("orange", `~${f(bitcoin)}`); const serBitcoinValue = c("amber", fd(bitcoinValue)); - const serAveragePricePaid = c("lime", fd(averagePricePaid)); + const serAverageCostBasis = c("lime", fd(averageCostBasis)); const serRoi = c("yellow", fp(roi / 100)); const serDollars = c("emerald", fd(dollars)); const serTotalFeesPaid = c("rose", fd(totalFeesPaid)); - p1.innerHTML = `After exchanging ${serInvestedAmount} in the span of ${serDaysCount} days, you would have accumulated ${serSats} Satoshis (${serBitcoin} Bitcoin) worth today ${serBitcoinValue} at an average price of ${serAveragePricePaid} per Bitcoin with a return of investment of ${serRoi}, have ${serDollars} left and paid a total of ${serTotalFeesPaid} in fees.`; + p1.innerHTML = `After exchanging ${serInvestedAmount} in the span of ${serDaysCount} days, you would have accumulated ${serSats} Satoshis (${serBitcoin} Bitcoin) worth today ${serBitcoinValue} at an average cost basis of ${serAverageCostBasis} per Bitcoin with a return of investment of ${serRoi}, have ${serDollars} left and paid a total of ${serTotalFeesPaid} in fees.`; const dayDiff = Math.floor( differenceBetweenDates(new Date(), lastInvestDay), @@ -1092,7 +1092,7 @@ export function init({ colors, createChartElement, signals, resources }) { totalValueData.set((a) => a); investmentData.set((a) => a); bitcoinAddedData.set((a) => a); - averagePricePaidData.set((a) => a); + averageCostBasisData.set((a) => a); bitcoinPriceData.set((a) => a); buyCountData.set((a) => a); totalFeesPaidData.set((a) => a); diff --git a/websites/bitview/scripts/utils/serde.js b/websites/bitview/scripts/utils/serde.js index cd550b1fe..7ea4e907d 100644 --- a/websites/bitview/scripts/utils/serde.js +++ b/websites/bitview/scripts/utils/serde.js @@ -308,7 +308,7 @@ export const serdeUnit = { (v.includes("_usd") && !v.endsWith("velocity")) || v.includes("cointime_value") || v.endsWith("_ago") || - v.endsWith("price_paid") || + v.endsWith("cost_basis") || v.endsWith("_price") || (v.startsWith("price") && (v.endsWith("min") || v.endsWith("max"))) || (v.endsWith("_cap") && !v.includes("rel_to")) ||