mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-11 11:08:13 -07:00
global: snapshot
This commit is contained in:
+196
-184
@@ -954,7 +954,8 @@ pub struct AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitReal
|
||||
pub investor_cap_raw: MetricPattern18<CentsSquaredSats>,
|
||||
pub investor_price: CentsSatsUsdPattern,
|
||||
pub investor_price_ratio: BpsRatioPattern,
|
||||
pub investor_price_ratio_ext: RatioPattern,
|
||||
pub investor_price_ratio_percentiles: RatioPattern,
|
||||
pub investor_price_ratio_std_dev: RatioPattern2,
|
||||
pub loss_value_created: MetricPattern1<Cents>,
|
||||
pub loss_value_destroyed: MetricPattern1<Cents>,
|
||||
pub lower_price_band: CentsSatsUsdPattern,
|
||||
@@ -981,7 +982,8 @@ pub struct AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitReal
|
||||
pub realized_loss_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub realized_price: CentsSatsUsdPattern,
|
||||
pub realized_price_ratio: BpsRatioPattern,
|
||||
pub realized_price_ratio_ext: RatioPattern,
|
||||
pub realized_price_ratio_percentiles: RatioPattern,
|
||||
pub realized_price_ratio_std_dev: RatioPattern2,
|
||||
pub realized_profit: CumulativeHeightPattern<Cents>,
|
||||
pub realized_profit_ema_1w: MetricPattern1<Cents>,
|
||||
pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
@@ -1019,7 +1021,8 @@ impl AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSe
|
||||
investor_cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_raw")),
|
||||
investor_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")),
|
||||
investor_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
investor_price_ratio_ext: RatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
investor_price_ratio_percentiles: RatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
investor_price_ratio_std_dev: RatioPattern2::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
loss_value_created: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_created")),
|
||||
loss_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_destroyed")),
|
||||
lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")),
|
||||
@@ -1046,7 +1049,130 @@ impl AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSe
|
||||
realized_loss_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_loss")),
|
||||
realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")),
|
||||
realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_price_ratio_ext: RatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_price_ratio_percentiles: RatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_price_ratio_std_dev: RatioPattern2::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")),
|
||||
realized_profit_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_ema_1w")),
|
||||
realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")),
|
||||
realized_profit_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit")),
|
||||
realized_profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit_to_loss_ratio")),
|
||||
sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio")),
|
||||
sell_side_risk_ratio_24h_ema: _1m1wPattern::new(client.clone(), _m(&acc, "sell_side_risk_ratio_24h_ema")),
|
||||
sent_in_loss: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_loss")),
|
||||
sent_in_loss_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_loss_ema_2w")),
|
||||
sent_in_profit: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_profit")),
|
||||
sent_in_profit_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_profit_ema_2w")),
|
||||
sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")),
|
||||
sopr_24h_ema: _1m1wPattern2::new(client.clone(), _m(&acc, "sopr_24h_ema")),
|
||||
upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")),
|
||||
value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")),
|
||||
value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_created")),
|
||||
value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")),
|
||||
value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_destroyed")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern2 {
|
||||
pub cap_raw: MetricPattern18<CentsSats>,
|
||||
pub capitulation_flow: MetricPattern1<Dollars>,
|
||||
pub gross_pnl: CentsUsdPattern,
|
||||
pub gross_pnl_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub investor_cap_raw: MetricPattern18<CentsSquaredSats>,
|
||||
pub investor_price: CentsSatsUsdPattern,
|
||||
pub investor_price_ratio: BpsRatioPattern,
|
||||
pub investor_price_ratio_percentiles: RatioPattern,
|
||||
pub investor_price_ratio_std_dev: RatioPattern2,
|
||||
pub loss_value_created: MetricPattern1<Cents>,
|
||||
pub loss_value_destroyed: MetricPattern1<Cents>,
|
||||
pub lower_price_band: CentsSatsUsdPattern,
|
||||
pub mvrv: MetricPattern1<StoredF32>,
|
||||
pub neg_realized_loss: MetricPattern1<Dollars>,
|
||||
pub net_pnl_change_1m: MetricPattern1<CentsSigned>,
|
||||
pub net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern,
|
||||
pub net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub net_realized_pnl: CumulativeHeightPattern<CentsSigned>,
|
||||
pub net_realized_pnl_ema_1w: MetricPattern1<CentsSigned>,
|
||||
pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub peak_regret: CumulativeHeightPattern<Cents>,
|
||||
pub peak_regret_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub profit_flow: MetricPattern1<Dollars>,
|
||||
pub profit_value_created: MetricPattern1<Cents>,
|
||||
pub profit_value_destroyed: MetricPattern1<Cents>,
|
||||
pub realized_cap: MetricPattern1<Dollars>,
|
||||
pub realized_cap_cents: MetricPattern1<Cents>,
|
||||
pub realized_cap_change_1m: MetricPattern1<CentsSigned>,
|
||||
pub realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern,
|
||||
pub realized_loss: CumulativeHeightPattern<Cents>,
|
||||
pub realized_loss_ema_1w: MetricPattern1<Cents>,
|
||||
pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub realized_loss_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub realized_price: CentsSatsUsdPattern,
|
||||
pub realized_price_ratio: BpsRatioPattern,
|
||||
pub realized_price_ratio_percentiles: RatioPattern,
|
||||
pub realized_price_ratio_std_dev: RatioPattern2,
|
||||
pub realized_profit: CumulativeHeightPattern<Cents>,
|
||||
pub realized_profit_ema_1w: MetricPattern1<Cents>,
|
||||
pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub realized_profit_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub realized_profit_to_loss_ratio: _1m1w1y24hPattern<StoredF64>,
|
||||
pub sell_side_risk_ratio: _1m1w1y24hPattern2,
|
||||
pub sell_side_risk_ratio_24h_ema: _1m1wPattern,
|
||||
pub sent_in_loss: BaseCumulativePattern,
|
||||
pub sent_in_loss_ema: _2wPattern,
|
||||
pub sent_in_profit: BaseCumulativePattern,
|
||||
pub sent_in_profit_ema: _2wPattern,
|
||||
pub sopr: _1m1w1y24hPattern<StoredF64>,
|
||||
pub sopr_24h_ema: _1m1wPattern2,
|
||||
pub upper_price_band: CentsSatsUsdPattern,
|
||||
pub value_created: MetricPattern1<Cents>,
|
||||
pub value_created_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub value_destroyed: MetricPattern1<Cents>,
|
||||
pub value_destroyed_sum: _1m1w1y24hPattern<Cents>,
|
||||
}
|
||||
|
||||
impl CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern2 {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "cap_raw")),
|
||||
capitulation_flow: MetricPattern1::new(client.clone(), _m(&acc, "capitulation_flow")),
|
||||
gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")),
|
||||
gross_pnl_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "gross_pnl_sum")),
|
||||
investor_cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_raw")),
|
||||
investor_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")),
|
||||
investor_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
investor_price_ratio_percentiles: RatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
investor_price_ratio_std_dev: RatioPattern2::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
loss_value_created: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_created")),
|
||||
loss_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_destroyed")),
|
||||
lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")),
|
||||
mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")),
|
||||
neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")),
|
||||
net_pnl_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "net_pnl_change_1m")),
|
||||
net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_market_cap")),
|
||||
net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_realized_cap")),
|
||||
net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")),
|
||||
net_realized_pnl_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl_ema_1w")),
|
||||
net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_realized_pnl_rel_to_realized_cap")),
|
||||
peak_regret: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_peak_regret")),
|
||||
peak_regret_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_peak_regret_rel_to_realized_cap")),
|
||||
profit_flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")),
|
||||
profit_value_created: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_created")),
|
||||
profit_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_destroyed")),
|
||||
realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")),
|
||||
realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")),
|
||||
realized_cap_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_change_1m")),
|
||||
realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_cap_rel_to_own_market_cap")),
|
||||
realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")),
|
||||
realized_loss_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_ema_1w")),
|
||||
realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")),
|
||||
realized_loss_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_loss")),
|
||||
realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")),
|
||||
realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_price_ratio_percentiles: RatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_price_ratio_std_dev: RatioPattern2::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")),
|
||||
realized_profit_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_ema_1w")),
|
||||
realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")),
|
||||
@@ -1187,124 +1313,6 @@ impl AdjustedCapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSe
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern2 {
|
||||
pub cap_raw: MetricPattern18<CentsSats>,
|
||||
pub capitulation_flow: MetricPattern1<Dollars>,
|
||||
pub gross_pnl: CentsUsdPattern,
|
||||
pub gross_pnl_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub investor_cap_raw: MetricPattern18<CentsSquaredSats>,
|
||||
pub investor_price: CentsSatsUsdPattern,
|
||||
pub investor_price_ratio: BpsRatioPattern,
|
||||
pub investor_price_ratio_ext: RatioPattern,
|
||||
pub loss_value_created: MetricPattern1<Cents>,
|
||||
pub loss_value_destroyed: MetricPattern1<Cents>,
|
||||
pub lower_price_band: CentsSatsUsdPattern,
|
||||
pub mvrv: MetricPattern1<StoredF32>,
|
||||
pub neg_realized_loss: MetricPattern1<Dollars>,
|
||||
pub net_pnl_change_1m: MetricPattern1<CentsSigned>,
|
||||
pub net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern,
|
||||
pub net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub net_realized_pnl: CumulativeHeightPattern<CentsSigned>,
|
||||
pub net_realized_pnl_ema_1w: MetricPattern1<CentsSigned>,
|
||||
pub net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub peak_regret: CumulativeHeightPattern<Cents>,
|
||||
pub peak_regret_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub profit_flow: MetricPattern1<Dollars>,
|
||||
pub profit_value_created: MetricPattern1<Cents>,
|
||||
pub profit_value_destroyed: MetricPattern1<Cents>,
|
||||
pub realized_cap: MetricPattern1<Dollars>,
|
||||
pub realized_cap_cents: MetricPattern1<Cents>,
|
||||
pub realized_cap_change_1m: MetricPattern1<CentsSigned>,
|
||||
pub realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern,
|
||||
pub realized_loss: CumulativeHeightPattern<Cents>,
|
||||
pub realized_loss_ema_1w: MetricPattern1<Cents>,
|
||||
pub realized_loss_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub realized_loss_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub realized_price: CentsSatsUsdPattern,
|
||||
pub realized_price_ratio: BpsRatioPattern,
|
||||
pub realized_price_ratio_ext: RatioPattern,
|
||||
pub realized_profit: CumulativeHeightPattern<Cents>,
|
||||
pub realized_profit_ema_1w: MetricPattern1<Cents>,
|
||||
pub realized_profit_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub realized_profit_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub realized_profit_to_loss_ratio: _1m1w1y24hPattern<StoredF64>,
|
||||
pub sell_side_risk_ratio: _1m1w1y24hPattern2,
|
||||
pub sell_side_risk_ratio_24h_ema: _1m1wPattern,
|
||||
pub sent_in_loss: BaseCumulativePattern,
|
||||
pub sent_in_loss_ema: _2wPattern,
|
||||
pub sent_in_profit: BaseCumulativePattern,
|
||||
pub sent_in_profit_ema: _2wPattern,
|
||||
pub sopr: _1m1w1y24hPattern<StoredF64>,
|
||||
pub sopr_24h_ema: _1m1wPattern2,
|
||||
pub upper_price_band: CentsSatsUsdPattern,
|
||||
pub value_created: MetricPattern1<Cents>,
|
||||
pub value_created_sum: _1m1w1y24hPattern<Cents>,
|
||||
pub value_destroyed: MetricPattern1<Cents>,
|
||||
pub value_destroyed_sum: _1m1w1y24hPattern<Cents>,
|
||||
}
|
||||
|
||||
impl CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern2 {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "cap_raw")),
|
||||
capitulation_flow: MetricPattern1::new(client.clone(), _m(&acc, "capitulation_flow")),
|
||||
gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")),
|
||||
gross_pnl_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "gross_pnl_sum")),
|
||||
investor_cap_raw: MetricPattern18::new(client.clone(), _m(&acc, "investor_cap_raw")),
|
||||
investor_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "investor_price")),
|
||||
investor_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
investor_price_ratio_ext: RatioPattern::new(client.clone(), _m(&acc, "investor_price_ratio")),
|
||||
loss_value_created: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_created")),
|
||||
loss_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "loss_value_destroyed")),
|
||||
lower_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "lower_price_band")),
|
||||
mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")),
|
||||
neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")),
|
||||
net_pnl_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "net_pnl_change_1m")),
|
||||
net_pnl_change_1m_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_market_cap")),
|
||||
net_pnl_change_1m_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_pnl_change_1m_rel_to_realized_cap")),
|
||||
net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")),
|
||||
net_realized_pnl_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "net_realized_pnl_ema_1w")),
|
||||
net_realized_pnl_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_realized_pnl_rel_to_realized_cap")),
|
||||
peak_regret: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_peak_regret")),
|
||||
peak_regret_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_peak_regret_rel_to_realized_cap")),
|
||||
profit_flow: MetricPattern1::new(client.clone(), _m(&acc, "profit_flow")),
|
||||
profit_value_created: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_created")),
|
||||
profit_value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "profit_value_destroyed")),
|
||||
realized_cap: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap")),
|
||||
realized_cap_cents: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_cents")),
|
||||
realized_cap_change_1m: MetricPattern1::new(client.clone(), _m(&acc, "realized_cap_change_1m")),
|
||||
realized_cap_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_cap_rel_to_own_market_cap")),
|
||||
realized_loss: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_loss")),
|
||||
realized_loss_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_loss_ema_1w")),
|
||||
realized_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_loss_rel_to_realized_cap")),
|
||||
realized_loss_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_loss")),
|
||||
realized_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "realized_price")),
|
||||
realized_price_ratio: BpsRatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_price_ratio_ext: RatioPattern::new(client.clone(), _m(&acc, "realized_price_ratio")),
|
||||
realized_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")),
|
||||
realized_profit_ema_1w: MetricPattern1::new(client.clone(), _m(&acc, "realized_profit_ema_1w")),
|
||||
realized_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "realized_profit_rel_to_realized_cap")),
|
||||
realized_profit_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit")),
|
||||
realized_profit_to_loss_ratio: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "realized_profit_to_loss_ratio")),
|
||||
sell_side_risk_ratio: _1m1w1y24hPattern2::new(client.clone(), _m(&acc, "sell_side_risk_ratio")),
|
||||
sell_side_risk_ratio_24h_ema: _1m1wPattern::new(client.clone(), _m(&acc, "sell_side_risk_ratio_24h_ema")),
|
||||
sent_in_loss: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_loss")),
|
||||
sent_in_loss_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_loss_ema_2w")),
|
||||
sent_in_profit: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_profit")),
|
||||
sent_in_profit_ema: _2wPattern::new(client.clone(), _m(&acc, "sent_in_profit_ema_2w")),
|
||||
sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")),
|
||||
sopr_24h_ema: _1m1wPattern2::new(client.clone(), _m(&acc, "sopr_24h_ema")),
|
||||
upper_price_band: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "upper_price_band")),
|
||||
value_created: MetricPattern1::new(client.clone(), _m(&acc, "value_created")),
|
||||
value_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_created")),
|
||||
value_destroyed: MetricPattern1::new(client.clone(), _m(&acc, "value_destroyed")),
|
||||
value_destroyed_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "value_destroyed")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern {
|
||||
pub cap_raw: MetricPattern18<CentsSats>,
|
||||
@@ -1479,58 +1487,6 @@ impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct BpsRatioPattern2 {
|
||||
pub bps: MetricPattern1<BasisPoints32>,
|
||||
pub ratio: MetricPattern1<StoredF32>,
|
||||
pub ratio_pct1: BpsRatioPattern,
|
||||
pub ratio_pct1_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct2: BpsRatioPattern,
|
||||
pub ratio_pct2_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct5: BpsRatioPattern,
|
||||
pub ratio_pct5_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct95: BpsRatioPattern,
|
||||
pub ratio_pct95_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct98: BpsRatioPattern,
|
||||
pub ratio_pct98_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct99: BpsRatioPattern,
|
||||
pub ratio_pct99_price: CentsSatsUsdPattern,
|
||||
pub ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sma_1m: BpsRatioPattern,
|
||||
pub ratio_sma_1w: BpsRatioPattern,
|
||||
}
|
||||
|
||||
impl BpsRatioPattern2 {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
bps: MetricPattern1::new(client.clone(), _m(&acc, "bps")),
|
||||
ratio: MetricPattern1::new(client.clone(), acc.clone()),
|
||||
ratio_pct1: BpsRatioPattern::new(client.clone(), _m(&acc, "pct1")),
|
||||
ratio_pct1_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct1")),
|
||||
ratio_pct2: BpsRatioPattern::new(client.clone(), _m(&acc, "pct2")),
|
||||
ratio_pct2_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct2")),
|
||||
ratio_pct5: BpsRatioPattern::new(client.clone(), _m(&acc, "pct5")),
|
||||
ratio_pct5_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct5")),
|
||||
ratio_pct95: BpsRatioPattern::new(client.clone(), _m(&acc, "pct95")),
|
||||
ratio_pct95_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct95")),
|
||||
ratio_pct98: BpsRatioPattern::new(client.clone(), _m(&acc, "pct98")),
|
||||
ratio_pct98_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct98")),
|
||||
ratio_pct99: BpsRatioPattern::new(client.clone(), _m(&acc, "pct99")),
|
||||
ratio_pct99_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct99")),
|
||||
ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sma_1m: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1m")),
|
||||
ratio_sma_1w: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1w")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct InvestedNegNetNuplSupplyUnrealizedPattern2 {
|
||||
pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
@@ -1634,7 +1590,9 @@ impl Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct RatioPattern {
|
||||
pub struct BpsRatioPattern2 {
|
||||
pub bps: MetricPattern1<BasisPoints32>,
|
||||
pub ratio: MetricPattern1<StoredF32>,
|
||||
pub ratio_pct1: BpsRatioPattern,
|
||||
pub ratio_pct1_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct2: BpsRatioPattern,
|
||||
@@ -1647,18 +1605,16 @@ pub struct RatioPattern {
|
||||
pub ratio_pct98_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct99: BpsRatioPattern,
|
||||
pub ratio_pct99_price: CentsSatsUsdPattern,
|
||||
pub ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sma_1m: BpsRatioPattern,
|
||||
pub ratio_sma_1w: BpsRatioPattern,
|
||||
}
|
||||
|
||||
impl RatioPattern {
|
||||
impl BpsRatioPattern2 {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
bps: MetricPattern1::new(client.clone(), _m(&acc, "bps")),
|
||||
ratio: MetricPattern1::new(client.clone(), acc.clone()),
|
||||
ratio_pct1: BpsRatioPattern::new(client.clone(), _m(&acc, "pct1")),
|
||||
ratio_pct1_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct1")),
|
||||
ratio_pct2: BpsRatioPattern::new(client.clone(), _m(&acc, "pct2")),
|
||||
@@ -1671,10 +1627,6 @@ impl RatioPattern {
|
||||
ratio_pct98_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct98")),
|
||||
ratio_pct99: BpsRatioPattern::new(client.clone(), _m(&acc, "pct99")),
|
||||
ratio_pct99_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct99")),
|
||||
ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sma_1m: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1m")),
|
||||
ratio_sma_1w: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1w")),
|
||||
}
|
||||
@@ -1725,6 +1677,46 @@ impl GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct RatioPattern {
|
||||
pub ratio_pct1: BpsRatioPattern,
|
||||
pub ratio_pct1_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct2: BpsRatioPattern,
|
||||
pub ratio_pct2_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct5: BpsRatioPattern,
|
||||
pub ratio_pct5_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct95: BpsRatioPattern,
|
||||
pub ratio_pct95_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct98: BpsRatioPattern,
|
||||
pub ratio_pct98_price: CentsSatsUsdPattern,
|
||||
pub ratio_pct99: BpsRatioPattern,
|
||||
pub ratio_pct99_price: CentsSatsUsdPattern,
|
||||
pub ratio_sma_1m: BpsRatioPattern,
|
||||
pub ratio_sma_1w: BpsRatioPattern,
|
||||
}
|
||||
|
||||
impl RatioPattern {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
ratio_pct1: BpsRatioPattern::new(client.clone(), _m(&acc, "pct1")),
|
||||
ratio_pct1_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct1")),
|
||||
ratio_pct2: BpsRatioPattern::new(client.clone(), _m(&acc, "pct2")),
|
||||
ratio_pct2_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct2")),
|
||||
ratio_pct5: BpsRatioPattern::new(client.clone(), _m(&acc, "pct5")),
|
||||
ratio_pct5_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct5")),
|
||||
ratio_pct95: BpsRatioPattern::new(client.clone(), _m(&acc, "pct95")),
|
||||
ratio_pct95_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct95")),
|
||||
ratio_pct98: BpsRatioPattern::new(client.clone(), _m(&acc, "pct98")),
|
||||
ratio_pct98_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct98")),
|
||||
ratio_pct99: BpsRatioPattern::new(client.clone(), _m(&acc, "pct99")),
|
||||
ratio_pct99_price: CentsSatsUsdPattern::new(client.clone(), _m(&acc, "pct99")),
|
||||
ratio_sma_1m: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1m")),
|
||||
ratio_sma_1w: BpsRatioPattern::new(client.clone(), _m(&acc, "sma_1w")),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct _10y1m1w1y2y3m3y4y5y6m6y8yPattern2 {
|
||||
pub _10y: BpsPercentRatioPattern,
|
||||
@@ -2433,6 +2425,26 @@ impl InvestedMaxMinPercentilesPattern {
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct RatioPattern2 {
|
||||
pub ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
pub ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern,
|
||||
}
|
||||
|
||||
impl RatioPattern2 {
|
||||
/// Create a new pattern node with accumulated metric name.
|
||||
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
|
||||
Self {
|
||||
ratio_sd: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_1y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_2y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
ratio_sd_4y: _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern::new(client.clone(), acc.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Pattern struct for repeated tree structure.
|
||||
pub struct _1m1w1y24hPattern<T> {
|
||||
pub _1m: MetricPattern1<T>,
|
||||
|
||||
@@ -6,8 +6,8 @@ use vecdb::{Exit, ReadableVec, Rw, StorageMode};
|
||||
use crate::{
|
||||
blocks,
|
||||
internal::{
|
||||
ComputedFromHeightRatioExtension, PercentFromHeight, RatioCents64, RatioDollarsBp32,
|
||||
RollingWindows,
|
||||
ComputedFromHeightRatioPercentiles, ComputedFromHeightRatioStdDevBands,
|
||||
PercentFromHeight, RatioCents64, RatioDollarsBp32, RollingWindows,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -24,8 +24,10 @@ pub struct RealizedExtended<M: StorageMode = Rw> {
|
||||
|
||||
pub realized_profit_to_loss_ratio: RollingWindows<StoredF64, M>,
|
||||
|
||||
pub realized_price_ratio_ext: ComputedFromHeightRatioExtension<M>,
|
||||
pub investor_price_ratio_ext: ComputedFromHeightRatioExtension<M>,
|
||||
pub realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles<M>,
|
||||
pub realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands<M>,
|
||||
pub investor_price_ratio_percentiles: ComputedFromHeightRatioPercentiles<M>,
|
||||
pub investor_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands<M>,
|
||||
}
|
||||
|
||||
impl RealizedExtended {
|
||||
@@ -37,13 +39,27 @@ impl RealizedExtended {
|
||||
realized_loss_sum: cfg.import_rolling("realized_loss", Version::ONE)?,
|
||||
realized_profit_to_loss_ratio: cfg
|
||||
.import_rolling("realized_profit_to_loss_ratio", Version::ONE)?,
|
||||
realized_price_ratio_ext: ComputedFromHeightRatioExtension::forced_import(
|
||||
realized_price_ratio_percentiles:
|
||||
ComputedFromHeightRatioPercentiles::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("realized_price"),
|
||||
cfg.version + Version::ONE,
|
||||
cfg.indexes,
|
||||
)?,
|
||||
realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("realized_price"),
|
||||
cfg.version + Version::ONE,
|
||||
cfg.indexes,
|
||||
)?,
|
||||
investor_price_ratio_ext: ComputedFromHeightRatioExtension::forced_import(
|
||||
investor_price_ratio_percentiles:
|
||||
ComputedFromHeightRatioPercentiles::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("investor_price"),
|
||||
cfg.version,
|
||||
cfg.indexes,
|
||||
)?,
|
||||
investor_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands::forced_import(
|
||||
cfg.db,
|
||||
&cfg.name("investor_price"),
|
||||
cfg.version,
|
||||
@@ -101,29 +117,36 @@ impl RealizedExtended {
|
||||
)?;
|
||||
}
|
||||
|
||||
// Extended ratio metrics
|
||||
self.realized_price_ratio_ext.compute_rest(
|
||||
// Realized price ratio: percentiles + stddev
|
||||
self.realized_price_ratio_percentiles.compute(
|
||||
blocks,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&base.realized_price_ratio.ratio.height,
|
||||
)?;
|
||||
self.realized_price_ratio_ext.compute_cents_bands(
|
||||
starting_indexes,
|
||||
&base.realized_price.cents.height,
|
||||
)?;
|
||||
self.realized_price_ratio_std_dev.compute(
|
||||
blocks,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&base.realized_price_ratio.ratio.height,
|
||||
&base.realized_price.cents.height,
|
||||
)?;
|
||||
|
||||
self.investor_price_ratio_ext.compute_rest(
|
||||
// Investor price ratio: percentiles + stddev
|
||||
self.investor_price_ratio_percentiles.compute(
|
||||
blocks,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&base.investor_price_ratio.ratio.height,
|
||||
)?;
|
||||
self.investor_price_ratio_ext.compute_cents_bands(
|
||||
starting_indexes,
|
||||
&base.investor_price.cents.height,
|
||||
)?;
|
||||
self.investor_price_ratio_std_dev.compute(
|
||||
blocks,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&base.investor_price_ratio.ratio.height,
|
||||
&base.investor_price.cents.height,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -6,7 +6,7 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode};
|
||||
|
||||
use crate::{blocks, indexes, prices};
|
||||
|
||||
use super::{ComputedFromHeightRatio, ComputedFromHeightRatioExtension};
|
||||
use super::{ComputedFromHeightRatio, ComputedFromHeightRatioPercentiles};
|
||||
|
||||
#[derive(Deref, DerefMut, Traversable)]
|
||||
pub struct ComputedFromHeightRatioExtended<M: StorageMode = Rw> {
|
||||
@@ -15,7 +15,7 @@ pub struct ComputedFromHeightRatioExtended<M: StorageMode = Rw> {
|
||||
#[traversable(flatten)]
|
||||
pub base: ComputedFromHeightRatio<M>,
|
||||
#[traversable(flatten)]
|
||||
pub extended: ComputedFromHeightRatioExtension<M>,
|
||||
pub percentiles: ComputedFromHeightRatioPercentiles<M>,
|
||||
}
|
||||
|
||||
impl ComputedFromHeightRatioExtended {
|
||||
@@ -27,11 +27,13 @@ impl ComputedFromHeightRatioExtended {
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
base: ComputedFromHeightRatio::forced_import(db, name, version, indexes)?,
|
||||
extended: ComputedFromHeightRatioExtension::forced_import(db, name, version, indexes)?,
|
||||
percentiles: ComputedFromHeightRatioPercentiles::forced_import(
|
||||
db, name, version, indexes,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
/// Compute ratio and all extended metrics from an externally-provided metric price (in cents).
|
||||
/// Compute ratio and all percentile metrics from an externally-provided metric price (in cents).
|
||||
pub(crate) fn compute_rest(
|
||||
&mut self,
|
||||
blocks: &blocks::Vecs,
|
||||
@@ -43,10 +45,8 @@ impl ComputedFromHeightRatioExtended {
|
||||
let close_price = &prices.price.cents.height;
|
||||
self.base
|
||||
.compute_ratio(starting_indexes, close_price, metric_price, exit)?;
|
||||
self.extended
|
||||
.compute_rest(blocks, starting_indexes, exit, &self.base.ratio.height)?;
|
||||
self.extended
|
||||
.compute_cents_bands(starting_indexes, metric_price, exit)?;
|
||||
self.percentiles
|
||||
.compute(blocks, starting_indexes, exit, &self.base.ratio.height, metric_price)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Cents, Height, Indexes, Version};
|
||||
use derive_more::{Deref, DerefMut};
|
||||
use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode};
|
||||
|
||||
use crate::{blocks, indexes, prices};
|
||||
|
||||
use super::{ComputedFromHeightRatioExtended, ComputedFromHeightRatioStdDevBands};
|
||||
|
||||
#[derive(Deref, DerefMut, Traversable)]
|
||||
pub struct ComputedFromHeightRatioFull<M: StorageMode = Rw> {
|
||||
#[deref]
|
||||
#[deref_mut]
|
||||
#[traversable(flatten)]
|
||||
pub base: ComputedFromHeightRatioExtended<M>,
|
||||
#[traversable(flatten)]
|
||||
pub std_dev: ComputedFromHeightRatioStdDevBands<M>,
|
||||
}
|
||||
|
||||
impl ComputedFromHeightRatioFull {
|
||||
pub(crate) fn forced_import(
|
||||
db: &Database,
|
||||
name: &str,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
Ok(Self {
|
||||
base: ComputedFromHeightRatioExtended::forced_import(db, name, version, indexes)?,
|
||||
std_dev: ComputedFromHeightRatioStdDevBands::forced_import(
|
||||
db, name, version, indexes,
|
||||
)?,
|
||||
})
|
||||
}
|
||||
|
||||
/// Compute ratio, percentiles, and all stddev bands from an externally-provided metric price (in cents).
|
||||
pub(crate) fn compute_rest(
|
||||
&mut self,
|
||||
blocks: &blocks::Vecs,
|
||||
prices: &prices::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
metric_price: &impl ReadableVec<Height, Cents>,
|
||||
) -> Result<()> {
|
||||
self.base
|
||||
.compute_rest(blocks, prices, starting_indexes, exit, metric_price)?;
|
||||
self.std_dev
|
||||
.compute(blocks, starting_indexes, exit, &self.base.base.ratio.height, metric_price)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,14 @@
|
||||
mod extended;
|
||||
mod extension;
|
||||
mod full;
|
||||
mod percentiles;
|
||||
mod price_extended;
|
||||
mod std_dev_bands;
|
||||
|
||||
pub use extended::*;
|
||||
pub use extension::*;
|
||||
pub use full::*;
|
||||
pub use percentiles::*;
|
||||
pub use price_extended::*;
|
||||
pub use std_dev_bands::*;
|
||||
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
|
||||
+6
-57
@@ -8,13 +8,13 @@ use vecdb::{
|
||||
|
||||
use crate::{
|
||||
blocks, indexes,
|
||||
internal::{ComputedFromHeightStdDevExtended, ExpandingPercentiles, Price, PriceTimesRatioBp32Cents},
|
||||
internal::{ExpandingPercentiles, Price, PriceTimesRatioBp32Cents},
|
||||
};
|
||||
|
||||
use super::{super::ComputedFromHeight, ComputedFromHeightRatio};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct ComputedFromHeightRatioExtension<M: StorageMode = Rw> {
|
||||
pub struct ComputedFromHeightRatioPercentiles<M: StorageMode = Rw> {
|
||||
pub ratio_sma_1w: ComputedFromHeightRatio<M>,
|
||||
pub ratio_sma_1m: ComputedFromHeightRatio<M>,
|
||||
pub ratio_pct99: ComputedFromHeightRatio<M>,
|
||||
@@ -30,18 +30,13 @@ pub struct ComputedFromHeightRatioExtension<M: StorageMode = Rw> {
|
||||
pub ratio_pct2_price: Price<ComputedFromHeight<Cents, M>>,
|
||||
pub ratio_pct1_price: Price<ComputedFromHeight<Cents, M>>,
|
||||
|
||||
pub ratio_sd: ComputedFromHeightStdDevExtended<M>,
|
||||
pub ratio_sd_4y: ComputedFromHeightStdDevExtended<M>,
|
||||
pub ratio_sd_2y: ComputedFromHeightStdDevExtended<M>,
|
||||
pub ratio_sd_1y: ComputedFromHeightStdDevExtended<M>,
|
||||
|
||||
#[traversable(skip)]
|
||||
expanding_pct: ExpandingPercentiles,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::new(4);
|
||||
|
||||
impl ComputedFromHeightRatioExtension {
|
||||
impl ComputedFromHeightRatioPercentiles {
|
||||
pub(crate) fn forced_import(
|
||||
db: &Database,
|
||||
name: &str,
|
||||
@@ -61,19 +56,6 @@ impl ComputedFromHeightRatioExtension {
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! import_sd {
|
||||
($suffix:expr, $period:expr, $days:expr) => {
|
||||
ComputedFromHeightStdDevExtended::forced_import(
|
||||
db,
|
||||
&format!("{name}_{}", $suffix),
|
||||
$period,
|
||||
$days,
|
||||
v,
|
||||
indexes,
|
||||
)?
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! import_price {
|
||||
($suffix:expr) => {
|
||||
Price::forced_import(db, &format!("{name}_{}", $suffix), v, indexes)?
|
||||
@@ -83,10 +65,6 @@ impl ComputedFromHeightRatioExtension {
|
||||
Ok(Self {
|
||||
ratio_sma_1w: import_ratio!("ratio_sma_1w"),
|
||||
ratio_sma_1m: import_ratio!("ratio_sma_1m"),
|
||||
ratio_sd: import_sd!("ratio", "", usize::MAX),
|
||||
ratio_sd_1y: import_sd!("ratio", "1y", 365),
|
||||
ratio_sd_2y: import_sd!("ratio", "2y", 2 * 365),
|
||||
ratio_sd_4y: import_sd!("ratio", "4y", 4 * 365),
|
||||
ratio_pct99: import_ratio!("ratio_pct99"),
|
||||
ratio_pct98: import_ratio!("ratio_pct98"),
|
||||
ratio_pct95: import_ratio!("ratio_pct95"),
|
||||
@@ -103,14 +81,14 @@ impl ComputedFromHeightRatioExtension {
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn compute_rest(
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
blocks: &blocks::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
ratio_source: &impl ReadableVec<Height, StoredF32>,
|
||||
metric_price: &impl ReadableVec<Height, Cents>,
|
||||
) -> Result<()> {
|
||||
// SMA using lookback vecs
|
||||
self.ratio_sma_1w.bps.height.compute_rolling_average(
|
||||
starting_indexes.height,
|
||||
&blocks.count.height_1w_ago,
|
||||
@@ -151,7 +129,6 @@ impl ComputedFromHeightRatioExtension {
|
||||
}
|
||||
}
|
||||
|
||||
// Process new blocks [start, ratio_len)
|
||||
let new_ratios = ratio_source.collect_range_at(start, ratio_len);
|
||||
let mut pct_vecs: [&mut EagerVec<PcoVec<Height, BasisPoints32>>; 6] = [
|
||||
&mut self.ratio_pct1.bps.height,
|
||||
@@ -179,25 +156,7 @@ impl ComputedFromHeightRatioExtension {
|
||||
self.mut_pct_vecs().try_for_each(|v| v.flush())?;
|
||||
}
|
||||
|
||||
// Compute stddev at height level
|
||||
for sd in [
|
||||
&mut self.ratio_sd,
|
||||
&mut self.ratio_sd_4y,
|
||||
&mut self.ratio_sd_2y,
|
||||
&mut self.ratio_sd_1y,
|
||||
] {
|
||||
sd.compute_all(blocks, starting_indexes, exit, ratio_source)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn compute_cents_bands(
|
||||
&mut self,
|
||||
starting_indexes: &Indexes,
|
||||
metric_price: &impl ReadableVec<Height, Cents>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
// Cents bands
|
||||
macro_rules! compute_band {
|
||||
($usd_field:ident, $band_source:expr) => {
|
||||
self.$usd_field
|
||||
@@ -218,16 +177,6 @@ impl ComputedFromHeightRatioExtension {
|
||||
compute_band!(ratio_pct2_price, &self.ratio_pct2.bps.height);
|
||||
compute_band!(ratio_pct1_price, &self.ratio_pct1.bps.height);
|
||||
|
||||
// Stddev cents bands
|
||||
for sd in [
|
||||
&mut self.ratio_sd,
|
||||
&mut self.ratio_sd_4y,
|
||||
&mut self.ratio_sd_2y,
|
||||
&mut self.ratio_sd_1y,
|
||||
] {
|
||||
sd.compute_cents_bands(starting_indexes, metric_price, exit)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{Cents, Height, Indexes, StoredF32, Version};
|
||||
use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode};
|
||||
|
||||
use crate::{blocks, indexes, internal::ComputedFromHeightStdDevExtended};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct ComputedFromHeightRatioStdDevBands<M: StorageMode = Rw> {
|
||||
pub ratio_sd: ComputedFromHeightStdDevExtended<M>,
|
||||
pub ratio_sd_4y: ComputedFromHeightStdDevExtended<M>,
|
||||
pub ratio_sd_2y: ComputedFromHeightStdDevExtended<M>,
|
||||
pub ratio_sd_1y: ComputedFromHeightStdDevExtended<M>,
|
||||
}
|
||||
|
||||
const VERSION: Version = Version::new(4);
|
||||
|
||||
impl ComputedFromHeightRatioStdDevBands {
|
||||
pub(crate) fn forced_import(
|
||||
db: &Database,
|
||||
name: &str,
|
||||
version: Version,
|
||||
indexes: &indexes::Vecs,
|
||||
) -> Result<Self> {
|
||||
let v = version + VERSION;
|
||||
|
||||
macro_rules! import_sd {
|
||||
($suffix:expr, $period:expr, $days:expr) => {
|
||||
ComputedFromHeightStdDevExtended::forced_import(
|
||||
db,
|
||||
&format!("{name}_{}", $suffix),
|
||||
$period,
|
||||
$days,
|
||||
v,
|
||||
indexes,
|
||||
)?
|
||||
};
|
||||
}
|
||||
|
||||
Ok(Self {
|
||||
ratio_sd: import_sd!("ratio", "", usize::MAX),
|
||||
ratio_sd_1y: import_sd!("ratio", "1y", 365),
|
||||
ratio_sd_2y: import_sd!("ratio", "2y", 2 * 365),
|
||||
ratio_sd_4y: import_sd!("ratio", "4y", 4 * 365),
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn compute(
|
||||
&mut self,
|
||||
blocks: &blocks::Vecs,
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
ratio_source: &impl ReadableVec<Height, StoredF32>,
|
||||
metric_price: &impl ReadableVec<Height, Cents>,
|
||||
) -> Result<()> {
|
||||
for sd in [
|
||||
&mut self.ratio_sd,
|
||||
&mut self.ratio_sd_4y,
|
||||
&mut self.ratio_sd_2y,
|
||||
&mut self.ratio_sd_1y,
|
||||
] {
|
||||
sd.compute_all(blocks, starting_indexes, exit, ratio_source)?;
|
||||
sd.compute_cents_bands(starting_indexes, metric_price, exit)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
@@ -61,12 +61,12 @@ impl Vecs {
|
||||
}
|
||||
|
||||
// DCA by period - average price (derived from stack)
|
||||
let sh = starting_indexes.height.to_usize();
|
||||
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)
|
||||
{
|
||||
let days = days as usize;
|
||||
let start = average_price.cents.height.len().min(starting_indexes.height.to_usize());
|
||||
let start = average_price.cents.height.len().min(starting_height);
|
||||
let stack_data = stack
|
||||
.sats
|
||||
.height
|
||||
@@ -124,7 +124,7 @@ impl Vecs {
|
||||
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_indexes.height.to_usize());
|
||||
let ls_start = stack.sats.height.len().min(starting_height);
|
||||
let lookback_data = lookback_price
|
||||
.cents
|
||||
.height
|
||||
@@ -163,8 +163,8 @@ impl Vecs {
|
||||
let start_days = super::ByDcaClass::<()>::start_days();
|
||||
for (stack, day1) in self.class_stack.iter_mut().zip(start_days) {
|
||||
let mut last_di: Option<Day1> = None;
|
||||
let mut prev_value = if sh > 0 {
|
||||
stack.sats.height.collect_one_at(sh - 1).unwrap_or_default()
|
||||
let mut prev_value = if starting_height > 0 {
|
||||
stack.sats.height.collect_one_at(starting_height - 1).unwrap_or_default()
|
||||
} else {
|
||||
Sats::ZERO
|
||||
};
|
||||
@@ -219,7 +219,7 @@ impl Vecs {
|
||||
.zip(start_days)
|
||||
{
|
||||
let from_usize = from.to_usize();
|
||||
let cls_start = average_price.cents.height.len().min(starting_indexes.height.to_usize());
|
||||
let cls_start = average_price.cents.height.len().min(starting_height);
|
||||
let stack_data = stack
|
||||
.sats
|
||||
.height
|
||||
|
||||
Reference in New Issue
Block a user