global: snapshot

This commit is contained in:
nym21
2026-03-07 11:42:11 +01:00
parent 5a73f1a88e
commit bf07570848
31 changed files with 1151 additions and 1009 deletions
+315 -299
View File
@@ -1127,108 +1127,6 @@ impl _0sdM0M1M1sdM2M2sdM3sdP0P1P1sdP2P2sdP3sdSdSmaZscorePattern {
}
}
/// Pattern struct for repeated tree structure.
pub struct InvestedNegNetNuplSupplyUnrealizedPattern3 {
pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern,
pub invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern,
pub neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub neg_unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub neg_unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_own_market_cap: BpsPercentRatioPattern,
pub nupl: MetricPattern1<StoredF32>,
pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_rel_to_circulating_supply: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern,
}
impl InvestedNegNetNuplSupplyUnrealizedPattern3 {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_loss_rel_to_realized_cap")),
invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_profit_rel_to_realized_cap")),
neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_market_cap")),
neg_unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_gross_pnl")),
neg_unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_own_market_cap")),
net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_market_cap")),
net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_gross_pnl")),
net_unrealized_pnl_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_market_cap")),
nupl: MetricPattern1::new(client.clone(), _m(&acc, "nupl")),
supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_circulating_supply")),
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")),
supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_circulating_supply")),
supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")),
supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_rel_to_circulating_supply")),
unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")),
unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_gross_pnl")),
unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")),
unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")),
unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_gross_pnl")),
unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct GrossMvrvNegNetRealizedSentSoprValuePattern {
pub gross_pnl: CentsUsdPattern,
pub mvrv: MetricPattern1<StoredF32>,
pub neg_realized_loss: MetricPattern1<Dollars>,
pub net_realized_pnl: CumulativeHeightPattern<CentsSigned>,
pub realized_cap: MetricPattern1<Dollars>,
pub realized_cap_cents: MetricPattern1<Cents>,
pub realized_cap_change_1m: MetricPattern1<CentsSigned>,
pub realized_loss: CumulativeHeightPattern<Cents>,
pub realized_price: CentsSatsUsdPattern,
pub realized_price_ratio: BpsRatioPattern,
pub realized_price_ratio_percentiles: RatioPattern,
pub realized_profit: CumulativeHeightPattern<Cents>,
pub sent_in_loss: BaseCumulativePattern,
pub sent_in_profit: BaseCumulativePattern,
pub sopr: _1m1w1y24hPattern<StoredF64>,
pub value_created: MetricPattern1<Cents>,
pub value_created_sum: _1m1w1y24hPattern<Cents>,
pub value_destroyed: MetricPattern1<Cents>,
pub value_destroyed_sum: _1m1w1y24hPattern<Cents>,
}
impl GrossMvrvNegNetRealizedSentSoprValuePattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "realized_gross_pnl")),
mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")),
neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")),
net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")),
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_loss: CumulativeHeightPattern::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_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")),
sent_in_loss: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_loss")),
sent_in_profit: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_profit")),
sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")),
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 Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75Pct80Pct85Pct90Pct95Pattern {
pub pct05: CentsSatsUsdPattern,
@@ -1279,6 +1177,98 @@ impl Pct05Pct10Pct15Pct20Pct25Pct30Pct35Pct40Pct45Pct50Pct55Pct60Pct65Pct70Pct75
}
}
/// Pattern struct for repeated tree structure.
pub struct InvestedNetNuplSupplyUnrealizedPattern3 {
pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern,
pub invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_own_market_cap: BpsPercentRatioPattern,
pub nupl: MetricPattern1<StoredF32>,
pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_rel_to_circulating_supply: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern,
}
impl InvestedNetNuplSupplyUnrealizedPattern3 {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_loss_rel_to_realized_cap")),
invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_profit_rel_to_realized_cap")),
net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_market_cap")),
net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_gross_pnl")),
net_unrealized_pnl_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_own_market_cap")),
nupl: MetricPattern1::new(client.clone(), _m(&acc, "nupl")),
supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_circulating_supply")),
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")),
supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_circulating_supply")),
supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")),
supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_rel_to_circulating_supply")),
unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")),
unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_gross_pnl")),
unrealized_loss_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_own_market_cap")),
unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")),
unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_gross_pnl")),
unrealized_profit_rel_to_own_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_own_market_cap")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct MvrvNegNetRealizedSentSoprValuePattern {
pub mvrv: MetricPattern1<StoredF32>,
pub neg_realized_loss: MetricPattern1<Dollars>,
pub net_realized_pnl: CumulativeHeightPattern<CentsSigned>,
pub realized_cap: MetricPattern1<Dollars>,
pub realized_cap_cents: MetricPattern1<Cents>,
pub realized_cap_change_1m: MetricPattern1<CentsSigned>,
pub realized_loss: CumulativeHeightPattern<Cents>,
pub realized_price: CentsSatsUsdPattern,
pub realized_price_ratio: BpsRatioPattern,
pub realized_profit: CumulativeHeightPattern<Cents>,
pub sent_in_loss: BaseCumulativePattern,
pub sent_in_profit: BaseCumulativePattern,
pub sopr: _1m1w1y24hPattern<StoredF64>,
pub value_created: MetricPattern1<Cents>,
pub value_created_sum: _1m1w1y24hPattern<Cents>,
pub value_destroyed: MetricPattern1<Cents>,
pub value_destroyed_sum: _1m1w1y24hPattern<Cents>,
}
impl MvrvNegNetRealizedSentSoprValuePattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
mvrv: MetricPattern1::new(client.clone(), _m(&acc, "mvrv")),
neg_realized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_realized_loss")),
net_realized_pnl: CumulativeHeightPattern::new(client.clone(), _m(&acc, "net_realized_pnl")),
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_loss: CumulativeHeightPattern::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_profit: CumulativeHeightPattern::new(client.clone(), _m(&acc, "realized_profit")),
sent_in_loss: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_loss")),
sent_in_profit: BaseCumulativePattern::new(client.clone(), _m(&acc, "sent_in_profit")),
sopr: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "sopr")),
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 BpsRatioPattern2 {
pub bps: MetricPattern1<BasisPoints32>,
@@ -1479,42 +1469,6 @@ impl _10y1m1w1y2y3m3y4y5y6m6y8yPattern3 {
}
}
/// Pattern struct for repeated tree structure.
pub struct InvestedNegNetNuplSupplyUnrealizedPattern {
pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern,
pub invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern,
pub neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern,
pub nupl: MetricPattern1<StoredF32>,
pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_rel_to_circulating_supply: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern,
}
impl InvestedNegNetNuplSupplyUnrealizedPattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_loss_rel_to_realized_cap")),
invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_profit_rel_to_realized_cap")),
neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "neg_unrealized_loss_rel_to_market_cap")),
net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_market_cap")),
nupl: MetricPattern1::new(client.clone(), _m(&acc, "nupl")),
supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_circulating_supply")),
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")),
supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_circulating_supply")),
supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")),
supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_rel_to_circulating_supply")),
unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")),
unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct _1m1w1y24hBaseBpsCumulativeHeightPercentRatioSumPattern {
pub _1m: BpsPercentRatioPattern,
@@ -1617,6 +1571,40 @@ impl AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern {
}
}
/// Pattern struct for repeated tree structure.
pub struct InvestedNetNuplSupplyUnrealizedPattern {
pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern,
pub invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern,
pub nupl: MetricPattern1<StoredF32>,
pub supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern,
pub supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern,
pub supply_rel_to_circulating_supply: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern,
}
impl InvestedNetNuplSupplyUnrealizedPattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_loss_rel_to_realized_cap")),
invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "invested_capital_in_profit_rel_to_realized_cap")),
net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl_rel_to_market_cap")),
nupl: MetricPattern1::new(client.clone(), _m(&acc, "nupl")),
supply_in_loss_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_circulating_supply")),
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_loss_rel_to_own_supply")),
supply_in_profit_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_circulating_supply")),
supply_in_profit_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_in_profit_rel_to_own_supply")),
supply_rel_to_circulating_supply: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "supply_rel_to_circulating_supply")),
unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_loss_rel_to_market_cap")),
unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), _m(&acc, "unrealized_profit_rel_to_market_cap")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct AverageGainsLossesRsiStochPattern {
pub average_gain: MetricPattern1<StoredF32>,
@@ -1709,6 +1697,36 @@ impl AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2 {
}
}
/// Pattern struct for repeated tree structure.
pub struct AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern {
pub average: _1m1w1y24hPattern<BasisPoints16>,
pub height: MetricPattern18<BasisPoints16>,
pub max: _1m1w1y24hPattern<BasisPoints16>,
pub median: _1m1w1y24hPattern<BasisPoints16>,
pub min: _1m1w1y24hPattern<BasisPoints16>,
pub pct10: _1m1w1y24hPattern<BasisPoints16>,
pub pct25: _1m1w1y24hPattern<BasisPoints16>,
pub pct75: _1m1w1y24hPattern<BasisPoints16>,
pub pct90: _1m1w1y24hPattern<BasisPoints16>,
}
impl AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
average: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "average")),
height: MetricPattern18::new(client.clone(), acc.clone()),
max: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "max")),
median: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "median")),
min: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "min")),
pct10: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p10")),
pct25: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p25")),
pct75: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p75")),
pct90: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p90")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern {
pub average: _1m1w1y24hPattern<StoredU64>,
@@ -1739,36 +1757,6 @@ impl AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern {
}
}
/// Pattern struct for repeated tree structure.
pub struct AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<T> {
pub average: _1m1w1y24hPattern<T>,
pub height: MetricPattern18<T>,
pub max: _1m1w1y24hPattern<T>,
pub median: _1m1w1y24hPattern<T>,
pub min: _1m1w1y24hPattern<T>,
pub pct10: _1m1w1y24hPattern<T>,
pub pct25: _1m1w1y24hPattern<T>,
pub pct75: _1m1w1y24hPattern<T>,
pub pct90: _1m1w1y24hPattern<T>,
}
impl<T: DeserializeOwned> AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<T> {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
average: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "average")),
height: MetricPattern18::new(client.clone(), acc.clone()),
max: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "max")),
median: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "median")),
min: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "min")),
pct10: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p10")),
pct25: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p25")),
pct75: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p75")),
pct90: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "p90")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct _1m1w1y24hBtcCentsSatsUsdPattern {
pub _1m: BtcCentsSatsUsdPattern,
@@ -1884,8 +1872,8 @@ pub struct ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern {
pub activity: CoinblocksCoindaysSentPattern,
pub cost_basis: MaxMinPattern,
pub outputs: UtxoPattern,
pub realized: GrossMvrvNegNetRealizedSentSoprValuePattern,
pub relative: InvestedNegNetNuplSupplyUnrealizedPattern,
pub realized: MvrvNegNetRealizedSentSoprValuePattern,
pub relative: InvestedNetNuplSupplyUnrealizedPattern,
pub supply: ChangeHalvedTotalPattern,
pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern,
}
@@ -1897,40 +1885,14 @@ impl ActivityCostOutputsRealizedRelativeSupplyUnrealizedPattern {
activity: CoinblocksCoindaysSentPattern::new(client.clone(), acc.clone()),
cost_basis: MaxMinPattern::new(client.clone(), _m(&acc, "cost_basis")),
outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")),
realized: GrossMvrvNegNetRealizedSentSoprValuePattern::new(client.clone(), acc.clone()),
relative: InvestedNegNetNuplSupplyUnrealizedPattern::new(client.clone(), acc.clone()),
realized: MvrvNegNetRealizedSentSoprValuePattern::new(client.clone(), acc.clone()),
relative: InvestedNetNuplSupplyUnrealizedPattern::new(client.clone(), acc.clone()),
supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")),
unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), acc.clone()),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct GrossNegNetSupplyUnrealizedPattern {
pub gross_pnl: CentsUsdPattern,
pub neg_unrealized_loss: MetricPattern1<Dollars>,
pub net_unrealized_pnl: CentsUsdPattern,
pub supply_in_loss: BtcCentsSatsUsdPattern,
pub supply_in_profit: BtcCentsSatsUsdPattern,
pub unrealized_loss: CentsUsdPattern,
pub unrealized_profit: CentsUsdPattern,
}
impl GrossNegNetSupplyUnrealizedPattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
gross_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_gross_pnl")),
neg_unrealized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")),
net_unrealized_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")),
supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")),
supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")),
unrealized_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")),
unrealized_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct MvrvRealizedPattern {
pub mvrv: MetricPattern1<StoredF32>,
@@ -1957,38 +1919,14 @@ impl MvrvRealizedPattern {
}
}
/// Pattern struct for repeated tree structure.
pub struct _1m1w1y24hBaseCumulativePattern {
pub _1m: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
pub _1w: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
pub _1y: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
pub _24h: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
pub base: BtcCentsSatsUsdPattern,
pub cumulative: BtcCentsSatsUsdPattern,
}
impl _1m1w1y24hBaseCumulativePattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
_1m: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), _m(&acc, "1m")),
_1w: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), _m(&acc, "1w")),
_1y: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), _m(&acc, "1y")),
_24h: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), _m(&acc, "24h")),
base: BtcCentsSatsUsdPattern::new(client.clone(), acc.clone()),
cumulative: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "cumulative")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 {
pub activity: SentPattern,
pub outputs: UtxoPattern,
pub realized: GrossMvrvNegNetRealizedSentSoprValuePattern,
pub realized: MvrvNegNetRealizedSentSoprValuePattern,
pub relative: SupplyPattern3,
pub supply: ChangeHalvedTotalPattern,
pub unrealized: GrossNegNetSupplyUnrealizedPattern,
pub unrealized: NegNetSupplyUnrealizedPattern,
}
impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 {
@@ -1997,10 +1935,10 @@ impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern2 {
Self {
activity: SentPattern::new(client.clone(), _m(&acc, "sent")),
outputs: UtxoPattern::new(client.clone(), _m(&acc, "utxo_count")),
realized: GrossMvrvNegNetRealizedSentSoprValuePattern::new(client.clone(), acc.clone()),
realized: MvrvNegNetRealizedSentSoprValuePattern::new(client.clone(), acc.clone()),
relative: SupplyPattern3::new(client.clone(), _m(&acc, "supply")),
supply: ChangeHalvedTotalPattern::new(client.clone(), _m(&acc, "supply")),
unrealized: GrossNegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()),
unrealized: NegNetSupplyUnrealizedPattern::new(client.clone(), acc.clone()),
}
}
}
@@ -2030,25 +1968,25 @@ impl ActivityOutputsRealizedRelativeSupplyUnrealizedPattern {
}
/// Pattern struct for repeated tree structure.
pub struct BalanceBothReactivatedReceivingSendingPattern {
pub balance_decreased: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<StoredU32>,
pub balance_increased: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<StoredU32>,
pub both: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<StoredU32>,
pub reactivated: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<StoredU32>,
pub receiving: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<StoredU32>,
pub sending: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<StoredU32>,
pub struct NegNetSupplyUnrealizedPattern {
pub neg_unrealized_loss: MetricPattern1<Dollars>,
pub net_unrealized_pnl: CentsUsdPattern,
pub supply_in_loss: BtcCentsSatsUsdPattern,
pub supply_in_profit: BtcCentsSatsUsdPattern,
pub unrealized_loss: CentsUsdPattern,
pub unrealized_profit: CentsUsdPattern,
}
impl BalanceBothReactivatedReceivingSendingPattern {
impl NegNetSupplyUnrealizedPattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
balance_decreased: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), _m(&acc, "balance_decreased")),
balance_increased: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), _m(&acc, "balance_increased")),
both: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), _m(&acc, "both")),
reactivated: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), _m(&acc, "reactivated")),
receiving: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), _m(&acc, "receiving")),
sending: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), _m(&acc, "sending")),
neg_unrealized_loss: MetricPattern1::new(client.clone(), _m(&acc, "neg_unrealized_loss")),
net_unrealized_pnl: CentsUsdPattern::new(client.clone(), _m(&acc, "net_unrealized_pnl")),
supply_in_loss: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_loss")),
supply_in_profit: BtcCentsSatsUsdPattern::new(client.clone(), _m(&acc, "supply_in_profit")),
unrealized_loss: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_loss")),
unrealized_profit: CentsUsdPattern::new(client.clone(), _m(&acc, "unrealized_profit")),
}
}
}
@@ -2119,6 +2057,28 @@ impl SupplyPattern3 {
}
}
/// Pattern struct for repeated tree structure.
pub struct _1m1w1y24hHeightPattern<T> {
pub _1m: MetricPattern1<T>,
pub _1w: MetricPattern1<T>,
pub _1y: MetricPattern1<T>,
pub _24h: MetricPattern1<T>,
pub height: MetricPattern18<T>,
}
impl<T: DeserializeOwned> _1m1w1y24hHeightPattern<T> {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
_1m: MetricPattern1::new(client.clone(), _m(&acc, "average_1m")),
_1w: MetricPattern1::new(client.clone(), _m(&acc, "average_1w")),
_1y: MetricPattern1::new(client.clone(), _m(&acc, "average_1y")),
_24h: MetricPattern1::new(client.clone(), _m(&acc, "average_24h")),
height: MetricPattern18::new(client.clone(), acc.clone()),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct _1m1w1y24hPattern6 {
pub _1m: BaseBtcCentsSatsUsdPattern,
@@ -2179,6 +2139,26 @@ impl _1m1w1y24hPattern5 {
}
}
/// Pattern struct for repeated tree structure.
pub struct BothReactivatedReceivingSendingPattern {
pub both: _1m1w1y24hHeightPattern<StoredU32>,
pub reactivated: _1m1w1y24hHeightPattern<StoredU32>,
pub receiving: _1m1w1y24hHeightPattern<StoredU32>,
pub sending: _1m1w1y24hHeightPattern<StoredU32>,
}
impl BothReactivatedReceivingSendingPattern {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
both: _1m1w1y24hHeightPattern::new(client.clone(), _m(&acc, "both")),
reactivated: _1m1w1y24hHeightPattern::new(client.clone(), _m(&acc, "reactivated")),
receiving: _1m1w1y24hHeightPattern::new(client.clone(), _m(&acc, "receiving")),
sending: _1m1w1y24hHeightPattern::new(client.clone(), _m(&acc, "sending")),
}
}
}
/// Pattern struct for repeated tree structure.
pub struct BtcCentsSatsUsdPattern {
pub btc: MetricPattern1<Bitcoin>,
@@ -2298,13 +2278,13 @@ impl BaseCumulativeSumPattern {
}
/// Pattern struct for repeated tree structure.
pub struct BpsPercentRatioPattern2 {
pub bps: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<BasisPoints16>,
pub struct BpsPercentRatioPattern3 {
pub bps: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern,
pub percent: MetricPattern1<StoredF32>,
pub ratio: MetricPattern1<StoredF32>,
}
impl BpsPercentRatioPattern2 {
impl BpsPercentRatioPattern3 {
/// Create a new pattern node with accumulated metric name.
pub fn new(client: Arc<BrkClientBase>, acc: String) -> Self {
Self {
@@ -2732,11 +2712,11 @@ pub struct MetricsTree_Blocks {
pub total_size: MetricPattern18<StoredU64>,
pub weight: MetricsTree_Blocks_Weight,
pub count: MetricsTree_Blocks_Count,
pub interval: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern<Timestamp>,
pub interval: _1m1w1y24hHeightPattern<Timestamp>,
pub halving: MetricsTree_Blocks_Halving,
pub vbytes: AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern,
pub size: MetricsTree_Blocks_Size,
pub fullness: BpsPercentRatioPattern2,
pub fullness: MetricsTree_Blocks_Fullness,
}
impl MetricsTree_Blocks {
@@ -2748,11 +2728,11 @@ impl MetricsTree_Blocks {
total_size: MetricPattern18::new(client.clone(), "total_size".to_string()),
weight: MetricsTree_Blocks_Weight::new(client.clone(), format!("{base_path}_weight")),
count: MetricsTree_Blocks_Count::new(client.clone(), format!("{base_path}_count")),
interval: AverageHeightMaxMedianMinPct10Pct25Pct75Pct90Pattern::new(client.clone(), "block_interval".to_string()),
interval: _1m1w1y24hHeightPattern::new(client.clone(), "block_interval".to_string()),
halving: MetricsTree_Blocks_Halving::new(client.clone(), format!("{base_path}_halving")),
vbytes: AverageCumulativeHeightMaxMedianMinPct10Pct25Pct75Pct90SumPattern::new(client.clone(), "block_vbytes".to_string()),
size: MetricsTree_Blocks_Size::new(client.clone(), format!("{base_path}_size")),
fullness: BpsPercentRatioPattern2::new(client.clone(), "block_fullness".to_string()),
fullness: MetricsTree_Blocks_Fullness::new(client.clone(), format!("{base_path}_fullness")),
}
}
}
@@ -2981,6 +2961,23 @@ impl MetricsTree_Blocks_Size {
}
}
/// Metrics tree node.
pub struct MetricsTree_Blocks_Fullness {
pub bps: _1m1w1y24hHeightPattern<BasisPoints16>,
pub ratio: MetricPattern1<StoredF32>,
pub percent: MetricPattern1<StoredF32>,
}
impl MetricsTree_Blocks_Fullness {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
bps: _1m1w1y24hHeightPattern::new(client.clone(), "block_fullness_bps".to_string()),
ratio: MetricPattern1::new(client.clone(), "block_fullness_ratio".to_string()),
percent: MetricPattern1::new(client.clone(), "block_fullness".to_string()),
}
}
}
/// Metrics tree node.
pub struct MetricsTree_Transactions {
pub first_txindex: MetricPattern18<TxIndex>,
@@ -3319,13 +3316,13 @@ impl MetricsTree_Scripts_Count {
/// Metrics tree node.
pub struct MetricsTree_Scripts_Value {
pub opreturn: _1m1w1y24hBaseCumulativePattern,
pub opreturn: BaseCumulativePattern,
}
impl MetricsTree_Scripts_Value {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
opreturn: _1m1w1y24hBaseCumulativePattern::new(client.clone(), "opreturn_value".to_string()),
opreturn: BaseCumulativePattern::new(client.clone(), "opreturn_value".to_string()),
}
}
}
@@ -3362,9 +3359,9 @@ impl MetricsTree_Mining {
/// Metrics tree node.
pub struct MetricsTree_Mining_Rewards {
pub coinbase: _1m1w1y24hBaseCumulativePattern,
pub subsidy: _1m1w1y24hBaseCumulativePattern,
pub fees: _1m1w1y24hBaseCumulativePattern,
pub coinbase: BaseCumulativeSumPattern,
pub subsidy: BaseCumulativePattern,
pub fees: MetricsTree_Mining_Rewards_Fees,
pub unclaimed_rewards: BaseCumulativeSumPattern,
pub fee_dominance: BpsPercentRatioPattern,
pub fee_dominance_rolling: _1m1w1y24hPattern2,
@@ -3376,9 +3373,9 @@ pub struct MetricsTree_Mining_Rewards {
impl MetricsTree_Mining_Rewards {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
coinbase: _1m1w1y24hBaseCumulativePattern::new(client.clone(), "coinbase".to_string()),
subsidy: _1m1w1y24hBaseCumulativePattern::new(client.clone(), "subsidy".to_string()),
fees: _1m1w1y24hBaseCumulativePattern::new(client.clone(), "fees".to_string()),
coinbase: BaseCumulativeSumPattern::new(client.clone(), "coinbase".to_string()),
subsidy: BaseCumulativePattern::new(client.clone(), "subsidy".to_string()),
fees: MetricsTree_Mining_Rewards_Fees::new(client.clone(), format!("{base_path}_fees")),
unclaimed_rewards: BaseCumulativeSumPattern::new(client.clone(), "unclaimed_rewards".to_string()),
fee_dominance: BpsPercentRatioPattern::new(client.clone(), "fee_dominance".to_string()),
fee_dominance_rolling: _1m1w1y24hPattern2::new(client.clone(), "fee_dominance".to_string()),
@@ -3389,6 +3386,29 @@ impl MetricsTree_Mining_Rewards {
}
}
/// Metrics tree node.
pub struct MetricsTree_Mining_Rewards_Fees {
pub base: BtcCentsSatsUsdPattern,
pub cumulative: BtcCentsSatsUsdPattern,
pub _24h: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
pub _1w: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
pub _1m: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
pub _1y: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2,
}
impl MetricsTree_Mining_Rewards_Fees {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
base: BtcCentsSatsUsdPattern::new(client.clone(), "fees".to_string()),
cumulative: BtcCentsSatsUsdPattern::new(client.clone(), "fees_cumulative".to_string()),
_24h: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_24h".to_string()),
_1w: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_1w".to_string()),
_1m: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_1m".to_string()),
_1y: AverageMaxMedianMinPct10Pct25Pct75Pct90SumPattern2::new(client.clone(), "fees_1y".to_string()),
}
}
}
/// Metrics tree node.
pub struct MetricsTree_Mining_Hashrate {
pub hash_rate: MetricPattern1<StoredF64>,
@@ -5552,7 +5572,6 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative {
pub unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern,
pub neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern,
pub nupl: MetricPattern1<StoredF32>,
pub invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern,
pub invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern,
@@ -5560,7 +5579,6 @@ pub struct MetricsTree_Distribution_UtxoCohorts_All_Relative {
pub supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern,
pub unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub neg_unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern,
pub net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern,
}
@@ -5570,7 +5588,6 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Relative {
unrealized_profit_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_market_cap".to_string()),
unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_market_cap".to_string()),
net_unrealized_pnl_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_market_cap".to_string()),
neg_unrealized_loss_rel_to_market_cap: BpsPercentRatioPattern::new(client.clone(), "neg_unrealized_loss_rel_to_market_cap".to_string()),
nupl: MetricPattern1::new(client.clone(), "nupl".to_string()),
invested_capital_in_profit_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "invested_capital_in_profit_rel_to_realized_cap".to_string()),
invested_capital_in_loss_rel_to_realized_cap: BpsPercentRatioPattern::new(client.clone(), "invested_capital_in_loss_rel_to_realized_cap".to_string()),
@@ -5578,7 +5595,6 @@ impl MetricsTree_Distribution_UtxoCohorts_All_Relative {
supply_in_loss_rel_to_own_supply: BpsPercentRatioPattern::new(client.clone(), "supply_in_loss_rel_to_own_supply".to_string()),
unrealized_profit_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_profit_rel_to_own_gross_pnl".to_string()),
unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "unrealized_loss_rel_to_own_gross_pnl".to_string()),
neg_unrealized_loss_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "neg_unrealized_loss_rel_to_own_gross_pnl".to_string()),
net_unrealized_pnl_rel_to_own_gross_pnl: BpsPercentRatioPattern::new(client.clone(), "net_unrealized_pnl_rel_to_own_gross_pnl".to_string()),
}
}
@@ -5592,7 +5608,7 @@ pub struct MetricsTree_Distribution_UtxoCohorts_Sth {
pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern,
pub cost_basis: InvestedMaxMinPercentilesPattern,
pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern,
pub relative: InvestedNegNetNuplSupplyUnrealizedPattern3,
pub relative: InvestedNetNuplSupplyUnrealizedPattern3,
pub dormancy: MetricPattern1<StoredF32>,
pub velocity: MetricPattern1<StoredF32>,
pub adjusted_value_created: MetricPattern1<Cents>,
@@ -5612,7 +5628,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Sth {
realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "sth".to_string()),
cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "sth".to_string()),
unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "sth".to_string()),
relative: InvestedNegNetNuplSupplyUnrealizedPattern3::new(client.clone(), "sth".to_string()),
relative: InvestedNetNuplSupplyUnrealizedPattern3::new(client.clone(), "sth".to_string()),
dormancy: MetricPattern1::new(client.clone(), "sth_dormancy".to_string()),
velocity: MetricPattern1::new(client.clone(), "sth_velocity".to_string()),
adjusted_value_created: MetricPattern1::new(client.clone(), "sth_adjusted_value_created".to_string()),
@@ -5633,7 +5649,7 @@ pub struct MetricsTree_Distribution_UtxoCohorts_Lth {
pub realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern,
pub cost_basis: InvestedMaxMinPercentilesPattern,
pub unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern,
pub relative: InvestedNegNetNuplSupplyUnrealizedPattern3,
pub relative: InvestedNetNuplSupplyUnrealizedPattern3,
pub dormancy: MetricPattern1<StoredF32>,
pub velocity: MetricPattern1<StoredF32>,
}
@@ -5647,7 +5663,7 @@ impl MetricsTree_Distribution_UtxoCohorts_Lth {
realized: CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSoprUpperValuePattern::new(client.clone(), "lth".to_string()),
cost_basis: InvestedMaxMinPercentilesPattern::new(client.clone(), "lth".to_string()),
unrealized: GreedGrossInvestedInvestorNegNetPainSupplyUnrealizedPattern::new(client.clone(), "lth".to_string()),
relative: InvestedNegNetNuplSupplyUnrealizedPattern3::new(client.clone(), "lth".to_string()),
relative: InvestedNetNuplSupplyUnrealizedPattern3::new(client.clone(), "lth".to_string()),
dormancy: MetricPattern1::new(client.clone(), "lth_dormancy".to_string()),
velocity: MetricPattern1::new(client.clone(), "lth_velocity".to_string()),
}
@@ -6151,29 +6167,29 @@ impl MetricsTree_Distribution_AddressCohorts_LtAmount {
/// Metrics tree node.
pub struct MetricsTree_Distribution_AddressActivity {
pub all: BalanceBothReactivatedReceivingSendingPattern,
pub p2pk65: BalanceBothReactivatedReceivingSendingPattern,
pub p2pk33: BalanceBothReactivatedReceivingSendingPattern,
pub p2pkh: BalanceBothReactivatedReceivingSendingPattern,
pub p2sh: BalanceBothReactivatedReceivingSendingPattern,
pub p2wpkh: BalanceBothReactivatedReceivingSendingPattern,
pub p2wsh: BalanceBothReactivatedReceivingSendingPattern,
pub p2tr: BalanceBothReactivatedReceivingSendingPattern,
pub p2a: BalanceBothReactivatedReceivingSendingPattern,
pub all: BothReactivatedReceivingSendingPattern,
pub p2pk65: BothReactivatedReceivingSendingPattern,
pub p2pk33: BothReactivatedReceivingSendingPattern,
pub p2pkh: BothReactivatedReceivingSendingPattern,
pub p2sh: BothReactivatedReceivingSendingPattern,
pub p2wpkh: BothReactivatedReceivingSendingPattern,
pub p2wsh: BothReactivatedReceivingSendingPattern,
pub p2tr: BothReactivatedReceivingSendingPattern,
pub p2a: BothReactivatedReceivingSendingPattern,
}
impl MetricsTree_Distribution_AddressActivity {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
all: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "address_activity".to_string()),
p2pk65: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk65_address_activity".to_string()),
p2pk33: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk33_address_activity".to_string()),
p2pkh: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2pkh_address_activity".to_string()),
p2sh: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2sh_address_activity".to_string()),
p2wpkh: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2wpkh_address_activity".to_string()),
p2wsh: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2wsh_address_activity".to_string()),
p2tr: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2tr_address_activity".to_string()),
p2a: BalanceBothReactivatedReceivingSendingPattern::new(client.clone(), "p2a_address_activity".to_string()),
all: BothReactivatedReceivingSendingPattern::new(client.clone(), "address_activity".to_string()),
p2pk65: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk65_address_activity".to_string()),
p2pk33: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pk33_address_activity".to_string()),
p2pkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2pkh_address_activity".to_string()),
p2sh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2sh_address_activity".to_string()),
p2wpkh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wpkh_address_activity".to_string()),
p2wsh: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2wsh_address_activity".to_string()),
p2tr: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2tr_address_activity".to_string()),
p2a: BothReactivatedReceivingSendingPattern::new(client.clone(), "p2a_address_activity".to_string()),
}
}
}
@@ -6238,29 +6254,29 @@ impl MetricsTree_Distribution_NewAddrCount {
/// Metrics tree node.
pub struct MetricsTree_Distribution_GrowthRate {
pub all: BpsPercentRatioPattern2,
pub p2pk65: BpsPercentRatioPattern2,
pub p2pk33: BpsPercentRatioPattern2,
pub p2pkh: BpsPercentRatioPattern2,
pub p2sh: BpsPercentRatioPattern2,
pub p2wpkh: BpsPercentRatioPattern2,
pub p2wsh: BpsPercentRatioPattern2,
pub p2tr: BpsPercentRatioPattern2,
pub p2a: BpsPercentRatioPattern2,
pub all: BpsPercentRatioPattern3,
pub p2pk65: BpsPercentRatioPattern3,
pub p2pk33: BpsPercentRatioPattern3,
pub p2pkh: BpsPercentRatioPattern3,
pub p2sh: BpsPercentRatioPattern3,
pub p2wpkh: BpsPercentRatioPattern3,
pub p2wsh: BpsPercentRatioPattern3,
pub p2tr: BpsPercentRatioPattern3,
pub p2a: BpsPercentRatioPattern3,
}
impl MetricsTree_Distribution_GrowthRate {
pub fn new(client: Arc<BrkClientBase>, base_path: String) -> Self {
Self {
all: BpsPercentRatioPattern2::new(client.clone(), "growth_rate".to_string()),
p2pk65: BpsPercentRatioPattern2::new(client.clone(), "p2pk65_growth_rate".to_string()),
p2pk33: BpsPercentRatioPattern2::new(client.clone(), "p2pk33_growth_rate".to_string()),
p2pkh: BpsPercentRatioPattern2::new(client.clone(), "p2pkh_growth_rate".to_string()),
p2sh: BpsPercentRatioPattern2::new(client.clone(), "p2sh_growth_rate".to_string()),
p2wpkh: BpsPercentRatioPattern2::new(client.clone(), "p2wpkh_growth_rate".to_string()),
p2wsh: BpsPercentRatioPattern2::new(client.clone(), "p2wsh_growth_rate".to_string()),
p2tr: BpsPercentRatioPattern2::new(client.clone(), "p2tr_growth_rate".to_string()),
p2a: BpsPercentRatioPattern2::new(client.clone(), "p2a_growth_rate".to_string()),
all: BpsPercentRatioPattern3::new(client.clone(), "growth_rate".to_string()),
p2pk65: BpsPercentRatioPattern3::new(client.clone(), "p2pk65_growth_rate".to_string()),
p2pk33: BpsPercentRatioPattern3::new(client.clone(), "p2pk33_growth_rate".to_string()),
p2pkh: BpsPercentRatioPattern3::new(client.clone(), "p2pkh_growth_rate".to_string()),
p2sh: BpsPercentRatioPattern3::new(client.clone(), "p2sh_growth_rate".to_string()),
p2wpkh: BpsPercentRatioPattern3::new(client.clone(), "p2wpkh_growth_rate".to_string()),
p2wsh: BpsPercentRatioPattern3::new(client.clone(), "p2wsh_growth_rate".to_string()),
p2tr: BpsPercentRatioPattern3::new(client.clone(), "p2tr_growth_rate".to_string()),
p2a: BpsPercentRatioPattern3::new(client.clone(), "p2a_growth_rate".to_string()),
}
}
}
@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::ComputedFromHeightDistribution};
use crate::{indexes, internal::ComputedFromHeightRollingAverage};
impl Vecs {
pub(crate) fn forced_import(
@@ -11,8 +11,12 @@ impl Vecs {
version: Version,
indexes: &indexes::Vecs,
) -> Result<Self> {
let interval =
ComputedFromHeightDistribution::forced_import(db, "block_interval", version, indexes)?;
let interval = ComputedFromHeightRollingAverage::forced_import(
db,
"block_interval",
version,
indexes,
)?;
Ok(Self(interval))
}
@@ -4,9 +4,9 @@ use brk_traversable::Traversable;
use brk_types::Timestamp;
use vecdb::{Rw, StorageMode};
use crate::internal::ComputedFromHeightDistribution;
use crate::internal::ComputedFromHeightRollingAverage;
#[derive(Deref, DerefMut, Traversable)]
pub struct Vecs<M: StorageMode = Rw>(
#[traversable(flatten)] pub ComputedFromHeightDistribution<Timestamp, M>,
#[traversable(flatten)] pub ComputedFromHeightRollingAverage<Timestamp, M>,
);
@@ -5,7 +5,7 @@ use vecdb::Database;
use super::Vecs;
use crate::{
indexes,
internal::{ComputedHeightDerivedFull, PercentFromHeightDistribution},
internal::{ComputedHeightDerivedFull, PercentFromHeightRollingAverage},
};
impl Vecs {
@@ -17,8 +17,12 @@ impl Vecs {
let weight =
ComputedHeightDerivedFull::forced_import(db, "block_weight", version, indexes)?;
let fullness =
PercentFromHeightDistribution::forced_import(db, "block_fullness", version, indexes)?;
let fullness = PercentFromHeightRollingAverage::forced_import(
db,
"block_fullness",
version,
indexes,
)?;
Ok(Self { weight, fullness })
}
@@ -2,10 +2,10 @@ use brk_traversable::Traversable;
use brk_types::{BasisPoints16, Weight};
use vecdb::{Rw, StorageMode};
use crate::internal::{ComputedHeightDerivedFull, PercentFromHeightDistribution};
use crate::internal::{ComputedHeightDerivedFull, PercentFromHeightRollingAverage};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub weight: ComputedHeightDerivedFull<Weight, M>,
pub fullness: PercentFromHeightDistribution<BasisPoints16, M>,
pub fullness: PercentFromHeightRollingAverage<BasisPoints16, M>,
}
@@ -8,11 +8,6 @@
//! | `sending` | Unique addresses that sent this block |
//! | `reactivated` | Addresses that were empty and now have funds |
//! | `both` | Addresses that both sent AND received same block |
//! | `balance_increased` | Receive-only addresses (balance definitely increased) |
//! | `balance_decreased` | Send-only addresses (balance definitely decreased) |
//!
//! Note: `balance_increased` and `balance_decreased` exclude "both" addresses
//! since their net balance change requires more complex tracking.
use brk_cohort::ByAddressType;
use brk_error::Result;
@@ -24,14 +19,10 @@ use vecdb::{AnyStoredVec, AnyVec, Database, Exit, Rw, StorageMode, WritableVec};
use crate::{
indexes,
internal::{ComputedFromHeightDistribution, WindowStarts},
internal::{ComputedFromHeightRollingAverage, WindowStarts},
};
/// Per-block activity counts - reset each block.
///
/// Note: `balance_increased` and `balance_decreased` are derived:
/// - `balance_increased = receiving - both` (receive-only addresses)
/// - `balance_decreased = sending - both` (send-only addresses)
#[derive(Debug, Default, Clone)]
pub struct BlockActivityCounts {
pub reactivated: u32,
@@ -74,12 +65,10 @@ impl AddressTypeToActivityCounts {
/// Activity count vectors for a single category (e.g., one address type or "all").
#[derive(Traversable)]
pub struct ActivityCountVecs<M: StorageMode = Rw> {
pub reactivated: ComputedFromHeightDistribution<StoredU32, M>,
pub sending: ComputedFromHeightDistribution<StoredU32, M>,
pub receiving: ComputedFromHeightDistribution<StoredU32, M>,
pub balance_increased: ComputedFromHeightDistribution<StoredU32, M>,
pub balance_decreased: ComputedFromHeightDistribution<StoredU32, M>,
pub both: ComputedFromHeightDistribution<StoredU32, M>,
pub reactivated: ComputedFromHeightRollingAverage<StoredU32, M>,
pub sending: ComputedFromHeightRollingAverage<StoredU32, M>,
pub receiving: ComputedFromHeightRollingAverage<StoredU32, M>,
pub both: ComputedFromHeightRollingAverage<StoredU32, M>,
}
impl ActivityCountVecs {
@@ -90,37 +79,25 @@ impl ActivityCountVecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
reactivated: ComputedFromHeightDistribution::forced_import(
reactivated: ComputedFromHeightRollingAverage::forced_import(
db,
&format!("{name}_reactivated"),
version,
indexes,
)?,
sending: ComputedFromHeightDistribution::forced_import(
sending: ComputedFromHeightRollingAverage::forced_import(
db,
&format!("{name}_sending"),
version,
indexes,
)?,
receiving: ComputedFromHeightDistribution::forced_import(
receiving: ComputedFromHeightRollingAverage::forced_import(
db,
&format!("{name}_receiving"),
version,
indexes,
)?,
balance_increased: ComputedFromHeightDistribution::forced_import(
db,
&format!("{name}_balance_increased"),
version,
indexes,
)?,
balance_decreased: ComputedFromHeightDistribution::forced_import(
db,
&format!("{name}_balance_decreased"),
version,
indexes,
)?,
both: ComputedFromHeightDistribution::forced_import(
both: ComputedFromHeightRollingAverage::forced_import(
db,
&format!("{name}_both"),
version,
@@ -135,8 +112,6 @@ impl ActivityCountVecs {
.len()
.min(self.sending.height.len())
.min(self.receiving.height.len())
.min(self.balance_increased.height.len())
.min(self.balance_decreased.height.len())
.min(self.both.height.len())
}
@@ -147,8 +122,6 @@ impl ActivityCountVecs {
&mut self.reactivated.height as &mut dyn AnyStoredVec,
&mut self.sending.height as &mut dyn AnyStoredVec,
&mut self.receiving.height as &mut dyn AnyStoredVec,
&mut self.balance_increased.height as &mut dyn AnyStoredVec,
&mut self.balance_decreased.height as &mut dyn AnyStoredVec,
&mut self.both.height as &mut dyn AnyStoredVec,
]
.into_par_iter()
@@ -158,8 +131,6 @@ impl ActivityCountVecs {
self.reactivated.height.reset()?;
self.sending.height.reset()?;
self.receiving.height.reset()?;
self.balance_increased.height.reset()?;
self.balance_decreased.height.reset()?;
self.both.height.reset()?;
Ok(())
}
@@ -178,14 +149,6 @@ impl ActivityCountVecs {
self.receiving
.height
.truncate_push(height, counts.receiving.into())?;
// Derived: balance_increased = receiving - both (receive-only addresses)
self.balance_increased
.height
.truncate_push(height, (counts.receiving - counts.both).into())?;
// Derived: balance_decreased = sending - both (send-only addresses)
self.balance_decreased
.height
.truncate_push(height, (counts.sending - counts.both).into())?;
self.both.height.truncate_push(height, counts.both.into())?;
Ok(())
}
@@ -199,10 +162,6 @@ impl ActivityCountVecs {
self.reactivated.compute_rest(max_from, windows, exit)?;
self.sending.compute_rest(max_from, windows, exit)?;
self.receiving.compute_rest(max_from, windows, exit)?;
self.balance_increased
.compute_rest(max_from, windows, exit)?;
self.balance_decreased
.compute_rest(max_from, windows, exit)?;
self.both.compute_rest(max_from, windows, exit)?;
Ok(())
}
@@ -254,8 +213,6 @@ impl AddressTypeToActivityCountVecs {
vecs.push(&mut type_vecs.reactivated.height);
vecs.push(&mut type_vecs.sending.height);
vecs.push(&mut type_vecs.receiving.height);
vecs.push(&mut type_vecs.balance_increased.height);
vecs.push(&mut type_vecs.balance_decreased.height);
vecs.push(&mut type_vecs.both.height);
}
vecs.into_par_iter()
@@ -11,7 +11,6 @@ use crate::{
distribution::state::RealizedOps,
internal::{
ComputedFromHeight, ComputedFromHeightCumulative,
ComputedFromHeightRatioPercentiles, FiatFromHeight,
LazyFromHeight, NegCentsUnsignedToDollars, RatioCents64,
RollingWindows, ValueFromHeightCumulative,
},
@@ -33,7 +32,6 @@ pub struct RealizedBase<M: StorageMode = Rw> {
pub neg_realized_loss: LazyFromHeight<Dollars, Cents>,
pub net_realized_pnl: ComputedFromHeightCumulative<CentsSigned, M>,
pub gross_pnl: FiatFromHeight<Cents, M>,
pub value_created: ComputedFromHeight<Cents, M>,
pub value_destroyed: ComputedFromHeight<Cents, M>,
@@ -41,8 +39,6 @@ pub struct RealizedBase<M: StorageMode = Rw> {
pub value_destroyed_sum: RollingWindows<Cents, M>,
pub sopr: RollingWindows<StoredF64, M>,
pub realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles<M>,
pub sent_in_profit: ValueFromHeightCumulative<M>,
pub sent_in_loss: ValueFromHeightCumulative<M>,
}
@@ -62,7 +58,6 @@ impl RealizedBase {
);
let net_realized_pnl = cfg.import("net_realized_pnl", v0)?;
let gross_pnl = cfg.import("realized_gross_pnl", v0)?;
let value_created = cfg.import("value_created", v0)?;
let value_destroyed = cfg.import("value_destroyed", v0)?;
@@ -70,26 +65,16 @@ impl RealizedBase {
let value_destroyed_sum = cfg.import("value_destroyed", v1)?;
let sopr = cfg.import("sopr", v1)?;
let realized_price_ratio_percentiles =
ComputedFromHeightRatioPercentiles::forced_import(
cfg.db,
&cfg.name("realized_price"),
cfg.version + v1,
cfg.indexes,
)?;
Ok(Self {
minimal,
realized_cap_change_1m: cfg.import("realized_cap_change_1m", v0)?,
neg_realized_loss,
net_realized_pnl,
gross_pnl,
value_created,
value_destroyed,
value_created_sum,
value_destroyed_sum,
sopr,
realized_price_ratio_percentiles,
sent_in_profit: cfg.import("sent_in_profit", v0)?,
sent_in_loss: cfg.import("sent_in_loss", v0)?,
})
@@ -176,13 +161,6 @@ impl RealizedBase {
Ok(())
})?;
self.gross_pnl.cents.height.compute_add(
starting_indexes.height,
&self.minimal.realized_profit.height,
&self.minimal.realized_loss.height,
exit,
)?;
Ok(())
}
@@ -234,15 +212,6 @@ impl RealizedBase {
)?;
}
// Realized price ratio percentiles
self.realized_price_ratio_percentiles.compute(
blocks,
starting_indexes,
exit,
&self.minimal.realized_price_ratio.ratio.height,
&self.minimal.realized_price.cents.height,
)?;
Ok(())
}
}
@@ -14,7 +14,7 @@ use crate::{
blocks,
distribution::state::RealizedState,
internal::{
CentsUnsignedToDollars, ComputedFromHeight, ComputedFromHeightCumulative,
CentsUnsignedToDollars, ComputedFromHeight, ComputedFromHeightCumulative, FiatFromHeight,
ComputedFromHeightRatio, ComputedFromHeightRatioPercentiles,
ComputedFromHeightRatioStdDevBands, LazyFromHeight, PercentFromHeight,
PercentRollingEmas1w1m, PercentRollingWindows, Price, RatioCents64, RatioCentsBp32,
@@ -35,6 +35,8 @@ pub struct RealizedFull<M: StorageMode = Rw> {
#[traversable(flatten)]
pub core: RealizedBase<M>,
pub gross_pnl: FiatFromHeight<Cents, M>,
pub realized_profit_rel_to_realized_cap: PercentFromHeight<BasisPoints32, M>,
pub realized_loss_rel_to_realized_cap: PercentFromHeight<BasisPoints32, M>,
pub net_realized_pnl_rel_to_realized_cap: PercentFromHeight<BasisPointsSigned32, M>,
@@ -83,6 +85,7 @@ pub struct RealizedFull<M: StorageMode = Rw> {
pub sent_in_profit_ema: RollingEmas2w<M>,
pub sent_in_loss_ema: RollingEmas2w<M>,
pub realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles<M>,
pub realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands<M>,
pub investor_price_ratio_percentiles: ComputedFromHeightRatioPercentiles<M>,
}
@@ -94,6 +97,8 @@ impl RealizedFull {
let core = RealizedBase::forced_import(cfg)?;
let gross_pnl = cfg.import("realized_gross_pnl", v0)?;
let profit_value_created = cfg.import("profit_value_created", v0)?;
let profit_value_destroyed: ComputedFromHeight<Cents> =
cfg.import("profit_value_destroyed", v0)?;
@@ -154,6 +159,7 @@ impl RealizedFull {
Ok(Self {
core,
gross_pnl,
realized_profit_rel_to_realized_cap,
realized_loss_rel_to_realized_cap,
net_realized_pnl_rel_to_realized_cap,
@@ -191,6 +197,12 @@ impl RealizedFull {
sopr_24h_ema,
sent_in_profit_ema,
sent_in_loss_ema,
realized_price_ratio_percentiles: ComputedFromHeightRatioPercentiles::forced_import(
cfg.db,
&realized_price_name,
realized_price_version,
cfg.indexes,
)?,
realized_price_ratio_std_dev: ComputedFromHeightRatioStdDevBands::forced_import(
cfg.db,
&realized_price_name,
@@ -366,12 +378,19 @@ impl RealizedFull {
exit,
)?;
// Gross PnL rolling sum
// Gross PnL
self.gross_pnl.cents.height.compute_add(
starting_indexes.height,
&self.core.minimal.realized_profit.height,
&self.core.minimal.realized_loss.height,
exit,
)?;
let window_starts = blocks.count.window_starts();
self.gross_pnl_sum.compute_rolling_sum(
starting_indexes.height,
&window_starts,
&self.core.gross_pnl.cents.height,
&self.gross_pnl.cents.height,
exit,
)?;
@@ -510,7 +529,14 @@ impl RealizedFull {
)?;
}
// Realized price stddev bands
self.realized_price_ratio_percentiles.compute(
blocks,
starting_indexes,
exit,
&self.core.minimal.realized_price_ratio.ratio.height,
&self.core.minimal.realized_price.cents.height,
)?;
self.realized_price_ratio_std_dev.compute(
blocks,
starting_indexes,
@@ -3,9 +3,7 @@ use brk_traversable::Traversable;
use brk_types::{BasisPoints16, BasisPoints32, BasisPointsSigned32, Dollars, Height, Version};
use vecdb::{Exit, ReadableVec, Rw, StorageMode};
use crate::internal::{
NegRatioDollarsBps32, PercentFromHeight, RatioDollarsBp16, RatioDollarsBp32, RatioDollarsBps32,
};
use crate::internal::{PercentFromHeight, RatioDollarsBp16, RatioDollarsBp32, RatioDollarsBps32};
use crate::distribution::metrics::{ImportConfig, UnrealizedFull};
@@ -14,7 +12,6 @@ use crate::distribution::metrics::{ImportConfig, UnrealizedFull};
pub struct RelativeExtendedOwnMarketCap<M: StorageMode = Rw> {
pub unrealized_profit_rel_to_own_market_cap: PercentFromHeight<BasisPoints16, M>,
pub unrealized_loss_rel_to_own_market_cap: PercentFromHeight<BasisPoints32, M>,
pub neg_unrealized_loss_rel_to_own_market_cap: PercentFromHeight<BasisPointsSigned32, M>,
pub net_unrealized_pnl_rel_to_own_market_cap: PercentFromHeight<BasisPointsSigned32, M>,
}
@@ -27,8 +24,6 @@ impl RelativeExtendedOwnMarketCap {
.import("unrealized_profit_rel_to_own_market_cap", v2)?,
unrealized_loss_rel_to_own_market_cap: cfg
.import("unrealized_loss_rel_to_own_market_cap", Version::new(3))?,
neg_unrealized_loss_rel_to_own_market_cap: cfg
.import("neg_unrealized_loss_rel_to_own_market_cap", Version::new(3))?,
net_unrealized_pnl_rel_to_own_market_cap: cfg
.import("net_unrealized_pnl_rel_to_own_market_cap", Version::new(3))?,
})
@@ -55,13 +50,6 @@ impl RelativeExtendedOwnMarketCap {
own_market_cap,
exit,
)?;
self.neg_unrealized_loss_rel_to_own_market_cap
.compute_binary::<Dollars, Dollars, NegRatioDollarsBps32>(
max_from,
&unrealized.unrealized_loss.usd.height,
own_market_cap,
exit,
)?;
self.net_unrealized_pnl_rel_to_own_market_cap
.compute_binary::<Dollars, Dollars, RatioDollarsBps32>(
max_from,
@@ -3,9 +3,7 @@ use brk_traversable::Traversable;
use brk_types::{BasisPoints16, BasisPointsSigned32, Dollars, Height, Version};
use vecdb::{Exit, Rw, StorageMode};
use crate::internal::{
NegRatioDollarsBps32, PercentFromHeight, RatioDollarsBp16, RatioDollarsBps32,
};
use crate::internal::{PercentFromHeight, RatioDollarsBp16, RatioDollarsBps32};
use crate::distribution::metrics::{ImportConfig, UnrealizedFull};
@@ -14,7 +12,6 @@ use crate::distribution::metrics::{ImportConfig, UnrealizedFull};
pub struct RelativeExtendedOwnPnl<M: StorageMode = Rw> {
pub unrealized_profit_rel_to_own_gross_pnl: PercentFromHeight<BasisPoints16, M>,
pub unrealized_loss_rel_to_own_gross_pnl: PercentFromHeight<BasisPoints16, M>,
pub neg_unrealized_loss_rel_to_own_gross_pnl: PercentFromHeight<BasisPointsSigned32, M>,
pub net_unrealized_pnl_rel_to_own_gross_pnl: PercentFromHeight<BasisPointsSigned32, M>,
}
@@ -27,8 +24,6 @@ impl RelativeExtendedOwnPnl {
.import("unrealized_profit_rel_to_own_gross_pnl", v1)?,
unrealized_loss_rel_to_own_gross_pnl: cfg
.import("unrealized_loss_rel_to_own_gross_pnl", v1)?,
neg_unrealized_loss_rel_to_own_gross_pnl: cfg
.import("neg_unrealized_loss_rel_to_own_gross_pnl", Version::new(2))?,
net_unrealized_pnl_rel_to_own_gross_pnl: cfg
.import("net_unrealized_pnl_rel_to_own_gross_pnl", Version::new(3))?,
})
@@ -54,13 +49,6 @@ impl RelativeExtendedOwnPnl {
&unrealized.gross_pnl.usd.height,
exit,
)?;
self.neg_unrealized_loss_rel_to_own_gross_pnl
.compute_binary::<Dollars, Dollars, NegRatioDollarsBps32>(
max_from,
&unrealized.unrealized_loss.usd.height,
&unrealized.gross_pnl.usd.height,
exit,
)?;
self.net_unrealized_pnl_rel_to_own_gross_pnl
.compute_binary::<Dollars, Dollars, RatioDollarsBps32>(
max_from,
@@ -7,8 +7,7 @@ use derive_more::{Deref, DerefMut};
use vecdb::{Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode};
use crate::internal::{
Bps32ToFloat, LazyFromHeight, NegRatioDollarsBps32, PercentFromHeight, RatioDollarsBp16,
RatioDollarsBps32,
Bps32ToFloat, LazyFromHeight, PercentFromHeight, RatioDollarsBp16, RatioDollarsBps32,
};
use crate::distribution::metrics::{ImportConfig, RealizedBase, UnrealizedFull};
@@ -26,7 +25,6 @@ pub struct RelativeFull<M: StorageMode = Rw> {
pub unrealized_profit_rel_to_market_cap: PercentFromHeight<BasisPoints16, M>,
pub unrealized_loss_rel_to_market_cap: PercentFromHeight<BasisPoints16, M>,
pub net_unrealized_pnl_rel_to_market_cap: PercentFromHeight<BasisPointsSigned32, M>,
pub neg_unrealized_loss_rel_to_market_cap: PercentFromHeight<BasisPointsSigned32, M>,
pub nupl: LazyFromHeight<StoredF32, BasisPointsSigned32>,
pub invested_capital_in_profit_rel_to_realized_cap: PercentFromHeight<BasisPoints16, M>,
@@ -60,8 +58,6 @@ impl RelativeFull {
unrealized_loss_rel_to_market_cap: cfg
.import("unrealized_loss_rel_to_market_cap", v2)?,
net_unrealized_pnl_rel_to_market_cap,
neg_unrealized_loss_rel_to_market_cap: cfg
.import("neg_unrealized_loss_rel_to_market_cap", v3)?,
nupl,
invested_capital_in_profit_rel_to_realized_cap: cfg.import(
"invested_capital_in_profit_rel_to_realized_cap",
@@ -111,14 +107,6 @@ impl RelativeFull {
market_cap,
exit,
)?;
self.neg_unrealized_loss_rel_to_market_cap
.compute_binary::<Dollars, Dollars, NegRatioDollarsBps32>(
max_from,
&unrealized.unrealized_loss.usd.height,
market_cap,
exit,
)?;
self.invested_capital_in_profit_rel_to_realized_cap
.compute_binary::<Dollars, Dollars, RatioDollarsBp16>(
max_from,
@@ -29,8 +29,6 @@ pub struct UnrealizedBase<M: StorageMode = Rw> {
pub neg_unrealized_loss: LazyFromHeight<Dollars, Cents>,
pub gross_pnl: FiatFromHeight<Cents, M>,
pub net_unrealized_pnl: FiatFromHeight<CentsSigned, M>,
}
@@ -50,8 +48,6 @@ impl UnrealizedBase {
&unrealized_loss.cents,
);
let gross_pnl = cfg.import("unrealized_gross_pnl", v0)?;
let net_unrealized_pnl = cfg.import("net_unrealized_pnl", v0)?;
Ok(Self {
@@ -60,7 +56,6 @@ impl UnrealizedBase {
unrealized_profit,
unrealized_loss,
neg_unrealized_loss,
gross_pnl,
net_unrealized_pnl,
})
}
@@ -131,13 +126,6 @@ impl UnrealizedBase {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
self.gross_pnl.cents.height.compute_add(
starting_indexes.height,
&self.unrealized_profit.cents.height,
&self.unrealized_loss.cents.height,
exit,
)?;
self.net_unrealized_pnl
.cents
.height
@@ -26,7 +26,8 @@ pub struct UnrealizedFull<M: StorageMode = Rw> {
#[traversable(flatten)]
pub base: UnrealizedBase<M>,
// --- Source-only fields ---
pub gross_pnl: FiatFromHeight<Cents, M>,
pub invested_capital_in_profit: FiatFromHeight<Cents, M>,
pub invested_capital_in_loss: FiatFromHeight<Cents, M>,
@@ -47,6 +48,8 @@ impl UnrealizedFull {
let base = UnrealizedBase::forced_import(cfg)?;
let gross_pnl = cfg.import("unrealized_gross_pnl", v0)?;
let invested_capital_in_profit = cfg.import("invested_capital_in_profit", v0)?;
let invested_capital_in_loss = cfg.import("invested_capital_in_loss", v0)?;
@@ -62,6 +65,7 @@ impl UnrealizedFull {
Ok(Self {
base,
gross_pnl,
invested_capital_in_profit,
invested_capital_in_loss,
invested_capital_in_profit_raw,
@@ -218,10 +222,16 @@ impl UnrealizedFull {
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
// Complete-tier: net_unrealized_pnl
self.base.compute_rest(starting_indexes, exit)?;
// Extended-only: Pain index (investor_price_of_losers - spot)
self.gross_pnl.cents.height.compute_add(
starting_indexes.height,
&self.base.unrealized_profit.cents.height,
&self.base.unrealized_loss.cents.height,
exit,
)?;
// Pain index (investor_price_of_losers - spot)
self.pain_index.cents.height.compute_transform3(
starting_indexes.height,
&self.investor_cap_in_loss_raw,
@@ -3,9 +3,11 @@ mod cumulative;
mod cumulative_sum;
mod distribution;
mod full;
mod rolling_average;
pub use aggregated::*;
pub use cumulative::*;
pub use cumulative_sum::*;
pub use distribution::*;
pub use full::*;
pub use rolling_average::*;
@@ -0,0 +1,78 @@
//! ComputedFromHeight with rolling average (no distribution stats).
//!
//! Stored height data + 4-window rolling averages (24h, 1w, 1m, 1y).
//! Use instead of ComputedFromHeightDistribution when only the average
//! is analytically useful (e.g., block interval, activity counts).
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Height, Version};
use schemars::JsonSchema;
use vecdb::{Database, EagerVec, Exit, ImportableVec, PcoVec, Rw, StorageMode};
use crate::indexes;
use crate::internal::{NumericValue, RollingWindows, WindowStarts};
#[derive(Traversable)]
pub struct ComputedFromHeightRollingAverage<T, M: StorageMode = Rw>
where
T: NumericValue + JsonSchema,
{
pub height: M::Stored<EagerVec<PcoVec<Height, T>>>,
#[traversable(flatten)]
pub average: RollingWindows<T, M>,
}
impl<T> ComputedFromHeightRollingAverage<T>
where
T: NumericValue + JsonSchema,
{
pub(crate) fn forced_import(
db: &Database,
name: &str,
version: Version,
indexes: &indexes::Vecs,
) -> Result<Self> {
let height: EagerVec<PcoVec<Height, T>> = EagerVec::forced_import(db, name, version)?;
let average =
RollingWindows::forced_import(db, &format!("{name}_average"), version, indexes)?;
Ok(Self { height, average })
}
/// Compute height data via closure, then rolling averages.
pub(crate) fn compute(
&mut self,
max_from: Height,
windows: &WindowStarts<'_>,
exit: &Exit,
compute_height: impl FnOnce(&mut EagerVec<PcoVec<Height, T>>) -> Result<()>,
) -> Result<()>
where
T: Default,
f64: From<T>,
{
compute_height(&mut self.height)?;
self.compute_rest(max_from, windows, exit)
}
/// Compute rolling averages from already-populated height data.
pub(crate) fn compute_rest(
&mut self,
max_from: Height,
windows: &WindowStarts<'_>,
exit: &Exit,
) -> Result<()>
where
T: Default,
f64: From<T>,
{
for (w, starts) in self.average.0.as_mut_array().into_iter().zip(windows.as_array()) {
w.height
.compute_rolling_average(max_from, *starts, &self.height, exit)?;
}
Ok(())
}
}
@@ -1,5 +1,7 @@
mod base;
mod distribution;
mod rolling_average;
pub use base::*;
pub use distribution::*;
pub use rolling_average::*;
@@ -0,0 +1,69 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Height, StoredF32, Version};
use vecdb::{Database, EagerVec, Exit, PcoVec, ReadableCloneableVec, Rw, StorageMode};
use crate::{
indexes,
internal::{BpsType, WindowStarts},
};
use crate::internal::{ComputedFromHeightRollingAverage, LazyFromHeight};
/// Like PercentFromHeight but with rolling average stats on the bps data.
#[derive(Traversable)]
pub struct PercentFromHeightRollingAverage<B: BpsType, M: StorageMode = Rw> {
pub bps: ComputedFromHeightRollingAverage<B, M>,
pub ratio: LazyFromHeight<StoredF32, B>,
pub percent: LazyFromHeight<StoredF32, B>,
}
impl<B: BpsType> PercentFromHeightRollingAverage<B> {
pub(crate) fn forced_import(
db: &Database,
name: &str,
version: Version,
indexes: &indexes::Vecs,
) -> Result<Self> {
let bps = ComputedFromHeightRollingAverage::forced_import(
db,
&format!("{name}_bps"),
version,
indexes,
)?;
let ratio = LazyFromHeight::from_height_source::<B::ToRatio>(
&format!("{name}_ratio"),
version,
bps.height.read_only_boxed_clone(),
indexes,
);
let percent = LazyFromHeight::from_height_source::<B::ToPercent>(
name,
version,
bps.height.read_only_boxed_clone(),
indexes,
);
Ok(Self {
bps,
ratio,
percent,
})
}
pub(crate) fn compute(
&mut self,
max_from: Height,
windows: &WindowStarts<'_>,
exit: &Exit,
compute_height: impl FnOnce(&mut EagerVec<PcoVec<Height, B>>) -> Result<()>,
) -> Result<()>
where
B: Default,
f64: From<B>,
{
self.bps.compute(max_from, windows, exit, compute_height)
}
}
@@ -1,7 +1,7 @@
use brk_error::Result;
use brk_traversable::Traversable;
use brk_types::{Cents, Height, Sats, Version};
use vecdb::{Database, Exit, Rw, StorageMode};
use vecdb::{Database, EagerVec, Exit, PcoVec, Rw, StorageMode};
use crate::{
indexes,
@@ -32,6 +32,17 @@ impl ValueFromHeightCumulative {
})
}
pub(crate) fn compute_with(
&mut self,
max_from: Height,
prices: &prices::Vecs,
exit: &Exit,
compute_sats: impl FnOnce(&mut EagerVec<PcoVec<Height, Sats>>) -> Result<()>,
) -> Result<()> {
compute_sats(&mut self.base.sats.height)?;
self.compute(prices, max_from, exit)
}
pub(crate) fn compute(
&mut self,
prices: &prices::Vecs,
@@ -23,7 +23,7 @@ pub use derived::{
RatioCents64, TimesSqrt,
};
pub use ratio::{
NegRatioDollarsBps32, RatioCentsBp32, RatioCentsSignedCentsBps32,
RatioCentsBp32, RatioCentsSignedCentsBps32,
RatioCentsSignedDollarsBps32, RatioDiffCentsBps32, RatioDiffDollarsBps32, RatioDiffF32Bps32,
RatioDollarsBp16, RatioDollarsBp32, RatioDollarsBps32, RatioSatsBp16, RatioU32Bp16,
RatioU64Bp16,
@@ -84,20 +84,6 @@ impl BinaryTransform<Dollars, Dollars, BasisPointsSigned32> for RatioDollarsBps3
}
}
pub struct NegRatioDollarsBps32;
impl BinaryTransform<Dollars, Dollars, BasisPointsSigned32> for NegRatioDollarsBps32 {
#[inline(always)]
fn apply(numerator: Dollars, denominator: Dollars) -> BasisPointsSigned32 {
let ratio = *(numerator / denominator);
if ratio.is_finite() {
BasisPointsSigned32::from(-ratio)
} else {
BasisPointsSigned32::ZERO
}
}
}
pub struct RatioCentsSignedCentsBps32;
impl BinaryTransform<CentsSigned, Cents, BasisPointsSigned32> for RatioCentsSignedCentsBps32 {
+2 -2
View File
@@ -32,8 +32,8 @@ impl Vecs {
self.hashrate.compute(
&blocks.count,
&blocks.difficulty,
&self.rewards.coinbase.rolling._24h.sum.sats.height,
&self.rewards.coinbase.rolling._24h.sum.usd.height,
&self.rewards.coinbase.sum._24h.sats.height,
&self.rewards.coinbase.sum._24h.usd.height,
starting_indexes,
exit,
)?;
@@ -76,29 +76,21 @@ impl Vecs {
},
)?;
self.subsidy.compute(
self.subsidy.base.sats.height.compute_transform2(
starting_indexes.height,
&window_starts,
prices,
exit,
|vec| {
vec.compute_transform2(
starting_indexes.height,
&self.coinbase.base.sats.height,
&self.fees.base.sats.height,
|(height, coinbase, fees, ..)| {
(
height,
coinbase.checked_sub(fees).unwrap_or_else(|| {
panic!("coinbase {coinbase:?} < fees {fees:?} at {height:?}")
}),
)
},
exit,
)?;
Ok(())
&self.coinbase.base.sats.height,
&self.fees.base.sats.height,
|(height, coinbase, fees, ..)| {
(
height,
coinbase.checked_sub(fees).unwrap_or_else(|| {
panic!("coinbase {coinbase:?} < fees {fees:?} at {height:?}")
}),
)
},
exit,
)?;
self.subsidy.compute(prices, starting_indexes.height, exit)?;
self.unclaimed_rewards.compute(
starting_indexes.height,
@@ -135,12 +127,12 @@ impl Vecs {
.as_mut_array()
.into_iter()
.zip(self.fees.rolling.as_array())
.zip(self.coinbase.rolling.as_array())
.zip(self.coinbase.sum.as_array())
{
fee_dom.compute_binary::<Sats, Sats, RatioSatsBp16>(
starting_indexes.height,
&fees_w.sum.sats.height,
&coinbase_w.sum.sats.height,
&coinbase_w.sats.height,
exit,
)?;
}
@@ -6,8 +6,8 @@ use super::Vecs;
use crate::{
indexes,
internal::{
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulativeSum,
ValueFromHeightFull,
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulative,
ValueFromHeightCumulativeSum, ValueFromHeightFull,
},
};
@@ -18,8 +18,8 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
coinbase: ValueFromHeightFull::forced_import(db, "coinbase", version, indexes)?,
subsidy: ValueFromHeightFull::forced_import(db, "subsidy", version, indexes)?,
coinbase: ValueFromHeightCumulativeSum::forced_import(db, "coinbase", version, indexes)?,
subsidy: ValueFromHeightCumulative::forced_import(db, "subsidy", version, indexes)?,
fees: ValueFromHeightFull::forced_import(db, "fees", version, indexes)?,
unclaimed_rewards: ValueFromHeightCumulativeSum::forced_import(
db,
@@ -3,14 +3,14 @@ use brk_types::{BasisPoints16, Cents};
use vecdb::{Rw, StorageMode};
use crate::internal::{
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulativeSum,
ValueFromHeightFull,
FiatFromHeight, PercentFromHeight, PercentRollingWindows, ValueFromHeightCumulative,
ValueFromHeightCumulativeSum, ValueFromHeightFull,
};
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub coinbase: ValueFromHeightFull<M>,
pub subsidy: ValueFromHeightFull<M>,
pub coinbase: ValueFromHeightCumulativeSum<M>,
pub subsidy: ValueFromHeightCumulative<M>,
pub fees: ValueFromHeightFull<M>,
pub unclaimed_rewards: ValueFromHeightCumulativeSum<M>,
pub fee_dominance: PercentFromHeight<BasisPoints16, M>,
+1 -1
View File
@@ -21,7 +21,7 @@ impl Vecs {
.compute(indexer, &blocks.count, starting_indexes, exit)?;
self.value
.compute(indexer, &blocks.count, prices, starting_indexes, exit)?;
.compute(indexer, prices, starting_indexes, exit)?;
self.adoption
.compute(&self.count, &outputs.count, starting_indexes, exit)?;
@@ -4,22 +4,18 @@ use brk_types::{Height, Indexes, OutputType, Sats, TxOutIndex};
use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableVec, VecIndex, WritableVec};
use super::Vecs;
use crate::{blocks, prices};
use crate::prices;
impl Vecs {
pub(crate) fn compute(
&mut self,
indexer: &Indexer,
count_vecs: &blocks::CountVecs,
prices: &prices::Vecs,
starting_indexes: &Indexes,
exit: &Exit,
) -> Result<()> {
let window_starts = count_vecs.window_starts();
self.opreturn.compute(
self.opreturn.compute_with(
starting_indexes.height,
&window_starts,
prices,
exit,
|height_vec| {
@@ -3,7 +3,7 @@ use brk_types::Version;
use vecdb::Database;
use super::Vecs;
use crate::{indexes, internal::ValueFromHeightFull};
use crate::{indexes, internal::ValueFromHeightCumulative};
impl Vecs {
pub(crate) fn forced_import(
@@ -12,7 +12,12 @@ impl Vecs {
indexes: &indexes::Vecs,
) -> Result<Self> {
Ok(Self {
opreturn: ValueFromHeightFull::forced_import(db, "opreturn_value", version, indexes)?,
opreturn: ValueFromHeightCumulative::forced_import(
db,
"opreturn_value",
version,
indexes,
)?,
})
}
}
@@ -1,9 +1,9 @@
use brk_traversable::Traversable;
use vecdb::{Rw, StorageMode};
use crate::internal::ValueFromHeightFull;
use crate::internal::ValueFromHeightCumulative;
#[derive(Traversable)]
pub struct Vecs<M: StorageMode = Rw> {
pub opreturn: ValueFromHeightFull<M>,
pub opreturn: ValueFromHeightCumulative<M>,
}
@@ -1,39 +1,91 @@
use brk_error::Result;
use brk_types::{BlockRewardsEntry, TimePeriod};
use vecdb::{ReadableOptionVec, VecIndex};
use brk_types::{BlockRewardsEntry, Height, Sats, TimePeriod};
use vecdb::{ReadableVec, VecIndex};
use super::day1_iter::Day1Iter;
use crate::Query;
impl Query {
pub fn block_rewards(&self, time_period: TimePeriod) -> Result<Vec<BlockRewardsEntry>> {
let computer = self.computer();
let current_height = self.height();
let start = current_height
.to_usize()
.saturating_sub(time_period.block_count());
let indexer = self.indexer();
let current_height = self.height().to_usize();
let start = current_height.saturating_sub(time_period.block_count());
let iter = Day1Iter::new(computer, start, current_height.to_usize());
let coinbase_vec = &computer.mining.rewards.coinbase.base.sats.height;
let timestamp_vec = &indexer.vecs.blocks.timestamp;
let rewards_vec = &computer
.mining
.rewards
.coinbase
.rolling
._24h
.distribution
.average
.sats
.day1;
match time_period {
// Per-block, exact rewards
TimePeriod::Day | TimePeriod::ThreeDays => {
let rewards: Vec<Sats> =
coinbase_vec.collect_range_at(start, current_height + 1);
let timestamps: Vec<brk_types::Timestamp> =
timestamp_vec.collect_range_at(start, current_height + 1);
Ok(iter.collect(|di, ts, h| {
rewards_vec
.collect_one_flat(di)
.map(|reward| BlockRewardsEntry {
avg_height: h.into(),
timestamp: *ts,
avg_rewards: *reward,
})
}))
Ok(rewards
.iter()
.zip(timestamps.iter())
.enumerate()
.map(|(i, (reward, ts))| BlockRewardsEntry {
avg_height: (start + i) as u32,
timestamp: **ts,
avg_rewards: **reward,
})
.collect())
}
// Daily averages, sampled to ~200 points
_ => {
let first_height_vec = &computer.indexes.day1.first_height;
let day1_vec = &computer.indexes.height.day1;
let start_di = day1_vec
.collect_one(Height::from(start))
.unwrap_or_default();
let end_di = day1_vec
.collect_one(Height::from(current_height))
.unwrap_or_default();
let total_days =
end_di.to_usize().saturating_sub(start_di.to_usize()) + 1;
let step = (total_days / 200).max(1);
let mut entries = Vec::with_capacity(total_days / step + 1);
let mut di = start_di.to_usize();
while di <= end_di.to_usize() {
let day = brk_types::Day1::from(di);
let next_day = brk_types::Day1::from(di + 1);
if let Some(first_h) = first_height_vec.collect_one(day) {
let next_h = first_height_vec
.collect_one(next_day)
.unwrap_or(Height::from(current_height + 1));
let block_count = next_h.to_usize() - first_h.to_usize();
if block_count > 0 {
let sum = coinbase_vec.fold_range(
first_h,
next_h,
Sats::ZERO,
|acc, v| acc + v,
);
let avg = *sum / block_count as u64;
if let Some(ts) = timestamp_vec.collect_one(first_h) {
entries.push(BlockRewardsEntry {
avg_height: first_h.to_usize() as u32,
timestamp: *ts,
avg_rewards: avg,
});
}
}
}
di += step;
}
Ok(entries)
}
}
}
}