mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
global: snapshot
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use brk_error::Result;
|
||||
use brk_types::{StoredF32, StoredF64};
|
||||
use brk_types::{BasisPointsSigned32, StoredF64};
|
||||
use vecdb::Exit;
|
||||
|
||||
use super::super::activity;
|
||||
@@ -14,15 +14,15 @@ impl Vecs {
|
||||
activity: &activity::Vecs,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.cointime_adj_inflation_rate.height.compute_transform2(
|
||||
self.cointime_adj_inflation_rate.bps.height.compute_transform2(
|
||||
starting_indexes.height,
|
||||
&activity.activity_to_vaultedness_ratio.height,
|
||||
&supply.inflation.height,
|
||||
|(h, ratio, inflation, ..)| (h, StoredF32::from((*ratio) * f64::from(*inflation))),
|
||||
&supply.inflation_rate.bps.height,
|
||||
|(h, ratio, inflation, ..)| (h, BasisPointsSigned32::from((*ratio) * f64::from(inflation))),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_btc_velocity
|
||||
self.cointime_adj_tx_velocity_btc
|
||||
.height
|
||||
.compute_transform2(
|
||||
starting_indexes.height,
|
||||
@@ -32,7 +32,7 @@ impl Vecs {
|
||||
exit,
|
||||
)?;
|
||||
|
||||
self.cointime_adj_tx_usd_velocity
|
||||
self.cointime_adj_tx_velocity_usd
|
||||
.height
|
||||
.compute_transform2(
|
||||
starting_indexes.height,
|
||||
|
||||
@@ -3,26 +3,29 @@ use brk_types::Version;
|
||||
use vecdb::Database;
|
||||
|
||||
use super::Vecs;
|
||||
use crate::{indexes, internal::ComputedFromHeight};
|
||||
use crate::{
|
||||
indexes,
|
||||
internal::{Bps32ToFloat, Bps32ToPercent, ComputedFromHeight, PercentFromHeight},
|
||||
};
|
||||
|
||||
impl Vecs {
|
||||
pub(crate) fn forced_import(db: &Database, version: Version, indexes: &indexes::Vecs) -> Result<Self> {
|
||||
Ok(Self {
|
||||
cointime_adj_inflation_rate: ComputedFromHeight::forced_import(
|
||||
cointime_adj_inflation_rate: PercentFromHeight::forced_import::<Bps32ToFloat, Bps32ToPercent>(
|
||||
db,
|
||||
"cointime_adj_inflation_rate",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_btc_velocity: ComputedFromHeight::forced_import(
|
||||
cointime_adj_tx_velocity_btc: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_btc_velocity",
|
||||
"cointime_adj_tx_velocity_btc",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
cointime_adj_tx_usd_velocity: ComputedFromHeight::forced_import(
|
||||
cointime_adj_tx_velocity_usd: ComputedFromHeight::forced_import(
|
||||
db,
|
||||
"cointime_adj_tx_usd_velocity",
|
||||
"cointime_adj_tx_velocity_usd",
|
||||
version,
|
||||
indexes,
|
||||
)?,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use brk_traversable::Traversable;
|
||||
use brk_types::{StoredF32, StoredF64};
|
||||
use brk_types::{BasisPointsSigned32, StoredF64};
|
||||
use vecdb::{Rw, StorageMode};
|
||||
|
||||
use crate::internal::ComputedFromHeight;
|
||||
use crate::internal::{ComputedFromHeight, PercentFromHeight};
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub cointime_adj_inflation_rate: ComputedFromHeight<StoredF32, M>,
|
||||
pub cointime_adj_tx_btc_velocity: ComputedFromHeight<StoredF64, M>,
|
||||
pub cointime_adj_tx_usd_velocity: ComputedFromHeight<StoredF64, M>,
|
||||
pub cointime_adj_inflation_rate: PercentFromHeight<BasisPointsSigned32, M>,
|
||||
pub cointime_adj_tx_velocity_btc: ComputedFromHeight<StoredF64, M>,
|
||||
pub cointime_adj_tx_velocity_usd: ComputedFromHeight<StoredF64, M>,
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ impl Vecs {
|
||||
value: &value::Vecs,
|
||||
exit: &Exit,
|
||||
) -> Result<()> {
|
||||
self.vocdd_365d_median.compute_rolling_median_from_starts(
|
||||
self.vocdd_median_1y.compute_rolling_median_from_starts(
|
||||
starting_indexes.height,
|
||||
&blocks.count.height_1y_ago,
|
||||
&value.vocdd.height,
|
||||
@@ -24,7 +24,7 @@ impl Vecs {
|
||||
self.hodl_bank.compute_cumulative_transformed_binary(
|
||||
starting_indexes.height,
|
||||
&prices.price.usd.height,
|
||||
&self.vocdd_365d_median,
|
||||
&self.vocdd_median_1y,
|
||||
|price, median| StoredF64::from(f64::from(price) - f64::from(median)),
|
||||
exit,
|
||||
)?;
|
||||
|
||||
@@ -13,7 +13,7 @@ impl Vecs {
|
||||
) -> Result<Self> {
|
||||
let v1 = version + Version::ONE;
|
||||
Ok(Self {
|
||||
vocdd_365d_median: EagerVec::forced_import(db, "vocdd_365d_median", v1)?,
|
||||
vocdd_median_1y: EagerVec::forced_import(db, "vocdd_median_1y", v1)?,
|
||||
hodl_bank: EagerVec::forced_import(db, "hodl_bank", v1)?,
|
||||
reserve_risk: ComputedFromHeight::forced_import(db, "reserve_risk", v1, indexes)?,
|
||||
})
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::internal::ComputedFromHeight;
|
||||
|
||||
#[derive(Traversable)]
|
||||
pub struct Vecs<M: StorageMode = Rw> {
|
||||
pub vocdd_365d_median: M::Stored<EagerVec<PcoVec<Height, StoredF64>>>,
|
||||
pub vocdd_median_1y: M::Stored<EagerVec<PcoVec<Height, StoredF64>>>,
|
||||
pub hodl_bank: M::Stored<EagerVec<PcoVec<Height, StoredF64>>>,
|
||||
pub reserve_risk: ComputedFromHeight<StoredF64, M>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user