mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-20 23:48:10 -07:00
global: snapshot part 6
This commit is contained in:
@@ -40,9 +40,9 @@ impl ActivityCore {
|
||||
pub(crate) fn min_len(&self) -> usize {
|
||||
self.minimal
|
||||
.min_len()
|
||||
.min(self.coindays_destroyed.base.height.len())
|
||||
.min(self.transfer_volume_in_profit.base.sats.height.len())
|
||||
.min(self.transfer_volume_in_loss.base.sats.height.len())
|
||||
.min(self.coindays_destroyed.block.height.len())
|
||||
.min(self.transfer_volume_in_profit.block.sats.height.len())
|
||||
.min(self.transfer_volume_in_loss.block.sats.height.len())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@@ -51,16 +51,16 @@ impl ActivityCore {
|
||||
state: &CohortState<impl RealizedOps, impl CostBasisOps>,
|
||||
) {
|
||||
self.minimal.push_state(state);
|
||||
self.coindays_destroyed.base.height.push(
|
||||
self.coindays_destroyed.block.height.push(
|
||||
StoredF64::from(Bitcoin::from(state.satdays_destroyed)),
|
||||
);
|
||||
self.transfer_volume_in_profit
|
||||
.base
|
||||
.block
|
||||
.sats
|
||||
.height
|
||||
.push(state.realized.sent_in_profit());
|
||||
self.transfer_volume_in_loss
|
||||
.base
|
||||
.block
|
||||
.sats
|
||||
.height
|
||||
.push(state.realized.sent_in_loss());
|
||||
@@ -68,11 +68,11 @@ impl ActivityCore {
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
let mut vecs = self.minimal.collect_vecs_mut();
|
||||
vecs.push(&mut self.coindays_destroyed.base.height);
|
||||
vecs.push(&mut self.transfer_volume_in_profit.inner.base.sats.height);
|
||||
vecs.push(&mut self.transfer_volume_in_profit.inner.base.cents.height);
|
||||
vecs.push(&mut self.transfer_volume_in_loss.inner.base.sats.height);
|
||||
vecs.push(&mut self.transfer_volume_in_loss.inner.base.cents.height);
|
||||
vecs.push(&mut self.coindays_destroyed.block.height);
|
||||
vecs.push(&mut self.transfer_volume_in_profit.inner.block.sats.height);
|
||||
vecs.push(&mut self.transfer_volume_in_profit.inner.block.cents.height);
|
||||
vecs.push(&mut self.transfer_volume_in_loss.inner.block.sats.height);
|
||||
vecs.push(&mut self.transfer_volume_in_loss.inner.block.cents.height);
|
||||
vecs
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ impl ActivityCore {
|
||||
self.minimal
|
||||
.compute_from_stateful(starting_indexes, &minimal_refs, exit)?;
|
||||
|
||||
sum_others!(self, starting_indexes, others, exit; coindays_destroyed.base.height);
|
||||
sum_others!(self, starting_indexes, others, exit; transfer_volume_in_profit.base.sats.height);
|
||||
sum_others!(self, starting_indexes, others, exit; transfer_volume_in_loss.base.sats.height);
|
||||
sum_others!(self, starting_indexes, others, exit; coindays_destroyed.block.height);
|
||||
sum_others!(self, starting_indexes, others, exit; transfer_volume_in_profit.block.sats.height);
|
||||
sum_others!(self, starting_indexes, others, exit; transfer_volume_in_loss.block.sats.height);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ impl ActivityMinimal {
|
||||
|
||||
pub(crate) fn min_len(&self) -> usize {
|
||||
self.transfer_volume
|
||||
.base
|
||||
.block
|
||||
.sats
|
||||
.height
|
||||
.len()
|
||||
@@ -35,14 +35,14 @@ impl ActivityMinimal {
|
||||
&mut self,
|
||||
state: &CohortState<impl RealizedOps, impl CostBasisOps>,
|
||||
) {
|
||||
self.transfer_volume.base.sats.height.push(state.sent);
|
||||
self.transfer_volume.block.sats.height.push(state.sent);
|
||||
}
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
let inner = &mut self.transfer_volume.inner;
|
||||
vec![
|
||||
&mut inner.base.sats.height as &mut dyn AnyStoredVec,
|
||||
&mut inner.base.cents.height,
|
||||
&mut inner.block.sats.height as &mut dyn AnyStoredVec,
|
||||
&mut inner.block.cents.height,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -52,11 +52,11 @@ impl ActivityMinimal {
|
||||
others: &[&Self],
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.transfer_volume.base.sats.height.compute_sum_of_others(
|
||||
self.transfer_volume.block.sats.height.compute_sum_of_others(
|
||||
starting_indexes.height,
|
||||
&others
|
||||
.iter()
|
||||
.map(|v| &v.transfer_volume.base.sats.height)
|
||||
.map(|v| &v.transfer_volume.block.sats.height)
|
||||
.collect::<Vec<_>>(),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -128,8 +128,8 @@ impl AllCohortMetrics {
|
||||
|
||||
self.asopr.compute_rest_part2(
|
||||
starting_indexes,
|
||||
&self.activity.transfer_volume.base.cents.height,
|
||||
&self.realized.core.sopr.value_destroyed.base.height,
|
||||
&self.activity.transfer_volume.block.cents.height,
|
||||
&self.realized.core.sopr.value_destroyed.block.height,
|
||||
under_1h_value_created,
|
||||
under_1h_value_destroyed,
|
||||
exit,
|
||||
|
||||
@@ -80,8 +80,8 @@ impl ExtendedAdjustedCohortMetrics {
|
||||
|
||||
self.asopr.compute_rest_part2(
|
||||
starting_indexes,
|
||||
&self.inner.activity.transfer_volume.base.cents.height,
|
||||
&self.inner.realized.core.sopr.value_destroyed.base.height,
|
||||
&self.inner.activity.transfer_volume.block.cents.height,
|
||||
&self.inner.realized.core.sopr.value_destroyed.block.height,
|
||||
under_1h_value_created,
|
||||
under_1h_value_destroyed,
|
||||
exit,
|
||||
|
||||
@@ -34,13 +34,13 @@ impl AdjustedSopr {
|
||||
under_1h_value_destroyed: &impl ReadableVec<Height, Cents>,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.transfer_volume.base.height.compute_subtract(
|
||||
self.transfer_volume.block.height.compute_subtract(
|
||||
starting_indexes.height,
|
||||
base_transfer_volume,
|
||||
under_1h_transfer_volume,
|
||||
exit,
|
||||
)?;
|
||||
self.value_destroyed.base.height.compute_subtract(
|
||||
self.value_destroyed.block.height.compute_subtract(
|
||||
starting_indexes.height,
|
||||
base_value_destroyed,
|
||||
under_1h_value_destroyed,
|
||||
|
||||
@@ -54,7 +54,7 @@ impl RealizedCore {
|
||||
let neg_loss_base = LazyPerBlock::from_height_source::<NegCentsUnsignedToDollars>(
|
||||
&cfg.name("neg_realized_loss"),
|
||||
cfg.version + Version::ONE,
|
||||
minimal.loss.base.cents.height.read_only_boxed_clone(),
|
||||
minimal.loss.block.cents.height.read_only_boxed_clone(),
|
||||
cfg.indexes,
|
||||
);
|
||||
|
||||
@@ -107,12 +107,12 @@ impl RealizedCore {
|
||||
#[inline(always)]
|
||||
pub(crate) fn push_state(&mut self, state: &CohortState<impl RealizedOps, impl CostBasisOps>) {
|
||||
self.minimal.push_state(state);
|
||||
self.sopr.value_destroyed.base.height.push(state.realized.value_destroyed());
|
||||
self.sopr.value_destroyed.block.height.push(state.realized.value_destroyed());
|
||||
}
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
let mut vecs = self.minimal.collect_vecs_mut();
|
||||
vecs.push(&mut self.sopr.value_destroyed.base.height);
|
||||
vecs.push(&mut self.sopr.value_destroyed.block.height);
|
||||
vecs
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ impl RealizedCore {
|
||||
self.minimal
|
||||
.compute_from_stateful(starting_indexes, &minimal_refs, exit)?;
|
||||
|
||||
sum_others!(self, starting_indexes, others, exit; sopr.value_destroyed.base.height);
|
||||
sum_others!(self, starting_indexes, others, exit; sopr.value_destroyed.block.height);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -142,10 +142,10 @@ impl RealizedCore {
|
||||
.value_destroyed
|
||||
.compute_rest(starting_indexes.height, exit)?;
|
||||
|
||||
self.net_pnl.base.cents.height.compute_transform2(
|
||||
self.net_pnl.block.cents.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&self.minimal.profit.base.cents.height,
|
||||
&self.minimal.loss.base.cents.height,
|
||||
&self.minimal.profit.block.cents.height,
|
||||
&self.minimal.loss.block.cents.height,
|
||||
|(i, profit, loss, ..)| {
|
||||
(
|
||||
i,
|
||||
|
||||
@@ -183,7 +183,7 @@ impl RealizedFull {
|
||||
.len()
|
||||
.min(self.cap_raw.len())
|
||||
.min(self.investor.cap_raw.len())
|
||||
.min(self.peak_regret.value.base.cents.height.len())
|
||||
.min(self.peak_regret.value.block.cents.height.len())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
@@ -203,7 +203,7 @@ impl RealizedFull {
|
||||
.push(state.realized.investor_cap_raw());
|
||||
self.peak_regret
|
||||
.value
|
||||
.base
|
||||
.block
|
||||
.cents
|
||||
.height
|
||||
.push(state.realized.peak_regret());
|
||||
@@ -214,7 +214,7 @@ impl RealizedFull {
|
||||
vecs.push(&mut self.investor.price.cents.height);
|
||||
vecs.push(&mut self.cap_raw as &mut dyn AnyStoredVec);
|
||||
vecs.push(&mut self.investor.cap_raw as &mut dyn AnyStoredVec);
|
||||
vecs.push(&mut self.peak_regret.value.base.cents.height);
|
||||
vecs.push(&mut self.peak_regret.value.block.cents.height);
|
||||
vecs
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ impl RealizedFull {
|
||||
|
||||
self.peak_regret
|
||||
.value
|
||||
.base
|
||||
.block
|
||||
.cents
|
||||
.height
|
||||
.push(accum.peak_regret());
|
||||
@@ -307,7 +307,7 @@ impl RealizedFull {
|
||||
.to_rcap
|
||||
.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.core.minimal.profit.base.cents.height,
|
||||
&self.core.minimal.profit.block.cents.height,
|
||||
&self.core.minimal.cap.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
@@ -315,7 +315,7 @@ impl RealizedFull {
|
||||
.to_rcap
|
||||
.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.core.minimal.loss.base.cents.height,
|
||||
&self.core.minimal.loss.block.cents.height,
|
||||
&self.core.minimal.cap.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
@@ -323,16 +323,16 @@ impl RealizedFull {
|
||||
.to_rcap
|
||||
.compute_binary::<CentsSigned, Cents, RatioCentsSignedCentsBps32>(
|
||||
starting_indexes.height,
|
||||
&self.core.net_pnl.base.cents.height,
|
||||
&self.core.net_pnl.block.cents.height,
|
||||
&self.core.minimal.cap.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
// Gross PnL
|
||||
self.gross_pnl.base.cents.height.compute_add(
|
||||
self.gross_pnl.block.cents.height.compute_add(
|
||||
starting_indexes.height,
|
||||
&self.core.minimal.profit.base.cents.height,
|
||||
&self.core.minimal.loss.base.cents.height,
|
||||
&self.core.minimal.profit.block.cents.height,
|
||||
&self.core.minimal.loss.block.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
self.gross_pnl.compute_rest(starting_indexes.height, exit)?;
|
||||
@@ -360,7 +360,7 @@ impl RealizedFull {
|
||||
.to_rcap
|
||||
.compute_binary::<Cents, Cents, RatioCentsBp32>(
|
||||
starting_indexes.height,
|
||||
&self.peak_regret.value.base.cents.height,
|
||||
&self.peak_regret.value.block.cents.height,
|
||||
&self.core.minimal.cap.cents.height,
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -62,22 +62,22 @@ impl RealizedMinimal {
|
||||
.cents
|
||||
.height
|
||||
.len()
|
||||
.min(self.profit.base.cents.height.len())
|
||||
.min(self.loss.base.cents.height.len())
|
||||
.min(self.profit.block.cents.height.len())
|
||||
.min(self.loss.block.cents.height.len())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub(crate) fn push_state(&mut self, state: &CohortState<impl RealizedOps, impl CostBasisOps>) {
|
||||
self.cap.cents.height.push(state.realized.cap());
|
||||
self.profit.base.cents.height.push(state.realized.profit());
|
||||
self.loss.base.cents.height.push(state.realized.loss());
|
||||
self.profit.block.cents.height.push(state.realized.profit());
|
||||
self.loss.block.cents.height.push(state.realized.loss());
|
||||
}
|
||||
|
||||
pub(crate) fn collect_vecs_mut(&mut self) -> Vec<&mut dyn AnyStoredVec> {
|
||||
vec![
|
||||
&mut self.cap.cents.height as &mut dyn AnyStoredVec,
|
||||
&mut self.profit.base.cents.height,
|
||||
&mut self.loss.base.cents.height,
|
||||
&mut self.profit.block.cents.height,
|
||||
&mut self.loss.block.cents.height,
|
||||
]
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ impl RealizedMinimal {
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
sum_others!(self, starting_indexes, others, exit; cap.cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; profit.base.cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; loss.base.cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; profit.block.cents.height);
|
||||
sum_others!(self, starting_indexes, others, exit; loss.block.cents.height);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user