diff --git a/crates/brk_bindgen/src/generate/tree.rs b/crates/brk_bindgen/src/generate/tree.rs index 0f1ac017c..c80baa029 100644 --- a/crates/brk_bindgen/src/generate/tree.rs +++ b/crates/brk_bindgen/src/generate/tree.rs @@ -57,10 +57,10 @@ pub fn prepare_tree_node<'a>( // Skip if this matches a parameterizable pattern AND has no outlier AND field parts match let base_result = get_pattern_instance_base(node); - let pattern_fully_matches = pattern_lookup + let pattern_compatible = pattern_lookup .get(&fields) .and_then(|name| metadata.find_pattern(name)) - .is_some_and(|p| { + .is_none_or(|p| { p.is_suffix_mode() == base_result.is_suffix_mode && p.field_parts_match(&base_result.field_parts) }); @@ -68,7 +68,7 @@ pub fn prepare_tree_node<'a>( && pattern_name != name && metadata.is_parameterizable(pattern_name) && !base_result.has_outlier - && pattern_fully_matches + && pattern_compatible { return None; } @@ -93,22 +93,19 @@ pub fn prepare_tree_node<'a>( .is_some_and(|cf| metadata.matches_pattern(cf)); // Check if the pattern mode AND field parts match the instance - let pattern_fully_matches = child_fields + // Uses is_none_or so that "no pattern" doesn't trigger inlining + let pattern_compatible = child_fields .as_ref() .and_then(|cf| metadata.find_pattern_by_fields(cf)) - .is_some_and(|p| { - // Mode must match (suffix vs prefix) - if p.is_suffix_mode() != base_result.is_suffix_mode { - return false; - } - // Field parts must also match - p.field_parts_match(&base_result.field_parts) + .is_none_or(|p| { + p.is_suffix_mode() == base_result.is_suffix_mode + && p.field_parts_match(&base_result.field_parts) }); // should_inline determines if we generate an inline struct type - // We inline if: it's a branch AND (doesn't match any pattern OR pattern doesn't fully match OR has outlier) + // We inline if: it's a branch AND (doesn't match any pattern OR pattern incompatible OR has outlier) let should_inline = - !is_leaf && (!matches_any_pattern || !pattern_fully_matches || base_result.has_outlier); + !is_leaf && (!matches_any_pattern || !pattern_compatible || base_result.has_outlier); // Inline type name (only used when should_inline is true) let inline_type_name = if should_inline { diff --git a/crates/brk_bindgen/tests/catalog_test.rs b/crates/brk_bindgen/tests/catalog_test.rs index ecc9263d4..29e82d22d 100644 --- a/crates/brk_bindgen/tests/catalog_test.rs +++ b/crates/brk_bindgen/tests/catalog_test.rs @@ -861,3 +861,83 @@ fn test_root_cost_basis_prefix() { let nested_prefix = find_common_prefix(&nested_bases); println!("Nested cost_basis prefix: {:?}", nested_prefix); } + +#[test] +fn test_price_sats_vs_usd_different_field_parts() { + // This test verifies that price.sats and price.usd, which have the same structure + // but different metric naming conventions, are handled correctly. + // + // price.sats has: price_ohlc_sats, price_sats_close, price_sats_high, etc. + // price.usd has: price_ohlc, price_close, price_high, etc. + // + // Both should use the same structural pattern but with different base arguments. + + let catalog = load_catalog(); + let metadata = ClientMetadata::from_catalog(catalog.clone()); + + // Generate JavaScript output + let mut js_output = String::new(); + writeln!(js_output, "// Test output").unwrap(); + brk_bindgen::javascript::client::generate_base_client(&mut js_output); + brk_bindgen::javascript::client::generate_index_accessors( + &mut js_output, + &metadata.index_set_patterns, + ); + brk_bindgen::javascript::client::generate_structural_patterns( + &mut js_output, + &metadata.structural_patterns, + &metadata, + ); + brk_bindgen::javascript::tree::generate_tree_typedefs( + &mut js_output, + &metadata.catalog, + &metadata, + ); + brk_bindgen::javascript::tree::generate_main_client( + &mut js_output, + &metadata.catalog, + &metadata, + &[], + ); + + // Verify price.sats uses sats-suffixed metrics + assert!( + js_output.contains("'price_ohlc_sats'"), + "price.sats.ohlc should use 'price_ohlc_sats'" + ); + assert!( + js_output.contains("'price_sats'") || js_output.contains("createSplitPattern2(this, 'price_sats')"), + "price.sats.split should use 'price_sats' base" + ); + + // Verify price.usd uses non-sats metrics (no _sats suffix) + assert!( + js_output.contains("createMetricPattern1(this, 'price_ohlc')"), + "price.usd.ohlc should use 'price_ohlc' (without _sats)" + ); + assert!( + js_output.contains("createSplitPattern2(this, 'price')"), + "price.usd.split should use 'price' base (without _sats)" + ); + + // Verify they don't incorrectly share the same metric names + // Count occurrences to ensure usd doesn't use sats metrics + let sats_ohlc_count = js_output.matches("'price_ohlc_sats'").count(); + let usd_ohlc_count = js_output.matches("'price_ohlc')").count(); + + println!("price_ohlc_sats occurrences: {}", sats_ohlc_count); + println!("price_ohlc occurrences: {}", usd_ohlc_count); + + assert!( + sats_ohlc_count >= 1, + "Should have at least one 'price_ohlc_sats' for price.sats" + ); + assert!( + usd_ohlc_count >= 1, + "Should have at least one 'price_ohlc' for price.usd" + ); + + println!("\nPrice sats vs usd field_parts test passed!"); + println!(" - price.sats correctly uses sats-suffixed metrics"); + println!(" - price.usd correctly uses non-sats metrics"); +} diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 616aba926..efb4da287 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -2974,40 +2974,6 @@ impl BitcoinPattern { } } -/// Pattern struct for repeated tree structure. -pub struct ClassAveragePricePattern { - pub _2015: MetricPattern4, - pub _2016: MetricPattern4, - pub _2017: MetricPattern4, - pub _2018: MetricPattern4, - pub _2019: MetricPattern4, - pub _2020: MetricPattern4, - pub _2021: MetricPattern4, - pub _2022: MetricPattern4, - pub _2023: MetricPattern4, - pub _2024: MetricPattern4, - pub _2025: MetricPattern4, -} - -impl ClassAveragePricePattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _2015: MetricPattern4::new(client.clone(), _m(&acc, "2015_returns")), - _2016: MetricPattern4::new(client.clone(), _m(&acc, "2016_returns")), - _2017: MetricPattern4::new(client.clone(), _m(&acc, "2017_returns")), - _2018: MetricPattern4::new(client.clone(), _m(&acc, "2018_returns")), - _2019: MetricPattern4::new(client.clone(), _m(&acc, "2019_returns")), - _2020: MetricPattern4::new(client.clone(), _m(&acc, "2020_returns")), - _2021: MetricPattern4::new(client.clone(), _m(&acc, "2021_returns")), - _2022: MetricPattern4::new(client.clone(), _m(&acc, "2022_returns")), - _2023: MetricPattern4::new(client.clone(), _m(&acc, "2023_returns")), - _2024: MetricPattern4::new(client.clone(), _m(&acc, "2024_returns")), - _2025: MetricPattern4::new(client.clone(), _m(&acc, "2025_returns")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct DollarsPattern { pub average: MetricPattern2, @@ -3043,33 +3009,35 @@ impl DollarsPattern { } /// Pattern struct for repeated tree structure. -pub struct RelativePattern2 { - pub neg_unrealized_loss_rel_to_own_market_cap: MetricPattern1, - pub neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1, - pub net_unrealized_pnl_rel_to_own_market_cap: MetricPattern1, - pub net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern1, - pub supply_in_loss_rel_to_own_supply: MetricPattern1, - pub supply_in_profit_rel_to_own_supply: MetricPattern1, - pub unrealized_loss_rel_to_own_market_cap: MetricPattern1, - pub unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1, - pub unrealized_profit_rel_to_own_market_cap: MetricPattern1, - pub unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern1, +pub struct ClassAveragePricePattern { + pub _2015: MetricPattern4, + pub _2016: MetricPattern4, + pub _2017: MetricPattern4, + pub _2018: MetricPattern4, + pub _2019: MetricPattern4, + pub _2020: MetricPattern4, + pub _2021: MetricPattern4, + pub _2022: MetricPattern4, + pub _2023: MetricPattern4, + pub _2024: MetricPattern4, + pub _2025: MetricPattern4, } -impl RelativePattern2 { +impl ClassAveragePricePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - neg_unrealized_loss_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_market_cap")), - neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_total_unrealized_pnl")), - net_unrealized_pnl_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_market_cap")), - net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_total_unrealized_pnl")), - supply_in_loss_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")), - supply_in_profit_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")), - unrealized_loss_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")), - unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_total_unrealized_pnl")), - unrealized_profit_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")), - unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_total_unrealized_pnl")), + _2015: MetricPattern4::new(client.clone(), _m(&acc, "2015_returns")), + _2016: MetricPattern4::new(client.clone(), _m(&acc, "2016_returns")), + _2017: MetricPattern4::new(client.clone(), _m(&acc, "2017_returns")), + _2018: MetricPattern4::new(client.clone(), _m(&acc, "2018_returns")), + _2019: MetricPattern4::new(client.clone(), _m(&acc, "2019_returns")), + _2020: MetricPattern4::new(client.clone(), _m(&acc, "2020_returns")), + _2021: MetricPattern4::new(client.clone(), _m(&acc, "2021_returns")), + _2022: MetricPattern4::new(client.clone(), _m(&acc, "2022_returns")), + _2023: MetricPattern4::new(client.clone(), _m(&acc, "2023_returns")), + _2024: MetricPattern4::new(client.clone(), _m(&acc, "2024_returns")), + _2025: MetricPattern4::new(client.clone(), _m(&acc, "2025_returns")), } } } @@ -3106,6 +3074,38 @@ impl RelativePattern { } } +/// Pattern struct for repeated tree structure. +pub struct RelativePattern2 { + pub neg_unrealized_loss_rel_to_own_market_cap: MetricPattern1, + pub neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1, + pub net_unrealized_pnl_rel_to_own_market_cap: MetricPattern1, + pub net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern1, + pub supply_in_loss_rel_to_own_supply: MetricPattern1, + pub supply_in_profit_rel_to_own_supply: MetricPattern1, + pub unrealized_loss_rel_to_own_market_cap: MetricPattern1, + pub unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1, + pub unrealized_profit_rel_to_own_market_cap: MetricPattern1, + pub unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern1, +} + +impl RelativePattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + neg_unrealized_loss_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_market_cap")), + neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_total_unrealized_pnl")), + net_unrealized_pnl_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_market_cap")), + net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_total_unrealized_pnl")), + supply_in_loss_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")), + supply_in_profit_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")), + unrealized_loss_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")), + unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_total_unrealized_pnl")), + unrealized_profit_rel_to_own_market_cap: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")), + unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern1::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_total_unrealized_pnl")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct CountPattern2 { pub average: MetricPattern1, @@ -3168,36 +3168,6 @@ impl AddrCountPattern { } } -/// Pattern struct for repeated tree structure. -pub struct FullnessPattern { - pub average: MetricPattern2, - pub base: MetricPattern11, - pub max: MetricPattern2, - pub median: MetricPattern6, - pub min: MetricPattern2, - pub pct10: MetricPattern6, - pub pct25: MetricPattern6, - pub pct75: MetricPattern6, - pub pct90: MetricPattern6, -} - -impl FullnessPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - average: MetricPattern2::new(client.clone(), _m(&acc, "average")), - base: MetricPattern11::new(client.clone(), acc.clone()), - max: MetricPattern2::new(client.clone(), _m(&acc, "max")), - median: MetricPattern6::new(client.clone(), _m(&acc, "median")), - min: MetricPattern2::new(client.clone(), _m(&acc, "min")), - pct10: MetricPattern6::new(client.clone(), _m(&acc, "pct10")), - pct25: MetricPattern6::new(client.clone(), _m(&acc, "pct25")), - pct75: MetricPattern6::new(client.clone(), _m(&acc, "pct75")), - pct90: MetricPattern6::new(client.clone(), _m(&acc, "pct90")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct FeeRatePattern { pub average: MetricPattern1, @@ -3228,6 +3198,36 @@ impl FeeRatePattern { } } +/// Pattern struct for repeated tree structure. +pub struct FullnessPattern { + pub average: MetricPattern2, + pub base: MetricPattern11, + pub max: MetricPattern2, + pub median: MetricPattern6, + pub min: MetricPattern2, + pub pct10: MetricPattern6, + pub pct25: MetricPattern6, + pub pct75: MetricPattern6, + pub pct90: MetricPattern6, +} + +impl FullnessPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + average: MetricPattern2::new(client.clone(), _m(&acc, "average")), + base: MetricPattern11::new(client.clone(), acc.clone()), + max: MetricPattern2::new(client.clone(), _m(&acc, "max")), + median: MetricPattern6::new(client.clone(), _m(&acc, "median")), + min: MetricPattern2::new(client.clone(), _m(&acc, "min")), + pct10: MetricPattern6::new(client.clone(), _m(&acc, "pct10")), + pct25: MetricPattern6::new(client.clone(), _m(&acc, "pct25")), + pct75: MetricPattern6::new(client.clone(), _m(&acc, "pct75")), + pct90: MetricPattern6::new(client.clone(), _m(&acc, "pct90")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct _0satsPattern { pub activity: ActivityPattern2, @@ -3282,84 +3282,6 @@ impl _100btcPattern { } } -/// Pattern struct for repeated tree structure. -pub struct _10yTo12yPattern { - pub activity: ActivityPattern2, - pub cost_basis: CostBasisPattern2, - pub outputs: OutputsPattern, - pub realized: RealizedPattern2, - pub relative: RelativePattern2, - pub supply: SupplyPattern2, - pub unrealized: UnrealizedPattern, -} - -impl _10yTo12yPattern { - /// 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()), - outputs: OutputsPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: RealizedPattern2::new(client.clone(), acc.clone()), - relative: RelativePattern2::new(client.clone(), acc.clone()), - supply: SupplyPattern2::new(client.clone(), _m(&acc, "supply")), - unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _0satsPattern2 { - pub activity: ActivityPattern2, - pub cost_basis: CostBasisPattern, - pub outputs: OutputsPattern, - pub realized: RealizedPattern, - pub relative: RelativePattern4, - pub supply: SupplyPattern2, - pub unrealized: UnrealizedPattern, -} - -impl _0satsPattern2 { - /// 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: CostBasisPattern::new(client.clone(), acc.clone()), - outputs: OutputsPattern::new(client.clone(), _m(&acc, "utxo_count")), - realized: RealizedPattern::new(client.clone(), acc.clone()), - relative: RelativePattern4::new(client.clone(), _m(&acc, "supply_in")), - supply: SupplyPattern2::new(client.clone(), _m(&acc, "supply")), - unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct PeriodCagrPattern { - pub _10y: MetricPattern4, - pub _2y: MetricPattern4, - pub _3y: MetricPattern4, - pub _4y: MetricPattern4, - pub _5y: MetricPattern4, - pub _6y: MetricPattern4, - pub _8y: MetricPattern4, -} - -impl PeriodCagrPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - _10y: MetricPattern4::new(client.clone(), _p("10y", &acc)), - _2y: MetricPattern4::new(client.clone(), _p("2y", &acc)), - _3y: MetricPattern4::new(client.clone(), _p("3y", &acc)), - _4y: MetricPattern4::new(client.clone(), _p("4y", &acc)), - _5y: MetricPattern4::new(client.clone(), _p("5y", &acc)), - _6y: MetricPattern4::new(client.clone(), _p("6y", &acc)), - _8y: MetricPattern4::new(client.clone(), _p("8y", &acc)), - } - } -} - /// Pattern struct for repeated tree structure. pub struct UnrealizedPattern { pub neg_unrealized_loss: MetricPattern1, @@ -3412,6 +3334,84 @@ impl _10yPattern { } } +/// Pattern struct for repeated tree structure. +pub struct _0satsPattern2 { + pub activity: ActivityPattern2, + pub cost_basis: CostBasisPattern, + pub outputs: OutputsPattern, + pub realized: RealizedPattern, + pub relative: RelativePattern4, + pub supply: SupplyPattern2, + pub unrealized: UnrealizedPattern, +} + +impl _0satsPattern2 { + /// 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: CostBasisPattern::new(client.clone(), acc.clone()), + outputs: OutputsPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: RealizedPattern::new(client.clone(), acc.clone()), + relative: RelativePattern4::new(client.clone(), _m(&acc, "supply_in")), + supply: SupplyPattern2::new(client.clone(), _m(&acc, "supply")), + unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _10yTo12yPattern { + pub activity: ActivityPattern2, + pub cost_basis: CostBasisPattern2, + pub outputs: OutputsPattern, + pub realized: RealizedPattern2, + pub relative: RelativePattern2, + pub supply: SupplyPattern2, + pub unrealized: UnrealizedPattern, +} + +impl _10yTo12yPattern { + /// 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()), + outputs: OutputsPattern::new(client.clone(), _m(&acc, "utxo_count")), + realized: RealizedPattern2::new(client.clone(), acc.clone()), + relative: RelativePattern2::new(client.clone(), acc.clone()), + supply: SupplyPattern2::new(client.clone(), _m(&acc, "supply")), + unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct PeriodCagrPattern { + pub _10y: MetricPattern4, + pub _2y: MetricPattern4, + pub _3y: MetricPattern4, + pub _4y: MetricPattern4, + pub _5y: MetricPattern4, + pub _6y: MetricPattern4, + pub _8y: MetricPattern4, +} + +impl PeriodCagrPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + _10y: MetricPattern4::new(client.clone(), _p("10y", &acc)), + _2y: MetricPattern4::new(client.clone(), _p("2y", &acc)), + _3y: MetricPattern4::new(client.clone(), _p("3y", &acc)), + _4y: MetricPattern4::new(client.clone(), _p("4y", &acc)), + _5y: MetricPattern4::new(client.clone(), _p("5y", &acc)), + _6y: MetricPattern4::new(client.clone(), _p("6y", &acc)), + _8y: MetricPattern4::new(client.clone(), _p("8y", &acc)), + } + } +} + /// Pattern struct for repeated tree structure. pub struct ActivityPattern2 { pub coinblocks_destroyed: BlockCountPattern, @@ -3455,37 +3455,19 @@ impl SplitPattern2 { } /// Pattern struct for repeated tree structure. -pub struct CoinbasePattern2 { - pub bitcoin: BlockCountPattern, - pub dollars: BlockCountPattern, - pub sats: BlockCountPattern, +pub struct CostBasisPattern2 { + pub max: MetricPattern1, + pub min: MetricPattern1, + pub percentiles: PercentilesPattern, } -impl CoinbasePattern2 { +impl CostBasisPattern2 { /// 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()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct SegwitAdoptionPattern { - pub base: MetricPattern11, - pub cumulative: MetricPattern2, - pub sum: MetricPattern2, -} - -impl SegwitAdoptionPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - base: MetricPattern11::new(client.clone(), acc.clone()), - cumulative: MetricPattern2::new(client.clone(), _m(&acc, "cumulative")), - sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), + max: MetricPattern1::new(client.clone(), _m(&acc, "max_cost_basis")), + min: MetricPattern1::new(client.clone(), _m(&acc, "min_cost_basis")), + percentiles: PercentilesPattern::new(client.clone(), _m(&acc, "cost_basis")), } } } @@ -3508,24 +3490,6 @@ impl CoinbasePattern { } } -/// Pattern struct for repeated tree structure. -pub struct UnclaimedRewardsPattern { - pub bitcoin: BitcoinPattern2, - pub dollars: BlockCountPattern, - pub sats: BlockCountPattern, -} - -impl UnclaimedRewardsPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bitcoin: BitcoinPattern2::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 _2015Pattern { pub bitcoin: MetricPattern4, @@ -3544,24 +3508,6 @@ impl _2015Pattern { } } -/// Pattern struct for repeated tree structure. -pub struct CostBasisPattern2 { - pub max: MetricPattern1, - pub min: MetricPattern1, - pub percentiles: PercentilesPattern, -} - -impl CostBasisPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - max: MetricPattern1::new(client.clone(), _m(&acc, "max_cost_basis")), - min: MetricPattern1::new(client.clone(), _m(&acc, "min_cost_basis")), - percentiles: PercentilesPattern::new(client.clone(), _m(&acc, "cost_basis")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct ActiveSupplyPattern { pub bitcoin: MetricPattern1, @@ -3581,33 +3527,71 @@ impl ActiveSupplyPattern { } /// Pattern struct for repeated tree structure. -pub struct CostBasisPattern { - pub max: MetricPattern1, - pub min: MetricPattern1, +pub struct SegwitAdoptionPattern { + pub base: MetricPattern11, + pub cumulative: MetricPattern2, + pub sum: MetricPattern2, } -impl CostBasisPattern { +impl SegwitAdoptionPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - max: MetricPattern1::new(client.clone(), _m(&acc, "max_cost_basis")), - min: MetricPattern1::new(client.clone(), _m(&acc, "min_cost_basis")), + base: MetricPattern11::new(client.clone(), acc.clone()), + cumulative: MetricPattern2::new(client.clone(), _m(&acc, "cumulative")), + sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), } } } /// Pattern struct for repeated tree structure. -pub struct RelativePattern4 { - pub supply_in_loss_rel_to_own_supply: MetricPattern1, - pub supply_in_profit_rel_to_own_supply: MetricPattern1, +pub struct CoinbasePattern2 { + pub bitcoin: BlockCountPattern, + pub dollars: BlockCountPattern, + pub sats: BlockCountPattern, } -impl RelativePattern4 { +impl CoinbasePattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - supply_in_loss_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "loss_rel_to_own_supply")), - supply_in_profit_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "profit_rel_to_own_supply")), + 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 UnclaimedRewardsPattern { + pub bitcoin: BitcoinPattern2, + pub dollars: BlockCountPattern, + pub sats: BlockCountPattern, +} + +impl UnclaimedRewardsPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + bitcoin: BitcoinPattern2::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 _1dReturns1mSdPattern { + pub sd: MetricPattern4, + pub sma: MetricPattern4, +} + +impl _1dReturns1mSdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + sd: MetricPattern4::new(client.clone(), _m(&acc, "sd")), + sma: MetricPattern4::new(client.clone(), _m(&acc, "sma")), } } } @@ -3629,17 +3613,33 @@ impl SupplyPattern2 { } /// Pattern struct for repeated tree structure. -pub struct _1dReturns1mSdPattern { - pub sd: MetricPattern4, - pub sma: MetricPattern4, +pub struct RelativePattern4 { + pub supply_in_loss_rel_to_own_supply: MetricPattern1, + pub supply_in_profit_rel_to_own_supply: MetricPattern1, } -impl _1dReturns1mSdPattern { +impl RelativePattern4 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - sd: MetricPattern4::new(client.clone(), _m(&acc, "sd")), - sma: MetricPattern4::new(client.clone(), _m(&acc, "sma")), + supply_in_loss_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "loss_rel_to_own_supply")), + supply_in_profit_rel_to_own_supply: MetricPattern1::new(client.clone(), _m(&acc, "profit_rel_to_own_supply")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct CostBasisPattern { + pub max: MetricPattern1, + pub min: MetricPattern1, +} + +impl CostBasisPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + max: MetricPattern1::new(client.clone(), _m(&acc, "max_cost_basis")), + min: MetricPattern1::new(client.clone(), _m(&acc, "min_cost_basis")), } } } @@ -3686,22 +3686,8 @@ impl SatsPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - ohlc: MetricPattern1::new(client.clone(), _m(&acc, "ohlc")), - split: SplitPattern2::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct OutputsPattern { - pub utxo_count: MetricPattern1, -} - -impl OutputsPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - utxo_count: MetricPattern1::new(client.clone(), acc.clone()), + ohlc: MetricPattern1::new(client.clone(), _m(&acc, "ohlc_sats")), + split: SplitPattern2::new(client.clone(), _m(&acc, "sats")), } } } @@ -3720,6 +3706,20 @@ impl RealizedPriceExtraPattern { } } +/// Pattern struct for repeated tree structure. +pub struct OutputsPattern { + pub utxo_count: MetricPattern1, +} + +impl OutputsPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + utxo_count: MetricPattern1::new(client.clone(), acc.clone()), + } + } +} + // Metrics tree /// Metrics tree node. diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 192da0685..d9e28b4ed 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -3313,6 +3313,45 @@ function createBitcoinPattern(client, acc) { }; } +/** + * @template T + * @typedef {Object} DollarsPattern + * @property {MetricPattern2} average + * @property {MetricPattern11} base + * @property {MetricPattern1} cumulative + * @property {MetricPattern2} max + * @property {MetricPattern6} median + * @property {MetricPattern2} min + * @property {MetricPattern6} pct10 + * @property {MetricPattern6} pct25 + * @property {MetricPattern6} pct75 + * @property {MetricPattern6} pct90 + * @property {MetricPattern2} sum + */ + +/** + * Create a DollarsPattern pattern node + * @template T + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {DollarsPattern} + */ +function createDollarsPattern(client, acc) { + return { + average: createMetricPattern2(client, _m(acc, "average")), + base: createMetricPattern11(client, acc), + cumulative: createMetricPattern1(client, _m(acc, "cumulative")), + max: createMetricPattern2(client, _m(acc, "max")), + median: createMetricPattern6(client, _m(acc, "median")), + min: createMetricPattern2(client, _m(acc, "min")), + pct10: createMetricPattern6(client, _m(acc, "pct10")), + pct25: createMetricPattern6(client, _m(acc, "pct25")), + pct75: createMetricPattern6(client, _m(acc, "pct75")), + pct90: createMetricPattern6(client, _m(acc, "pct90")), + sum: createMetricPattern2(client, _m(acc, "sum")), + }; +} + /** * @template T * @typedef {Object} ClassAveragePricePattern @@ -3353,41 +3392,64 @@ function createClassAveragePricePattern(client, acc) { } /** - * @template T - * @typedef {Object} DollarsPattern - * @property {MetricPattern2} average - * @property {MetricPattern11} base - * @property {MetricPattern1} cumulative - * @property {MetricPattern2} max - * @property {MetricPattern6} median - * @property {MetricPattern2} min - * @property {MetricPattern6} pct10 - * @property {MetricPattern6} pct25 - * @property {MetricPattern6} pct75 - * @property {MetricPattern6} pct90 - * @property {MetricPattern2} sum + * @typedef {Object} RelativePattern + * @property {MetricPattern1} negUnrealizedLossRelToMarketCap + * @property {MetricPattern1} netUnrealizedPnlRelToMarketCap + * @property {MetricPattern1} nupl + * @property {MetricPattern1} supplyInLossRelToCirculatingSupply + * @property {MetricPattern1} supplyInLossRelToOwnSupply + * @property {MetricPattern1} supplyInProfitRelToCirculatingSupply + * @property {MetricPattern1} supplyInProfitRelToOwnSupply + * @property {MetricPattern4} supplyRelToCirculatingSupply + * @property {MetricPattern1} unrealizedLossRelToMarketCap + * @property {MetricPattern1} unrealizedProfitRelToMarketCap */ /** - * Create a DollarsPattern pattern node - * @template T + * Create a RelativePattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {DollarsPattern} + * @returns {RelativePattern} */ -function createDollarsPattern(client, acc) { +function createRelativePattern(client, acc) { return { - average: createMetricPattern2(client, _m(acc, "average")), - base: createMetricPattern11(client, acc), - cumulative: createMetricPattern1(client, _m(acc, "cumulative")), - max: createMetricPattern2(client, _m(acc, "max")), - median: createMetricPattern6(client, _m(acc, "median")), - min: createMetricPattern2(client, _m(acc, "min")), - pct10: createMetricPattern6(client, _m(acc, "pct10")), - pct25: createMetricPattern6(client, _m(acc, "pct25")), - pct75: createMetricPattern6(client, _m(acc, "pct75")), - pct90: createMetricPattern6(client, _m(acc, "pct90")), - sum: createMetricPattern2(client, _m(acc, "sum")), + negUnrealizedLossRelToMarketCap: createMetricPattern1( + client, + _m(acc, "neg_unrealized_loss_rel_to_market_cap"), + ), + netUnrealizedPnlRelToMarketCap: createMetricPattern1( + client, + _m(acc, "net_unrealized_pnl_rel_to_market_cap"), + ), + nupl: createMetricPattern1(client, _m(acc, "nupl")), + supplyInLossRelToCirculatingSupply: createMetricPattern1( + client, + _m(acc, "supply_in_loss_rel_to_circulating_supply"), + ), + supplyInLossRelToOwnSupply: createMetricPattern1( + client, + _m(acc, "supply_in_loss_rel_to_own_supply"), + ), + supplyInProfitRelToCirculatingSupply: createMetricPattern1( + client, + _m(acc, "supply_in_profit_rel_to_circulating_supply"), + ), + supplyInProfitRelToOwnSupply: createMetricPattern1( + client, + _m(acc, "supply_in_profit_rel_to_own_supply"), + ), + supplyRelToCirculatingSupply: createMetricPattern4( + client, + _m(acc, "supply_rel_to_circulating_supply"), + ), + unrealizedLossRelToMarketCap: createMetricPattern1( + client, + _m(acc, "unrealized_loss_rel_to_market_cap"), + ), + unrealizedProfitRelToMarketCap: createMetricPattern1( + client, + _m(acc, "unrealized_profit_rel_to_market_cap"), + ), }; } @@ -3456,68 +3518,6 @@ function createRelativePattern2(client, acc) { }; } -/** - * @typedef {Object} RelativePattern - * @property {MetricPattern1} negUnrealizedLossRelToMarketCap - * @property {MetricPattern1} netUnrealizedPnlRelToMarketCap - * @property {MetricPattern1} nupl - * @property {MetricPattern1} supplyInLossRelToCirculatingSupply - * @property {MetricPattern1} supplyInLossRelToOwnSupply - * @property {MetricPattern1} supplyInProfitRelToCirculatingSupply - * @property {MetricPattern1} supplyInProfitRelToOwnSupply - * @property {MetricPattern4} supplyRelToCirculatingSupply - * @property {MetricPattern1} unrealizedLossRelToMarketCap - * @property {MetricPattern1} unrealizedProfitRelToMarketCap - */ - -/** - * Create a RelativePattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {RelativePattern} - */ -function createRelativePattern(client, acc) { - return { - negUnrealizedLossRelToMarketCap: createMetricPattern1( - client, - _m(acc, "neg_unrealized_loss_rel_to_market_cap"), - ), - netUnrealizedPnlRelToMarketCap: createMetricPattern1( - client, - _m(acc, "net_unrealized_pnl_rel_to_market_cap"), - ), - nupl: createMetricPattern1(client, _m(acc, "nupl")), - supplyInLossRelToCirculatingSupply: createMetricPattern1( - client, - _m(acc, "supply_in_loss_rel_to_circulating_supply"), - ), - supplyInLossRelToOwnSupply: createMetricPattern1( - client, - _m(acc, "supply_in_loss_rel_to_own_supply"), - ), - supplyInProfitRelToCirculatingSupply: createMetricPattern1( - client, - _m(acc, "supply_in_profit_rel_to_circulating_supply"), - ), - supplyInProfitRelToOwnSupply: createMetricPattern1( - client, - _m(acc, "supply_in_profit_rel_to_own_supply"), - ), - supplyRelToCirculatingSupply: createMetricPattern4( - client, - _m(acc, "supply_rel_to_circulating_supply"), - ), - unrealizedLossRelToMarketCap: createMetricPattern1( - client, - _m(acc, "unrealized_loss_rel_to_market_cap"), - ), - unrealizedProfitRelToMarketCap: createMetricPattern1( - client, - _m(acc, "unrealized_profit_rel_to_market_cap"), - ), - }; -} - /** * @template T * @typedef {Object} CountPattern2 @@ -3588,41 +3588,6 @@ function createAddrCountPattern(client, acc) { }; } -/** - * @template T - * @typedef {Object} FullnessPattern - * @property {MetricPattern2} average - * @property {MetricPattern11} base - * @property {MetricPattern2} max - * @property {MetricPattern6} median - * @property {MetricPattern2} min - * @property {MetricPattern6} pct10 - * @property {MetricPattern6} pct25 - * @property {MetricPattern6} pct75 - * @property {MetricPattern6} pct90 - */ - -/** - * Create a FullnessPattern pattern node - * @template T - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {FullnessPattern} - */ -function createFullnessPattern(client, acc) { - return { - average: createMetricPattern2(client, _m(acc, "average")), - base: createMetricPattern11(client, acc), - max: createMetricPattern2(client, _m(acc, "max")), - median: createMetricPattern6(client, _m(acc, "median")), - min: createMetricPattern2(client, _m(acc, "min")), - pct10: createMetricPattern6(client, _m(acc, "pct10")), - pct25: createMetricPattern6(client, _m(acc, "pct25")), - pct75: createMetricPattern6(client, _m(acc, "pct75")), - pct90: createMetricPattern6(client, _m(acc, "pct90")), - }; -} - /** * @template T * @typedef {Object} FeeRatePattern @@ -3658,6 +3623,41 @@ function createFeeRatePattern(client, acc) { }; } +/** + * @template T + * @typedef {Object} FullnessPattern + * @property {MetricPattern2} average + * @property {MetricPattern11} base + * @property {MetricPattern2} max + * @property {MetricPattern6} median + * @property {MetricPattern2} min + * @property {MetricPattern6} pct10 + * @property {MetricPattern6} pct25 + * @property {MetricPattern6} pct75 + * @property {MetricPattern6} pct90 + */ + +/** + * Create a FullnessPattern pattern node + * @template T + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {FullnessPattern} + */ +function createFullnessPattern(client, acc) { + return { + average: createMetricPattern2(client, _m(acc, "average")), + base: createMetricPattern11(client, acc), + max: createMetricPattern2(client, _m(acc, "max")), + median: createMetricPattern6(client, _m(acc, "median")), + min: createMetricPattern2(client, _m(acc, "min")), + pct10: createMetricPattern6(client, _m(acc, "pct10")), + pct25: createMetricPattern6(client, _m(acc, "pct25")), + pct75: createMetricPattern6(client, _m(acc, "pct75")), + pct90: createMetricPattern6(client, _m(acc, "pct90")), + }; +} + /** * @typedef {Object} _0satsPattern * @property {ActivityPattern2} activity @@ -3718,93 +3718,6 @@ function create_100btcPattern(client, acc) { }; } -/** - * @typedef {Object} _10yTo12yPattern - * @property {ActivityPattern2} activity - * @property {CostBasisPattern2} costBasis - * @property {OutputsPattern} outputs - * @property {RealizedPattern2} realized - * @property {RelativePattern2} relative - * @property {SupplyPattern2} supply - * @property {UnrealizedPattern} unrealized - */ - -/** - * Create a _10yTo12yPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_10yTo12yPattern} - */ -function create_10yTo12yPattern(client, acc) { - return { - activity: createActivityPattern2(client, acc), - costBasis: createCostBasisPattern2(client, acc), - outputs: createOutputsPattern(client, _m(acc, "utxo_count")), - realized: createRealizedPattern2(client, acc), - relative: createRelativePattern2(client, acc), - supply: createSupplyPattern2(client, _m(acc, "supply")), - unrealized: createUnrealizedPattern(client, acc), - }; -} - -/** - * @typedef {Object} _0satsPattern2 - * @property {ActivityPattern2} activity - * @property {CostBasisPattern} costBasis - * @property {OutputsPattern} outputs - * @property {RealizedPattern} realized - * @property {RelativePattern4} relative - * @property {SupplyPattern2} supply - * @property {UnrealizedPattern} unrealized - */ - -/** - * Create a _0satsPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_0satsPattern2} - */ -function create_0satsPattern2(client, acc) { - return { - activity: createActivityPattern2(client, acc), - costBasis: createCostBasisPattern(client, acc), - outputs: createOutputsPattern(client, _m(acc, "utxo_count")), - realized: createRealizedPattern(client, acc), - relative: createRelativePattern4(client, _m(acc, "supply_in")), - supply: createSupplyPattern2(client, _m(acc, "supply")), - unrealized: createUnrealizedPattern(client, acc), - }; -} - -/** - * @typedef {Object} PeriodCagrPattern - * @property {MetricPattern4} _10y - * @property {MetricPattern4} _2y - * @property {MetricPattern4} _3y - * @property {MetricPattern4} _4y - * @property {MetricPattern4} _5y - * @property {MetricPattern4} _6y - * @property {MetricPattern4} _8y - */ - -/** - * Create a PeriodCagrPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {PeriodCagrPattern} - */ -function createPeriodCagrPattern(client, acc) { - return { - _10y: createMetricPattern4(client, _p("10y", acc)), - _2y: createMetricPattern4(client, _p("2y", acc)), - _3y: createMetricPattern4(client, _p("3y", acc)), - _4y: createMetricPattern4(client, _p("4y", acc)), - _5y: createMetricPattern4(client, _p("5y", acc)), - _6y: createMetricPattern4(client, _p("6y", acc)), - _8y: createMetricPattern4(client, _p("8y", acc)), - }; -} - /** * @typedef {Object} UnrealizedPattern * @property {MetricPattern1} negUnrealizedLoss @@ -3878,6 +3791,93 @@ function create_10yPattern(client, acc) { }; } +/** + * @typedef {Object} _0satsPattern2 + * @property {ActivityPattern2} activity + * @property {CostBasisPattern} costBasis + * @property {OutputsPattern} outputs + * @property {RealizedPattern} realized + * @property {RelativePattern4} relative + * @property {SupplyPattern2} supply + * @property {UnrealizedPattern} unrealized + */ + +/** + * Create a _0satsPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_0satsPattern2} + */ +function create_0satsPattern2(client, acc) { + return { + activity: createActivityPattern2(client, acc), + costBasis: createCostBasisPattern(client, acc), + outputs: createOutputsPattern(client, _m(acc, "utxo_count")), + realized: createRealizedPattern(client, acc), + relative: createRelativePattern4(client, _m(acc, "supply_in")), + supply: createSupplyPattern2(client, _m(acc, "supply")), + unrealized: createUnrealizedPattern(client, acc), + }; +} + +/** + * @typedef {Object} _10yTo12yPattern + * @property {ActivityPattern2} activity + * @property {CostBasisPattern2} costBasis + * @property {OutputsPattern} outputs + * @property {RealizedPattern2} realized + * @property {RelativePattern2} relative + * @property {SupplyPattern2} supply + * @property {UnrealizedPattern} unrealized + */ + +/** + * Create a _10yTo12yPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_10yTo12yPattern} + */ +function create_10yTo12yPattern(client, acc) { + return { + activity: createActivityPattern2(client, acc), + costBasis: createCostBasisPattern2(client, acc), + outputs: createOutputsPattern(client, _m(acc, "utxo_count")), + realized: createRealizedPattern2(client, acc), + relative: createRelativePattern2(client, acc), + supply: createSupplyPattern2(client, _m(acc, "supply")), + unrealized: createUnrealizedPattern(client, acc), + }; +} + +/** + * @typedef {Object} PeriodCagrPattern + * @property {MetricPattern4} _10y + * @property {MetricPattern4} _2y + * @property {MetricPattern4} _3y + * @property {MetricPattern4} _4y + * @property {MetricPattern4} _5y + * @property {MetricPattern4} _6y + * @property {MetricPattern4} _8y + */ + +/** + * Create a PeriodCagrPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {PeriodCagrPattern} + */ +function createPeriodCagrPattern(client, acc) { + return { + _10y: createMetricPattern4(client, _p("10y", acc)), + _2y: createMetricPattern4(client, _p("2y", acc)), + _3y: createMetricPattern4(client, _p("3y", acc)), + _4y: createMetricPattern4(client, _p("4y", acc)), + _5y: createMetricPattern4(client, _p("5y", acc)), + _6y: createMetricPattern4(client, _p("6y", acc)), + _8y: createMetricPattern4(client, _p("8y", acc)), + }; +} + /** * @typedef {Object} ActivityPattern2 * @property {BlockCountPattern} coinblocksDestroyed @@ -3941,44 +3941,23 @@ function createSplitPattern2(client, acc) { } /** - * @typedef {Object} CoinbasePattern2 - * @property {BlockCountPattern} bitcoin - * @property {BlockCountPattern} dollars - * @property {BlockCountPattern} sats + * @typedef {Object} CostBasisPattern2 + * @property {MetricPattern1} max + * @property {MetricPattern1} min + * @property {PercentilesPattern} percentiles */ /** - * Create a CoinbasePattern2 pattern node + * Create a CostBasisPattern2 pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CoinbasePattern2} + * @returns {CostBasisPattern2} */ -function createCoinbasePattern2(client, acc) { +function createCostBasisPattern2(client, acc) { return { - bitcoin: createBlockCountPattern(client, _m(acc, "btc")), - dollars: createBlockCountPattern(client, _m(acc, "usd")), - sats: createBlockCountPattern(client, acc), - }; -} - -/** - * @typedef {Object} SegwitAdoptionPattern - * @property {MetricPattern11} base - * @property {MetricPattern2} cumulative - * @property {MetricPattern2} sum - */ - -/** - * Create a SegwitAdoptionPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {SegwitAdoptionPattern} - */ -function createSegwitAdoptionPattern(client, acc) { - return { - base: createMetricPattern11(client, acc), - cumulative: createMetricPattern2(client, _m(acc, "cumulative")), - sum: createMetricPattern2(client, _m(acc, "sum")), + max: createMetricPattern1(client, _m(acc, "max_cost_basis")), + min: createMetricPattern1(client, _m(acc, "min_cost_basis")), + percentiles: createPercentilesPattern(client, _m(acc, "cost_basis")), }; } @@ -4003,27 +3982,6 @@ function createCoinbasePattern(client, acc) { }; } -/** - * @typedef {Object} UnclaimedRewardsPattern - * @property {BitcoinPattern2} bitcoin - * @property {BlockCountPattern} dollars - * @property {BlockCountPattern} sats - */ - -/** - * Create a UnclaimedRewardsPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {UnclaimedRewardsPattern} - */ -function createUnclaimedRewardsPattern(client, acc) { - return { - bitcoin: createBitcoinPattern2(client, _m(acc, "btc")), - dollars: createBlockCountPattern(client, _m(acc, "usd")), - sats: createBlockCountPattern(client, acc), - }; -} - /** * @typedef {Object} _2015Pattern * @property {MetricPattern4} bitcoin @@ -4045,27 +4003,6 @@ function create_2015Pattern(client, acc) { }; } -/** - * @typedef {Object} CostBasisPattern2 - * @property {MetricPattern1} max - * @property {MetricPattern1} min - * @property {PercentilesPattern} percentiles - */ - -/** - * Create a CostBasisPattern2 pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {CostBasisPattern2} - */ -function createCostBasisPattern2(client, acc) { - return { - max: createMetricPattern1(client, _m(acc, "max_cost_basis")), - min: createMetricPattern1(client, _m(acc, "min_cost_basis")), - percentiles: createPercentilesPattern(client, _m(acc, "cost_basis")), - }; -} - /** * @typedef {Object} ActiveSupplyPattern * @property {MetricPattern1} bitcoin @@ -4088,21 +4025,103 @@ function createActiveSupplyPattern(client, acc) { } /** - * @typedef {Object} CostBasisPattern - * @property {MetricPattern1} max - * @property {MetricPattern1} min + * @typedef {Object} SegwitAdoptionPattern + * @property {MetricPattern11} base + * @property {MetricPattern2} cumulative + * @property {MetricPattern2} sum */ /** - * Create a CostBasisPattern pattern node + * Create a SegwitAdoptionPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {CostBasisPattern} + * @returns {SegwitAdoptionPattern} */ -function createCostBasisPattern(client, acc) { +function createSegwitAdoptionPattern(client, acc) { return { - max: createMetricPattern1(client, _m(acc, "max_cost_basis")), - min: createMetricPattern1(client, _m(acc, "min_cost_basis")), + base: createMetricPattern11(client, acc), + cumulative: createMetricPattern2(client, _m(acc, "cumulative")), + sum: createMetricPattern2(client, _m(acc, "sum")), + }; +} + +/** + * @typedef {Object} CoinbasePattern2 + * @property {BlockCountPattern} bitcoin + * @property {BlockCountPattern} dollars + * @property {BlockCountPattern} sats + */ + +/** + * Create a CoinbasePattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {CoinbasePattern2} + */ +function createCoinbasePattern2(client, acc) { + return { + bitcoin: createBlockCountPattern(client, _m(acc, "btc")), + dollars: createBlockCountPattern(client, _m(acc, "usd")), + sats: createBlockCountPattern(client, acc), + }; +} + +/** + * @typedef {Object} UnclaimedRewardsPattern + * @property {BitcoinPattern2} bitcoin + * @property {BlockCountPattern} dollars + * @property {BlockCountPattern} sats + */ + +/** + * Create a UnclaimedRewardsPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {UnclaimedRewardsPattern} + */ +function createUnclaimedRewardsPattern(client, acc) { + return { + bitcoin: createBitcoinPattern2(client, _m(acc, "btc")), + dollars: createBlockCountPattern(client, _m(acc, "usd")), + sats: createBlockCountPattern(client, acc), + }; +} + +/** + * @typedef {Object} _1dReturns1mSdPattern + * @property {MetricPattern4} sd + * @property {MetricPattern4} sma + */ + +/** + * Create a _1dReturns1mSdPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {_1dReturns1mSdPattern} + */ +function create_1dReturns1mSdPattern(client, acc) { + return { + sd: createMetricPattern4(client, _m(acc, "sd")), + sma: createMetricPattern4(client, _m(acc, "sma")), + }; +} + +/** + * @typedef {Object} SupplyPattern2 + * @property {ActiveSupplyPattern} halved + * @property {ActiveSupplyPattern} total + */ + +/** + * Create a SupplyPattern2 pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {SupplyPattern2} + */ +function createSupplyPattern2(client, acc) { + return { + halved: createActiveSupplyPattern(client, _m(acc, "halved")), + total: createActiveSupplyPattern(client, acc), }; } @@ -4132,40 +4151,21 @@ function createRelativePattern4(client, acc) { } /** - * @typedef {Object} SupplyPattern2 - * @property {ActiveSupplyPattern} halved - * @property {ActiveSupplyPattern} total + * @typedef {Object} CostBasisPattern + * @property {MetricPattern1} max + * @property {MetricPattern1} min */ /** - * Create a SupplyPattern2 pattern node + * Create a CostBasisPattern pattern node * @param {BrkClientBase} client * @param {string} acc - Accumulated metric name - * @returns {SupplyPattern2} + * @returns {CostBasisPattern} */ -function createSupplyPattern2(client, acc) { +function createCostBasisPattern(client, acc) { return { - halved: createActiveSupplyPattern(client, _m(acc, "halved")), - total: createActiveSupplyPattern(client, acc), - }; -} - -/** - * @typedef {Object} _1dReturns1mSdPattern - * @property {MetricPattern4} sd - * @property {MetricPattern4} sma - */ - -/** - * Create a _1dReturns1mSdPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {_1dReturns1mSdPattern} - */ -function create_1dReturns1mSdPattern(client, acc) { - return { - sd: createMetricPattern4(client, _m(acc, "sd")), - sma: createMetricPattern4(client, _m(acc, "sma")), + max: createMetricPattern1(client, _m(acc, "max_cost_basis")), + min: createMetricPattern1(client, _m(acc, "min_cost_basis")), }; } @@ -4227,25 +4227,8 @@ function createBlockCountPattern(client, acc) { */ function createSatsPattern(client, acc) { return { - ohlc: createMetricPattern1(client, _m(acc, "ohlc")), - split: createSplitPattern2(client, acc), - }; -} - -/** - * @typedef {Object} OutputsPattern - * @property {MetricPattern1} utxoCount - */ - -/** - * Create a OutputsPattern pattern node - * @param {BrkClientBase} client - * @param {string} acc - Accumulated metric name - * @returns {OutputsPattern} - */ -function createOutputsPattern(client, acc) { - return { - utxoCount: createMetricPattern1(client, acc), + ohlc: createMetricPattern1(client, _m(acc, "ohlc_sats")), + split: createSplitPattern2(client, _m(acc, "sats")), }; } @@ -4266,6 +4249,23 @@ function createRealizedPriceExtraPattern(client, acc) { }; } +/** + * @typedef {Object} OutputsPattern + * @property {MetricPattern1} utxoCount + */ + +/** + * Create a OutputsPattern pattern node + * @param {BrkClientBase} client + * @param {string} acc - Accumulated metric name + * @returns {OutputsPattern} + */ +function createOutputsPattern(client, acc) { + return { + utxoCount: createMetricPattern1(client, acc), + }; +} + // Catalog tree typedefs /** diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index daab0ac03..f00671390 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -3699,24 +3699,6 @@ class BitcoinPattern: self.sum: MetricPattern2[Bitcoin] = MetricPattern2(client, _m(acc, "sum")) -class ClassAveragePricePattern(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._2015: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2015_returns")) - self._2016: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2016_returns")) - self._2017: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2017_returns")) - self._2018: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2018_returns")) - self._2019: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2019_returns")) - self._2020: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2020_returns")) - self._2021: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2021_returns")) - self._2022: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2022_returns")) - self._2023: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2023_returns")) - self._2024: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2024_returns")) - self._2025: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2025_returns")) - - class DollarsPattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -3737,6 +3719,61 @@ class DollarsPattern(Generic[T]): self.sum: MetricPattern2[T] = MetricPattern2(client, _m(acc, "sum")) +class ClassAveragePricePattern(Generic[T]): + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._2015: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2015_returns")) + self._2016: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2016_returns")) + self._2017: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2017_returns")) + self._2018: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2018_returns")) + self._2019: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2019_returns")) + self._2020: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2020_returns")) + self._2021: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2021_returns")) + self._2022: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2022_returns")) + self._2023: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2023_returns")) + self._2024: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2024_returns")) + self._2025: MetricPattern4[T] = MetricPattern4(client, _m(acc, "2025_returns")) + + +class RelativePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.neg_unrealized_loss_rel_to_market_cap: MetricPattern1[StoredF32] = ( + MetricPattern1(client, _m(acc, "neg_unrealized_loss_rel_to_market_cap")) + ) + self.net_unrealized_pnl_rel_to_market_cap: MetricPattern1[StoredF32] = ( + MetricPattern1(client, _m(acc, "net_unrealized_pnl_rel_to_market_cap")) + ) + self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, "nupl")) + self.supply_in_loss_rel_to_circulating_supply: MetricPattern1[StoredF64] = ( + MetricPattern1(client, _m(acc, "supply_in_loss_rel_to_circulating_supply")) + ) + self.supply_in_loss_rel_to_own_supply: MetricPattern1[StoredF64] = ( + MetricPattern1(client, _m(acc, "supply_in_loss_rel_to_own_supply")) + ) + self.supply_in_profit_rel_to_circulating_supply: MetricPattern1[StoredF64] = ( + MetricPattern1( + client, _m(acc, "supply_in_profit_rel_to_circulating_supply") + ) + ) + self.supply_in_profit_rel_to_own_supply: MetricPattern1[StoredF64] = ( + MetricPattern1(client, _m(acc, "supply_in_profit_rel_to_own_supply")) + ) + self.supply_rel_to_circulating_supply: MetricPattern4[StoredF64] = ( + MetricPattern4(client, _m(acc, "supply_rel_to_circulating_supply")) + ) + self.unrealized_loss_rel_to_market_cap: MetricPattern1[StoredF32] = ( + MetricPattern1(client, _m(acc, "unrealized_loss_rel_to_market_cap")) + ) + self.unrealized_profit_rel_to_market_cap: MetricPattern1[StoredF32] = ( + MetricPattern1(client, _m(acc, "unrealized_profit_rel_to_market_cap")) + ) + + class RelativePattern2: """Pattern struct for repeated tree structure.""" @@ -3782,43 +3819,6 @@ class RelativePattern2: ) -class RelativePattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.neg_unrealized_loss_rel_to_market_cap: MetricPattern1[StoredF32] = ( - MetricPattern1(client, _m(acc, "neg_unrealized_loss_rel_to_market_cap")) - ) - self.net_unrealized_pnl_rel_to_market_cap: MetricPattern1[StoredF32] = ( - MetricPattern1(client, _m(acc, "net_unrealized_pnl_rel_to_market_cap")) - ) - self.nupl: MetricPattern1[StoredF32] = MetricPattern1(client, _m(acc, "nupl")) - self.supply_in_loss_rel_to_circulating_supply: MetricPattern1[StoredF64] = ( - MetricPattern1(client, _m(acc, "supply_in_loss_rel_to_circulating_supply")) - ) - self.supply_in_loss_rel_to_own_supply: MetricPattern1[StoredF64] = ( - MetricPattern1(client, _m(acc, "supply_in_loss_rel_to_own_supply")) - ) - self.supply_in_profit_rel_to_circulating_supply: MetricPattern1[StoredF64] = ( - MetricPattern1( - client, _m(acc, "supply_in_profit_rel_to_circulating_supply") - ) - ) - self.supply_in_profit_rel_to_own_supply: MetricPattern1[StoredF64] = ( - MetricPattern1(client, _m(acc, "supply_in_profit_rel_to_own_supply")) - ) - self.supply_rel_to_circulating_supply: MetricPattern4[StoredF64] = ( - MetricPattern4(client, _m(acc, "supply_rel_to_circulating_supply")) - ) - self.unrealized_loss_rel_to_market_cap: MetricPattern1[StoredF32] = ( - MetricPattern1(client, _m(acc, "unrealized_loss_rel_to_market_cap")) - ) - self.unrealized_profit_rel_to_market_cap: MetricPattern1[StoredF32] = ( - MetricPattern1(client, _m(acc, "unrealized_profit_rel_to_market_cap")) - ) - - class CountPattern2(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -3860,22 +3860,6 @@ class AddrCountPattern: self.p2wsh: MetricPattern1[StoredU64] = MetricPattern1(client, _p("p2wsh", acc)) -class FullnessPattern(Generic[T]): - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.average: MetricPattern2[T] = MetricPattern2(client, _m(acc, "average")) - self.base: MetricPattern11[T] = MetricPattern11(client, acc) - self.max: MetricPattern2[T] = MetricPattern2(client, _m(acc, "max")) - self.median: MetricPattern6[T] = MetricPattern6(client, _m(acc, "median")) - self.min: MetricPattern2[T] = MetricPattern2(client, _m(acc, "min")) - self.pct10: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct10")) - self.pct25: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct25")) - self.pct75: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct75")) - self.pct90: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct90")) - - class FeeRatePattern(Generic[T]): """Pattern struct for repeated tree structure.""" @@ -3892,6 +3876,22 @@ class FeeRatePattern(Generic[T]): self.txindex: MetricPattern27[T] = MetricPattern27(client, acc) +class FullnessPattern(Generic[T]): + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.average: MetricPattern2[T] = MetricPattern2(client, _m(acc, "average")) + self.base: MetricPattern11[T] = MetricPattern11(client, acc) + self.max: MetricPattern2[T] = MetricPattern2(client, _m(acc, "max")) + self.median: MetricPattern6[T] = MetricPattern6(client, _m(acc, "median")) + self.min: MetricPattern2[T] = MetricPattern2(client, _m(acc, "min")) + self.pct10: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct10")) + self.pct25: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct25")) + self.pct75: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct75")) + self.pct90: MetricPattern6[T] = MetricPattern6(client, _m(acc, "pct90")) + + class _0satsPattern: """Pattern struct for repeated tree structure.""" @@ -3923,48 +3923,6 @@ class _100btcPattern: self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) -class _10yTo12yPattern: - """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.outputs: OutputsPattern = OutputsPattern(client, _m(acc, "utxo_count")) - self.realized: RealizedPattern2 = RealizedPattern2(client, acc) - self.relative: RelativePattern2 = RelativePattern2(client, acc) - self.supply: SupplyPattern2 = SupplyPattern2(client, _m(acc, "supply")) - self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) - - -class _0satsPattern2: - """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: CostBasisPattern = CostBasisPattern(client, acc) - self.outputs: OutputsPattern = OutputsPattern(client, _m(acc, "utxo_count")) - self.realized: RealizedPattern = RealizedPattern(client, acc) - self.relative: RelativePattern4 = RelativePattern4(client, _m(acc, "supply_in")) - self.supply: SupplyPattern2 = SupplyPattern2(client, _m(acc, "supply")) - self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) - - -class PeriodCagrPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self._10y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("10y", acc)) - self._2y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("2y", acc)) - self._3y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("3y", acc)) - self._4y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("4y", acc)) - self._5y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("5y", acc)) - self._6y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("6y", acc)) - self._8y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("8y", acc)) - - class UnrealizedPattern: """Pattern struct for repeated tree structure.""" @@ -4007,6 +3965,48 @@ class _10yPattern: self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) +class _0satsPattern2: + """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: CostBasisPattern = CostBasisPattern(client, acc) + self.outputs: OutputsPattern = OutputsPattern(client, _m(acc, "utxo_count")) + self.realized: RealizedPattern = RealizedPattern(client, acc) + self.relative: RelativePattern4 = RelativePattern4(client, _m(acc, "supply_in")) + self.supply: SupplyPattern2 = SupplyPattern2(client, _m(acc, "supply")) + self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) + + +class _10yTo12yPattern: + """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.outputs: OutputsPattern = OutputsPattern(client, _m(acc, "utxo_count")) + self.realized: RealizedPattern2 = RealizedPattern2(client, acc) + self.relative: RelativePattern2 = RelativePattern2(client, acc) + self.supply: SupplyPattern2 = SupplyPattern2(client, _m(acc, "supply")) + self.unrealized: UnrealizedPattern = UnrealizedPattern(client, acc) + + +class PeriodCagrPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self._10y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("10y", acc)) + self._2y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("2y", acc)) + self._3y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("3y", acc)) + self._4y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("4y", acc)) + self._5y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("5y", acc)) + self._6y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("6y", acc)) + self._8y: MetricPattern4[StoredF32] = MetricPattern4(client, _p("8y", acc)) + + class ActivityPattern2: """Pattern struct for repeated tree structure.""" @@ -4040,64 +4040,6 @@ class SplitPattern2(Generic[T]): self.open: MetricPattern1[T] = MetricPattern1(client, _m(acc, "open")) -class CoinbasePattern2: - """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) - - -class SegwitAdoptionPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.base: MetricPattern11[StoredF32] = MetricPattern11(client, acc) - self.cumulative: MetricPattern2[StoredF32] = MetricPattern2( - client, _m(acc, "cumulative") - ) - self.sum: MetricPattern2[StoredF32] = MetricPattern2(client, _m(acc, "sum")) - - -class CoinbasePattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.bitcoin: BitcoinPattern = BitcoinPattern(client, _m(acc, "btc")) - self.dollars: DollarsPattern[Dollars] = DollarsPattern(client, _m(acc, "usd")) - self.sats: DollarsPattern[Sats] = DollarsPattern(client, acc) - - -class UnclaimedRewardsPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.bitcoin: BitcoinPattern2[Bitcoin] = BitcoinPattern2(client, _m(acc, "btc")) - self.dollars: BlockCountPattern[Dollars] = BlockCountPattern( - client, _m(acc, "usd") - ) - self.sats: BlockCountPattern[Sats] = BlockCountPattern(client, acc) - - -class _2015Pattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.bitcoin: MetricPattern4[Bitcoin] = MetricPattern4(client, _m(acc, "btc")) - self.dollars: MetricPattern4[Dollars] = MetricPattern4(client, _m(acc, "usd")) - self.sats: MetricPattern4[Sats] = MetricPattern4(client, acc) - - class CostBasisPattern2: """Pattern struct for repeated tree structure.""" @@ -4114,6 +4056,26 @@ class CostBasisPattern2: ) +class CoinbasePattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.bitcoin: BitcoinPattern = BitcoinPattern(client, _m(acc, "btc")) + self.dollars: DollarsPattern[Dollars] = DollarsPattern(client, _m(acc, "usd")) + self.sats: DollarsPattern[Sats] = DollarsPattern(client, acc) + + +class _2015Pattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.bitcoin: MetricPattern4[Bitcoin] = MetricPattern4(client, _m(acc, "btc")) + self.dollars: MetricPattern4[Dollars] = MetricPattern4(client, _m(acc, "usd")) + self.sats: MetricPattern4[Sats] = MetricPattern4(client, acc) + + class ActiveSupplyPattern: """Pattern struct for repeated tree structure.""" @@ -4124,17 +4086,62 @@ class ActiveSupplyPattern: self.sats: MetricPattern1[Sats] = MetricPattern1(client, acc) -class CostBasisPattern: +class SegwitAdoptionPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.max: MetricPattern1[Dollars] = MetricPattern1( - client, _m(acc, "max_cost_basis") + self.base: MetricPattern11[StoredF32] = MetricPattern11(client, acc) + self.cumulative: MetricPattern2[StoredF32] = MetricPattern2( + client, _m(acc, "cumulative") ) - self.min: MetricPattern1[Dollars] = MetricPattern1( - client, _m(acc, "min_cost_basis") + self.sum: MetricPattern2[StoredF32] = MetricPattern2(client, _m(acc, "sum")) + + +class CoinbasePattern2: + """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) + + +class UnclaimedRewardsPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.bitcoin: BitcoinPattern2[Bitcoin] = BitcoinPattern2(client, _m(acc, "btc")) + self.dollars: BlockCountPattern[Dollars] = BlockCountPattern( + client, _m(acc, "usd") + ) + self.sats: BlockCountPattern[Sats] = BlockCountPattern(client, acc) + + +class _1dReturns1mSdPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.sd: MetricPattern4[StoredF32] = MetricPattern4(client, _m(acc, "sd")) + self.sma: MetricPattern4[StoredF32] = MetricPattern4(client, _m(acc, "sma")) + + +class SupplyPattern2: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.halved: ActiveSupplyPattern = ActiveSupplyPattern( + client, _m(acc, "halved") + ) + self.total: ActiveSupplyPattern = ActiveSupplyPattern(client, acc) class RelativePattern4: @@ -4150,24 +4157,17 @@ class RelativePattern4: ) -class SupplyPattern2: +class CostBasisPattern: """Pattern struct for repeated tree structure.""" def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.halved: ActiveSupplyPattern = ActiveSupplyPattern( - client, _m(acc, "halved") + self.max: MetricPattern1[Dollars] = MetricPattern1( + client, _m(acc, "max_cost_basis") + ) + self.min: MetricPattern1[Dollars] = MetricPattern1( + client, _m(acc, "min_cost_basis") ) - self.total: ActiveSupplyPattern = ActiveSupplyPattern(client, acc) - - -class _1dReturns1mSdPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.sd: MetricPattern4[StoredF32] = MetricPattern4(client, _m(acc, "sd")) - self.sma: MetricPattern4[StoredF32] = MetricPattern4(client, _m(acc, "sma")) class BitcoinPattern2(Generic[T]): @@ -4197,16 +4197,8 @@ class SatsPattern(Generic[T]): def __init__(self, client: BrkClientBase, acc: str): """Create pattern node with accumulated metric name.""" - self.ohlc: MetricPattern1[T] = MetricPattern1(client, _m(acc, "ohlc")) - self.split: SplitPattern2[T] = SplitPattern2(client, acc) - - -class OutputsPattern: - """Pattern struct for repeated tree structure.""" - - def __init__(self, client: BrkClientBase, acc: str): - """Create pattern node with accumulated metric name.""" - self.utxo_count: MetricPattern1[StoredU64] = MetricPattern1(client, acc) + self.ohlc: MetricPattern1[T] = MetricPattern1(client, _m(acc, "ohlc_sats")) + self.split: SplitPattern2[T] = SplitPattern2(client, _m(acc, "sats")) class RealizedPriceExtraPattern: @@ -4217,6 +4209,14 @@ class RealizedPriceExtraPattern: self.ratio: MetricPattern4[StoredF32] = MetricPattern4(client, acc) +class OutputsPattern: + """Pattern struct for repeated tree structure.""" + + def __init__(self, client: BrkClientBase, acc: str): + """Create pattern node with accumulated metric name.""" + self.utxo_count: MetricPattern1[StoredU64] = MetricPattern1(client, acc) + + # Metrics tree classes