diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index 44dc94fdd..4b1727c7e 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -3574,97 +3574,97 @@ impl MetricsTree_Blocks_Count { /// Metrics tree node. pub struct MetricsTree_Blocks_Lookback { - pub height_1h_ago: MetricPattern18, - pub height_24h_ago: MetricPattern18, - pub height_3d_ago: MetricPattern18, - pub height_1w_ago: MetricPattern18, - pub height_8d_ago: MetricPattern18, - pub height_9d_ago: MetricPattern18, - pub height_12d_ago: MetricPattern18, - pub height_13d_ago: MetricPattern18, - pub height_2w_ago: MetricPattern18, - pub height_21d_ago: MetricPattern18, - pub height_26d_ago: MetricPattern18, - pub height_1m_ago: MetricPattern18, - pub height_34d_ago: MetricPattern18, - pub height_55d_ago: MetricPattern18, - pub height_2m_ago: MetricPattern18, - pub height_9w_ago: MetricPattern18, - pub height_12w_ago: MetricPattern18, - pub height_89d_ago: MetricPattern18, - pub height_3m_ago: MetricPattern18, - pub height_14w_ago: MetricPattern18, - pub height_111d_ago: MetricPattern18, - pub height_144d_ago: MetricPattern18, - pub height_6m_ago: MetricPattern18, - pub height_26w_ago: MetricPattern18, - pub height_200d_ago: MetricPattern18, - pub height_9m_ago: MetricPattern18, - pub height_350d_ago: MetricPattern18, - pub height_12m_ago: MetricPattern18, - pub height_1y_ago: MetricPattern18, - pub height_14m_ago: MetricPattern18, - pub height_2y_ago: MetricPattern18, - pub height_26m_ago: MetricPattern18, - pub height_3y_ago: MetricPattern18, - pub height_200w_ago: MetricPattern18, - pub height_4y_ago: MetricPattern18, - pub height_5y_ago: MetricPattern18, - pub height_6y_ago: MetricPattern18, - pub height_8y_ago: MetricPattern18, - pub height_9y_ago: MetricPattern18, - pub height_10y_ago: MetricPattern18, - pub height_12y_ago: MetricPattern18, - pub height_14y_ago: MetricPattern18, - pub height_26y_ago: MetricPattern18, + pub _1h: MetricPattern18, + pub _24h: MetricPattern18, + pub _3d: MetricPattern18, + pub _1w: MetricPattern18, + pub _8d: MetricPattern18, + pub _9d: MetricPattern18, + pub _12d: MetricPattern18, + pub _13d: MetricPattern18, + pub _2w: MetricPattern18, + pub _21d: MetricPattern18, + pub _26d: MetricPattern18, + pub _1m: MetricPattern18, + pub _34d: MetricPattern18, + pub _55d: MetricPattern18, + pub _2m: MetricPattern18, + pub _9w: MetricPattern18, + pub _12w: MetricPattern18, + pub _89d: MetricPattern18, + pub _3m: MetricPattern18, + pub _14w: MetricPattern18, + pub _111d: MetricPattern18, + pub _144d: MetricPattern18, + pub _6m: MetricPattern18, + pub _26w: MetricPattern18, + pub _200d: MetricPattern18, + pub _9m: MetricPattern18, + pub _350d: MetricPattern18, + pub _12m: MetricPattern18, + pub _1y: MetricPattern18, + pub _14m: MetricPattern18, + pub _2y: MetricPattern18, + pub _26m: MetricPattern18, + pub _3y: MetricPattern18, + pub _200w: MetricPattern18, + pub _4y: MetricPattern18, + pub _5y: MetricPattern18, + pub _6y: MetricPattern18, + pub _8y: MetricPattern18, + pub _9y: MetricPattern18, + pub _10y: MetricPattern18, + pub _12y: MetricPattern18, + pub _14y: MetricPattern18, + pub _26y: MetricPattern18, } impl MetricsTree_Blocks_Lookback { pub fn new(client: Arc, base_path: String) -> Self { Self { - height_1h_ago: MetricPattern18::new(client.clone(), "height_1h_ago".to_string()), - height_24h_ago: MetricPattern18::new(client.clone(), "height_24h_ago".to_string()), - height_3d_ago: MetricPattern18::new(client.clone(), "height_3d_ago".to_string()), - height_1w_ago: MetricPattern18::new(client.clone(), "height_1w_ago".to_string()), - height_8d_ago: MetricPattern18::new(client.clone(), "height_8d_ago".to_string()), - height_9d_ago: MetricPattern18::new(client.clone(), "height_9d_ago".to_string()), - height_12d_ago: MetricPattern18::new(client.clone(), "height_12d_ago".to_string()), - height_13d_ago: MetricPattern18::new(client.clone(), "height_13d_ago".to_string()), - height_2w_ago: MetricPattern18::new(client.clone(), "height_2w_ago".to_string()), - height_21d_ago: MetricPattern18::new(client.clone(), "height_21d_ago".to_string()), - height_26d_ago: MetricPattern18::new(client.clone(), "height_26d_ago".to_string()), - height_1m_ago: MetricPattern18::new(client.clone(), "height_1m_ago".to_string()), - height_34d_ago: MetricPattern18::new(client.clone(), "height_34d_ago".to_string()), - height_55d_ago: MetricPattern18::new(client.clone(), "height_55d_ago".to_string()), - height_2m_ago: MetricPattern18::new(client.clone(), "height_2m_ago".to_string()), - height_9w_ago: MetricPattern18::new(client.clone(), "height_9w_ago".to_string()), - height_12w_ago: MetricPattern18::new(client.clone(), "height_12w_ago".to_string()), - height_89d_ago: MetricPattern18::new(client.clone(), "height_89d_ago".to_string()), - height_3m_ago: MetricPattern18::new(client.clone(), "height_3m_ago".to_string()), - height_14w_ago: MetricPattern18::new(client.clone(), "height_14w_ago".to_string()), - height_111d_ago: MetricPattern18::new(client.clone(), "height_111d_ago".to_string()), - height_144d_ago: MetricPattern18::new(client.clone(), "height_144d_ago".to_string()), - height_6m_ago: MetricPattern18::new(client.clone(), "height_6m_ago".to_string()), - height_26w_ago: MetricPattern18::new(client.clone(), "height_26w_ago".to_string()), - height_200d_ago: MetricPattern18::new(client.clone(), "height_200d_ago".to_string()), - height_9m_ago: MetricPattern18::new(client.clone(), "height_9m_ago".to_string()), - height_350d_ago: MetricPattern18::new(client.clone(), "height_350d_ago".to_string()), - height_12m_ago: MetricPattern18::new(client.clone(), "height_12m_ago".to_string()), - height_1y_ago: MetricPattern18::new(client.clone(), "height_1y_ago".to_string()), - height_14m_ago: MetricPattern18::new(client.clone(), "height_14m_ago".to_string()), - height_2y_ago: MetricPattern18::new(client.clone(), "height_2y_ago".to_string()), - height_26m_ago: MetricPattern18::new(client.clone(), "height_26m_ago".to_string()), - height_3y_ago: MetricPattern18::new(client.clone(), "height_3y_ago".to_string()), - height_200w_ago: MetricPattern18::new(client.clone(), "height_200w_ago".to_string()), - height_4y_ago: MetricPattern18::new(client.clone(), "height_4y_ago".to_string()), - height_5y_ago: MetricPattern18::new(client.clone(), "height_5y_ago".to_string()), - height_6y_ago: MetricPattern18::new(client.clone(), "height_6y_ago".to_string()), - height_8y_ago: MetricPattern18::new(client.clone(), "height_8y_ago".to_string()), - height_9y_ago: MetricPattern18::new(client.clone(), "height_9y_ago".to_string()), - height_10y_ago: MetricPattern18::new(client.clone(), "height_10y_ago".to_string()), - height_12y_ago: MetricPattern18::new(client.clone(), "height_12y_ago".to_string()), - height_14y_ago: MetricPattern18::new(client.clone(), "height_14y_ago".to_string()), - height_26y_ago: MetricPattern18::new(client.clone(), "height_26y_ago".to_string()), + _1h: MetricPattern18::new(client.clone(), "height_1h_ago".to_string()), + _24h: MetricPattern18::new(client.clone(), "height_24h_ago".to_string()), + _3d: MetricPattern18::new(client.clone(), "height_3d_ago".to_string()), + _1w: MetricPattern18::new(client.clone(), "height_1w_ago".to_string()), + _8d: MetricPattern18::new(client.clone(), "height_8d_ago".to_string()), + _9d: MetricPattern18::new(client.clone(), "height_9d_ago".to_string()), + _12d: MetricPattern18::new(client.clone(), "height_12d_ago".to_string()), + _13d: MetricPattern18::new(client.clone(), "height_13d_ago".to_string()), + _2w: MetricPattern18::new(client.clone(), "height_2w_ago".to_string()), + _21d: MetricPattern18::new(client.clone(), "height_21d_ago".to_string()), + _26d: MetricPattern18::new(client.clone(), "height_26d_ago".to_string()), + _1m: MetricPattern18::new(client.clone(), "height_1m_ago".to_string()), + _34d: MetricPattern18::new(client.clone(), "height_34d_ago".to_string()), + _55d: MetricPattern18::new(client.clone(), "height_55d_ago".to_string()), + _2m: MetricPattern18::new(client.clone(), "height_2m_ago".to_string()), + _9w: MetricPattern18::new(client.clone(), "height_9w_ago".to_string()), + _12w: MetricPattern18::new(client.clone(), "height_12w_ago".to_string()), + _89d: MetricPattern18::new(client.clone(), "height_89d_ago".to_string()), + _3m: MetricPattern18::new(client.clone(), "height_3m_ago".to_string()), + _14w: MetricPattern18::new(client.clone(), "height_14w_ago".to_string()), + _111d: MetricPattern18::new(client.clone(), "height_111d_ago".to_string()), + _144d: MetricPattern18::new(client.clone(), "height_144d_ago".to_string()), + _6m: MetricPattern18::new(client.clone(), "height_6m_ago".to_string()), + _26w: MetricPattern18::new(client.clone(), "height_26w_ago".to_string()), + _200d: MetricPattern18::new(client.clone(), "height_200d_ago".to_string()), + _9m: MetricPattern18::new(client.clone(), "height_9m_ago".to_string()), + _350d: MetricPattern18::new(client.clone(), "height_350d_ago".to_string()), + _12m: MetricPattern18::new(client.clone(), "height_12m_ago".to_string()), + _1y: MetricPattern18::new(client.clone(), "height_1y_ago".to_string()), + _14m: MetricPattern18::new(client.clone(), "height_14m_ago".to_string()), + _2y: MetricPattern18::new(client.clone(), "height_2y_ago".to_string()), + _26m: MetricPattern18::new(client.clone(), "height_26m_ago".to_string()), + _3y: MetricPattern18::new(client.clone(), "height_3y_ago".to_string()), + _200w: MetricPattern18::new(client.clone(), "height_200w_ago".to_string()), + _4y: MetricPattern18::new(client.clone(), "height_4y_ago".to_string()), + _5y: MetricPattern18::new(client.clone(), "height_5y_ago".to_string()), + _6y: MetricPattern18::new(client.clone(), "height_6y_ago".to_string()), + _8y: MetricPattern18::new(client.clone(), "height_8y_ago".to_string()), + _9y: MetricPattern18::new(client.clone(), "height_9y_ago".to_string()), + _10y: MetricPattern18::new(client.clone(), "height_10y_ago".to_string()), + _12y: MetricPattern18::new(client.clone(), "height_12y_ago".to_string()), + _14y: MetricPattern18::new(client.clone(), "height_14y_ago".to_string()), + _26y: MetricPattern18::new(client.clone(), "height_26y_ago".to_string()), } } } @@ -5280,15 +5280,12 @@ pub struct MetricsTree_Market_MovingAverage_Sma { pub _89d: BpsCentsRatioSatsUsdPattern, pub _111d: BpsCentsRatioSatsUsdPattern, pub _144d: BpsCentsRatioSatsUsdPattern, - pub _200d: BpsCentsRatioSatsUsdPattern, - pub _350d: BpsCentsRatioSatsUsdPattern, + pub _200d: MetricsTree_Market_MovingAverage_Sma_200d, + pub _350d: MetricsTree_Market_MovingAverage_Sma_350d, pub _1y: BpsCentsRatioSatsUsdPattern, pub _2y: BpsCentsRatioSatsUsdPattern, pub _200w: BpsCentsRatioSatsUsdPattern, pub _4y: BpsCentsRatioSatsUsdPattern, - pub _200d_x2_4: CentsSatsUsdPattern, - pub _200d_x0_8: CentsSatsUsdPattern, - pub _350d_x2: CentsSatsUsdPattern, } impl MetricsTree_Market_MovingAverage_Sma { @@ -5304,15 +5301,60 @@ impl MetricsTree_Market_MovingAverage_Sma { _89d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_89d".to_string()), _111d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_111d".to_string()), _144d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_144d".to_string()), - _200d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_200d".to_string()), - _350d: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_350d".to_string()), + _200d: MetricsTree_Market_MovingAverage_Sma_200d::new(client.clone(), format!("{base_path}_200d")), + _350d: MetricsTree_Market_MovingAverage_Sma_350d::new(client.clone(), format!("{base_path}_350d")), _1y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_1y".to_string()), _2y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_2y".to_string()), _200w: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_200w".to_string()), _4y: BpsCentsRatioSatsUsdPattern::new(client.clone(), "price_sma_4y".to_string()), - _200d_x2_4: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x2_4".to_string()), - _200d_x0_8: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x0_8".to_string()), - _350d_x2: CentsSatsUsdPattern::new(client.clone(), "price_sma_350d_x2".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_200d { + pub cents: MetricPattern1, + pub usd: MetricPattern1, + pub sats: MetricPattern1, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, + pub x2_4: CentsSatsUsdPattern, + pub x0_8: CentsSatsUsdPattern, +} + +impl MetricsTree_Market_MovingAverage_Sma_200d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), "price_sma_200d_cents".to_string()), + usd: MetricPattern1::new(client.clone(), "price_sma_200d_usd".to_string()), + sats: MetricPattern1::new(client.clone(), "price_sma_200d_sats".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_200d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_200d_ratio".to_string()), + x2_4: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x2_4".to_string()), + x0_8: CentsSatsUsdPattern::new(client.clone(), "price_sma_200d_x0_8".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_MovingAverage_Sma_350d { + pub cents: MetricPattern1, + pub usd: MetricPattern1, + pub sats: MetricPattern1, + pub bps: MetricPattern1, + pub ratio: MetricPattern1, + pub x2: CentsSatsUsdPattern, +} + +impl MetricsTree_Market_MovingAverage_Sma_350d { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + cents: MetricPattern1::new(client.clone(), "price_sma_350d_cents".to_string()), + usd: MetricPattern1::new(client.clone(), "price_sma_350d_usd".to_string()), + sats: MetricPattern1::new(client.clone(), "price_sma_350d_sats".to_string()), + bps: MetricPattern1::new(client.clone(), "price_sma_350d_ratio_bps".to_string()), + ratio: MetricPattern1::new(client.clone(), "price_sma_350d_ratio".to_string()), + x2: CentsSatsUsdPattern::new(client.clone(), "price_sma_350d_x2".to_string()), } } } @@ -5362,37 +5404,46 @@ impl MetricsTree_Market_MovingAverage_Ema { /// Metrics tree node. pub struct MetricsTree_Market_Dca { - pub dca_sats_per_day: MetricPattern18, - pub period_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3, - pub period_cost_basis: MetricsTree_Market_Dca_PeriodCostBasis, - pub period_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2, - pub period_cagr: _10y2y3y4y5y6y8yPattern, - pub period_lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3, - pub period_lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2, - pub class_stack: MetricsTree_Market_Dca_ClassStack, - pub class_cost_basis: MetricsTree_Market_Dca_ClassCostBasis, - pub class_return: MetricsTree_Market_Dca_ClassReturn, + pub sats_per_day: MetricPattern18, + pub period: MetricsTree_Market_Dca_Period, + pub class: MetricsTree_Market_Dca_Class, } impl MetricsTree_Market_Dca { pub fn new(client: Arc, base_path: String) -> Self { Self { - dca_sats_per_day: MetricPattern18::new(client.clone(), "dca_sats_per_day".to_string()), - period_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "dca_stack".to_string()), - period_cost_basis: MetricsTree_Market_Dca_PeriodCostBasis::new(client.clone(), format!("{base_path}_period_cost_basis")), - period_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "dca_return".to_string()), - period_cagr: _10y2y3y4y5y6y8yPattern::new(client.clone(), "dca_cagr".to_string()), - period_lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "lump_sum_stack".to_string()), - period_lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "lump_sum_return".to_string()), - class_stack: MetricsTree_Market_Dca_ClassStack::new(client.clone(), format!("{base_path}_class_stack")), - class_cost_basis: MetricsTree_Market_Dca_ClassCostBasis::new(client.clone(), format!("{base_path}_class_cost_basis")), - class_return: MetricsTree_Market_Dca_ClassReturn::new(client.clone(), format!("{base_path}_class_return")), + sats_per_day: MetricPattern18::new(client.clone(), "dca_sats_per_day".to_string()), + period: MetricsTree_Market_Dca_Period::new(client.clone(), format!("{base_path}_period")), + class: MetricsTree_Market_Dca_Class::new(client.clone(), format!("{base_path}_class")), } } } /// Metrics tree node. -pub struct MetricsTree_Market_Dca_PeriodCostBasis { +pub struct MetricsTree_Market_Dca_Period { + pub stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3, + pub cost_basis: MetricsTree_Market_Dca_Period_CostBasis, + pub r#return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2, + pub cagr: _10y2y3y4y5y6y8yPattern, + pub lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3, + pub lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2, +} + +impl MetricsTree_Market_Dca_Period { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "dca_stack".to_string()), + cost_basis: MetricsTree_Market_Dca_Period_CostBasis::new(client.clone(), format!("{base_path}_cost_basis")), + r#return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "dca_return".to_string()), + cagr: _10y2y3y4y5y6y8yPattern::new(client.clone(), "dca_cagr".to_string()), + lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3::new(client.clone(), "lump_sum_stack".to_string()), + lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2::new(client.clone(), "lump_sum_return".to_string()), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_Dca_Period_CostBasis { pub _1w: CentsSatsUsdPattern, pub _1m: CentsSatsUsdPattern, pub _3m: CentsSatsUsdPattern, @@ -5407,7 +5458,7 @@ pub struct MetricsTree_Market_Dca_PeriodCostBasis { pub _10y: CentsSatsUsdPattern, } -impl MetricsTree_Market_Dca_PeriodCostBasis { +impl MetricsTree_Market_Dca_Period_CostBasis { pub fn new(client: Arc, base_path: String) -> Self { Self { _1w: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_1w".to_string()), @@ -5427,7 +5478,24 @@ impl MetricsTree_Market_Dca_PeriodCostBasis { } /// Metrics tree node. -pub struct MetricsTree_Market_Dca_ClassStack { +pub struct MetricsTree_Market_Dca_Class { + pub stack: MetricsTree_Market_Dca_Class_Stack, + pub cost_basis: MetricsTree_Market_Dca_Class_CostBasis, + pub r#return: MetricsTree_Market_Dca_Class_R#return, +} + +impl MetricsTree_Market_Dca_Class { + pub fn new(client: Arc, base_path: String) -> Self { + Self { + stack: MetricsTree_Market_Dca_Class_Stack::new(client.clone(), format!("{base_path}_stack")), + cost_basis: MetricsTree_Market_Dca_Class_CostBasis::new(client.clone(), format!("{base_path}_cost_basis")), + r#return: MetricsTree_Market_Dca_Class_R#return::new(client.clone(), format!("{base_path}_r#return")), + } + } +} + +/// Metrics tree node. +pub struct MetricsTree_Market_Dca_Class_Stack { pub from_2015: BtcCentsSatsUsdPattern, pub from_2016: BtcCentsSatsUsdPattern, pub from_2017: BtcCentsSatsUsdPattern, @@ -5442,7 +5510,7 @@ pub struct MetricsTree_Market_Dca_ClassStack { pub from_2026: BtcCentsSatsUsdPattern, } -impl MetricsTree_Market_Dca_ClassStack { +impl MetricsTree_Market_Dca_Class_Stack { pub fn new(client: Arc, base_path: String) -> Self { Self { from_2015: BtcCentsSatsUsdPattern::new(client.clone(), "dca_stack_from_2015".to_string()), @@ -5462,7 +5530,7 @@ impl MetricsTree_Market_Dca_ClassStack { } /// Metrics tree node. -pub struct MetricsTree_Market_Dca_ClassCostBasis { +pub struct MetricsTree_Market_Dca_Class_CostBasis { pub from_2015: CentsSatsUsdPattern, pub from_2016: CentsSatsUsdPattern, pub from_2017: CentsSatsUsdPattern, @@ -5477,7 +5545,7 @@ pub struct MetricsTree_Market_Dca_ClassCostBasis { pub from_2026: CentsSatsUsdPattern, } -impl MetricsTree_Market_Dca_ClassCostBasis { +impl MetricsTree_Market_Dca_Class_CostBasis { pub fn new(client: Arc, base_path: String) -> Self { Self { from_2015: CentsSatsUsdPattern::new(client.clone(), "dca_cost_basis_from_2015".to_string()), @@ -5497,7 +5565,7 @@ impl MetricsTree_Market_Dca_ClassCostBasis { } /// Metrics tree node. -pub struct MetricsTree_Market_Dca_ClassReturn { +pub struct MetricsTree_Market_Dca_Class_R#return { pub from_2015: BpsPercentRatioPattern, pub from_2016: BpsPercentRatioPattern, pub from_2017: BpsPercentRatioPattern, @@ -5512,7 +5580,7 @@ pub struct MetricsTree_Market_Dca_ClassReturn { pub from_2026: BpsPercentRatioPattern, } -impl MetricsTree_Market_Dca_ClassReturn { +impl MetricsTree_Market_Dca_Class_R#return { pub fn new(client: Arc, base_path: String) -> Self { Self { from_2015: BpsPercentRatioPattern::new(client.clone(), "dca_return_from_2015".to_string()), diff --git a/crates/brk_computer/src/blocks/lookback.rs b/crates/brk_computer/src/blocks/lookback.rs index b175b2c16..e3f37f714 100644 --- a/crates/brk_computer/src/blocks/lookback.rs +++ b/crates/brk_computer/src/blocks/lookback.rs @@ -9,153 +9,153 @@ use super::time; #[derive(Traversable)] pub struct Vecs { - pub height_1h_ago: M::Stored>>, - pub height_24h_ago: M::Stored>>, // 1d - pub height_3d_ago: M::Stored>>, - pub height_1w_ago: M::Stored>>, // 7d - pub height_8d_ago: M::Stored>>, - pub height_9d_ago: M::Stored>>, - pub height_12d_ago: M::Stored>>, - pub height_13d_ago: M::Stored>>, - pub height_2w_ago: M::Stored>>, // 14d - pub height_21d_ago: M::Stored>>, - pub height_26d_ago: M::Stored>>, - pub height_1m_ago: M::Stored>>, // 30d - pub height_34d_ago: M::Stored>>, - pub height_55d_ago: M::Stored>>, - pub height_2m_ago: M::Stored>>, // 60d - pub height_9w_ago: M::Stored>>, // 63d - pub height_12w_ago: M::Stored>>, // 84d - pub height_89d_ago: M::Stored>>, - pub height_3m_ago: M::Stored>>, // 90d - pub height_14w_ago: M::Stored>>, // 98d - pub height_111d_ago: M::Stored>>, - pub height_144d_ago: M::Stored>>, - pub height_6m_ago: M::Stored>>, // 180d - pub height_26w_ago: M::Stored>>, // 182d - pub height_200d_ago: M::Stored>>, - pub height_9m_ago: M::Stored>>, // 270d - pub height_350d_ago: M::Stored>>, - pub height_12m_ago: M::Stored>>, // 360d - pub height_1y_ago: M::Stored>>, // 365d - pub height_14m_ago: M::Stored>>, // 420d - pub height_2y_ago: M::Stored>>, // 730d - pub height_26m_ago: M::Stored>>, // 780d - pub height_3y_ago: M::Stored>>, // 1095d - pub height_200w_ago: M::Stored>>, // 1400d - pub height_4y_ago: M::Stored>>, // 1460d - pub height_5y_ago: M::Stored>>, // 1825d - pub height_6y_ago: M::Stored>>, // 2190d - pub height_8y_ago: M::Stored>>, // 2920d - pub height_9y_ago: M::Stored>>, // 3285d - pub height_10y_ago: M::Stored>>, // 3650d - pub height_12y_ago: M::Stored>>, // 4380d - pub height_14y_ago: M::Stored>>, // 5110d - pub height_26y_ago: M::Stored>>, // 9490d + pub _1h: M::Stored>>, + pub _24h: M::Stored>>, // 1d + pub _3d: M::Stored>>, + pub _1w: M::Stored>>, // 7d + pub _8d: M::Stored>>, + pub _9d: M::Stored>>, + pub _12d: M::Stored>>, + pub _13d: M::Stored>>, + pub _2w: M::Stored>>, // 14d + pub _21d: M::Stored>>, + pub _26d: M::Stored>>, + pub _1m: M::Stored>>, // 30d + pub _34d: M::Stored>>, + pub _55d: M::Stored>>, + pub _2m: M::Stored>>, // 60d + pub _9w: M::Stored>>, // 63d + pub _12w: M::Stored>>, // 84d + pub _89d: M::Stored>>, + pub _3m: M::Stored>>, // 90d + pub _14w: M::Stored>>, // 98d + pub _111d: M::Stored>>, + pub _144d: M::Stored>>, + pub _6m: M::Stored>>, // 180d + pub _26w: M::Stored>>, // 182d + pub _200d: M::Stored>>, + pub _9m: M::Stored>>, // 270d + pub _350d: M::Stored>>, + pub _12m: M::Stored>>, // 360d + pub _1y: M::Stored>>, // 365d + pub _14m: M::Stored>>, // 420d + pub _2y: M::Stored>>, // 730d + pub _26m: M::Stored>>, // 780d + pub _3y: M::Stored>>, // 1095d + pub _200w: M::Stored>>, // 1400d + pub _4y: M::Stored>>, // 1460d + pub _5y: M::Stored>>, // 1825d + pub _6y: M::Stored>>, // 2190d + pub _8y: M::Stored>>, // 2920d + pub _9y: M::Stored>>, // 3285d + pub _10y: M::Stored>>, // 3650d + pub _12y: M::Stored>>, // 4380d + pub _14y: M::Stored>>, // 5110d + pub _26y: M::Stored>>, // 9490d } impl Vecs { pub(crate) fn forced_import(db: &Database, version: Version) -> Result { Ok(Self { - height_1h_ago: ImportableVec::forced_import(db, "height_1h_ago", version)?, - height_24h_ago: ImportableVec::forced_import(db, "height_24h_ago", version)?, - height_3d_ago: ImportableVec::forced_import(db, "height_3d_ago", version)?, - height_1w_ago: ImportableVec::forced_import(db, "height_1w_ago", version)?, - height_8d_ago: ImportableVec::forced_import(db, "height_8d_ago", version)?, - height_9d_ago: ImportableVec::forced_import(db, "height_9d_ago", version)?, - height_12d_ago: ImportableVec::forced_import(db, "height_12d_ago", version)?, - height_13d_ago: ImportableVec::forced_import(db, "height_13d_ago", version)?, - height_2w_ago: ImportableVec::forced_import(db, "height_2w_ago", version)?, - height_21d_ago: ImportableVec::forced_import(db, "height_21d_ago", version)?, - height_26d_ago: ImportableVec::forced_import(db, "height_26d_ago", version)?, - height_1m_ago: ImportableVec::forced_import(db, "height_1m_ago", version)?, - height_34d_ago: ImportableVec::forced_import(db, "height_34d_ago", version)?, - height_55d_ago: ImportableVec::forced_import(db, "height_55d_ago", version)?, - height_2m_ago: ImportableVec::forced_import(db, "height_2m_ago", version)?, - height_9w_ago: ImportableVec::forced_import(db, "height_9w_ago", version)?, - height_12w_ago: ImportableVec::forced_import(db, "height_12w_ago", version)?, - height_89d_ago: ImportableVec::forced_import(db, "height_89d_ago", version)?, - height_3m_ago: ImportableVec::forced_import(db, "height_3m_ago", version)?, - height_14w_ago: ImportableVec::forced_import(db, "height_14w_ago", version)?, - height_111d_ago: ImportableVec::forced_import(db, "height_111d_ago", version)?, - height_144d_ago: ImportableVec::forced_import(db, "height_144d_ago", version)?, - height_6m_ago: ImportableVec::forced_import(db, "height_6m_ago", version)?, - height_26w_ago: ImportableVec::forced_import(db, "height_26w_ago", version)?, - height_200d_ago: ImportableVec::forced_import(db, "height_200d_ago", version)?, - height_9m_ago: ImportableVec::forced_import(db, "height_9m_ago", version)?, - height_350d_ago: ImportableVec::forced_import(db, "height_350d_ago", version)?, - height_12m_ago: ImportableVec::forced_import(db, "height_12m_ago", version)?, - height_1y_ago: ImportableVec::forced_import(db, "height_1y_ago", version)?, - height_14m_ago: ImportableVec::forced_import(db, "height_14m_ago", version)?, - height_2y_ago: ImportableVec::forced_import(db, "height_2y_ago", version)?, - height_26m_ago: ImportableVec::forced_import(db, "height_26m_ago", version)?, - height_3y_ago: ImportableVec::forced_import(db, "height_3y_ago", version)?, - height_200w_ago: ImportableVec::forced_import(db, "height_200w_ago", version)?, - height_4y_ago: ImportableVec::forced_import(db, "height_4y_ago", version)?, - height_5y_ago: ImportableVec::forced_import(db, "height_5y_ago", version)?, - height_6y_ago: ImportableVec::forced_import(db, "height_6y_ago", version)?, - height_8y_ago: ImportableVec::forced_import(db, "height_8y_ago", version)?, - height_9y_ago: ImportableVec::forced_import(db, "height_9y_ago", version)?, - height_10y_ago: ImportableVec::forced_import(db, "height_10y_ago", version)?, - height_12y_ago: ImportableVec::forced_import(db, "height_12y_ago", version)?, - height_14y_ago: ImportableVec::forced_import(db, "height_14y_ago", version)?, - height_26y_ago: ImportableVec::forced_import(db, "height_26y_ago", version)?, + _1h: ImportableVec::forced_import(db, "height_1h_ago", version)?, + _24h: ImportableVec::forced_import(db, "height_24h_ago", version)?, + _3d: ImportableVec::forced_import(db, "height_3d_ago", version)?, + _1w: ImportableVec::forced_import(db, "height_1w_ago", version)?, + _8d: ImportableVec::forced_import(db, "height_8d_ago", version)?, + _9d: ImportableVec::forced_import(db, "height_9d_ago", version)?, + _12d: ImportableVec::forced_import(db, "height_12d_ago", version)?, + _13d: ImportableVec::forced_import(db, "height_13d_ago", version)?, + _2w: ImportableVec::forced_import(db, "height_2w_ago", version)?, + _21d: ImportableVec::forced_import(db, "height_21d_ago", version)?, + _26d: ImportableVec::forced_import(db, "height_26d_ago", version)?, + _1m: ImportableVec::forced_import(db, "height_1m_ago", version)?, + _34d: ImportableVec::forced_import(db, "height_34d_ago", version)?, + _55d: ImportableVec::forced_import(db, "height_55d_ago", version)?, + _2m: ImportableVec::forced_import(db, "height_2m_ago", version)?, + _9w: ImportableVec::forced_import(db, "height_9w_ago", version)?, + _12w: ImportableVec::forced_import(db, "height_12w_ago", version)?, + _89d: ImportableVec::forced_import(db, "height_89d_ago", version)?, + _3m: ImportableVec::forced_import(db, "height_3m_ago", version)?, + _14w: ImportableVec::forced_import(db, "height_14w_ago", version)?, + _111d: ImportableVec::forced_import(db, "height_111d_ago", version)?, + _144d: ImportableVec::forced_import(db, "height_144d_ago", version)?, + _6m: ImportableVec::forced_import(db, "height_6m_ago", version)?, + _26w: ImportableVec::forced_import(db, "height_26w_ago", version)?, + _200d: ImportableVec::forced_import(db, "height_200d_ago", version)?, + _9m: ImportableVec::forced_import(db, "height_9m_ago", version)?, + _350d: ImportableVec::forced_import(db, "height_350d_ago", version)?, + _12m: ImportableVec::forced_import(db, "height_12m_ago", version)?, + _1y: ImportableVec::forced_import(db, "height_1y_ago", version)?, + _14m: ImportableVec::forced_import(db, "height_14m_ago", version)?, + _2y: ImportableVec::forced_import(db, "height_2y_ago", version)?, + _26m: ImportableVec::forced_import(db, "height_26m_ago", version)?, + _3y: ImportableVec::forced_import(db, "height_3y_ago", version)?, + _200w: ImportableVec::forced_import(db, "height_200w_ago", version)?, + _4y: ImportableVec::forced_import(db, "height_4y_ago", version)?, + _5y: ImportableVec::forced_import(db, "height_5y_ago", version)?, + _6y: ImportableVec::forced_import(db, "height_6y_ago", version)?, + _8y: ImportableVec::forced_import(db, "height_8y_ago", version)?, + _9y: ImportableVec::forced_import(db, "height_9y_ago", version)?, + _10y: ImportableVec::forced_import(db, "height_10y_ago", version)?, + _12y: ImportableVec::forced_import(db, "height_12y_ago", version)?, + _14y: ImportableVec::forced_import(db, "height_14y_ago", version)?, + _26y: ImportableVec::forced_import(db, "height_26y_ago", version)?, }) } pub fn window_starts(&self) -> WindowStarts<'_> { WindowStarts { - _24h: &self.height_24h_ago, - _1w: &self.height_1w_ago, - _1m: &self.height_1m_ago, - _1y: &self.height_1y_ago, + _24h: &self._24h, + _1w: &self._1w, + _1m: &self._1m, + _1y: &self._1y, } } pub fn start_vec(&self, days: usize) -> &EagerVec> { match days { - 1 => &self.height_24h_ago, - 3 => &self.height_3d_ago, - 7 => &self.height_1w_ago, - 8 => &self.height_8d_ago, - 9 => &self.height_9d_ago, - 12 => &self.height_12d_ago, - 13 => &self.height_13d_ago, - 14 => &self.height_2w_ago, - 21 => &self.height_21d_ago, - 26 => &self.height_26d_ago, - 30 => &self.height_1m_ago, - 34 => &self.height_34d_ago, - 55 => &self.height_55d_ago, - 60 => &self.height_2m_ago, - 63 => &self.height_9w_ago, - 84 => &self.height_12w_ago, - 89 => &self.height_89d_ago, - 90 => &self.height_3m_ago, - 98 => &self.height_14w_ago, - 111 => &self.height_111d_ago, - 144 => &self.height_144d_ago, - 180 => &self.height_6m_ago, - 182 => &self.height_26w_ago, - 200 => &self.height_200d_ago, - 270 => &self.height_9m_ago, - 350 => &self.height_350d_ago, - 360 => &self.height_12m_ago, - 365 => &self.height_1y_ago, - 420 => &self.height_14m_ago, - 730 => &self.height_2y_ago, - 780 => &self.height_26m_ago, - 1095 => &self.height_3y_ago, - 1400 => &self.height_200w_ago, - 1460 => &self.height_4y_ago, - 1825 => &self.height_5y_ago, - 2190 => &self.height_6y_ago, - 2920 => &self.height_8y_ago, - 3285 => &self.height_9y_ago, - 3650 => &self.height_10y_ago, - 4380 => &self.height_12y_ago, - 5110 => &self.height_14y_ago, - 9490 => &self.height_26y_ago, + 1 => &self._24h, + 3 => &self._3d, + 7 => &self._1w, + 8 => &self._8d, + 9 => &self._9d, + 12 => &self._12d, + 13 => &self._13d, + 14 => &self._2w, + 21 => &self._21d, + 26 => &self._26d, + 30 => &self._1m, + 34 => &self._34d, + 55 => &self._55d, + 60 => &self._2m, + 63 => &self._9w, + 84 => &self._12w, + 89 => &self._89d, + 90 => &self._3m, + 98 => &self._14w, + 111 => &self._111d, + 144 => &self._144d, + 180 => &self._6m, + 182 => &self._26w, + 200 => &self._200d, + 270 => &self._9m, + 350 => &self._350d, + 360 => &self._12m, + 365 => &self._1y, + 420 => &self._14m, + 730 => &self._2y, + 780 => &self._26m, + 1095 => &self._3y, + 1400 => &self._200w, + 1460 => &self._4y, + 1825 => &self._5y, + 2190 => &self._6y, + 2920 => &self._8y, + 3285 => &self._9y, + 3650 => &self._10y, + 4380 => &self._12y, + 5110 => &self._14y, + 9490 => &self._26y, _ => panic!("No start vec for {days} days"), } } @@ -167,67 +167,67 @@ impl Vecs { exit: &Exit, ) -> Result<()> { self.compute_rolling_start_hours(time, starting_indexes, exit, 1, |s| { - &mut s.height_1h_ago + &mut s._1h })?; - self.compute_rolling_start(time, starting_indexes, exit, 1, |s| &mut s.height_24h_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 3, |s| &mut s.height_3d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 7, |s| &mut s.height_1w_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 8, |s| &mut s.height_8d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 9, |s| &mut s.height_9d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 12, |s| &mut s.height_12d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 13, |s| &mut s.height_13d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 14, |s| &mut s.height_2w_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 21, |s| &mut s.height_21d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 26, |s| &mut s.height_26d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 30, |s| &mut s.height_1m_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 34, |s| &mut s.height_34d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 55, |s| &mut s.height_55d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 60, |s| &mut s.height_2m_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 63, |s| &mut s.height_9w_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 84, |s| &mut s.height_12w_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 89, |s| &mut s.height_89d_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 90, |s| &mut s.height_3m_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 98, |s| &mut s.height_14w_ago)?; + self.compute_rolling_start(time, starting_indexes, exit, 1, |s| &mut s._24h)?; + self.compute_rolling_start(time, starting_indexes, exit, 3, |s| &mut s._3d)?; + self.compute_rolling_start(time, starting_indexes, exit, 7, |s| &mut s._1w)?; + self.compute_rolling_start(time, starting_indexes, exit, 8, |s| &mut s._8d)?; + self.compute_rolling_start(time, starting_indexes, exit, 9, |s| &mut s._9d)?; + self.compute_rolling_start(time, starting_indexes, exit, 12, |s| &mut s._12d)?; + self.compute_rolling_start(time, starting_indexes, exit, 13, |s| &mut s._13d)?; + self.compute_rolling_start(time, starting_indexes, exit, 14, |s| &mut s._2w)?; + self.compute_rolling_start(time, starting_indexes, exit, 21, |s| &mut s._21d)?; + self.compute_rolling_start(time, starting_indexes, exit, 26, |s| &mut s._26d)?; + self.compute_rolling_start(time, starting_indexes, exit, 30, |s| &mut s._1m)?; + self.compute_rolling_start(time, starting_indexes, exit, 34, |s| &mut s._34d)?; + self.compute_rolling_start(time, starting_indexes, exit, 55, |s| &mut s._55d)?; + self.compute_rolling_start(time, starting_indexes, exit, 60, |s| &mut s._2m)?; + self.compute_rolling_start(time, starting_indexes, exit, 63, |s| &mut s._9w)?; + self.compute_rolling_start(time, starting_indexes, exit, 84, |s| &mut s._12w)?; + self.compute_rolling_start(time, starting_indexes, exit, 89, |s| &mut s._89d)?; + self.compute_rolling_start(time, starting_indexes, exit, 90, |s| &mut s._3m)?; + self.compute_rolling_start(time, starting_indexes, exit, 98, |s| &mut s._14w)?; self.compute_rolling_start(time, starting_indexes, exit, 111, |s| { - &mut s.height_111d_ago + &mut s._111d })?; self.compute_rolling_start(time, starting_indexes, exit, 144, |s| { - &mut s.height_144d_ago + &mut s._144d })?; - self.compute_rolling_start(time, starting_indexes, exit, 180, |s| &mut s.height_6m_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 182, |s| &mut s.height_26w_ago)?; + self.compute_rolling_start(time, starting_indexes, exit, 180, |s| &mut s._6m)?; + self.compute_rolling_start(time, starting_indexes, exit, 182, |s| &mut s._26w)?; self.compute_rolling_start(time, starting_indexes, exit, 200, |s| { - &mut s.height_200d_ago + &mut s._200d })?; - self.compute_rolling_start(time, starting_indexes, exit, 270, |s| &mut s.height_9m_ago)?; + self.compute_rolling_start(time, starting_indexes, exit, 270, |s| &mut s._9m)?; self.compute_rolling_start(time, starting_indexes, exit, 350, |s| { - &mut s.height_350d_ago + &mut s._350d })?; - self.compute_rolling_start(time, starting_indexes, exit, 360, |s| &mut s.height_12m_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 365, |s| &mut s.height_1y_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 420, |s| &mut s.height_14m_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 730, |s| &mut s.height_2y_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 780, |s| &mut s.height_26m_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 1095, |s| &mut s.height_3y_ago)?; + self.compute_rolling_start(time, starting_indexes, exit, 360, |s| &mut s._12m)?; + self.compute_rolling_start(time, starting_indexes, exit, 365, |s| &mut s._1y)?; + self.compute_rolling_start(time, starting_indexes, exit, 420, |s| &mut s._14m)?; + self.compute_rolling_start(time, starting_indexes, exit, 730, |s| &mut s._2y)?; + self.compute_rolling_start(time, starting_indexes, exit, 780, |s| &mut s._26m)?; + self.compute_rolling_start(time, starting_indexes, exit, 1095, |s| &mut s._3y)?; self.compute_rolling_start(time, starting_indexes, exit, 1400, |s| { - &mut s.height_200w_ago + &mut s._200w })?; - self.compute_rolling_start(time, starting_indexes, exit, 1460, |s| &mut s.height_4y_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 1825, |s| &mut s.height_5y_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 2190, |s| &mut s.height_6y_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 2920, |s| &mut s.height_8y_ago)?; - self.compute_rolling_start(time, starting_indexes, exit, 3285, |s| &mut s.height_9y_ago)?; + self.compute_rolling_start(time, starting_indexes, exit, 1460, |s| &mut s._4y)?; + self.compute_rolling_start(time, starting_indexes, exit, 1825, |s| &mut s._5y)?; + self.compute_rolling_start(time, starting_indexes, exit, 2190, |s| &mut s._6y)?; + self.compute_rolling_start(time, starting_indexes, exit, 2920, |s| &mut s._8y)?; + self.compute_rolling_start(time, starting_indexes, exit, 3285, |s| &mut s._9y)?; self.compute_rolling_start(time, starting_indexes, exit, 3650, |s| { - &mut s.height_10y_ago + &mut s._10y })?; self.compute_rolling_start(time, starting_indexes, exit, 4380, |s| { - &mut s.height_12y_ago + &mut s._12y })?; self.compute_rolling_start(time, starting_indexes, exit, 5110, |s| { - &mut s.height_14y_ago + &mut s._14y })?; self.compute_rolling_start(time, starting_indexes, exit, 9490, |s| { - &mut s.height_26y_ago + &mut s._26y })?; Ok(()) diff --git a/crates/brk_computer/src/cointime/reserve_risk/compute.rs b/crates/brk_computer/src/cointime/reserve_risk/compute.rs index fe481e225..db41f1c53 100644 --- a/crates/brk_computer/src/cointime/reserve_risk/compute.rs +++ b/crates/brk_computer/src/cointime/reserve_risk/compute.rs @@ -16,7 +16,7 @@ impl Vecs { ) -> Result<()> { self.vocdd_median_1y.compute_rolling_median_from_starts( starting_indexes.height, - &blocks.lookback.height_1y_ago, + &blocks.lookback._1y, &value.vocdd.raw.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/address/activity.rs b/crates/brk_computer/src/distribution/address/activity.rs index 911eee0e3..12706c14c 100644 --- a/crates/brk_computer/src/distribution/address/activity.rs +++ b/crates/brk_computer/src/distribution/address/activity.rs @@ -106,7 +106,7 @@ impl ActivityCountVecs { }) } - pub(crate) fn min_stateful_height(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.reactivated .height .len() @@ -197,10 +197,10 @@ impl AddressTypeToActivityCountVecs { )) } - pub(crate) fn min_stateful_height(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.0 .values() - .map(|v| v.min_stateful_height()) + .map(|v| v.min_stateful_len()) .min() .unwrap_or(0) } @@ -272,10 +272,10 @@ impl AddressActivityVecs { }) } - pub(crate) fn min_stateful_height(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.all - .min_stateful_height() - .min(self.by_addresstype.min_stateful_height()) + .min_stateful_len() + .min(self.by_addresstype.min_stateful_len()) } pub(crate) fn par_iter_height_mut( diff --git a/crates/brk_computer/src/distribution/address/address_count.rs b/crates/brk_computer/src/distribution/address/address_count.rs index 86be4525f..1efe10cb9 100644 --- a/crates/brk_computer/src/distribution/address/address_count.rs +++ b/crates/brk_computer/src/distribution/address/address_count.rs @@ -125,7 +125,7 @@ impl AddressTypeToAddrCountVecs { )?)) } - pub(crate) fn min_stateful_height(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.0.values().map(|v| v.height.len()).min().unwrap() } @@ -181,8 +181,8 @@ impl AddrCountsVecs { }) } - pub(crate) fn min_stateful_height(&self) -> usize { - self.all.height.len().min(self.by_addresstype.min_stateful_height()) + pub(crate) fn min_stateful_len(&self) -> usize { + self.all.height.len().min(self.by_addresstype.min_stateful_len()) } pub(crate) fn par_iter_height_mut( diff --git a/crates/brk_computer/src/distribution/cohorts/address/groups.rs b/crates/brk_computer/src/distribution/cohorts/address/groups.rs index 7d88d8fa6..1f3f41358 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/groups.rs +++ b/crates/brk_computer/src/distribution/cohorts/address/groups.rs @@ -98,7 +98,7 @@ impl AddressCohorts { self.par_iter_mut().try_for_each(|v| { v.addr_count_delta.compute( starting_indexes.height, - &blocks.lookback.height_1m_ago, + &blocks.lookback._1m, &v.addr_count.height, exit, ) @@ -141,9 +141,9 @@ impl AddressCohorts { } /// Get minimum height from all separate cohorts' height-indexed vectors. - pub(crate) fn min_separate_stateful_height_len(&self) -> Height { + pub(crate) fn min_stateful_len(&self) -> Height { self.iter_separate() - .map(|v| Height::from(v.min_stateful_height_len())) + .map(|v| Height::from(v.min_stateful_len())) .min() .unwrap_or_default() } diff --git a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs index 001a38058..d74d9fabd 100644 --- a/crates/brk_computer/src/distribution/cohorts/address/vecs.rs +++ b/crates/brk_computer/src/distribution/cohorts/address/vecs.rs @@ -102,11 +102,11 @@ impl Filtered for AddressCohortVecs { } impl DynCohortVecs for AddressCohortVecs { - fn min_stateful_height_len(&self) -> usize { + fn min_stateful_len(&self) -> usize { self.addr_count .height .len() - .min(self.metrics.min_stateful_height_len()) + .min(self.metrics.min_stateful_len()) } fn reset_state_starting_height(&mut self) { diff --git a/crates/brk_computer/src/distribution/cohorts/traits.rs b/crates/brk_computer/src/distribution/cohorts/traits.rs index c4f8aaee0..11f250d39 100644 --- a/crates/brk_computer/src/distribution/cohorts/traits.rs +++ b/crates/brk_computer/src/distribution/cohorts/traits.rs @@ -9,7 +9,7 @@ use crate::{blocks, prices}; /// This trait enables heterogeneous cohort processing via trait objects. pub trait DynCohortVecs: Send + Sync { /// Get minimum length across height-indexed vectors written in block loop. - fn min_stateful_height_len(&self) -> usize; + fn min_stateful_len(&self) -> usize; /// Reset the starting height for state tracking. fn reset_state_starting_height(&mut self); diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs b/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs index 857aec36e..b3a565411 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/groups.rs @@ -712,10 +712,9 @@ impl UTXOCohorts { .try_for_each(|v| v.write_state(height, cleanup)) } - /// Get minimum height from all separate cohorts' + profitability + overlapping realized height-indexed vectors. - pub(crate) fn min_separate_stateful_height_len(&self) -> Height { + pub(crate) fn min_stateful_len(&self) -> Height { self.iter_separate() - .map(|v| Height::from(v.min_stateful_height_len())) + .map(|v| Height::from(v.min_stateful_len())) .chain( self.matured .iter() @@ -723,15 +722,15 @@ impl UTXOCohorts { ) .min() .unwrap_or_default() - .min(Height::from(self.profitability.min_stateful_height_len())) + .min(Height::from(self.profitability.min_stateful_len())) .min(Height::from( - self.all.metrics.realized.min_stateful_height_len(), + self.all.metrics.realized.min_stateful_len(), )) .min(Height::from( - self.sth.metrics.realized.min_stateful_height_len(), + self.sth.metrics.realized.min_stateful_len(), )) .min(Height::from( - self.lth.metrics.realized.min_stateful_height_len(), + self.lth.metrics.realized.min_stateful_len(), )) } diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs index b80f458d6..66ab63ec9 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/core.rs @@ -14,8 +14,8 @@ impl Filtered for UTXOCohortVecs { } impl DynCohortVecs for UTXOCohortVecs { - fn min_stateful_height_len(&self) -> usize { - self.metrics.min_stateful_height_len() + fn min_stateful_len(&self) -> usize { + self.metrics.min_stateful_len() } fn reset_state_starting_height(&mut self) { diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs index b223ebae3..df61652a5 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/minimal.rs @@ -18,8 +18,8 @@ impl Filtered for UTXOCohortVecs { } impl DynCohortVecs for UTXOCohortVecs { - fn min_stateful_height_len(&self) -> usize { - self.metrics.min_stateful_height_len() + fn min_stateful_len(&self) -> usize { + self.metrics.min_stateful_len() } fn reset_state_starting_height(&mut self) { diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs index a5775b7cf..7a1f4a0ae 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/mod.rs @@ -116,8 +116,8 @@ impl Filtered for UTXOCohortVecs { } impl DynCohortVecs for UTXOCohortVecs { - fn min_stateful_height_len(&self) -> usize { - self.metrics.min_stateful_height_len() + fn min_stateful_len(&self) -> usize { + self.metrics.min_stateful_len() } fn reset_state_starting_height(&mut self) { diff --git a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs index abd9b6f41..d24f91adb 100644 --- a/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs +++ b/crates/brk_computer/src/distribution/cohorts/utxo/vecs/type.rs @@ -14,8 +14,8 @@ impl Filtered for UTXOCohortVecs { } impl DynCohortVecs for UTXOCohortVecs { - fn min_stateful_height_len(&self) -> usize { - self.metrics.min_stateful_height_len() + fn min_stateful_len(&self) -> usize { + self.metrics.min_stateful_len() } fn reset_state_starting_height(&mut self) { diff --git a/crates/brk_computer/src/distribution/metrics/activity/core.rs b/crates/brk_computer/src/distribution/metrics/activity/core.rs index f36a8b921..9d30fd4b3 100644 --- a/crates/brk_computer/src/distribution/metrics/activity/core.rs +++ b/crates/brk_computer/src/distribution/metrics/activity/core.rs @@ -111,13 +111,13 @@ impl ActivityCore { ) -> Result<()> { self.sent.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.sent.raw.height, exit, )?; self.coindays_destroyed.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.coindays_destroyed.raw.height, exit, )?; @@ -140,14 +140,14 @@ impl ActivityCore { self.sent_in_profit.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.sent_in_profit.raw.sats.height, &self.sent_in_profit.raw.cents.height, exit, )?; self.sent_in_loss.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.sent_in_loss.raw.sats.height, &self.sent_in_loss.raw.cents.height, exit, diff --git a/crates/brk_computer/src/distribution/metrics/cohort/all.rs b/crates/brk_computer/src/distribution/metrics/cohort/all.rs index 8b60975bd..b8c309546 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/all.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/all.rs @@ -55,14 +55,14 @@ impl CohortMetricsBase for AllCohortMetrics { Ok(()) } - fn min_stateful_height_len(&self) -> usize { + fn min_stateful_len(&self) -> usize { self.supply .min_len() .min(self.outputs.min_len()) .min(self.activity.min_len()) - .min(self.realized.min_stateful_height_len()) - .min(self.unrealized.min_stateful_height_len()) - .min(self.cost_basis.min_stateful_height_len()) + .min(self.realized.min_stateful_len()) + .min(self.unrealized.min_stateful_len()) + .min(self.cost_basis.min_stateful_len()) } fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { diff --git a/crates/brk_computer/src/distribution/metrics/cohort/core.rs b/crates/brk_computer/src/distribution/metrics/cohort/core.rs index b2a5f3688..8d1ffc34b 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/core.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/core.rs @@ -37,13 +37,13 @@ impl CoreCohortMetrics { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.supply .min_len() .min(self.outputs.min_len()) .min(self.activity.min_len()) - .min(self.realized.min_stateful_height_len()) - .min(self.unrealized.min_stateful_height_len()) + .min(self.realized.min_stateful_len()) + .min(self.unrealized.min_stateful_len()) } pub(crate) fn validate_computed_versions(&mut self, base_version: Version) -> Result<()> { diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs index 1bdb123d1..a74c644b4 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended.rs @@ -51,14 +51,14 @@ impl CohortMetricsBase for ExtendedCohortMetrics { Ok(()) } - fn min_stateful_height_len(&self) -> usize { + fn min_stateful_len(&self) -> usize { self.supply .min_len() .min(self.outputs.min_len()) .min(self.activity.min_len()) - .min(self.realized.min_stateful_height_len()) - .min(self.unrealized.min_stateful_height_len()) - .min(self.cost_basis.min_stateful_height_len()) + .min(self.realized.min_stateful_len()) + .min(self.unrealized.min_stateful_len()) + .min(self.cost_basis.min_stateful_len()) } fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { diff --git a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs index 244ec8e8e..9e0ccd7b3 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/extended_adjusted.rs @@ -37,8 +37,8 @@ impl CohortMetricsBase for ExtendedAdjustedCohortMetrics { self.inner.validate_computed_versions(base_version) } - fn min_stateful_height_len(&self) -> usize { - self.inner.min_stateful_height_len() + fn min_stateful_len(&self) -> usize { + self.inner.min_stateful_len() } fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { diff --git a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs index f2f924a59..8df35fc81 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/minimal.rs @@ -33,11 +33,11 @@ impl MinimalCohortMetrics { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.supply .min_len() .min(self.outputs.min_len()) - .min(self.realized.min_stateful_height_len()) + .min(self.realized.min_stateful_len()) } pub(crate) fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { diff --git a/crates/brk_computer/src/distribution/metrics/cohort/type.rs b/crates/brk_computer/src/distribution/metrics/cohort/type.rs index d1e86a367..8c2763d3f 100644 --- a/crates/brk_computer/src/distribution/metrics/cohort/type.rs +++ b/crates/brk_computer/src/distribution/metrics/cohort/type.rs @@ -34,12 +34,12 @@ impl TypeCohortMetrics { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.supply .min_len() .min(self.outputs.min_len()) - .min(self.realized.min_stateful_height_len()) - .min(self.unrealized.min_stateful_height_len()) + .min(self.realized.min_stateful_len()) + .min(self.unrealized.min_stateful_len()) } pub(crate) fn collect_all_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> { diff --git a/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs b/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs index ee6d8a8d3..fa262b4d8 100644 --- a/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/cost_basis/mod.rs @@ -44,7 +44,7 @@ impl CostBasis { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.min .cents .height diff --git a/crates/brk_computer/src/distribution/metrics/mod.rs b/crates/brk_computer/src/distribution/metrics/mod.rs index 38a032461..86ddda5db 100644 --- a/crates/brk_computer/src/distribution/metrics/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/mod.rs @@ -155,13 +155,13 @@ pub trait CohortMetricsBase: CohortMetricsState Vec<&mut dyn AnyStoredVec>; - fn min_stateful_height_len(&self) -> usize { + fn min_stateful_len(&self) -> usize { self.supply() .min_len() .min(self.outputs().min_len()) .min(self.activity().min_len()) - .min(self.realized().min_stateful_height_len()) - .min(self.unrealized().min_stateful_height_len()) + .min(self.realized().min_stateful_len()) + .min(self.unrealized().min_stateful_len()) } fn truncate_push(&mut self, height: Height, state: &CohortState>) -> Result<()> { diff --git a/crates/brk_computer/src/distribution/metrics/outputs/full.rs b/crates/brk_computer/src/distribution/metrics/outputs/full.rs index 29155aa12..203a50c7b 100644 --- a/crates/brk_computer/src/distribution/metrics/outputs/full.rs +++ b/crates/brk_computer/src/distribution/metrics/outputs/full.rs @@ -55,7 +55,7 @@ impl OutputsFull { ) -> Result<()> { self.utxo_count_delta.compute( starting_indexes.height, - &blocks.lookback.height_1m_ago, + &blocks.lookback._1m, &self.base.utxo_count.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/profitability.rs b/crates/brk_computer/src/distribution/metrics/profitability.rs index 3b314cc90..3ac1389de 100644 --- a/crates/brk_computer/src/distribution/metrics/profitability.rs +++ b/crates/brk_computer/src/distribution/metrics/profitability.rs @@ -72,7 +72,7 @@ pub struct ProfitabilityMetrics { } impl ProfitabilityMetrics { - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.range.iter() .chain(self.profit.iter()) .chain(self.loss.iter()) diff --git a/crates/brk_computer/src/distribution/metrics/realized/core.rs b/crates/brk_computer/src/distribution/metrics/realized/core.rs index 09ffa7cf8..e4056e04b 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/core.rs @@ -74,8 +74,8 @@ impl RealizedCore { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.minimal.min_stateful_height_len() + pub(crate) fn min_stateful_len(&self) -> usize { + self.minimal.min_stateful_len() } pub(crate) fn truncate_push(&mut self, height: Height, state: &CohortState) -> Result<()> { @@ -149,14 +149,14 @@ impl RealizedCore { self.cap_delta.compute( starting_indexes.height, - &blocks.lookback.height_1m_ago, + &blocks.lookback._1m, &self.minimal.cap.cents.height, exit, )?; self.net_pnl.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.net_pnl.raw.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/realized/full.rs b/crates/brk_computer/src/distribution/metrics/realized/full.rs index 1d06ffae9..32df5d554 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/full.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/full.rs @@ -263,10 +263,11 @@ impl RealizedFull { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.core - .min_stateful_height_len() - .min(self.profit.value_created.height.len()) + pub(crate) fn min_stateful_len(&self) -> usize { + self.profit + .value_created + .height + .len() .min(self.profit.value_destroyed.height.len()) .min(self.loss.value_created.height.len()) .min(self.loss.value_destroyed.height.len()) @@ -541,7 +542,7 @@ impl RealizedFull { // Net PnL delta (1m base + 24h/1w/1y extended) self.net_pnl.delta.compute( starting_indexes.height, - &blocks.lookback.height_1m_ago, + &blocks.lookback._1m, &self.net_pnl.cumulative.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs index 07655e146..38241bcbb 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/minimal.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/minimal.rs @@ -69,7 +69,7 @@ impl RealizedMinimal { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.cap .cents .height @@ -129,25 +129,25 @@ impl RealizedMinimal { ) -> Result<()> { self.profit.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.profit.raw.cents.height, exit, )?; self.loss.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.loss.raw.cents.height, exit, )?; self.sopr.value_created.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.sopr.value_created.raw.height, exit, )?; self.sopr.value_destroyed.sum.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.sopr.value_destroyed.raw.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/realized/mod.rs b/crates/brk_computer/src/distribution/metrics/realized/mod.rs index 3f5719ccd..e5711465a 100644 --- a/crates/brk_computer/src/distribution/metrics/realized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/realized/mod.rs @@ -22,7 +22,7 @@ use crate::{blocks, distribution::state::{WithCapital, CohortState, CostBasisDat pub trait RealizedLike: Send + Sync { fn as_core(&self) -> &RealizedCore; fn as_core_mut(&mut self) -> &mut RealizedCore; - fn min_stateful_height_len(&self) -> usize; + fn min_stateful_len(&self) -> usize; fn truncate_push(&mut self, height: Height, state: &CohortState>) -> Result<()>; fn compute_rest_part1(&mut self, blocks: &blocks::Vecs, starting_indexes: &Indexes, exit: &Exit) -> Result<()>; fn compute_from_stateful( @@ -36,7 +36,7 @@ pub trait RealizedLike: Send + Sync { impl RealizedLike for RealizedCore { fn as_core(&self) -> &RealizedCore { self } fn as_core_mut(&mut self) -> &mut RealizedCore { self } - fn min_stateful_height_len(&self) -> usize { self.min_stateful_height_len() } + fn min_stateful_len(&self) -> usize { self.min_stateful_len() } fn truncate_push(&mut self, height: Height, state: &CohortState>) -> Result<()> { self.truncate_push(height, state) } @@ -51,7 +51,7 @@ impl RealizedLike for RealizedCore { impl RealizedLike for RealizedFull { fn as_core(&self) -> &RealizedCore { &self.core } fn as_core_mut(&mut self) -> &mut RealizedCore { &mut self.core } - fn min_stateful_height_len(&self) -> usize { self.min_stateful_height_len() } + fn min_stateful_len(&self) -> usize { self.min_stateful_len() } fn truncate_push(&mut self, height: Height, state: &CohortState>) -> Result<()> { self.truncate_push(height, state) } diff --git a/crates/brk_computer/src/distribution/metrics/supply/full.rs b/crates/brk_computer/src/distribution/metrics/supply/full.rs index 70a3d9cba..df040e003 100644 --- a/crates/brk_computer/src/distribution/metrics/supply/full.rs +++ b/crates/brk_computer/src/distribution/metrics/supply/full.rs @@ -56,7 +56,7 @@ impl SupplyFull { ) -> Result<()> { self.delta.compute( starting_indexes.height, - &blocks.lookback.height_1m_ago, + &blocks.lookback._1m, &self.core.total.sats.height, exit, ) diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs index 73da43b90..e6302b442 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/base.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/base.rs @@ -46,9 +46,9 @@ impl UnrealizedBase { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.core - .min_stateful_height_len() + .min_stateful_len() .min(self.invested_capital_in_profit_raw.len()) .min(self.invested_capital_in_loss_raw.len()) .min(self.investor_cap_in_profit_raw.len()) diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs index 14d418ce5..7922e29f0 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/basic.rs @@ -26,7 +26,7 @@ impl UnrealizedBasic { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { + pub(crate) fn min_stateful_len(&self) -> usize { self.profit .raw .cents @@ -75,13 +75,13 @@ impl UnrealizedBasic { ) -> Result<()> { self.profit.sum.compute_rolling_sum( max_from, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.profit.raw.cents.height, exit, )?; self.loss.sum.compute_rolling_sum( max_from, - &blocks.lookback.height_24h_ago, + &blocks.lookback._24h, &self.loss.raw.cents.height, exit, )?; diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs index 6d79e357b..afe4d24c8 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/core.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/core.rs @@ -49,8 +49,8 @@ impl UnrealizedCore { }) } - pub(crate) fn min_stateful_height_len(&self) -> usize { - self.basic.min_stateful_height_len() + pub(crate) fn min_stateful_len(&self) -> usize { + self.basic.min_stateful_len() } pub(crate) fn truncate_push( diff --git a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs index 572f7537a..239d1149f 100644 --- a/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs +++ b/crates/brk_computer/src/distribution/metrics/unrealized/mod.rs @@ -17,7 +17,7 @@ use crate::{blocks, distribution::state::UnrealizedState, prices}; pub trait UnrealizedLike: Send + Sync { fn as_base(&self) -> &UnrealizedBase; fn as_base_mut(&mut self) -> &mut UnrealizedBase; - fn min_stateful_height_len(&self) -> usize; + fn min_stateful_len(&self) -> usize; fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()>; fn compute_rest( &mut self, @@ -40,8 +40,8 @@ impl UnrealizedLike for UnrealizedBase { fn as_base_mut(&mut self) -> &mut UnrealizedBase { self } - fn min_stateful_height_len(&self) -> usize { - self.min_stateful_height_len() + fn min_stateful_len(&self) -> usize { + self.min_stateful_len() } fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()> { self.truncate_push(height, state) @@ -71,8 +71,8 @@ impl UnrealizedLike for UnrealizedFull { fn as_base_mut(&mut self) -> &mut UnrealizedBase { &mut self.inner } - fn min_stateful_height_len(&self) -> usize { - self.inner.min_stateful_height_len() + fn min_stateful_len(&self) -> usize { + self.inner.min_stateful_len() } fn truncate_push(&mut self, height: Height, state: &UnrealizedState) -> Result<()> { self.truncate_push_all(height, state) diff --git a/crates/brk_computer/src/distribution/vecs.rs b/crates/brk_computer/src/distribution/vecs.rs index 3d99bc0d0..b41feda6a 100644 --- a/crates/brk_computer/src/distribution/vecs.rs +++ b/crates/brk_computer/src/distribution/vecs.rs @@ -23,7 +23,7 @@ use crate::{ state::BlockState, }, indexes, inputs, - internal::{finalize_db, open_db, ComputedPerBlockCumulative}, + internal::{ComputedPerBlockCumulative, finalize_db, open_db}, outputs, prices, transactions, }; @@ -240,16 +240,7 @@ impl Vecs { // 1. Find minimum height we have data for across stateful vecs let current_height = Height::from(self.supply_state.len()); - debug!("supply_state.len={}", self.supply_state.len()); - debug!("utxo_cohorts.min={}", self.utxo_cohorts.min_separate_stateful_height_len()); - debug!("address_cohorts.min={}", self.address_cohorts.min_separate_stateful_height_len()); - debug!("address_indexes.min={}", self.any_address_indexes.min_stamped_height()); - debug!("addresses_data.min={}", self.addresses_data.min_stamped_height()); - debug!("addr_count.min={}", self.addr_count.min_stateful_height()); - debug!("empty_addr_count.min={}", self.empty_addr_count.min_stateful_height()); - debug!("address_activity.min={}", self.address_activity.min_stateful_height()); - debug!("coinblocks_destroyed.raw.height.len={}", self.coinblocks_destroyed.raw.height.len()); - let min_stateful = self.min_stateful_height_len(); + let min_stateful = self.min_stateful_len(); // 2. Determine start mode and recover/reset state // Clamp to starting_indexes.height to handle reorg (indexer may require earlier start) @@ -423,10 +414,8 @@ impl Vecs { )?; // 6b. Compute address count sum (by addresstype → all) - self.addr_count - .compute_rest(starting_indexes, exit)?; - self.empty_addr_count - .compute_rest(starting_indexes, exit)?; + self.addr_count.compute_rest(starting_indexes, exit)?; + self.empty_addr_count.compute_rest(starting_indexes, exit)?; // 6c. Compute total_addr_count = addr_count + empty_addr_count self.total_addr_count.compute( @@ -486,16 +475,47 @@ impl Vecs { } /// Get minimum length across all height-indexed stateful vectors. - fn min_stateful_height_len(&self) -> Height { + fn min_stateful_len(&self) -> Height { + debug!("supply_state.len={}", self.supply_state.len()); + debug!( + "utxo_cohorts.min={}", + self.utxo_cohorts.min_stateful_len() + ); + debug!( + "address_cohorts.min={}", + self.address_cohorts.min_stateful_len() + ); + debug!( + "address_indexes.min={}", + self.any_address_indexes.min_stamped_height() + ); + debug!( + "addresses_data.min={}", + self.addresses_data.min_stamped_height() + ); + debug!("addr_count.min={}", self.addr_count.min_stateful_len()); + debug!( + "empty_addr_count.min={}", + self.empty_addr_count.min_stateful_len() + ); + debug!( + "address_activity.min={}", + self.address_activity.min_stateful_len() + ); + debug!( + "coinblocks_destroyed.raw.height.len={}", + self.coinblocks_destroyed.raw.height.len() + ); + self.utxo_cohorts - .min_separate_stateful_height_len() - .min(self.address_cohorts.min_separate_stateful_height_len()) + .min_stateful_len() + .min(self.address_cohorts.min_stateful_len()) .min(Height::from(self.supply_state.len())) .min(self.any_address_indexes.min_stamped_height()) .min(self.addresses_data.min_stamped_height()) - .min(Height::from(self.addr_count.min_stateful_height())) - .min(Height::from(self.empty_addr_count.min_stateful_height())) - .min(Height::from(self.address_activity.min_stateful_height())) + .min(Height::from(self.addr_count.min_stateful_len())) + .min(Height::from(self.empty_addr_count.min_stateful_len())) + .min(Height::from(self.address_activity.min_stateful_len())) .min(Height::from(self.coinblocks_destroyed.raw.height.len())) } } diff --git a/crates/brk_computer/src/internal/per_block/ratio/sma.rs b/crates/brk_computer/src/internal/per_block/ratio/sma.rs index e50df755e..326042849 100644 --- a/crates/brk_computer/src/internal/per_block/ratio/sma.rs +++ b/crates/brk_computer/src/internal/per_block/ratio/sma.rs @@ -67,11 +67,11 @@ impl RatioSma { // Rolling SMAs for (sma, lookback) in [ - (&mut self._1w, &blocks.lookback.height_1w_ago), - (&mut self._1m, &blocks.lookback.height_1m_ago), - (&mut self._1y, &blocks.lookback.height_1y_ago), - (&mut self._2y, &blocks.lookback.height_2y_ago), - (&mut self._4y, &blocks.lookback.height_4y_ago), + (&mut self._1w, &blocks.lookback._1w), + (&mut self._1m, &blocks.lookback._1m), + (&mut self._1y, &blocks.lookback._1y), + (&mut self._2y, &blocks.lookback._2y), + (&mut self._4y, &blocks.lookback._4y), ] { sma.bps.height.compute_rolling_average( starting_indexes.height, diff --git a/crates/brk_computer/src/market/dca/compute.rs b/crates/brk_computer/src/market/dca/compute.rs index 96c296168..c10e9d780 100644 --- a/crates/brk_computer/src/market/dca/compute.rs +++ b/crates/brk_computer/src/market/dca/compute.rs @@ -26,7 +26,7 @@ impl Vecs { // Value = sats_from_dca(close_price) on day-boundary blocks, Sats::ZERO otherwise. { let mut last_di: Option = None; - self.dca_sats_per_day.compute_transform( + self.sats_per_day.compute_transform( starting_indexes.height, h2d, |(h, di, _)| { @@ -50,12 +50,12 @@ impl Vecs { } // DCA by period - stack (rolling sum via _start vecs) - for (stack, days) in self.period_stack.iter_mut_with_days() { + for (stack, days) in self.period.stack.iter_mut_with_days() { let window_starts = blocks.lookback.start_vec(days as usize); stack.sats.height.compute_rolling_sum( starting_indexes.height, window_starts, - &self.dca_sats_per_day, + &self.sats_per_day, exit, )?; } @@ -63,7 +63,7 @@ impl Vecs { // DCA by period - average price (derived from stack) let starting_height = starting_indexes.height.to_usize(); for (average_price, stack, days) in - self.period_cost_basis.zip_mut_with_days(&self.period_stack) + self.period.cost_basis.zip_mut_with_days(&self.period.stack) { let days = days as usize; let start = average_price.cents.height.len().min(starting_height); @@ -91,9 +91,10 @@ impl Vecs { // DCA by period - returns (compute from average price) for (returns, (average_price, _)) in self - .period_return + .period + .r#return .iter_mut() - .zip(self.period_cost_basis.iter_with_days()) + .zip(self.period.cost_basis.iter_with_days()) { returns.compute_binary::( starting_indexes.height, @@ -104,7 +105,7 @@ impl Vecs { } // DCA by period - CAGR (computed from returns at height level) - for (cagr, returns, days) in self.period_cagr.zip_mut_with_period(&self.period_return) { + for (cagr, returns, days) in self.period.cagr.zip_mut_with_period(&self.period.r#return) { let years = days as f64 / 365.0; cagr.bps.height.compute_transform( starting_indexes.height, @@ -121,7 +122,7 @@ impl Vecs { // Lump sum by period - stack let lookback_dca = lookback.price_lookback.as_dca_period(); for (stack, lookback_price, days) in - self.period_lump_sum_stack.zip_mut_with_days(&lookback_dca) + self.period.lump_sum_stack.zip_mut_with_days(&lookback_dca) { let total_invested = DCA_AMOUNT * days as usize; let ls_start = stack.sats.height.len().min(starting_height); @@ -147,7 +148,8 @@ impl Vecs { // Lump sum by period - returns (compute from lookback price) for (returns, (lookback_price, _)) in self - .period_lump_sum_return + .period + .lump_sum_return .iter_mut() .zip(lookback_dca.iter_with_days()) { @@ -161,7 +163,7 @@ impl Vecs { // DCA by year class - stack (cumulative sum from class start date) let start_days = super::ByDcaClass::<()>::start_days(); - for (stack, day1) in self.class_stack.iter_mut().zip(start_days) { + for (stack, day1) in self.class.stack.iter_mut().zip(start_days) { let mut last_di: Option = None; let mut prev_value = if starting_height > 0 { stack.sats.height.collect_one_at(starting_height - 1).unwrap_or_default() @@ -213,9 +215,10 @@ impl Vecs { // DCA by year class - average price (derived from stack) let start_days = super::ByDcaClass::<()>::start_days(); for ((average_price, stack), from) in self - .class_cost_basis + .class + .cost_basis .iter_mut() - .zip(self.class_stack.iter()) + .zip(self.class.stack.iter()) .zip(start_days) { let from_usize = from.to_usize(); @@ -243,9 +246,10 @@ impl Vecs { // DCA by year class - returns (compute from average price) for (returns, average_price) in self - .class_return + .class + .r#return .iter_mut() - .zip(self.class_cost_basis.iter()) + .zip(self.class.cost_basis.iter()) { returns.compute_binary::( starting_indexes.height, diff --git a/crates/brk_computer/src/market/dca/import.rs b/crates/brk_computer/src/market/dca/import.rs index 87b5275ee..340b2d8a7 100644 --- a/crates/brk_computer/src/market/dca/import.rs +++ b/crates/brk_computer/src/market/dca/import.rs @@ -3,6 +3,7 @@ use brk_types::Version; use vecdb::{Database, ImportableVec}; use super::{ByDcaCagr, ByDcaClass, ByDcaPeriod, Vecs}; +use super::vecs::{ClassVecs, PeriodVecs}; use crate::{ indexes, internal::{AmountPerBlock, PercentPerBlock, Price}, @@ -14,27 +15,27 @@ impl Vecs { version: Version, indexes: &indexes::Vecs, ) -> Result { - let period_stack = ByDcaPeriod::try_new(|name, _days| { + let stack = ByDcaPeriod::try_new(|name, _days| { AmountPerBlock::forced_import(db, &format!("dca_stack_{name}"), version, indexes) })?; - let period_cost_basis = ByDcaPeriod::try_new(|name, _days| { + let cost_basis = ByDcaPeriod::try_new(|name, _days| { Price::forced_import(db, &format!("dca_cost_basis_{name}"), version, indexes) })?; - let period_return = ByDcaPeriod::try_new(|name, _days| { + let r#return = ByDcaPeriod::try_new(|name, _days| { PercentPerBlock::forced_import(db, &format!("dca_return_{name}"), version, indexes) })?; - let period_cagr = ByDcaCagr::try_new(|name, _days| { + let cagr = ByDcaCagr::try_new(|name, _days| { PercentPerBlock::forced_import(db, &format!("dca_cagr_{name}"), version, indexes) })?; - let period_lump_sum_stack = ByDcaPeriod::try_new(|name, _days| { + let lump_sum_stack = ByDcaPeriod::try_new(|name, _days| { AmountPerBlock::forced_import(db, &format!("lump_sum_stack_{name}"), version, indexes) })?; - let period_lump_sum_return = ByDcaPeriod::try_new(|name, _days| { + let lump_sum_return = ByDcaPeriod::try_new(|name, _days| { PercentPerBlock::forced_import( db, &format!("lump_sum_return_{name}"), @@ -56,16 +57,20 @@ impl Vecs { })?; Ok(Self { - dca_sats_per_day: ImportableVec::forced_import(db, "dca_sats_per_day", version)?, - period_stack, - period_cost_basis, - period_return, - period_cagr, - period_lump_sum_stack, - period_lump_sum_return, - class_stack, - class_cost_basis, - class_return, + sats_per_day: ImportableVec::forced_import(db, "dca_sats_per_day", version)?, + period: PeriodVecs { + stack, + cost_basis, + r#return, + cagr, + lump_sum_stack, + lump_sum_return, + }, + class: ClassVecs { + stack: class_stack, + cost_basis: class_cost_basis, + r#return: class_return, + }, }) } } diff --git a/crates/brk_computer/src/market/dca/vecs.rs b/crates/brk_computer/src/market/dca/vecs.rs index fffea582e..38a6ab8ae 100644 --- a/crates/brk_computer/src/market/dca/vecs.rs +++ b/crates/brk_computer/src/market/dca/vecs.rs @@ -4,24 +4,27 @@ use vecdb::{EagerVec, PcoVec, Rw, StorageMode}; use super::{ByDcaCagr, ByDcaClass, ByDcaPeriod}; use crate::internal::{AmountPerBlock, ComputedPerBlock, PercentPerBlock, Price}; + +#[derive(Traversable)] +pub struct PeriodVecs { + pub stack: ByDcaPeriod>, + pub cost_basis: ByDcaPeriod>>, + pub r#return: ByDcaPeriod>, + pub cagr: ByDcaCagr>, + pub lump_sum_stack: ByDcaPeriod>, + pub lump_sum_return: ByDcaPeriod>, +} + +#[derive(Traversable)] +pub struct ClassVecs { + pub stack: ByDcaClass>, + pub cost_basis: ByDcaClass>>, + pub r#return: ByDcaClass>, +} + #[derive(Traversable)] pub struct Vecs { - /// Per-height DCA sats contribution: sats_from_dca(close) on day boundaries, 0 otherwise. - /// Computed once, reused by all period rolling sums. - pub dca_sats_per_day: M::Stored>>, - - // DCA by period - pub period_stack: ByDcaPeriod>, - pub period_cost_basis: ByDcaPeriod>>, - pub period_return: ByDcaPeriod>, - pub period_cagr: ByDcaCagr>, - - // Lump sum by period (for comparison with DCA) - pub period_lump_sum_stack: ByDcaPeriod>, - pub period_lump_sum_return: ByDcaPeriod>, - - // DCA by year class - pub class_stack: ByDcaClass>, - pub class_cost_basis: ByDcaClass>>, - pub class_return: ByDcaClass>, + pub sats_per_day: M::Stored>>, + pub period: PeriodVecs, + pub class: ClassVecs, } diff --git a/crates/brk_computer/src/market/moving_average/vecs.rs b/crates/brk_computer/src/market/moving_average/vecs.rs index a3930cb7f..030da5c74 100644 --- a/crates/brk_computer/src/market/moving_average/vecs.rs +++ b/crates/brk_computer/src/market/moving_average/vecs.rs @@ -22,8 +22,11 @@ pub struct SmaVecs { pub _2y: PriceWithRatioPerBlock, pub _200w: PriceWithRatioPerBlock, pub _4y: PriceWithRatioPerBlock, + #[traversable(wrap = "200d", rename = "x2_4")] pub _200d_x2_4: Price>, + #[traversable(wrap = "200d", rename = "x0_8")] pub _200d_x0_8: Price>, + #[traversable(wrap = "350d", rename = "x2")] pub _350d_x2: Price>, } diff --git a/crates/brk_computer/src/market/range/compute.rs b/crates/brk_computer/src/market/range/compute.rs index 0625c48f7..95987e377 100644 --- a/crates/brk_computer/src/market/range/compute.rs +++ b/crates/brk_computer/src/market/range/compute.rs @@ -19,22 +19,22 @@ impl Vecs { ( &mut self.min._1w.cents.height, &mut self.max._1w.cents.height, - &blocks.lookback.height_1w_ago, + &blocks.lookback._1w, ), ( &mut self.min._2w.cents.height, &mut self.max._2w.cents.height, - &blocks.lookback.height_2w_ago, + &blocks.lookback._2w, ), ( &mut self.min._1m.cents.height, &mut self.max._1m.cents.height, - &blocks.lookback.height_1m_ago, + &blocks.lookback._1m, ), ( &mut self.min._1y.cents.height, &mut self.max._1y.cents.height, - &blocks.lookback.height_1y_ago, + &blocks.lookback._1y, ), ] { min_vec.compute_rolling_min_from_starts( @@ -75,7 +75,7 @@ impl Vecs { // 2w rolling sum of true range self.true_range_sum_2w.height.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_2w_ago, + &blocks.lookback._2w, &self.true_range.height, exit, )?; @@ -88,7 +88,7 @@ impl Vecs { &self.true_range_sum_2w.height, &self.max._2w.cents.height, &self.min._2w.cents.height, - &blocks.lookback.height_2w_ago, + &blocks.lookback._2w, |(h, tr_sum, max, min, window_start, ..)| { let range = f64::from(max) - f64::from(min); let n = (h.to_usize() - window_start.to_usize() + 1) as f32; diff --git a/crates/brk_computer/src/market/technical/compute.rs b/crates/brk_computer/src/market/technical/compute.rs index 178a27f90..8529a6e02 100644 --- a/crates/brk_computer/src/market/technical/compute.rs +++ b/crates/brk_computer/src/market/technical/compute.rs @@ -44,7 +44,7 @@ impl Vecs { self.stoch_d.bps.height.compute_rolling_average( starting_indexes.height, - &blocks.lookback.height_3d_ago, + &blocks.lookback._3d, &self.stoch_k.bps.height, exit, )?; diff --git a/crates/brk_computer/src/mining/hashrate/compute.rs b/crates/brk_computer/src/mining/hashrate/compute.rs index ebbc0668d..ee018058e 100644 --- a/crates/brk_computer/src/mining/hashrate/compute.rs +++ b/crates/brk_computer/src/mining/hashrate/compute.rs @@ -38,10 +38,10 @@ impl Vecs { let hash_rate = &self.hash_rate.height; for (sma, window) in [ - (&mut self.hash_rate_sma._1w.height, &lookback.height_1w_ago), - (&mut self.hash_rate_sma._1m.height, &lookback.height_1m_ago), - (&mut self.hash_rate_sma._2m.height, &lookback.height_2m_ago), - (&mut self.hash_rate_sma._1y.height, &lookback.height_1y_ago), + (&mut self.hash_rate_sma._1w.height, &lookback._1w), + (&mut self.hash_rate_sma._1m.height, &lookback._1m), + (&mut self.hash_rate_sma._2m.height, &lookback._2m), + (&mut self.hash_rate_sma._1y.height, &lookback._1y), ] { sma.compute_rolling_average(starting_indexes.height, window, hash_rate, exit)?; } diff --git a/crates/brk_computer/src/mining/rewards/compute.rs b/crates/brk_computer/src/mining/rewards/compute.rs index 10c8e533a..f01662438 100644 --- a/crates/brk_computer/src/mining/rewards/compute.rs +++ b/crates/brk_computer/src/mining/rewards/compute.rs @@ -156,7 +156,7 @@ impl Vecs { self.subsidy_sma_1y.cents.height.compute_rolling_average( starting_indexes.height, - &lookback.height_1y_ago, + &lookback._1y, &self.subsidy.base.cents.height, exit, )?; diff --git a/crates/brk_computer/src/supply/compute.rs b/crates/brk_computer/src/supply/compute.rs index b0cbee183..182396a3a 100644 --- a/crates/brk_computer/src/supply/compute.rs +++ b/crates/brk_computer/src/supply/compute.rs @@ -35,7 +35,7 @@ impl Vecs { .height .compute_rolling_ratio_change( starting_indexes.height, - &blocks.lookback.height_1y_ago, + &blocks.lookback._1y, &circulating_supply.height, exit, )?; diff --git a/crates/brk_computer/src/supply/velocity/compute.rs b/crates/brk_computer/src/supply/velocity/compute.rs index a9d4cdf69..335f72904 100644 --- a/crates/brk_computer/src/supply/velocity/compute.rs +++ b/crates/brk_computer/src/supply/velocity/compute.rs @@ -20,7 +20,7 @@ impl Vecs { // BTC velocity at height level self.btc.height.compute_rolling_ratio( starting_indexes.height, - &blocks.lookback.height_1y_ago, + &blocks.lookback._1y, &transactions.volume.sent_sum.sats, &circulating_supply.sats.height, exit, @@ -29,7 +29,7 @@ impl Vecs { // USD velocity at height level self.usd.height.compute_rolling_ratio( starting_indexes.height, - &blocks.lookback.height_1y_ago, + &blocks.lookback._1y, &transactions.volume.sent_sum.usd, &circulating_supply.usd.height, exit, diff --git a/crates/brk_computer/src/transactions/volume/compute.rs b/crates/brk_computer/src/transactions/volume/compute.rs index 9c6bec525..0d0c747db 100644 --- a/crates/brk_computer/src/transactions/volume/compute.rs +++ b/crates/brk_computer/src/transactions/volume/compute.rs @@ -60,7 +60,7 @@ impl Vecs { // Annualized volume: rolling 1y sum of per-block sent volume self.annualized_volume.sats.height.compute_rolling_sum( starting_indexes.height, - &blocks.lookback.height_1y_ago, + &blocks.lookback._1y, &self.sent_sum.sats, exit, )?; diff --git a/modules/brk-client/index.js b/modules/brk-client/index.js index 7dbd51984..8ee163738 100644 --- a/modules/brk-client/index.js +++ b/modules/brk-client/index.js @@ -4491,49 +4491,49 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Blocks_Lookback - * @property {MetricPattern18} height1hAgo - * @property {MetricPattern18} height24hAgo - * @property {MetricPattern18} height3dAgo - * @property {MetricPattern18} height1wAgo - * @property {MetricPattern18} height8dAgo - * @property {MetricPattern18} height9dAgo - * @property {MetricPattern18} height12dAgo - * @property {MetricPattern18} height13dAgo - * @property {MetricPattern18} height2wAgo - * @property {MetricPattern18} height21dAgo - * @property {MetricPattern18} height26dAgo - * @property {MetricPattern18} height1mAgo - * @property {MetricPattern18} height34dAgo - * @property {MetricPattern18} height55dAgo - * @property {MetricPattern18} height2mAgo - * @property {MetricPattern18} height9wAgo - * @property {MetricPattern18} height12wAgo - * @property {MetricPattern18} height89dAgo - * @property {MetricPattern18} height3mAgo - * @property {MetricPattern18} height14wAgo - * @property {MetricPattern18} height111dAgo - * @property {MetricPattern18} height144dAgo - * @property {MetricPattern18} height6mAgo - * @property {MetricPattern18} height26wAgo - * @property {MetricPattern18} height200dAgo - * @property {MetricPattern18} height9mAgo - * @property {MetricPattern18} height350dAgo - * @property {MetricPattern18} height12mAgo - * @property {MetricPattern18} height1yAgo - * @property {MetricPattern18} height14mAgo - * @property {MetricPattern18} height2yAgo - * @property {MetricPattern18} height26mAgo - * @property {MetricPattern18} height3yAgo - * @property {MetricPattern18} height200wAgo - * @property {MetricPattern18} height4yAgo - * @property {MetricPattern18} height5yAgo - * @property {MetricPattern18} height6yAgo - * @property {MetricPattern18} height8yAgo - * @property {MetricPattern18} height9yAgo - * @property {MetricPattern18} height10yAgo - * @property {MetricPattern18} height12yAgo - * @property {MetricPattern18} height14yAgo - * @property {MetricPattern18} height26yAgo + * @property {MetricPattern18} _1h + * @property {MetricPattern18} _24h + * @property {MetricPattern18} _3d + * @property {MetricPattern18} _1w + * @property {MetricPattern18} _8d + * @property {MetricPattern18} _9d + * @property {MetricPattern18} _12d + * @property {MetricPattern18} _13d + * @property {MetricPattern18} _2w + * @property {MetricPattern18} _21d + * @property {MetricPattern18} _26d + * @property {MetricPattern18} _1m + * @property {MetricPattern18} _34d + * @property {MetricPattern18} _55d + * @property {MetricPattern18} _2m + * @property {MetricPattern18} _9w + * @property {MetricPattern18} _12w + * @property {MetricPattern18} _89d + * @property {MetricPattern18} _3m + * @property {MetricPattern18} _14w + * @property {MetricPattern18} _111d + * @property {MetricPattern18} _144d + * @property {MetricPattern18} _6m + * @property {MetricPattern18} _26w + * @property {MetricPattern18} _200d + * @property {MetricPattern18} _9m + * @property {MetricPattern18} _350d + * @property {MetricPattern18} _12m + * @property {MetricPattern18} _1y + * @property {MetricPattern18} _14m + * @property {MetricPattern18} _2y + * @property {MetricPattern18} _26m + * @property {MetricPattern18} _3y + * @property {MetricPattern18} _200w + * @property {MetricPattern18} _4y + * @property {MetricPattern18} _5y + * @property {MetricPattern18} _6y + * @property {MetricPattern18} _8y + * @property {MetricPattern18} _9y + * @property {MetricPattern18} _10y + * @property {MetricPattern18} _12y + * @property {MetricPattern18} _14y + * @property {MetricPattern18} _26y */ /** @@ -5229,15 +5229,33 @@ function createRawPattern(client, acc) { * @property {BpsCentsRatioSatsUsdPattern} _89d * @property {BpsCentsRatioSatsUsdPattern} _111d * @property {BpsCentsRatioSatsUsdPattern} _144d - * @property {BpsCentsRatioSatsUsdPattern} _200d - * @property {BpsCentsRatioSatsUsdPattern} _350d + * @property {MetricsTree_Market_MovingAverage_Sma_200d} _200d + * @property {MetricsTree_Market_MovingAverage_Sma_350d} _350d * @property {BpsCentsRatioSatsUsdPattern} _1y * @property {BpsCentsRatioSatsUsdPattern} _2y * @property {BpsCentsRatioSatsUsdPattern} _200w * @property {BpsCentsRatioSatsUsdPattern} _4y - * @property {CentsSatsUsdPattern} _200dX24 - * @property {CentsSatsUsdPattern} _200dX08 - * @property {CentsSatsUsdPattern} _350dX2 + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_200d + * @property {MetricPattern1} cents + * @property {MetricPattern1} usd + * @property {MetricPattern1} sats + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + * @property {CentsSatsUsdPattern} x24 + * @property {CentsSatsUsdPattern} x08 + */ + +/** + * @typedef {Object} MetricsTree_Market_MovingAverage_Sma_350d + * @property {MetricPattern1} cents + * @property {MetricPattern1} usd + * @property {MetricPattern1} sats + * @property {MetricPattern1} bps + * @property {MetricPattern1} ratio + * @property {CentsSatsUsdPattern} x2 */ /** @@ -5262,20 +5280,23 @@ function createRawPattern(client, acc) { /** * @typedef {Object} MetricsTree_Market_Dca - * @property {MetricPattern18} dcaSatsPerDay - * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern3} periodStack - * @property {MetricsTree_Market_Dca_PeriodCostBasis} periodCostBasis - * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} periodReturn - * @property {_10y2y3y4y5y6y8yPattern} periodCagr - * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern3} periodLumpSumStack - * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} periodLumpSumReturn - * @property {MetricsTree_Market_Dca_ClassStack} classStack - * @property {MetricsTree_Market_Dca_ClassCostBasis} classCostBasis - * @property {MetricsTree_Market_Dca_ClassReturn} classReturn + * @property {MetricPattern18} satsPerDay + * @property {MetricsTree_Market_Dca_Period} period + * @property {MetricsTree_Market_Dca_Class} class */ /** - * @typedef {Object} MetricsTree_Market_Dca_PeriodCostBasis + * @typedef {Object} MetricsTree_Market_Dca_Period + * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern3} stack + * @property {MetricsTree_Market_Dca_Period_CostBasis} costBasis + * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} r#return + * @property {_10y2y3y4y5y6y8yPattern} cagr + * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern3} lumpSumStack + * @property {_10y1m1w1y2y3m3y4y5y6m6y8yPattern2} lumpSumReturn + */ + +/** + * @typedef {Object} MetricsTree_Market_Dca_Period_CostBasis * @property {CentsSatsUsdPattern} _1w * @property {CentsSatsUsdPattern} _1m * @property {CentsSatsUsdPattern} _3m @@ -5291,7 +5312,14 @@ function createRawPattern(client, acc) { */ /** - * @typedef {Object} MetricsTree_Market_Dca_ClassStack + * @typedef {Object} MetricsTree_Market_Dca_Class + * @property {MetricsTree_Market_Dca_Class_Stack} stack + * @property {MetricsTree_Market_Dca_Class_CostBasis} costBasis + * @property {MetricsTree_Market_Dca_Class_R#return} r#return + */ + +/** + * @typedef {Object} MetricsTree_Market_Dca_Class_Stack * @property {BtcCentsSatsUsdPattern} from2015 * @property {BtcCentsSatsUsdPattern} from2016 * @property {BtcCentsSatsUsdPattern} from2017 @@ -5307,7 +5335,7 @@ function createRawPattern(client, acc) { */ /** - * @typedef {Object} MetricsTree_Market_Dca_ClassCostBasis + * @typedef {Object} MetricsTree_Market_Dca_Class_CostBasis * @property {CentsSatsUsdPattern} from2015 * @property {CentsSatsUsdPattern} from2016 * @property {CentsSatsUsdPattern} from2017 @@ -5323,7 +5351,7 @@ function createRawPattern(client, acc) { */ /** - * @typedef {Object} MetricsTree_Market_Dca_ClassReturn + * @typedef {Object} MetricsTree_Market_Dca_Class_R#return * @property {BpsPercentRatioPattern} from2015 * @property {BpsPercentRatioPattern} from2016 * @property {BpsPercentRatioPattern} from2017 @@ -7191,49 +7219,49 @@ class BrkClient extends BrkClientBase { blockCount: createCumulativeRawSumPattern(this, 'block_count'), }, lookback: { - height1hAgo: createMetricPattern18(this, 'height_1h_ago'), - height24hAgo: createMetricPattern18(this, 'height_24h_ago'), - height3dAgo: createMetricPattern18(this, 'height_3d_ago'), - height1wAgo: createMetricPattern18(this, 'height_1w_ago'), - height8dAgo: createMetricPattern18(this, 'height_8d_ago'), - height9dAgo: createMetricPattern18(this, 'height_9d_ago'), - height12dAgo: createMetricPattern18(this, 'height_12d_ago'), - height13dAgo: createMetricPattern18(this, 'height_13d_ago'), - height2wAgo: createMetricPattern18(this, 'height_2w_ago'), - height21dAgo: createMetricPattern18(this, 'height_21d_ago'), - height26dAgo: createMetricPattern18(this, 'height_26d_ago'), - height1mAgo: createMetricPattern18(this, 'height_1m_ago'), - height34dAgo: createMetricPattern18(this, 'height_34d_ago'), - height55dAgo: createMetricPattern18(this, 'height_55d_ago'), - height2mAgo: createMetricPattern18(this, 'height_2m_ago'), - height9wAgo: createMetricPattern18(this, 'height_9w_ago'), - height12wAgo: createMetricPattern18(this, 'height_12w_ago'), - height89dAgo: createMetricPattern18(this, 'height_89d_ago'), - height3mAgo: createMetricPattern18(this, 'height_3m_ago'), - height14wAgo: createMetricPattern18(this, 'height_14w_ago'), - height111dAgo: createMetricPattern18(this, 'height_111d_ago'), - height144dAgo: createMetricPattern18(this, 'height_144d_ago'), - height6mAgo: createMetricPattern18(this, 'height_6m_ago'), - height26wAgo: createMetricPattern18(this, 'height_26w_ago'), - height200dAgo: createMetricPattern18(this, 'height_200d_ago'), - height9mAgo: createMetricPattern18(this, 'height_9m_ago'), - height350dAgo: createMetricPattern18(this, 'height_350d_ago'), - height12mAgo: createMetricPattern18(this, 'height_12m_ago'), - height1yAgo: createMetricPattern18(this, 'height_1y_ago'), - height14mAgo: createMetricPattern18(this, 'height_14m_ago'), - height2yAgo: createMetricPattern18(this, 'height_2y_ago'), - height26mAgo: createMetricPattern18(this, 'height_26m_ago'), - height3yAgo: createMetricPattern18(this, 'height_3y_ago'), - height200wAgo: createMetricPattern18(this, 'height_200w_ago'), - height4yAgo: createMetricPattern18(this, 'height_4y_ago'), - height5yAgo: createMetricPattern18(this, 'height_5y_ago'), - height6yAgo: createMetricPattern18(this, 'height_6y_ago'), - height8yAgo: createMetricPattern18(this, 'height_8y_ago'), - height9yAgo: createMetricPattern18(this, 'height_9y_ago'), - height10yAgo: createMetricPattern18(this, 'height_10y_ago'), - height12yAgo: createMetricPattern18(this, 'height_12y_ago'), - height14yAgo: createMetricPattern18(this, 'height_14y_ago'), - height26yAgo: createMetricPattern18(this, 'height_26y_ago'), + _1h: createMetricPattern18(this, 'height_1h_ago'), + _24h: createMetricPattern18(this, 'height_24h_ago'), + _3d: createMetricPattern18(this, 'height_3d_ago'), + _1w: createMetricPattern18(this, 'height_1w_ago'), + _8d: createMetricPattern18(this, 'height_8d_ago'), + _9d: createMetricPattern18(this, 'height_9d_ago'), + _12d: createMetricPattern18(this, 'height_12d_ago'), + _13d: createMetricPattern18(this, 'height_13d_ago'), + _2w: createMetricPattern18(this, 'height_2w_ago'), + _21d: createMetricPattern18(this, 'height_21d_ago'), + _26d: createMetricPattern18(this, 'height_26d_ago'), + _1m: createMetricPattern18(this, 'height_1m_ago'), + _34d: createMetricPattern18(this, 'height_34d_ago'), + _55d: createMetricPattern18(this, 'height_55d_ago'), + _2m: createMetricPattern18(this, 'height_2m_ago'), + _9w: createMetricPattern18(this, 'height_9w_ago'), + _12w: createMetricPattern18(this, 'height_12w_ago'), + _89d: createMetricPattern18(this, 'height_89d_ago'), + _3m: createMetricPattern18(this, 'height_3m_ago'), + _14w: createMetricPattern18(this, 'height_14w_ago'), + _111d: createMetricPattern18(this, 'height_111d_ago'), + _144d: createMetricPattern18(this, 'height_144d_ago'), + _6m: createMetricPattern18(this, 'height_6m_ago'), + _26w: createMetricPattern18(this, 'height_26w_ago'), + _200d: createMetricPattern18(this, 'height_200d_ago'), + _9m: createMetricPattern18(this, 'height_9m_ago'), + _350d: createMetricPattern18(this, 'height_350d_ago'), + _12m: createMetricPattern18(this, 'height_12m_ago'), + _1y: createMetricPattern18(this, 'height_1y_ago'), + _14m: createMetricPattern18(this, 'height_14m_ago'), + _2y: createMetricPattern18(this, 'height_2y_ago'), + _26m: createMetricPattern18(this, 'height_26m_ago'), + _3y: createMetricPattern18(this, 'height_3y_ago'), + _200w: createMetricPattern18(this, 'height_200w_ago'), + _4y: createMetricPattern18(this, 'height_4y_ago'), + _5y: createMetricPattern18(this, 'height_5y_ago'), + _6y: createMetricPattern18(this, 'height_6y_ago'), + _8y: createMetricPattern18(this, 'height_8y_ago'), + _9y: createMetricPattern18(this, 'height_9y_ago'), + _10y: createMetricPattern18(this, 'height_10y_ago'), + _12y: createMetricPattern18(this, 'height_12y_ago'), + _14y: createMetricPattern18(this, 'height_14y_ago'), + _26y: createMetricPattern18(this, 'height_26y_ago'), }, interval: create_1m1w1y24hHeightPattern(this, 'block_interval'), halving: { @@ -7701,15 +7729,27 @@ class BrkClient extends BrkClientBase { _89d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_89d'), _111d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_111d'), _144d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_144d'), - _200d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_200d'), - _350d: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_350d'), + _200d: { + cents: createMetricPattern1(this, 'price_sma_200d_cents'), + usd: createMetricPattern1(this, 'price_sma_200d_usd'), + sats: createMetricPattern1(this, 'price_sma_200d_sats'), + bps: createMetricPattern1(this, 'price_sma_200d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_200d_ratio'), + x24: createCentsSatsUsdPattern(this, 'price_sma_200d_x2_4'), + x08: createCentsSatsUsdPattern(this, 'price_sma_200d_x0_8'), + }, + _350d: { + cents: createMetricPattern1(this, 'price_sma_350d_cents'), + usd: createMetricPattern1(this, 'price_sma_350d_usd'), + sats: createMetricPattern1(this, 'price_sma_350d_sats'), + bps: createMetricPattern1(this, 'price_sma_350d_ratio_bps'), + ratio: createMetricPattern1(this, 'price_sma_350d_ratio'), + x2: createCentsSatsUsdPattern(this, 'price_sma_350d_x2'), + }, _1y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_1y'), _2y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_2y'), _200w: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_200w'), _4y: createBpsCentsRatioSatsUsdPattern(this, 'price_sma_4y'), - _200dX24: createCentsSatsUsdPattern(this, 'price_sma_200d_x2_4'), - _200dX08: createCentsSatsUsdPattern(this, 'price_sma_200d_x0_8'), - _350dX2: createCentsSatsUsdPattern(this, 'price_sma_350d_x2'), }, ema: { _1w: createBpsCentsRatioSatsUsdPattern(this, 'price_ema_1w'), @@ -7731,67 +7771,71 @@ class BrkClient extends BrkClientBase { }, }, dca: { - dcaSatsPerDay: createMetricPattern18(this, 'dca_sats_per_day'), - periodStack: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(this, 'dca_stack'), - periodCostBasis: { - _1w: createCentsSatsUsdPattern(this, 'dca_cost_basis_1w'), - _1m: createCentsSatsUsdPattern(this, 'dca_cost_basis_1m'), - _3m: createCentsSatsUsdPattern(this, 'dca_cost_basis_3m'), - _6m: createCentsSatsUsdPattern(this, 'dca_cost_basis_6m'), - _1y: createCentsSatsUsdPattern(this, 'dca_cost_basis_1y'), - _2y: createCentsSatsUsdPattern(this, 'dca_cost_basis_2y'), - _3y: createCentsSatsUsdPattern(this, 'dca_cost_basis_3y'), - _4y: createCentsSatsUsdPattern(this, 'dca_cost_basis_4y'), - _5y: createCentsSatsUsdPattern(this, 'dca_cost_basis_5y'), - _6y: createCentsSatsUsdPattern(this, 'dca_cost_basis_6y'), - _8y: createCentsSatsUsdPattern(this, 'dca_cost_basis_8y'), - _10y: createCentsSatsUsdPattern(this, 'dca_cost_basis_10y'), + satsPerDay: createMetricPattern18(this, 'dca_sats_per_day'), + period: { + stack: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(this, 'dca_stack'), + costBasis: { + _1w: createCentsSatsUsdPattern(this, 'dca_cost_basis_1w'), + _1m: createCentsSatsUsdPattern(this, 'dca_cost_basis_1m'), + _3m: createCentsSatsUsdPattern(this, 'dca_cost_basis_3m'), + _6m: createCentsSatsUsdPattern(this, 'dca_cost_basis_6m'), + _1y: createCentsSatsUsdPattern(this, 'dca_cost_basis_1y'), + _2y: createCentsSatsUsdPattern(this, 'dca_cost_basis_2y'), + _3y: createCentsSatsUsdPattern(this, 'dca_cost_basis_3y'), + _4y: createCentsSatsUsdPattern(this, 'dca_cost_basis_4y'), + _5y: createCentsSatsUsdPattern(this, 'dca_cost_basis_5y'), + _6y: createCentsSatsUsdPattern(this, 'dca_cost_basis_6y'), + _8y: createCentsSatsUsdPattern(this, 'dca_cost_basis_8y'), + _10y: createCentsSatsUsdPattern(this, 'dca_cost_basis_10y'), + }, + r#return: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(this, 'dca_return'), + cagr: create_10y2y3y4y5y6y8yPattern(this, 'dca_cagr'), + lumpSumStack: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(this, 'lump_sum_stack'), + lumpSumReturn: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(this, 'lump_sum_return'), }, - periodReturn: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(this, 'dca_return'), - periodCagr: create_10y2y3y4y5y6y8yPattern(this, 'dca_cagr'), - periodLumpSumStack: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern3(this, 'lump_sum_stack'), - periodLumpSumReturn: create_10y1m1w1y2y3m3y4y5y6m6y8yPattern2(this, 'lump_sum_return'), - classStack: { - from2015: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2015'), - from2016: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2016'), - from2017: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2017'), - from2018: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2018'), - from2019: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2019'), - from2020: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2020'), - from2021: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2021'), - from2022: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2022'), - from2023: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2023'), - from2024: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2024'), - from2025: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2025'), - from2026: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2026'), - }, - classCostBasis: { - from2015: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2015'), - from2016: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2016'), - from2017: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2017'), - from2018: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2018'), - from2019: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2019'), - from2020: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2020'), - from2021: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2021'), - from2022: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2022'), - from2023: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2023'), - from2024: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2024'), - from2025: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2025'), - from2026: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2026'), - }, - classReturn: { - from2015: createBpsPercentRatioPattern(this, 'dca_return_from_2015'), - from2016: createBpsPercentRatioPattern(this, 'dca_return_from_2016'), - from2017: createBpsPercentRatioPattern(this, 'dca_return_from_2017'), - from2018: createBpsPercentRatioPattern(this, 'dca_return_from_2018'), - from2019: createBpsPercentRatioPattern(this, 'dca_return_from_2019'), - from2020: createBpsPercentRatioPattern(this, 'dca_return_from_2020'), - from2021: createBpsPercentRatioPattern(this, 'dca_return_from_2021'), - from2022: createBpsPercentRatioPattern(this, 'dca_return_from_2022'), - from2023: createBpsPercentRatioPattern(this, 'dca_return_from_2023'), - from2024: createBpsPercentRatioPattern(this, 'dca_return_from_2024'), - from2025: createBpsPercentRatioPattern(this, 'dca_return_from_2025'), - from2026: createBpsPercentRatioPattern(this, 'dca_return_from_2026'), + class: { + stack: { + from2015: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2015'), + from2016: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2016'), + from2017: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2017'), + from2018: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2018'), + from2019: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2019'), + from2020: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2020'), + from2021: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2021'), + from2022: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2022'), + from2023: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2023'), + from2024: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2024'), + from2025: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2025'), + from2026: createBtcCentsSatsUsdPattern(this, 'dca_stack_from_2026'), + }, + costBasis: { + from2015: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2015'), + from2016: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2016'), + from2017: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2017'), + from2018: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2018'), + from2019: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2019'), + from2020: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2020'), + from2021: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2021'), + from2022: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2022'), + from2023: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2023'), + from2024: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2024'), + from2025: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2025'), + from2026: createCentsSatsUsdPattern(this, 'dca_cost_basis_from_2026'), + }, + r#return: { + from2015: createBpsPercentRatioPattern(this, 'dca_return_from_2015'), + from2016: createBpsPercentRatioPattern(this, 'dca_return_from_2016'), + from2017: createBpsPercentRatioPattern(this, 'dca_return_from_2017'), + from2018: createBpsPercentRatioPattern(this, 'dca_return_from_2018'), + from2019: createBpsPercentRatioPattern(this, 'dca_return_from_2019'), + from2020: createBpsPercentRatioPattern(this, 'dca_return_from_2020'), + from2021: createBpsPercentRatioPattern(this, 'dca_return_from_2021'), + from2022: createBpsPercentRatioPattern(this, 'dca_return_from_2022'), + from2023: createBpsPercentRatioPattern(this, 'dca_return_from_2023'), + from2024: createBpsPercentRatioPattern(this, 'dca_return_from_2024'), + from2025: createBpsPercentRatioPattern(this, 'dca_return_from_2025'), + from2026: createBpsPercentRatioPattern(this, 'dca_return_from_2026'), + }, }, }, technical: { diff --git a/packages/brk_client/brk_client/__init__.py b/packages/brk_client/brk_client/__init__.py index e995bf3b6..0db1058d3 100644 --- a/packages/brk_client/brk_client/__init__.py +++ b/packages/brk_client/brk_client/__init__.py @@ -3377,49 +3377,49 @@ class MetricsTree_Blocks_Lookback: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.height_1h_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_1h_ago') - self.height_24h_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_24h_ago') - self.height_3d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_3d_ago') - self.height_1w_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_1w_ago') - self.height_8d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_8d_ago') - self.height_9d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_9d_ago') - self.height_12d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_12d_ago') - self.height_13d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_13d_ago') - self.height_2w_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_2w_ago') - self.height_21d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_21d_ago') - self.height_26d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_26d_ago') - self.height_1m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_1m_ago') - self.height_34d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_34d_ago') - self.height_55d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_55d_ago') - self.height_2m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_2m_ago') - self.height_9w_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_9w_ago') - self.height_12w_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_12w_ago') - self.height_89d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_89d_ago') - self.height_3m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_3m_ago') - self.height_14w_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_14w_ago') - self.height_111d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_111d_ago') - self.height_144d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_144d_ago') - self.height_6m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_6m_ago') - self.height_26w_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_26w_ago') - self.height_200d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_200d_ago') - self.height_9m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_9m_ago') - self.height_350d_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_350d_ago') - self.height_12m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_12m_ago') - self.height_1y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_1y_ago') - self.height_14m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_14m_ago') - self.height_2y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_2y_ago') - self.height_26m_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_26m_ago') - self.height_3y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_3y_ago') - self.height_200w_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_200w_ago') - self.height_4y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_4y_ago') - self.height_5y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_5y_ago') - self.height_6y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_6y_ago') - self.height_8y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_8y_ago') - self.height_9y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_9y_ago') - self.height_10y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_10y_ago') - self.height_12y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_12y_ago') - self.height_14y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_14y_ago') - self.height_26y_ago: MetricPattern18[Height] = MetricPattern18(client, 'height_26y_ago') + self._1h: MetricPattern18[Height] = MetricPattern18(client, 'height_1h_ago') + self._24h: MetricPattern18[Height] = MetricPattern18(client, 'height_24h_ago') + self._3d: MetricPattern18[Height] = MetricPattern18(client, 'height_3d_ago') + self._1w: MetricPattern18[Height] = MetricPattern18(client, 'height_1w_ago') + self._8d: MetricPattern18[Height] = MetricPattern18(client, 'height_8d_ago') + self._9d: MetricPattern18[Height] = MetricPattern18(client, 'height_9d_ago') + self._12d: MetricPattern18[Height] = MetricPattern18(client, 'height_12d_ago') + self._13d: MetricPattern18[Height] = MetricPattern18(client, 'height_13d_ago') + self._2w: MetricPattern18[Height] = MetricPattern18(client, 'height_2w_ago') + self._21d: MetricPattern18[Height] = MetricPattern18(client, 'height_21d_ago') + self._26d: MetricPattern18[Height] = MetricPattern18(client, 'height_26d_ago') + self._1m: MetricPattern18[Height] = MetricPattern18(client, 'height_1m_ago') + self._34d: MetricPattern18[Height] = MetricPattern18(client, 'height_34d_ago') + self._55d: MetricPattern18[Height] = MetricPattern18(client, 'height_55d_ago') + self._2m: MetricPattern18[Height] = MetricPattern18(client, 'height_2m_ago') + self._9w: MetricPattern18[Height] = MetricPattern18(client, 'height_9w_ago') + self._12w: MetricPattern18[Height] = MetricPattern18(client, 'height_12w_ago') + self._89d: MetricPattern18[Height] = MetricPattern18(client, 'height_89d_ago') + self._3m: MetricPattern18[Height] = MetricPattern18(client, 'height_3m_ago') + self._14w: MetricPattern18[Height] = MetricPattern18(client, 'height_14w_ago') + self._111d: MetricPattern18[Height] = MetricPattern18(client, 'height_111d_ago') + self._144d: MetricPattern18[Height] = MetricPattern18(client, 'height_144d_ago') + self._6m: MetricPattern18[Height] = MetricPattern18(client, 'height_6m_ago') + self._26w: MetricPattern18[Height] = MetricPattern18(client, 'height_26w_ago') + self._200d: MetricPattern18[Height] = MetricPattern18(client, 'height_200d_ago') + self._9m: MetricPattern18[Height] = MetricPattern18(client, 'height_9m_ago') + self._350d: MetricPattern18[Height] = MetricPattern18(client, 'height_350d_ago') + self._12m: MetricPattern18[Height] = MetricPattern18(client, 'height_12m_ago') + self._1y: MetricPattern18[Height] = MetricPattern18(client, 'height_1y_ago') + self._14m: MetricPattern18[Height] = MetricPattern18(client, 'height_14m_ago') + self._2y: MetricPattern18[Height] = MetricPattern18(client, 'height_2y_ago') + self._26m: MetricPattern18[Height] = MetricPattern18(client, 'height_26m_ago') + self._3y: MetricPattern18[Height] = MetricPattern18(client, 'height_3y_ago') + self._200w: MetricPattern18[Height] = MetricPattern18(client, 'height_200w_ago') + self._4y: MetricPattern18[Height] = MetricPattern18(client, 'height_4y_ago') + self._5y: MetricPattern18[Height] = MetricPattern18(client, 'height_5y_ago') + self._6y: MetricPattern18[Height] = MetricPattern18(client, 'height_6y_ago') + self._8y: MetricPattern18[Height] = MetricPattern18(client, 'height_8y_ago') + self._9y: MetricPattern18[Height] = MetricPattern18(client, 'height_9y_ago') + self._10y: MetricPattern18[Height] = MetricPattern18(client, 'height_10y_ago') + self._12y: MetricPattern18[Height] = MetricPattern18(client, 'height_12y_ago') + self._14y: MetricPattern18[Height] = MetricPattern18(client, 'height_14y_ago') + self._26y: MetricPattern18[Height] = MetricPattern18(client, 'height_26y_ago') class MetricsTree_Blocks_Halving: """Metrics tree node.""" @@ -4177,6 +4177,29 @@ class MetricsTree_Market_Range: self.true_range_sum_2w: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_true_range_sum_2w') self.choppiness_index_2w: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'price_choppiness_index_2w') +class MetricsTree_Market_MovingAverage_Sma_200d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.cents: MetricPattern1[Cents] = MetricPattern1(client, 'price_sma_200d_cents') + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, 'price_sma_200d_usd') + self.sats: MetricPattern1[SatsFract] = MetricPattern1(client, 'price_sma_200d_sats') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_200d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_200d_ratio') + self.x2_4: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x2_4') + self.x0_8: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x0_8') + +class MetricsTree_Market_MovingAverage_Sma_350d: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.cents: MetricPattern1[Cents] = MetricPattern1(client, 'price_sma_350d_cents') + self.usd: MetricPattern1[Dollars] = MetricPattern1(client, 'price_sma_350d_usd') + self.sats: MetricPattern1[SatsFract] = MetricPattern1(client, 'price_sma_350d_sats') + self.bps: MetricPattern1[BasisPoints32] = MetricPattern1(client, 'price_sma_350d_ratio_bps') + self.ratio: MetricPattern1[StoredF32] = MetricPattern1(client, 'price_sma_350d_ratio') + self.x2: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_350d_x2') + class MetricsTree_Market_MovingAverage_Sma: """Metrics tree node.""" @@ -4191,15 +4214,12 @@ class MetricsTree_Market_MovingAverage_Sma: self._89d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_89d') self._111d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_111d') self._144d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_144d') - self._200d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_200d') - self._350d: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_350d') + self._200d: MetricsTree_Market_MovingAverage_Sma_200d = MetricsTree_Market_MovingAverage_Sma_200d(client) + self._350d: MetricsTree_Market_MovingAverage_Sma_350d = MetricsTree_Market_MovingAverage_Sma_350d(client) self._1y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_1y') self._2y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_2y') self._200w: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_200w') self._4y: BpsCentsRatioSatsUsdPattern = BpsCentsRatioSatsUsdPattern(client, 'price_sma_4y') - self._200d_x2_4: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x2_4') - self._200d_x0_8: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_200d_x0_8') - self._350d_x2: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'price_sma_350d_x2') class MetricsTree_Market_MovingAverage_Ema: """Metrics tree node.""" @@ -4229,7 +4249,7 @@ class MetricsTree_Market_MovingAverage: self.sma: MetricsTree_Market_MovingAverage_Sma = MetricsTree_Market_MovingAverage_Sma(client) self.ema: MetricsTree_Market_MovingAverage_Ema = MetricsTree_Market_MovingAverage_Ema(client) -class MetricsTree_Market_Dca_PeriodCostBasis: +class MetricsTree_Market_Dca_Period_CostBasis: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -4246,7 +4266,18 @@ class MetricsTree_Market_Dca_PeriodCostBasis: self._8y: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'dca_cost_basis_8y') self._10y: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'dca_cost_basis_10y') -class MetricsTree_Market_Dca_ClassStack: +class MetricsTree_Market_Dca_Period: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, 'dca_stack') + self.cost_basis: MetricsTree_Market_Dca_Period_CostBasis = MetricsTree_Market_Dca_Period_CostBasis(client) + self.r#return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, 'dca_return') + self.cagr: _10y2y3y4y5y6y8yPattern = _10y2y3y4y5y6y8yPattern(client, 'dca_cagr') + self.lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, 'lump_sum_stack') + self.lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, 'lump_sum_return') + +class MetricsTree_Market_Dca_Class_Stack: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -4263,7 +4294,7 @@ class MetricsTree_Market_Dca_ClassStack: self.from_2025: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'dca_stack_from_2025') self.from_2026: BtcCentsSatsUsdPattern = BtcCentsSatsUsdPattern(client, 'dca_stack_from_2026') -class MetricsTree_Market_Dca_ClassCostBasis: +class MetricsTree_Market_Dca_Class_CostBasis: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -4280,7 +4311,7 @@ class MetricsTree_Market_Dca_ClassCostBasis: self.from_2025: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'dca_cost_basis_from_2025') self.from_2026: CentsSatsUsdPattern = CentsSatsUsdPattern(client, 'dca_cost_basis_from_2026') -class MetricsTree_Market_Dca_ClassReturn: +class MetricsTree_Market_Dca_Class_R#return: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): @@ -4297,20 +4328,21 @@ class MetricsTree_Market_Dca_ClassReturn: self.from_2025: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2025') self.from_2026: BpsPercentRatioPattern = BpsPercentRatioPattern(client, 'dca_return_from_2026') +class MetricsTree_Market_Dca_Class: + """Metrics tree node.""" + + def __init__(self, client: BrkClientBase, base_path: str = ''): + self.stack: MetricsTree_Market_Dca_Class_Stack = MetricsTree_Market_Dca_Class_Stack(client) + self.cost_basis: MetricsTree_Market_Dca_Class_CostBasis = MetricsTree_Market_Dca_Class_CostBasis(client) + self.r#return: MetricsTree_Market_Dca_Class_R#return = MetricsTree_Market_Dca_Class_R#return(client) + class MetricsTree_Market_Dca: """Metrics tree node.""" def __init__(self, client: BrkClientBase, base_path: str = ''): - self.dca_sats_per_day: MetricPattern18[Sats] = MetricPattern18(client, 'dca_sats_per_day') - self.period_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, 'dca_stack') - self.period_cost_basis: MetricsTree_Market_Dca_PeriodCostBasis = MetricsTree_Market_Dca_PeriodCostBasis(client) - self.period_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, 'dca_return') - self.period_cagr: _10y2y3y4y5y6y8yPattern = _10y2y3y4y5y6y8yPattern(client, 'dca_cagr') - self.period_lump_sum_stack: _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern3(client, 'lump_sum_stack') - self.period_lump_sum_return: _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 = _10y1m1w1y2y3m3y4y5y6m6y8yPattern2(client, 'lump_sum_return') - self.class_stack: MetricsTree_Market_Dca_ClassStack = MetricsTree_Market_Dca_ClassStack(client) - self.class_cost_basis: MetricsTree_Market_Dca_ClassCostBasis = MetricsTree_Market_Dca_ClassCostBasis(client) - self.class_return: MetricsTree_Market_Dca_ClassReturn = MetricsTree_Market_Dca_ClassReturn(client) + self.sats_per_day: MetricPattern18[Sats] = MetricPattern18(client, 'dca_sats_per_day') + self.period: MetricsTree_Market_Dca_Period = MetricsTree_Market_Dca_Period(client) + self.class: MetricsTree_Market_Dca_Class = MetricsTree_Market_Dca_Class(client) class MetricsTree_Market_Technical_Rsi_1w: """Metrics tree node."""