diff --git a/crates/brk_client/src/lib.rs b/crates/brk_client/src/lib.rs index f62c7fec0..ce97d65f6 100644 --- a/crates/brk_client/src/lib.rs +++ b/crates/brk_client/src/lib.rs @@ -3339,56 +3339,6 @@ impl Price111dSmaPattern { } } -/// Pattern struct for repeated tree structure. -pub struct ActivePriceRatioPattern { - pub ratio: MetricPattern4, - pub ratio_1m_sma: MetricPattern4, - pub ratio_1w_sma: MetricPattern4, - pub ratio_1y_sd: Ratio1ySdPattern, - pub ratio_2y_sd: Ratio1ySdPattern, - pub ratio_4y_sd: Ratio1ySdPattern, - pub ratio_pct1: MetricPattern4, - pub ratio_pct1_usd: MetricPattern4, - pub ratio_pct2: MetricPattern4, - pub ratio_pct2_usd: MetricPattern4, - pub ratio_pct5: MetricPattern4, - pub ratio_pct5_usd: MetricPattern4, - pub ratio_pct95: MetricPattern4, - pub ratio_pct95_usd: MetricPattern4, - pub ratio_pct98: MetricPattern4, - pub ratio_pct98_usd: MetricPattern4, - pub ratio_pct99: MetricPattern4, - pub ratio_pct99_usd: MetricPattern4, - pub ratio_sd: Ratio1ySdPattern, -} - -impl ActivePriceRatioPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - ratio: MetricPattern4::new(client.clone(), acc.clone()), - ratio_1m_sma: MetricPattern4::new(client.clone(), _m(&acc, "1m_sma")), - ratio_1w_sma: MetricPattern4::new(client.clone(), _m(&acc, "1w_sma")), - ratio_1y_sd: Ratio1ySdPattern::new(client.clone(), _m(&acc, "1y")), - ratio_2y_sd: Ratio1ySdPattern::new(client.clone(), _m(&acc, "2y")), - ratio_4y_sd: Ratio1ySdPattern::new(client.clone(), _m(&acc, "4y")), - ratio_pct1: MetricPattern4::new(client.clone(), _m(&acc, "pct1")), - ratio_pct1_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct1_usd")), - ratio_pct2: MetricPattern4::new(client.clone(), _m(&acc, "pct2")), - ratio_pct2_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct2_usd")), - ratio_pct5: MetricPattern4::new(client.clone(), _m(&acc, "pct5")), - ratio_pct5_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct5_usd")), - ratio_pct95: MetricPattern4::new(client.clone(), _m(&acc, "pct95")), - ratio_pct95_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct95_usd")), - ratio_pct98: MetricPattern4::new(client.clone(), _m(&acc, "pct98")), - ratio_pct98_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct98_usd")), - ratio_pct99: MetricPattern4::new(client.clone(), _m(&acc, "pct99")), - ratio_pct99_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct99_usd")), - ratio_sd: Ratio1ySdPattern::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct PercentilesPattern { pub cost_basis_pct05: MetricPattern4, @@ -3439,6 +3389,56 @@ impl PercentilesPattern { } } +/// Pattern struct for repeated tree structure. +pub struct ActivePriceRatioPattern { + pub ratio: MetricPattern4, + pub ratio_1m_sma: MetricPattern4, + pub ratio_1w_sma: MetricPattern4, + pub ratio_1y_sd: Ratio1ySdPattern, + pub ratio_2y_sd: Ratio1ySdPattern, + pub ratio_4y_sd: Ratio1ySdPattern, + pub ratio_pct1: MetricPattern4, + pub ratio_pct1_usd: MetricPattern4, + pub ratio_pct2: MetricPattern4, + pub ratio_pct2_usd: MetricPattern4, + pub ratio_pct5: MetricPattern4, + pub ratio_pct5_usd: MetricPattern4, + pub ratio_pct95: MetricPattern4, + pub ratio_pct95_usd: MetricPattern4, + pub ratio_pct98: MetricPattern4, + pub ratio_pct98_usd: MetricPattern4, + pub ratio_pct99: MetricPattern4, + pub ratio_pct99_usd: MetricPattern4, + pub ratio_sd: Ratio1ySdPattern, +} + +impl ActivePriceRatioPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + ratio: MetricPattern4::new(client.clone(), acc.clone()), + ratio_1m_sma: MetricPattern4::new(client.clone(), _m(&acc, "1m_sma")), + ratio_1w_sma: MetricPattern4::new(client.clone(), _m(&acc, "1w_sma")), + ratio_1y_sd: Ratio1ySdPattern::new(client.clone(), _m(&acc, "1y")), + ratio_2y_sd: Ratio1ySdPattern::new(client.clone(), _m(&acc, "2y")), + ratio_4y_sd: Ratio1ySdPattern::new(client.clone(), _m(&acc, "4y")), + ratio_pct1: MetricPattern4::new(client.clone(), _m(&acc, "pct1")), + ratio_pct1_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct1_usd")), + ratio_pct2: MetricPattern4::new(client.clone(), _m(&acc, "pct2")), + ratio_pct2_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct2_usd")), + ratio_pct5: MetricPattern4::new(client.clone(), _m(&acc, "pct5")), + ratio_pct5_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct5_usd")), + ratio_pct95: MetricPattern4::new(client.clone(), _m(&acc, "pct95")), + ratio_pct95_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct95_usd")), + ratio_pct98: MetricPattern4::new(client.clone(), _m(&acc, "pct98")), + ratio_pct98_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct98_usd")), + ratio_pct99: MetricPattern4::new(client.clone(), _m(&acc, "pct99")), + ratio_pct99_usd: MetricPattern4::new(client.clone(), _m(&acc, "pct99_usd")), + ratio_sd: Ratio1ySdPattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct RelativePattern5 { pub neg_unrealized_loss_rel_to_market_cap: MetricPattern5, @@ -3703,38 +3703,6 @@ impl ClassAvgPricePattern { } } -/// Pattern struct for repeated tree structure. -pub struct RelativePattern2 { - pub neg_unrealized_loss_rel_to_own_market_cap: MetricPattern5, - pub neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5, - pub net_unrealized_pnl_rel_to_own_market_cap: MetricPattern3, - pub net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern3, - pub supply_in_loss_rel_to_own_supply: MetricPattern5, - pub supply_in_profit_rel_to_own_supply: MetricPattern5, - pub unrealized_loss_rel_to_own_market_cap: MetricPattern5, - pub unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5, - pub unrealized_profit_rel_to_own_market_cap: MetricPattern5, - pub unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern5, -} - -impl RelativePattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - neg_unrealized_loss_rel_to_own_market_cap: MetricPattern5::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_market_cap")), - neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_total_unrealized_pnl")), - net_unrealized_pnl_rel_to_own_market_cap: MetricPattern3::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_market_cap")), - net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern3::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_total_unrealized_pnl")), - supply_in_loss_rel_to_own_supply: MetricPattern5::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")), - supply_in_profit_rel_to_own_supply: MetricPattern5::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")), - unrealized_loss_rel_to_own_market_cap: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")), - unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_total_unrealized_pnl")), - unrealized_profit_rel_to_own_market_cap: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")), - unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_total_unrealized_pnl")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct RelativePattern { pub neg_unrealized_loss_rel_to_market_cap: MetricPattern5, @@ -3767,34 +3735,66 @@ impl RelativePattern { } } +/// Pattern struct for repeated tree structure. +pub struct RelativePattern2 { + pub neg_unrealized_loss_rel_to_own_market_cap: MetricPattern5, + pub neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5, + pub net_unrealized_pnl_rel_to_own_market_cap: MetricPattern3, + pub net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern3, + pub supply_in_loss_rel_to_own_supply: MetricPattern5, + pub supply_in_profit_rel_to_own_supply: MetricPattern5, + pub unrealized_loss_rel_to_own_market_cap: MetricPattern5, + pub unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5, + pub unrealized_profit_rel_to_own_market_cap: MetricPattern5, + pub unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern5, +} + +impl RelativePattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + neg_unrealized_loss_rel_to_own_market_cap: MetricPattern5::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_market_cap")), + neg_unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_total_unrealized_pnl")), + net_unrealized_pnl_rel_to_own_market_cap: MetricPattern3::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_market_cap")), + net_unrealized_pnl_rel_to_own_total_unrealized_pnl: MetricPattern3::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_total_unrealized_pnl")), + supply_in_loss_rel_to_own_supply: MetricPattern5::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")), + supply_in_profit_rel_to_own_supply: MetricPattern5::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")), + unrealized_loss_rel_to_own_market_cap: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")), + unrealized_loss_rel_to_own_total_unrealized_pnl: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_total_unrealized_pnl")), + unrealized_profit_rel_to_own_market_cap: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")), + unrealized_profit_rel_to_own_total_unrealized_pnl: MetricPattern5::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_total_unrealized_pnl")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct BlockSizePattern { - pub average: MetricPattern2, + pub average: MetricPattern1, pub cumulative: MetricPattern1, - pub max: MetricPattern2, - pub median: MetricPattern21, - pub min: MetricPattern2, - pub pct10: MetricPattern21, - pub pct25: MetricPattern21, - pub pct75: MetricPattern21, - pub pct90: MetricPattern21, - pub sum: MetricPattern2, + pub max: MetricPattern1, + pub median: MetricPattern25, + pub min: MetricPattern1, + pub pct10: MetricPattern25, + pub pct25: MetricPattern25, + pub pct75: MetricPattern25, + pub pct90: MetricPattern25, + pub sum: MetricPattern1, } impl BlockSizePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - average: MetricPattern2::new(client.clone(), _m(&acc, "avg")), + average: MetricPattern1::new(client.clone(), _m(&acc, "avg")), cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - max: MetricPattern2::new(client.clone(), _m(&acc, "max")), - median: MetricPattern21::new(client.clone(), _m(&acc, "median")), - min: MetricPattern2::new(client.clone(), _m(&acc, "min")), - pct10: MetricPattern21::new(client.clone(), _m(&acc, "pct10")), - pct25: MetricPattern21::new(client.clone(), _m(&acc, "pct25")), - pct75: MetricPattern21::new(client.clone(), _m(&acc, "pct75")), - pct90: MetricPattern21::new(client.clone(), _m(&acc, "pct90")), - sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), + max: MetricPattern1::new(client.clone(), _m(&acc, "max")), + median: MetricPattern25::new(client.clone(), _m(&acc, "median")), + min: MetricPattern1::new(client.clone(), _m(&acc, "min")), + pct10: MetricPattern25::new(client.clone(), _m(&acc, "pct10")), + pct25: MetricPattern25::new(client.clone(), _m(&acc, "pct25")), + pct75: MetricPattern25::new(client.clone(), _m(&acc, "pct75")), + pct90: MetricPattern25::new(client.clone(), _m(&acc, "pct90")), + sum: MetricPattern1::new(client.clone(), _m(&acc, "sum")), } } } @@ -3829,6 +3829,34 @@ impl UnrealizedPattern { } } +/// Pattern struct for repeated tree structure. +pub struct BlockIntervalPattern { + pub average: MetricPattern2, + pub max: MetricPattern2, + pub median: MetricPattern21, + pub min: MetricPattern2, + pub pct10: MetricPattern21, + pub pct25: MetricPattern21, + pub pct75: MetricPattern21, + pub pct90: MetricPattern21, +} + +impl BlockIntervalPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + average: MetricPattern2::new(client.clone(), _m(&acc, "avg")), + max: MetricPattern2::new(client.clone(), _m(&acc, "max")), + median: MetricPattern21::new(client.clone(), _m(&acc, "median")), + min: MetricPattern2::new(client.clone(), _m(&acc, "min")), + pct10: MetricPattern21::new(client.clone(), _m(&acc, "pct10")), + pct25: MetricPattern21::new(client.clone(), _m(&acc, "pct25")), + pct75: MetricPattern21::new(client.clone(), _m(&acc, "pct75")), + pct90: MetricPattern21::new(client.clone(), _m(&acc, "pct90")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct AddresstypeToHeightToAddrCountPattern { pub p2a: MetricPattern29, @@ -3857,60 +3885,6 @@ impl AddresstypeToHeightToAddrCountPattern { } } -/// Pattern struct for repeated tree structure. -pub struct BlockIntervalPattern { - pub average: MetricPattern1, - pub max: MetricPattern1, - pub median: MetricPattern25, - pub min: MetricPattern1, - pub pct10: MetricPattern25, - pub pct25: MetricPattern25, - pub pct75: MetricPattern25, - pub pct90: MetricPattern25, -} - -impl BlockIntervalPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - average: MetricPattern1::new(client.clone(), _m(&acc, "avg")), - max: MetricPattern1::new(client.clone(), _m(&acc, "max")), - median: MetricPattern25::new(client.clone(), _m(&acc, "median")), - min: MetricPattern1::new(client.clone(), _m(&acc, "min")), - pct10: MetricPattern25::new(client.clone(), _m(&acc, "pct10")), - pct25: MetricPattern25::new(client.clone(), _m(&acc, "pct25")), - pct75: MetricPattern25::new(client.clone(), _m(&acc, "pct75")), - pct90: MetricPattern25::new(client.clone(), _m(&acc, "pct90")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _0satsPattern { - pub activity: ActivityPattern2, - pub addr_count: MetricPattern1, - pub cost_basis: CostBasisPattern, - pub realized: RealizedPattern, - pub relative: RelativePattern, - pub supply: SupplyPattern3, - pub unrealized: UnrealizedPattern, -} - -impl _0satsPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - activity: ActivityPattern2::new(client.clone(), acc.clone()), - addr_count: MetricPattern1::new(client.clone(), _m(&acc, "addr_count")), - cost_basis: CostBasisPattern::new(client.clone(), acc.clone()), - realized: RealizedPattern::new(client.clone(), acc.clone()), - relative: RelativePattern::new(client.clone(), acc.clone()), - supply: SupplyPattern3::new(client.clone(), acc.clone()), - unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct PeriodCagrPattern { pub _10y: MetricPattern4, @@ -3938,56 +3912,9 @@ impl PeriodCagrPattern { } /// Pattern struct for repeated tree structure. -pub struct _0satsPattern2 { - pub activity: ActivityPattern2, - pub cost_basis: CostBasisPattern, - pub realized: RealizedPattern, - pub relative: RelativePattern4, - pub supply: SupplyPattern3, - pub unrealized: UnrealizedPattern, -} - -impl _0satsPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - activity: ActivityPattern2::new(client.clone(), acc.clone()), - cost_basis: CostBasisPattern::new(client.clone(), acc.clone()), - realized: RealizedPattern::new(client.clone(), acc.clone()), - relative: RelativePattern4::new(client.clone(), _m(&acc, "supply_in")), - supply: SupplyPattern3::new(client.clone(), acc.clone()), - unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _10yPattern { - pub activity: ActivityPattern2, - pub cost_basis: CostBasisPattern, - pub realized: RealizedPattern4, - pub relative: RelativePattern, - pub supply: SupplyPattern3, - pub unrealized: UnrealizedPattern, -} - -impl _10yPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - activity: ActivityPattern2::new(client.clone(), acc.clone()), - cost_basis: CostBasisPattern::new(client.clone(), acc.clone()), - realized: RealizedPattern4::new(client.clone(), acc.clone()), - relative: RelativePattern::new(client.clone(), acc.clone()), - supply: SupplyPattern3::new(client.clone(), acc.clone()), - unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _100btcPattern { +pub struct _0satsPattern { pub activity: ActivityPattern2, + pub addr_count: MetricPattern1, pub cost_basis: CostBasisPattern, pub realized: RealizedPattern, pub relative: RelativePattern, @@ -3995,11 +3922,12 @@ pub struct _100btcPattern { pub unrealized: UnrealizedPattern, } -impl _100btcPattern { +impl _0satsPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { activity: ActivityPattern2::new(client.clone(), acc.clone()), + addr_count: MetricPattern1::new(client.clone(), _m(&acc, "addr_count")), cost_basis: CostBasisPattern::new(client.clone(), acc.clone()), realized: RealizedPattern::new(client.clone(), acc.clone()), relative: RelativePattern::new(client.clone(), acc.clone()), @@ -4033,6 +3961,78 @@ impl _10yTo12yPattern { } } +/// Pattern struct for repeated tree structure. +pub struct _10yPattern { + pub activity: ActivityPattern2, + pub cost_basis: CostBasisPattern, + pub realized: RealizedPattern4, + pub relative: RelativePattern, + pub supply: SupplyPattern3, + pub unrealized: UnrealizedPattern, +} + +impl _10yPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + activity: ActivityPattern2::new(client.clone(), acc.clone()), + cost_basis: CostBasisPattern::new(client.clone(), acc.clone()), + realized: RealizedPattern4::new(client.clone(), acc.clone()), + relative: RelativePattern::new(client.clone(), acc.clone()), + supply: SupplyPattern3::new(client.clone(), acc.clone()), + unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _0satsPattern2 { + pub activity: ActivityPattern2, + pub cost_basis: CostBasisPattern, + pub realized: RealizedPattern, + pub relative: RelativePattern4, + pub supply: SupplyPattern3, + pub unrealized: UnrealizedPattern, +} + +impl _0satsPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + activity: ActivityPattern2::new(client.clone(), acc.clone()), + cost_basis: CostBasisPattern::new(client.clone(), acc.clone()), + realized: RealizedPattern::new(client.clone(), acc.clone()), + relative: RelativePattern4::new(client.clone(), _m(&acc, "supply_in")), + supply: SupplyPattern3::new(client.clone(), acc.clone()), + unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _100btcPattern { + pub activity: ActivityPattern2, + pub cost_basis: CostBasisPattern, + pub realized: RealizedPattern, + pub relative: RelativePattern, + pub supply: SupplyPattern3, + pub unrealized: UnrealizedPattern, +} + +impl _100btcPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + activity: ActivityPattern2::new(client.clone(), acc.clone()), + cost_basis: CostBasisPattern::new(client.clone(), acc.clone()), + realized: RealizedPattern::new(client.clone(), acc.clone()), + relative: RelativePattern::new(client.clone(), acc.clone()), + supply: SupplyPattern3::new(client.clone(), acc.clone()), + unrealized: UnrealizedPattern::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct SegwitAdoptionPattern { pub average: MetricPattern2, @@ -4057,28 +4057,6 @@ impl SegwitAdoptionPattern { } } -/// Pattern struct for repeated tree structure. -pub struct ActivityPattern2 { - pub coinblocks_destroyed: BlockCountPattern, - pub coindays_destroyed: BlockCountPattern, - pub satblocks_destroyed: MetricPattern25, - pub satdays_destroyed: MetricPattern25, - pub sent: SentPattern, -} - -impl ActivityPattern2 { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - coinblocks_destroyed: BlockCountPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")), - coindays_destroyed: BlockCountPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), - satblocks_destroyed: MetricPattern25::new(client.clone(), _m(&acc, "satblocks_destroyed")), - satdays_destroyed: MetricPattern25::new(client.clone(), _m(&acc, "satdays_destroyed")), - sent: SentPattern::new(client.clone(), _m(&acc, "sent")), - } - } -} - /// Pattern struct for repeated tree structure. pub struct SupplyPattern3 { pub supply: SupplyPattern2, @@ -4102,21 +4080,23 @@ impl SupplyPattern3 { } /// Pattern struct for repeated tree structure. -pub struct SupplyPattern2 { - pub base: MetricPattern25, - pub bitcoin: MetricPattern4, - pub dollars: MetricPattern4, - pub sats: MetricPattern4, +pub struct ActivityPattern2 { + pub coinblocks_destroyed: BlockCountPattern, + pub coindays_destroyed: BlockCountPattern, + pub satblocks_destroyed: MetricPattern25, + pub satdays_destroyed: MetricPattern25, + pub sent: SentPattern, } -impl SupplyPattern2 { +impl ActivityPattern2 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - base: MetricPattern25::new(client.clone(), acc.clone()), - bitcoin: MetricPattern4::new(client.clone(), _m(&acc, "btc")), - dollars: MetricPattern4::new(client.clone(), _m(&acc, "usd")), - sats: MetricPattern4::new(client.clone(), acc.clone()), + coinblocks_destroyed: BlockCountPattern::new(client.clone(), _m(&acc, "coinblocks_destroyed")), + coindays_destroyed: BlockCountPattern::new(client.clone(), _m(&acc, "coindays_destroyed")), + satblocks_destroyed: MetricPattern25::new(client.clone(), _m(&acc, "satblocks_destroyed")), + satdays_destroyed: MetricPattern25::new(client.clone(), _m(&acc, "satdays_destroyed")), + sent: SentPattern::new(client.clone(), _m(&acc, "sent")), } } } @@ -4141,6 +4121,26 @@ impl OpreturnPattern { } } +/// Pattern struct for repeated tree structure. +pub struct SupplyPattern2 { + pub base: MetricPattern25, + pub bitcoin: MetricPattern4, + pub dollars: MetricPattern4, + pub sats: MetricPattern4, +} + +impl SupplyPattern2 { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + base: MetricPattern25::new(client.clone(), acc.clone()), + bitcoin: MetricPattern4::new(client.clone(), _m(&acc, "btc")), + dollars: MetricPattern4::new(client.clone(), _m(&acc, "usd")), + sats: MetricPattern4::new(client.clone(), acc.clone()), + } + } +} + /// Pattern struct for repeated tree structure. pub struct SentPattern { pub base: MetricPattern25, @@ -4161,24 +4161,6 @@ impl SentPattern { } } -/// Pattern struct for repeated tree structure. -pub struct CoinbasePattern { - pub bitcoin: BitcoinPattern, - pub dollars: BitcoinPattern, - pub sats: BitcoinPattern, -} - -impl CoinbasePattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - bitcoin: BitcoinPattern::new(client.clone(), _m(&acc, "btc")), - dollars: BitcoinPattern::new(client.clone(), _m(&acc, "usd")), - sats: BitcoinPattern::new(client.clone(), acc.clone()), - } - } -} - /// Pattern struct for repeated tree structure. pub struct UnclaimedRewardsPattern { pub bitcoin: BlockCountPattern, @@ -4234,19 +4216,19 @@ impl CostBasisPattern2 { } /// Pattern struct for repeated tree structure. -pub struct BlockCountPattern { - pub base: MetricPattern25, - pub cumulative: MetricPattern1, - pub sum: MetricPattern2, +pub struct CoinbasePattern { + pub bitcoin: BitcoinPattern, + pub dollars: BitcoinPattern, + pub sats: BitcoinPattern, } -impl BlockCountPattern { +impl CoinbasePattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - base: MetricPattern25::new(client.clone(), acc.clone()), - cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), + bitcoin: BitcoinPattern::new(client.clone(), _m(&acc, "btc")), + dollars: BitcoinPattern::new(client.clone(), _m(&acc, "usd")), + sats: BitcoinPattern::new(client.clone(), acc.clone()), } } } @@ -4270,17 +4252,19 @@ impl BitcoinPattern2 { } /// Pattern struct for repeated tree structure. -pub struct SatsPattern4 { - pub cumulative: MetricPattern1, - pub last: MetricPattern2, +pub struct BlockCountPattern { + pub base: MetricPattern25, + pub cumulative: MetricPattern1, + pub sum: MetricPattern2, } -impl SatsPattern4 { +impl BlockCountPattern { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { + base: MetricPattern25::new(client.clone(), acc.clone()), cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), - last: MetricPattern2::new(client.clone(), acc.clone()), + sum: MetricPattern2::new(client.clone(), _m(&acc, "sum")), } } } @@ -4301,6 +4285,38 @@ impl RelativePattern4 { } } +/// Pattern struct for repeated tree structure. +pub struct SupplyValuePattern { + pub bitcoin: MetricPattern25, + pub dollars: MetricPattern25, +} + +impl SupplyValuePattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + bitcoin: MetricPattern25::new(client.clone(), _m(&acc, "btc")), + dollars: MetricPattern25::new(client.clone(), _m(&acc, "usd")), + } + } +} + +/// Pattern struct for repeated tree structure. +pub struct _1dReturns1mSdPattern { + pub sd: MetricPattern4, + pub sma: MetricPattern4, +} + +impl _1dReturns1mSdPattern { + /// Create a new pattern node with accumulated metric name. + pub fn new(client: Arc, acc: String) -> Self { + Self { + sd: MetricPattern4::new(client.clone(), _m(&acc, "sd")), + sma: MetricPattern4::new(client.clone(), _m(&acc, "sma")), + } + } +} + /// Pattern struct for repeated tree structure. pub struct SatsPattern { pub cumulative: MetricPattern1, @@ -4334,33 +4350,17 @@ impl CostBasisPattern { } /// Pattern struct for repeated tree structure. -pub struct SupplyValuePattern { - pub bitcoin: MetricPattern25, - pub dollars: MetricPattern25, +pub struct SatsPattern4 { + pub cumulative: MetricPattern1, + pub last: MetricPattern2, } -impl SupplyValuePattern { +impl SatsPattern4 { /// Create a new pattern node with accumulated metric name. pub fn new(client: Arc, acc: String) -> Self { Self { - bitcoin: MetricPattern25::new(client.clone(), _m(&acc, "btc")), - dollars: MetricPattern25::new(client.clone(), _m(&acc, "usd")), - } - } -} - -/// Pattern struct for repeated tree structure. -pub struct _1dReturns1mSdPattern { - pub sd: MetricPattern4, - pub sma: MetricPattern4, -} - -impl _1dReturns1mSdPattern { - /// Create a new pattern node with accumulated metric name. - pub fn new(client: Arc, acc: String) -> Self { - Self { - sd: MetricPattern4::new(client.clone(), _m(&acc, "sd")), - sma: MetricPattern4::new(client.clone(), _m(&acc, "sma")), + cumulative: MetricPattern1::new(client.clone(), _m(&acc, "cumulative")), + last: MetricPattern2::new(client.clone(), acc.clone()), } } } @@ -5772,6 +5772,7 @@ pub struct CatalogTree_Computed_Market_Ath { pub max_years_between_price_aths: MetricPattern4, pub price_ath: MetricPattern3, pub price_drawdown: MetricPattern3, + pub years_since_price_ath: MetricPattern4, } impl CatalogTree_Computed_Market_Ath { @@ -5782,6 +5783,7 @@ impl CatalogTree_Computed_Market_Ath { max_years_between_price_aths: MetricPattern4::new(client.clone(), format!("{base_path}_max_years_between_price_aths")), price_ath: MetricPattern3::new(client.clone(), format!("{base_path}_price_ath")), price_drawdown: MetricPattern3::new(client.clone(), format!("{base_path}_price_drawdown")), + years_since_price_ath: MetricPattern4::new(client.clone(), format!("{base_path}_years_since_price_ath")), } } } @@ -7139,7 +7141,7 @@ pub struct BrkClient { impl BrkClient { /// Client version. - pub const VERSION: &'static str = "v0.1.0-alpha.1"; + pub const VERSION: &'static str = "v0.1.0-alpha.2"; /// Create a new client with the given base URL. pub fn new(base_url: impl Into) -> Self { diff --git a/crates/brk_computer/src/market/ath/import.rs b/crates/brk_computer/src/market/ath/import.rs index c2e4b0d09..8d31ef23c 100644 --- a/crates/brk_computer/src/market/ath/import.rs +++ b/crates/brk_computer/src/market/ath/import.rs @@ -50,6 +50,26 @@ impl Vecs { &indexes_to_max_days_between_price_aths, ); + let indexes_to_days_since_price_ath = ComputedVecsFromDateIndex::forced_import( + db, + "days_since_price_ath", + Source::Compute, + version, + indexes, + last, + )?; + + let indexes_to_years_since_price_ath = + LazyVecsFromDateIndex::from_computed::( + "years_since_price_ath", + version, + indexes_to_days_since_price_ath + .dateindex + .as_ref() + .map(|v| v.boxed_clone()), + &indexes_to_days_since_price_ath, + ); + let indexes_to_price_drawdown = LazyVecsFrom2FromDateIndex::from_computed::( "price_drawdown", @@ -63,14 +83,8 @@ impl Vecs { height_to_price_drawdown: EagerVec::forced_import(db, "price_drawdown", version)?, indexes_to_price_ath, indexes_to_price_drawdown, - indexes_to_days_since_price_ath: ComputedVecsFromDateIndex::forced_import( - db, - "days_since_price_ath", - Source::Compute, - version, - indexes, - last, - )?, + indexes_to_days_since_price_ath, + indexes_to_years_since_price_ath, indexes_to_max_days_between_price_aths, indexes_to_max_years_between_price_aths, }) diff --git a/crates/brk_computer/src/market/ath/vecs.rs b/crates/brk_computer/src/market/ath/vecs.rs index 8547c4600..47d3a7351 100644 --- a/crates/brk_computer/src/market/ath/vecs.rs +++ b/crates/brk_computer/src/market/ath/vecs.rs @@ -14,6 +14,7 @@ pub struct Vecs { pub indexes_to_price_ath: ComputedVecsFromDateIndex, pub indexes_to_price_drawdown: LazyVecsFrom2FromDateIndex, Dollars>, pub indexes_to_days_since_price_ath: ComputedVecsFromDateIndex, + pub indexes_to_years_since_price_ath: LazyVecsFromDateIndex, pub indexes_to_max_days_between_price_aths: ComputedVecsFromDateIndex, pub indexes_to_max_years_between_price_aths: LazyVecsFromDateIndex, }