mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
computer: renames
This commit is contained in:
@@ -966,7 +966,7 @@ pub struct CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSell
|
||||
pub net_realized_pnl_sum: _24hPattern<CentsSigned>,
|
||||
pub net_realized_pnl_sum_extended: _1m1w1yPattern<CentsSigned>,
|
||||
pub peak_regret: CumulativeHeightPattern<Cents>,
|
||||
pub peak_regret_rel_to_realized_cap: BpsPercentRatioPattern,
|
||||
pub peak_regret_rel_to_rcap: BpsPercentRatioPattern,
|
||||
pub profit_flow: MetricPattern1<Dollars>,
|
||||
pub profit_value_created: MetricPattern1<Cents>,
|
||||
pub profit_value_created_sum: _1m1w1y24hPattern<Cents>,
|
||||
@@ -1037,7 +1037,7 @@ impl CapCapitulationGrossInvestorLossLowerMvrvNegNetPeakProfitRealizedSellSentSo
|
||||
net_realized_pnl_sum: _24hPattern::new(client.clone(), _m(&acc, "net_realized_pnl_24h")),
|
||||
net_realized_pnl_sum_extended: _1m1w1yPattern::new(client.clone(), _m(&acc, "net_realized_pnl")),
|
||||
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")),
|
||||
peak_regret_rel_to_rcap: 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_created_sum: _1m1w1y24hPattern::new(client.clone(), _m(&acc, "profit_value_created")),
|
||||
|
||||
@@ -18,7 +18,7 @@ impl Vecs {
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
let all_metrics = &distribution.utxo_cohorts.all.metrics;
|
||||
let realized_cap_cents = &all_metrics.realized.realized_cap_cents.height;
|
||||
let realized_cap_cents = &all_metrics.realized.cap_cents.height;
|
||||
let circulating_supply = &all_metrics.supply.total.btc.height;
|
||||
|
||||
self.thermo_cap.cents.height.compute_transform(
|
||||
|
||||
@@ -21,7 +21,7 @@ impl Vecs {
|
||||
) -> Result<()> {
|
||||
let all_metrics = &distribution.utxo_cohorts.all.metrics;
|
||||
let circulating_supply = &all_metrics.supply.total.btc.height;
|
||||
let realized_price = &all_metrics.realized.realized_price.cents.height;
|
||||
let realized_price = &all_metrics.realized.price.cents.height;
|
||||
|
||||
self.vaulted_price.cents.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
|
||||
@@ -27,11 +27,11 @@ pub struct RealizedCore<M: StorageMode = Rw> {
|
||||
#[traversable(flatten)]
|
||||
pub minimal: RealizedMinimal<M>,
|
||||
|
||||
pub realized_cap_delta: FiatRollingDelta1m<Cents, CentsSigned, M>,
|
||||
pub cap_delta: FiatRollingDelta1m<Cents, CentsSigned, M>,
|
||||
|
||||
pub neg_realized_loss: LazyPerBlock<Dollars, Cents>,
|
||||
pub net_realized_pnl: ComputedPerBlock<CentsSigned, M>,
|
||||
pub net_realized_pnl_sum: RollingWindow24h<CentsSigned, M>,
|
||||
pub neg_loss: LazyPerBlock<Dollars, Cents>,
|
||||
pub net_pnl: ComputedPerBlock<CentsSigned, M>,
|
||||
pub net_pnl_sum: RollingWindow24h<CentsSigned, M>,
|
||||
|
||||
pub value_created: ComputedPerBlock<Cents, M>,
|
||||
pub value_destroyed: ComputedPerBlock<Cents, M>,
|
||||
@@ -50,7 +50,7 @@ impl RealizedCore {
|
||||
let neg_realized_loss = LazyPerBlock::from_height_source::<NegCentsUnsignedToDollars>(
|
||||
&cfg.name("neg_realized_loss"),
|
||||
cfg.version + Version::ONE,
|
||||
minimal.realized_loss.height.read_only_boxed_clone(),
|
||||
minimal.loss.height.read_only_boxed_clone(),
|
||||
cfg.indexes,
|
||||
);
|
||||
|
||||
@@ -65,10 +65,10 @@ impl RealizedCore {
|
||||
|
||||
Ok(Self {
|
||||
minimal,
|
||||
realized_cap_delta: cfg.import("realized_cap_delta", v1)?,
|
||||
neg_realized_loss,
|
||||
net_realized_pnl,
|
||||
net_realized_pnl_sum,
|
||||
cap_delta: cfg.import("realized_cap_delta", v1)?,
|
||||
neg_loss: neg_realized_loss,
|
||||
net_pnl: net_realized_pnl,
|
||||
net_pnl_sum: net_realized_pnl_sum,
|
||||
value_created,
|
||||
value_destroyed,
|
||||
value_created_sum,
|
||||
@@ -124,12 +124,13 @@ impl RealizedCore {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.minimal.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
self.minimal
|
||||
.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
|
||||
self.net_realized_pnl.height.compute_transform2(
|
||||
self.net_pnl.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.minimal.realized_profit.height,
|
||||
&self.minimal.realized_loss.height,
|
||||
&self.minimal.profit.height,
|
||||
&self.minimal.loss.height,
|
||||
|(i, profit, loss, ..)| {
|
||||
(
|
||||
i,
|
||||
@@ -153,17 +154,17 @@ impl RealizedCore {
|
||||
self.minimal
|
||||
.compute_rest_part2(prices, starting_indexes, height_to_supply, exit)?;
|
||||
|
||||
self.realized_cap_delta.compute(
|
||||
self.cap_delta.compute(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_1m_ago,
|
||||
&self.minimal.realized_cap_cents.height,
|
||||
&self.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.net_realized_pnl_sum.compute_rolling_sum(
|
||||
self.net_pnl_sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&self.net_realized_pnl.height,
|
||||
&self.net_pnl.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -180,12 +181,14 @@ impl RealizedCore {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.sopr._24h.compute_binary::<Cents, Cents, RatioCents64>(
|
||||
starting_indexes.height,
|
||||
&self.value_created_sum._24h.height,
|
||||
&self.value_destroyed_sum._24h.height,
|
||||
exit,
|
||||
)?;
|
||||
self.sopr
|
||||
._24h
|
||||
.compute_binary::<Cents, Cents, RatioCents64>(
|
||||
starting_indexes.height,
|
||||
&self.value_created_sum._24h.height,
|
||||
&self.value_destroyed_sum._24h.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -14,12 +14,11 @@ use crate::{
|
||||
blocks,
|
||||
distribution::state::RealizedState,
|
||||
internal::{
|
||||
CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative,
|
||||
RatioPerBlock, RatioPerBlockPercentiles,
|
||||
RatioPerBlockStdDevBands, FiatPerBlock, FiatRollingDelta1m,
|
||||
FiatRollingDeltaExcept1m, LazyPerBlock, PercentPerBlock, PercentRollingWindows, Price,
|
||||
RatioCents64, RatioCentsBp32, RatioCentsSignedCentsBps32, RatioCentsSignedDollarsBps32,
|
||||
RatioDollarsBp32, RollingWindows, RollingWindowsFrom1w,
|
||||
CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative, FiatPerBlock,
|
||||
FiatRollingDelta1m, FiatRollingDeltaExcept1m, LazyPerBlock, PercentPerBlock,
|
||||
PercentRollingWindows, Price, RatioCents64, RatioCentsBp32, RatioCentsSignedCentsBps32,
|
||||
RatioCentsSignedDollarsBps32, RatioDollarsBp32, RatioPerBlock, RatioPerBlockPercentiles,
|
||||
RatioPerBlockStdDevBands, RollingWindows, RollingWindowsFrom1w,
|
||||
},
|
||||
prices,
|
||||
};
|
||||
@@ -37,9 +36,9 @@ pub struct RealizedFull<M: StorageMode = Rw> {
|
||||
|
||||
pub gross_pnl: FiatPerBlock<Cents, M>,
|
||||
|
||||
pub realized_profit_rel_to_realized_cap: PercentPerBlock<BasisPoints32, M>,
|
||||
pub realized_loss_rel_to_realized_cap: PercentPerBlock<BasisPoints32, M>,
|
||||
pub net_realized_pnl_rel_to_realized_cap: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
pub profit_rel_to_rcap: PercentPerBlock<BasisPoints32, M>,
|
||||
pub loss_rel_to_rcap: PercentPerBlock<BasisPoints32, M>,
|
||||
pub net_pnl_rel_to_rcap: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
|
||||
pub profit_value_created: ComputedPerBlock<Cents, M>,
|
||||
pub profit_value_destroyed: ComputedPerBlock<Cents, M>,
|
||||
@@ -56,18 +55,18 @@ pub struct RealizedFull<M: StorageMode = Rw> {
|
||||
|
||||
pub gross_pnl_sum: RollingWindows<Cents, M>,
|
||||
|
||||
pub net_realized_pnl_cumulative: ComputedPerBlock<CentsSigned, M>,
|
||||
#[traversable(rename = "net_realized_pnl_sum")]
|
||||
pub net_realized_pnl_sum_extended: RollingWindowsFrom1w<CentsSigned, M>,
|
||||
pub net_pnl_cumulative: ComputedPerBlock<CentsSigned, M>,
|
||||
#[traversable(rename = "net_pnl_sum")]
|
||||
pub net_pnl_sum_extended: RollingWindowsFrom1w<CentsSigned, M>,
|
||||
|
||||
pub net_pnl_delta: FiatRollingDelta1m<CentsSigned, CentsSigned, M>,
|
||||
#[traversable(rename = "net_pnl_delta")]
|
||||
pub net_pnl_delta_extended: FiatRollingDeltaExcept1m<CentsSigned, CentsSigned, M>,
|
||||
pub net_pnl_change_1m_rel_to_realized_cap: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
pub net_pnl_change_1m_rel_to_market_cap: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
pub net_pnl_change_1m_rel_to_rcap: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
pub net_pnl_change_1m_rel_to_mcap: PercentPerBlock<BasisPointsSigned32, M>,
|
||||
|
||||
#[traversable(rename = "realized_cap_delta")]
|
||||
pub realized_cap_delta_extended: FiatRollingDeltaExcept1m<Cents, CentsSigned, M>,
|
||||
#[traversable(rename = "cap_delta")]
|
||||
pub cap_delta_extended: FiatRollingDeltaExcept1m<Cents, CentsSigned, M>,
|
||||
|
||||
pub investor_price: Price<ComputedPerBlock<Cents, M>>,
|
||||
pub investor_price_ratio: RatioPerBlock<M>,
|
||||
@@ -83,13 +82,13 @@ pub struct RealizedFull<M: StorageMode = Rw> {
|
||||
pub peak_regret: ComputedPerBlockCumulative<Cents, M>,
|
||||
pub peak_regret_rel_to_realized_cap: PercentPerBlock<BasisPoints32, M>,
|
||||
|
||||
pub realized_cap_rel_to_own_market_cap: PercentPerBlock<BasisPoints32, M>,
|
||||
pub cap_rel_to_own_mcap: PercentPerBlock<BasisPoints32, M>,
|
||||
|
||||
#[traversable(rename = "realized_profit_sum")]
|
||||
pub realized_profit_sum_extended: RollingWindowsFrom1w<Cents, M>,
|
||||
#[traversable(rename = "realized_loss_sum")]
|
||||
pub realized_loss_sum_extended: RollingWindowsFrom1w<Cents, M>,
|
||||
pub realized_profit_to_loss_ratio: RollingWindows<StoredF64, M>,
|
||||
#[traversable(rename = "profit_sum")]
|
||||
pub profit_sum_extended: RollingWindowsFrom1w<Cents, M>,
|
||||
#[traversable(rename = "loss_sum")]
|
||||
pub loss_sum_extended: RollingWindowsFrom1w<Cents, M>,
|
||||
pub profit_to_loss_ratio: RollingWindows<StoredF64, M>,
|
||||
|
||||
#[traversable(rename = "value_created_sum")]
|
||||
pub value_created_sum_extended: RollingWindowsFrom1w<Cents, M>,
|
||||
@@ -103,8 +102,8 @@ pub struct RealizedFull<M: StorageMode = Rw> {
|
||||
#[traversable(rename = "sent_in_loss_sum")]
|
||||
pub sent_in_loss_sum_extended: RollingWindowsFrom1w<Sats, M>,
|
||||
|
||||
pub realized_price_ratio_percentiles: RatioPerBlockPercentiles<M>,
|
||||
pub realized_price_ratio_std_dev: RatioPerBlockStdDevBands<M>,
|
||||
pub price_ratio_percentiles: RatioPerBlockPercentiles<M>,
|
||||
pub price_ratio_std_dev: RatioPerBlockStdDevBands<M>,
|
||||
pub investor_price_ratio_percentiles: RatioPerBlockPercentiles<M>,
|
||||
}
|
||||
|
||||
@@ -152,8 +151,7 @@ impl RealizedFull {
|
||||
let cap_raw = cfg.import("cap_raw", v0)?;
|
||||
let investor_cap_raw = cfg.import("investor_cap_raw", v0)?;
|
||||
|
||||
let sell_side_risk_ratio =
|
||||
cfg.import("sell_side_risk_ratio", Version::new(2))?;
|
||||
let sell_side_risk_ratio = cfg.import("sell_side_risk_ratio", Version::new(2))?;
|
||||
|
||||
let peak_regret = cfg.import("realized_peak_regret", Version::new(2))?;
|
||||
let peak_regret_rel_to_realized_cap =
|
||||
@@ -178,9 +176,9 @@ impl RealizedFull {
|
||||
Ok(Self {
|
||||
base,
|
||||
gross_pnl,
|
||||
realized_profit_rel_to_realized_cap,
|
||||
realized_loss_rel_to_realized_cap,
|
||||
net_realized_pnl_rel_to_realized_cap,
|
||||
profit_rel_to_rcap: realized_profit_rel_to_realized_cap,
|
||||
loss_rel_to_rcap: realized_loss_rel_to_realized_cap,
|
||||
net_pnl_rel_to_rcap: net_realized_pnl_rel_to_realized_cap,
|
||||
profit_value_created,
|
||||
profit_value_destroyed,
|
||||
loss_value_created,
|
||||
@@ -192,15 +190,15 @@ impl RealizedFull {
|
||||
capitulation_flow,
|
||||
profit_flow,
|
||||
gross_pnl_sum,
|
||||
net_realized_pnl_cumulative: cfg.import("net_realized_pnl_cumulative", Version::ONE)?,
|
||||
net_realized_pnl_sum_extended: cfg.import("net_realized_pnl", Version::ONE)?,
|
||||
net_pnl_cumulative: cfg.import("net_realized_pnl_cumulative", Version::ONE)?,
|
||||
net_pnl_sum_extended: cfg.import("net_realized_pnl", Version::ONE)?,
|
||||
net_pnl_delta: cfg.import("net_pnl_delta", Version::new(5))?,
|
||||
net_pnl_delta_extended: cfg.import("net_pnl_delta", Version::new(5))?,
|
||||
net_pnl_change_1m_rel_to_realized_cap: cfg
|
||||
net_pnl_change_1m_rel_to_rcap: cfg
|
||||
.import("net_pnl_change_1m_rel_to_realized_cap", Version::new(4))?,
|
||||
net_pnl_change_1m_rel_to_market_cap: cfg
|
||||
net_pnl_change_1m_rel_to_mcap: cfg
|
||||
.import("net_pnl_change_1m_rel_to_market_cap", Version::new(4))?,
|
||||
realized_cap_delta_extended: cfg.import("realized_cap_delta", Version::new(5))?,
|
||||
cap_delta_extended: cfg.import("realized_cap_delta", Version::new(5))?,
|
||||
investor_price,
|
||||
investor_price_ratio,
|
||||
lower_price_band,
|
||||
@@ -210,24 +208,22 @@ impl RealizedFull {
|
||||
sell_side_risk_ratio,
|
||||
peak_regret,
|
||||
peak_regret_rel_to_realized_cap,
|
||||
realized_cap_rel_to_own_market_cap: cfg
|
||||
.import("realized_cap_rel_to_own_market_cap", v1)?,
|
||||
realized_profit_sum_extended: cfg.import("realized_profit", v1)?,
|
||||
realized_loss_sum_extended: cfg.import("realized_loss", v1)?,
|
||||
realized_profit_to_loss_ratio: cfg
|
||||
.import("realized_profit_to_loss_ratio", v1)?,
|
||||
cap_rel_to_own_mcap: cfg.import("realized_cap_rel_to_own_market_cap", v1)?,
|
||||
profit_sum_extended: cfg.import("realized_profit", v1)?,
|
||||
loss_sum_extended: cfg.import("realized_loss", v1)?,
|
||||
profit_to_loss_ratio: cfg.import("realized_profit_to_loss_ratio", v1)?,
|
||||
value_created_sum_extended,
|
||||
value_destroyed_sum_extended,
|
||||
sopr_extended,
|
||||
sent_in_profit_sum_extended: cfg.import("sent_in_profit", v1)?,
|
||||
sent_in_loss_sum_extended: cfg.import("sent_in_loss", v1)?,
|
||||
realized_price_ratio_percentiles: RatioPerBlockPercentiles::forced_import(
|
||||
price_ratio_percentiles: RatioPerBlockPercentiles::forced_import(
|
||||
cfg.db,
|
||||
&realized_price_name,
|
||||
realized_price_version,
|
||||
cfg.indexes,
|
||||
)?,
|
||||
realized_price_ratio_std_dev: RatioPerBlockStdDevBands::forced_import(
|
||||
price_ratio_std_dev: RatioPerBlockStdDevBands::forced_import(
|
||||
cfg.db,
|
||||
&realized_price_name,
|
||||
realized_price_version,
|
||||
@@ -355,15 +351,14 @@ impl RealizedFull {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.base.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
self.base
|
||||
.compute_rest_part1(blocks, starting_indexes, exit)?;
|
||||
|
||||
self.net_realized_pnl_cumulative
|
||||
.height
|
||||
.compute_cumulative(
|
||||
starting_indexes.height,
|
||||
&self.base.core.net_realized_pnl.height,
|
||||
exit,
|
||||
)?;
|
||||
self.net_pnl_cumulative.height.compute_cumulative(
|
||||
starting_indexes.height,
|
||||
&self.base.core.net_pnl.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.peak_regret
|
||||
.compute_rest(starting_indexes.height, exit)?;
|
||||
@@ -390,10 +385,10 @@ impl RealizedFull {
|
||||
let window_starts = blocks.lookback.window_starts();
|
||||
|
||||
// Extended rolling sum (1w, 1m, 1y) for net_realized_pnl
|
||||
self.net_realized_pnl_sum_extended.compute_rolling_sum(
|
||||
self.net_pnl_sum_extended.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
&self.base.core.net_realized_pnl.height,
|
||||
&self.base.core.net_pnl.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -426,25 +421,25 @@ impl RealizedFull {
|
||||
}
|
||||
|
||||
// Realized P/L rel to realized cap
|
||||
self.realized_profit_rel_to_realized_cap
|
||||
self.profit_rel_to_rcap
|
||||
.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.base.core.minimal.realized_profit.height,
|
||||
&self.base.core.minimal.realized_cap_cents.height,
|
||||
&self.base.core.minimal.profit.height,
|
||||
&self.base.core.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.realized_loss_rel_to_realized_cap
|
||||
self.loss_rel_to_rcap
|
||||
.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.base.core.minimal.realized_loss.height,
|
||||
&self.base.core.minimal.realized_cap_cents.height,
|
||||
&self.base.core.minimal.loss.height,
|
||||
&self.base.core.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.net_realized_pnl_rel_to_realized_cap
|
||||
self.net_pnl_rel_to_rcap
|
||||
.compute_binary::<CentsSigned, Cents, RatioCentsSignedCentsBps32>(
|
||||
starting_indexes.height,
|
||||
&self.base.core.net_realized_pnl.height,
|
||||
&self.base.core.minimal.realized_cap_cents.height,
|
||||
&self.base.core.net_pnl.height,
|
||||
&self.base.core.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -491,8 +486,8 @@ impl RealizedFull {
|
||||
// Gross PnL
|
||||
self.gross_pnl.cents.height.compute_add(
|
||||
starting_indexes.height,
|
||||
&self.base.core.minimal.realized_profit.height,
|
||||
&self.base.core.minimal.realized_loss.height,
|
||||
&self.base.core.minimal.profit.height,
|
||||
&self.base.core.minimal.loss.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -507,23 +502,23 @@ impl RealizedFull {
|
||||
self.net_pnl_delta.compute(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_1m_ago,
|
||||
&self.net_realized_pnl_cumulative.height,
|
||||
&self.net_pnl_cumulative.height,
|
||||
exit,
|
||||
)?;
|
||||
self.net_pnl_delta_extended.compute(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
&self.net_realized_pnl_cumulative.height,
|
||||
&self.net_pnl_cumulative.height,
|
||||
exit,
|
||||
)?;
|
||||
self.net_pnl_change_1m_rel_to_realized_cap
|
||||
self.net_pnl_change_1m_rel_to_rcap
|
||||
.compute_binary::<CentsSigned, Cents, RatioCentsSignedCentsBps32>(
|
||||
starting_indexes.height,
|
||||
&self.net_pnl_delta.change_1m.cents.height,
|
||||
&self.base.core.minimal.realized_cap_cents.height,
|
||||
&self.base.core.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.net_pnl_change_1m_rel_to_market_cap
|
||||
self.net_pnl_change_1m_rel_to_mcap
|
||||
.compute_binary::<CentsSigned, Dollars, RatioCentsSignedDollarsBps32>(
|
||||
starting_indexes.height,
|
||||
&self.net_pnl_delta.change_1m.cents.height,
|
||||
@@ -532,10 +527,10 @@ impl RealizedFull {
|
||||
)?;
|
||||
|
||||
// Realized cap delta extended (24h/1w/1y — 1m is in RealizedCore)
|
||||
self.realized_cap_delta_extended.compute(
|
||||
self.cap_delta_extended.compute(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
&self.base.core.minimal.realized_cap_cents.height,
|
||||
&self.base.core.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -544,7 +539,7 @@ impl RealizedFull {
|
||||
.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.peak_regret.height,
|
||||
&self.base.core.minimal.realized_cap_cents.height,
|
||||
&self.base.core.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -558,7 +553,7 @@ impl RealizedFull {
|
||||
|
||||
self.lower_price_band.cents.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.base.core.minimal.realized_price.cents.height,
|
||||
&self.base.core.minimal.price.cents.height,
|
||||
&self.investor_price.cents.height,
|
||||
|(i, rp, ip, ..)| {
|
||||
let rp = rp.as_u128();
|
||||
@@ -575,7 +570,7 @@ impl RealizedFull {
|
||||
self.upper_price_band.cents.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.investor_price.cents.height,
|
||||
&self.base.core.minimal.realized_price.cents.height,
|
||||
&self.base.core.minimal.price.cents.height,
|
||||
|(i, ip, rp, ..)| {
|
||||
let ip = ip.as_u128();
|
||||
let rp = rp.as_u128();
|
||||
@@ -598,47 +593,49 @@ impl RealizedFull {
|
||||
ssrr.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&rv.height,
|
||||
&self.base.core.minimal.realized_cap_cents.height,
|
||||
&self.base.core.minimal.cap_cents.height,
|
||||
exit,
|
||||
)?;
|
||||
}
|
||||
|
||||
// Extended: realized profit/loss rolling sums (1w, 1m, 1y)
|
||||
self.realized_profit_sum_extended.compute_rolling_sum(
|
||||
self.profit_sum_extended.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
&self.base.core.minimal.realized_profit.height,
|
||||
&self.base.core.minimal.profit.height,
|
||||
exit,
|
||||
)?;
|
||||
self.realized_loss_sum_extended.compute_rolling_sum(
|
||||
self.loss_sum_extended.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&window_starts,
|
||||
&self.base.core.minimal.realized_loss.height,
|
||||
&self.base.core.minimal.loss.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// Realized cap relative to own market cap
|
||||
self.realized_cap_rel_to_own_market_cap
|
||||
self.cap_rel_to_own_mcap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.base.core.minimal.realized_cap.height,
|
||||
&self.base.core.minimal.cap.height,
|
||||
height_to_market_cap,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// Realized profit to loss ratios
|
||||
self.realized_profit_to_loss_ratio._24h.compute_binary::<Cents, Cents, RatioCents64>(
|
||||
starting_indexes.height,
|
||||
&self.base.core.minimal.realized_profit_sum._24h.height,
|
||||
&self.base.core.minimal.realized_loss_sum._24h.height,
|
||||
exit,
|
||||
)?;
|
||||
self.profit_to_loss_ratio
|
||||
._24h
|
||||
.compute_binary::<Cents, Cents, RatioCents64>(
|
||||
starting_indexes.height,
|
||||
&self.base.core.minimal.profit_sum._24h.height,
|
||||
&self.base.core.minimal.loss_sum._24h.height,
|
||||
exit,
|
||||
)?;
|
||||
for ((ratio, profit), loss) in self
|
||||
.realized_profit_to_loss_ratio
|
||||
.profit_to_loss_ratio
|
||||
.as_mut_array_from_1w()
|
||||
.into_iter()
|
||||
.zip(self.realized_profit_sum_extended.as_array())
|
||||
.zip(self.realized_loss_sum_extended.as_array())
|
||||
.zip(self.profit_sum_extended.as_array())
|
||||
.zip(self.loss_sum_extended.as_array())
|
||||
{
|
||||
ratio.compute_binary::<Cents, Cents, RatioCents64>(
|
||||
starting_indexes.height,
|
||||
@@ -648,20 +645,20 @@ impl RealizedFull {
|
||||
)?;
|
||||
}
|
||||
|
||||
self.realized_price_ratio_percentiles.compute(
|
||||
self.price_ratio_percentiles.compute(
|
||||
blocks,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&self.base.core.minimal.realized_price_ratio.ratio.height,
|
||||
&self.base.core.minimal.realized_price.cents.height,
|
||||
&self.base.core.minimal.price_ratio.ratio.height,
|
||||
&self.base.core.minimal.price.cents.height,
|
||||
)?;
|
||||
|
||||
self.realized_price_ratio_std_dev.compute(
|
||||
self.price_ratio_std_dev.compute(
|
||||
blocks,
|
||||
starting_indexes,
|
||||
exit,
|
||||
&self.base.core.minimal.realized_price_ratio.ratio.height,
|
||||
&self.base.core.minimal.realized_price.cents.height,
|
||||
&self.base.core.minimal.price_ratio.ratio.height,
|
||||
&self.base.core.minimal.price.cents.height,
|
||||
)?;
|
||||
|
||||
// Investor price: percentiles
|
||||
|
||||
@@ -3,14 +3,16 @@ use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
BasisPoints32, Bitcoin, Cents, Dollars, Height, Indexes, Sats, StoredF32, Version,
|
||||
};
|
||||
use vecdb::{AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec};
|
||||
use vecdb::{
|
||||
AnyStoredVec, AnyVec, Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode, WritableVec,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
blocks,
|
||||
distribution::state::RealizedOps,
|
||||
internal::{
|
||||
CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative,
|
||||
RatioPerBlock, Identity, LazyPerBlock, Price, RollingWindow24h,
|
||||
CentsUnsignedToDollars, ComputedPerBlock, ComputedPerBlockCumulative, Identity,
|
||||
LazyPerBlock, Price, RatioPerBlock, RollingWindow24h,
|
||||
},
|
||||
prices,
|
||||
};
|
||||
@@ -19,16 +21,16 @@ use crate::distribution::metrics::ImportConfig;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct RealizedMinimal<M: StorageMode = Rw> {
|
||||
pub realized_cap_cents: ComputedPerBlock<Cents, M>,
|
||||
pub realized_profit: ComputedPerBlockCumulative<Cents, M>,
|
||||
pub realized_loss: ComputedPerBlockCumulative<Cents, M>,
|
||||
pub realized_cap: LazyPerBlock<Dollars, Cents>,
|
||||
pub realized_price: Price<ComputedPerBlock<Cents, M>>,
|
||||
pub realized_price_ratio: RatioPerBlock<M>,
|
||||
pub cap_cents: ComputedPerBlock<Cents, M>,
|
||||
pub profit: ComputedPerBlockCumulative<Cents, M>,
|
||||
pub loss: ComputedPerBlockCumulative<Cents, M>,
|
||||
pub cap: LazyPerBlock<Dollars, Cents>,
|
||||
pub price: Price<ComputedPerBlock<Cents, M>>,
|
||||
pub price_ratio: RatioPerBlock<M>,
|
||||
pub mvrv: LazyPerBlock<StoredF32>,
|
||||
|
||||
pub realized_profit_sum: RollingWindow24h<Cents, M>,
|
||||
pub realized_loss_sum: RollingWindow24h<Cents, M>,
|
||||
pub profit_sum: RollingWindow24h<Cents, M>,
|
||||
pub loss_sum: RollingWindow24h<Cents, M>,
|
||||
}
|
||||
|
||||
impl RealizedMinimal {
|
||||
@@ -46,8 +48,7 @@ impl RealizedMinimal {
|
||||
let realized_loss = cfg.import("realized_loss", Version::ZERO)?;
|
||||
|
||||
let realized_price = cfg.import("realized_price", Version::ONE)?;
|
||||
let realized_price_ratio: RatioPerBlock =
|
||||
cfg.import("realized_price", Version::ONE)?;
|
||||
let realized_price_ratio: RatioPerBlock = cfg.import("realized_price", Version::ONE)?;
|
||||
let mvrv = LazyPerBlock::from_lazy::<Identity<StoredF32>, BasisPoints32>(
|
||||
&cfg.name("mvrv"),
|
||||
cfg.version,
|
||||
@@ -58,48 +59,38 @@ impl RealizedMinimal {
|
||||
let realized_loss_sum = cfg.import("realized_loss", Version::ONE)?;
|
||||
|
||||
Ok(Self {
|
||||
realized_cap_cents,
|
||||
realized_profit,
|
||||
realized_loss,
|
||||
realized_cap,
|
||||
realized_price,
|
||||
realized_price_ratio,
|
||||
cap_cents: realized_cap_cents,
|
||||
profit: realized_profit,
|
||||
loss: realized_loss,
|
||||
cap: realized_cap,
|
||||
price: realized_price,
|
||||
price_ratio: realized_price_ratio,
|
||||
mvrv,
|
||||
realized_profit_sum,
|
||||
realized_loss_sum,
|
||||
profit_sum: realized_profit_sum,
|
||||
loss_sum: realized_loss_sum,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
self.realized_cap_cents
|
||||
self.cap_cents
|
||||
.height
|
||||
.len()
|
||||
.min(self.realized_profit.height.len())
|
||||
.min(self.realized_loss.height.len())
|
||||
.min(self.profit.height.len())
|
||||
.min(self.loss.height.len())
|
||||
}
|
||||
|
||||
pub(crate) fn truncate_push(
|
||||
&mut self,
|
||||
height: Height,
|
||||
state: &impl RealizedOps,
|
||||
) -> Result<()> {
|
||||
self.realized_cap_cents
|
||||
.height
|
||||
.truncate_push(height, state.cap())?;
|
||||
self.realized_profit
|
||||
.height
|
||||
.truncate_push(height, state.profit())?;
|
||||
self.realized_loss
|
||||
.height
|
||||
.truncate_push(height, state.loss())?;
|
||||
pub(crate) fn truncate_push(&mut self, height: Height, state: &impl RealizedOps) -> Result<()> {
|
||||
self.cap_cents.height.truncate_push(height, state.cap())?;
|
||||
self.profit.height.truncate_push(height, state.profit())?;
|
||||
self.loss.height.truncate_push(height, state.loss())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
vec![
|
||||
&mut self.realized_cap_cents.height as &mut dyn AnyStoredVec,
|
||||
&mut self.realized_profit.height,
|
||||
&mut self.realized_loss.height,
|
||||
&mut self.cap_cents.height as &mut dyn AnyStoredVec,
|
||||
&mut self.profit.height,
|
||||
&mut self.loss.height,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -109,9 +100,9 @@ impl RealizedMinimal {
|
||||
others: &[&Self],
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
sum_others!(self, starting_indexes, others, exit; realized_cap_cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; realized_profit.height);
|
||||
sum_others!(self, starting_indexes, others, exit; realized_loss.height);
|
||||
sum_others!(self, starting_indexes, others, exit; cap_cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; profit.height);
|
||||
sum_others!(self, starting_indexes, others, exit; loss.height);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -121,20 +112,18 @@ impl RealizedMinimal {
|
||||
starting_indexes: &Indexes,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.realized_profit
|
||||
.compute_rest(starting_indexes.height, exit)?;
|
||||
self.realized_loss
|
||||
.compute_rest(starting_indexes.height, exit)?;
|
||||
self.realized_profit_sum.compute_rolling_sum(
|
||||
self.profit.compute_rest(starting_indexes.height, exit)?;
|
||||
self.loss.compute_rest(starting_indexes.height, exit)?;
|
||||
self.profit_sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&self.realized_profit.height,
|
||||
&self.profit.height,
|
||||
exit,
|
||||
)?;
|
||||
self.realized_loss_sum.compute_rolling_sum(
|
||||
self.loss_sum.compute_rolling_sum(
|
||||
starting_indexes.height,
|
||||
&blocks.lookback.height_24h_ago,
|
||||
&self.realized_loss.height,
|
||||
&self.loss.height,
|
||||
exit,
|
||||
)?;
|
||||
Ok(())
|
||||
@@ -147,9 +136,9 @@ impl RealizedMinimal {
|
||||
height_to_supply: &impl ReadableVec<Height, Bitcoin>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.realized_price.cents.height.compute_transform2(
|
||||
self.price.cents.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.realized_cap_cents.height,
|
||||
&self.cap_cents.height,
|
||||
height_to_supply,
|
||||
|(i, cap_cents, supply, ..)| {
|
||||
let cap = cap_cents.as_u128();
|
||||
@@ -163,10 +152,10 @@ impl RealizedMinimal {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.realized_price_ratio.compute_ratio(
|
||||
self.price_ratio.compute_ratio(
|
||||
starting_indexes,
|
||||
&prices.price.cents.height,
|
||||
&self.realized_price.cents.height,
|
||||
&self.price.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -39,21 +39,21 @@ impl RelativeExtendedOwnMarketCap {
|
||||
self.unrealized_profit_rel_to_own_market_cap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp16>(
|
||||
max_from,
|
||||
&unrealized.unrealized_profit.usd.height,
|
||||
&unrealized.profit.usd.height,
|
||||
own_market_cap,
|
||||
exit,
|
||||
)?;
|
||||
self.unrealized_loss_rel_to_own_market_cap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp32>(
|
||||
max_from,
|
||||
&unrealized.unrealized_loss.usd.height,
|
||||
&unrealized.loss.usd.height,
|
||||
own_market_cap,
|
||||
exit,
|
||||
)?;
|
||||
self.net_unrealized_pnl_rel_to_own_market_cap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBps32>(
|
||||
max_from,
|
||||
&unrealized.net_unrealized_pnl.usd.height,
|
||||
&unrealized.net_pnl.usd.height,
|
||||
own_market_cap,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -39,21 +39,21 @@ impl RelativeExtendedOwnPnl {
|
||||
self.unrealized_profit_rel_to_own_gross_pnl
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp16>(
|
||||
max_from,
|
||||
&unrealized.unrealized_profit.usd.height,
|
||||
&unrealized.profit.usd.height,
|
||||
gross_pnl_usd,
|
||||
exit,
|
||||
)?;
|
||||
self.unrealized_loss_rel_to_own_gross_pnl
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp16>(
|
||||
max_from,
|
||||
&unrealized.unrealized_loss.usd.height,
|
||||
&unrealized.loss.usd.height,
|
||||
gross_pnl_usd,
|
||||
exit,
|
||||
)?;
|
||||
self.net_unrealized_pnl_rel_to_own_gross_pnl
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBps32>(
|
||||
max_from,
|
||||
&unrealized.net_unrealized_pnl.usd.height,
|
||||
&unrealized.net_pnl.usd.height,
|
||||
gross_pnl_usd,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
use brk_error::Result;
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{
|
||||
BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, StoredF32, Version,
|
||||
};
|
||||
use brk_types::{BasisPoints16, BasisPointsSigned32, Dollars, Height, Sats, StoredF32, Version};
|
||||
use vecdb::{Exit, ReadableCloneableVec, ReadableVec, Rw, StorageMode};
|
||||
|
||||
use crate::internal::{
|
||||
Bps32ToFloat, LazyPerBlock, PercentPerBlock, RatioDollarsBp16, RatioDollarsBps32,
|
||||
RatioSatsBp16,
|
||||
Bps32ToFloat, LazyPerBlock, PercentPerBlock, RatioDollarsBp16, RatioDollarsBps32, RatioSatsBp16,
|
||||
};
|
||||
|
||||
use crate::distribution::metrics::{ImportConfig, UnrealizedCore};
|
||||
@@ -46,8 +43,7 @@ impl RelativeFull {
|
||||
Ok(Self {
|
||||
supply_in_profit_rel_to_own_supply: cfg
|
||||
.import("supply_in_profit_rel_to_own_supply", v1)?,
|
||||
supply_in_loss_rel_to_own_supply: cfg
|
||||
.import("supply_in_loss_rel_to_own_supply", v1)?,
|
||||
supply_in_loss_rel_to_own_supply: cfg.import("supply_in_loss_rel_to_own_supply", v1)?,
|
||||
unrealized_profit_rel_to_market_cap: cfg
|
||||
.import("unrealized_profit_rel_to_market_cap", v2)?,
|
||||
unrealized_loss_rel_to_market_cap: cfg
|
||||
@@ -83,21 +79,21 @@ impl RelativeFull {
|
||||
self.unrealized_profit_rel_to_market_cap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp16>(
|
||||
max_from,
|
||||
&unrealized.unrealized_profit.usd.height,
|
||||
&unrealized.profit.usd.height,
|
||||
market_cap,
|
||||
exit,
|
||||
)?;
|
||||
self.unrealized_loss_rel_to_market_cap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBp16>(
|
||||
max_from,
|
||||
&unrealized.unrealized_loss.usd.height,
|
||||
&unrealized.loss.usd.height,
|
||||
market_cap,
|
||||
exit,
|
||||
)?;
|
||||
self.net_unrealized_pnl_rel_to_market_cap
|
||||
.compute_binary::<Dollars, Dollars, RatioDollarsBps32>(
|
||||
max_from,
|
||||
&unrealized.net_unrealized_pnl.usd.height,
|
||||
&unrealized.net_pnl.usd.height,
|
||||
market_cap,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -9,9 +9,7 @@ use crate::{
|
||||
metrics::{ImportConfig, unrealized::UnrealizedMinimal},
|
||||
state::UnrealizedState,
|
||||
},
|
||||
internal::{
|
||||
CentsSubtractToCentsSigned, FiatPerBlock, LazyPerBlock, NegCentsUnsignedToDollars,
|
||||
},
|
||||
internal::{CentsSubtractToCentsSigned, FiatPerBlock, LazyPerBlock, NegCentsUnsignedToDollars},
|
||||
prices,
|
||||
};
|
||||
|
||||
@@ -24,12 +22,10 @@ pub struct UnrealizedCore<M: StorageMode = Rw> {
|
||||
#[traversable(flatten)]
|
||||
pub minimal: UnrealizedMinimal<M>,
|
||||
|
||||
pub unrealized_profit: FiatPerBlock<Cents, M>,
|
||||
pub unrealized_loss: FiatPerBlock<Cents, M>,
|
||||
|
||||
pub neg_unrealized_loss: LazyPerBlock<Dollars, Cents>,
|
||||
|
||||
pub net_unrealized_pnl: FiatPerBlock<CentsSigned, M>,
|
||||
pub profit: FiatPerBlock<Cents, M>,
|
||||
pub loss: FiatPerBlock<Cents, M>,
|
||||
pub neg_loss: LazyPerBlock<Dollars, Cents>,
|
||||
pub net_pnl: FiatPerBlock<CentsSigned, M>,
|
||||
}
|
||||
|
||||
impl UnrealizedCore {
|
||||
@@ -52,18 +48,18 @@ impl UnrealizedCore {
|
||||
|
||||
Ok(Self {
|
||||
minimal,
|
||||
unrealized_profit,
|
||||
unrealized_loss,
|
||||
neg_unrealized_loss,
|
||||
net_unrealized_pnl,
|
||||
profit: unrealized_profit,
|
||||
loss: unrealized_loss,
|
||||
neg_loss: neg_unrealized_loss,
|
||||
net_pnl: net_unrealized_pnl,
|
||||
})
|
||||
}
|
||||
|
||||
pub(crate) fn min_stateful_height_len(&self) -> usize {
|
||||
self.minimal
|
||||
.min_stateful_height_len()
|
||||
.min(self.unrealized_profit.cents.height.len())
|
||||
.min(self.unrealized_loss.cents.height.len())
|
||||
.min(self.profit.cents.height.len())
|
||||
.min(self.loss.cents.height.len())
|
||||
}
|
||||
|
||||
pub(crate) fn truncate_push(
|
||||
@@ -72,11 +68,11 @@ impl UnrealizedCore {
|
||||
height_state: &UnrealizedState,
|
||||
) -> Result<()> {
|
||||
self.minimal.truncate_push(height, height_state)?;
|
||||
self.unrealized_profit
|
||||
self.profit
|
||||
.cents
|
||||
.height
|
||||
.truncate_push(height, height_state.unrealized_profit)?;
|
||||
self.unrealized_loss
|
||||
self.loss
|
||||
.cents
|
||||
.height
|
||||
.truncate_push(height, height_state.unrealized_loss)?;
|
||||
@@ -86,8 +82,8 @@ impl UnrealizedCore {
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
let mut vecs = self.minimal.collect_vecs_mut();
|
||||
vecs.push(&mut self.unrealized_profit.cents.height);
|
||||
vecs.push(&mut self.unrealized_loss.cents.height);
|
||||
vecs.push(&mut self.profit.cents.height);
|
||||
vecs.push(&mut self.loss.cents.height);
|
||||
vecs
|
||||
}
|
||||
|
||||
@@ -101,8 +97,8 @@ impl UnrealizedCore {
|
||||
self.minimal
|
||||
.compute_from_sources(starting_indexes, &minimal_refs, exit)?;
|
||||
|
||||
sum_others!(self, starting_indexes, others, exit; unrealized_profit.cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; unrealized_loss.cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; profit.cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; loss.cents.height);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -117,13 +113,13 @@ impl UnrealizedCore {
|
||||
self.minimal
|
||||
.compute_rest(prices, starting_indexes.height, exit)?;
|
||||
|
||||
self.net_unrealized_pnl
|
||||
self.net_pnl
|
||||
.cents
|
||||
.height
|
||||
.compute_binary::<Cents, Cents, CentsSubtractToCentsSigned>(
|
||||
starting_indexes.height,
|
||||
&self.unrealized_profit.cents.height,
|
||||
&self.unrealized_loss.cents.height,
|
||||
&self.profit.cents.height,
|
||||
&self.loss.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
|
||||
@@ -88,24 +88,30 @@ impl UnrealizedFull {
|
||||
|
||||
self.gross_pnl.cents.height.compute_add(
|
||||
starting_indexes.height,
|
||||
&self.inner.core.unrealized_profit.cents.height,
|
||||
&self.inner.core.unrealized_loss.cents.height,
|
||||
&self.inner.core.profit.cents.height,
|
||||
&self.inner.core.loss.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.invested_capital_in_profit.cents.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.inner.invested_capital_in_profit_raw,
|
||||
|(h, raw, ..)| (h, CentsSats::to_cents(raw)),
|
||||
exit,
|
||||
)?;
|
||||
self.invested_capital_in_profit
|
||||
.cents
|
||||
.height
|
||||
.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.inner.invested_capital_in_profit_raw,
|
||||
|(h, raw, ..)| (h, CentsSats::to_cents(raw)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.invested_capital_in_loss.cents.height.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.inner.invested_capital_in_loss_raw,
|
||||
|(h, raw, ..)| (h, CentsSats::to_cents(raw)),
|
||||
exit,
|
||||
)?;
|
||||
self.invested_capital_in_loss
|
||||
.cents
|
||||
.height
|
||||
.compute_transform(
|
||||
starting_indexes.height,
|
||||
&self.inner.invested_capital_in_loss_raw,
|
||||
|(h, raw, ..)| (h, CentsSats::to_cents(raw)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.compute_rest_extended(prices, starting_indexes, exit)?;
|
||||
Ok(())
|
||||
|
||||
@@ -61,10 +61,10 @@ impl Vecs {
|
||||
|
||||
// 24h, 1w, 1y from extended; 1m from core delta
|
||||
let rcr_rates = [
|
||||
&all_realized.realized_cap_delta_extended.rate_24h.bps.height,
|
||||
&all_realized.realized_cap_delta_extended.rate_1w.bps.height,
|
||||
&all_realized.realized_cap_delta.rate_1m.bps.height,
|
||||
&all_realized.realized_cap_delta_extended.rate_1y.bps.height,
|
||||
&all_realized.cap_delta_extended.rate_24h.bps.height,
|
||||
&all_realized.cap_delta_extended.rate_1w.bps.height,
|
||||
&all_realized.cap_delta.rate_1m.bps.height,
|
||||
&all_realized.cap_delta_extended.rate_1y.bps.height,
|
||||
];
|
||||
|
||||
for i in 0..4 {
|
||||
|
||||
Reference in New Issue
Block a user