mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-07-23 17:08:10 -07:00
global: snapshot
This commit is contained in:
+3
-3
@@ -5,7 +5,7 @@ use brk_types::{Bitcoin, Dollars, Sats, Version};
|
|||||||
use derive_more::{Deref, DerefMut};
|
use derive_more::{Deref, DerefMut};
|
||||||
use vecdb::UnaryTransform;
|
use vecdb::UnaryTransform;
|
||||||
|
|
||||||
use crate::internal::{LazyValueHeight, LazyValueHeightDerivedLast, ValueFromHeightLast};
|
use crate::internal::{LazyValueFromHeight, LazyValueHeightDerivedLast, ValueFromHeightLast};
|
||||||
|
|
||||||
const VERSION: Version = Version::ZERO;
|
const VERSION: Version = Version::ZERO;
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ const VERSION: Version = Version::ZERO;
|
|||||||
#[traversable(merge)]
|
#[traversable(merge)]
|
||||||
pub struct LazyValueFromHeightLast {
|
pub struct LazyValueFromHeightLast {
|
||||||
#[traversable(flatten)]
|
#[traversable(flatten)]
|
||||||
pub height: LazyValueHeight,
|
pub height: LazyValueFromHeight,
|
||||||
#[deref]
|
#[deref]
|
||||||
#[deref_mut]
|
#[deref_mut]
|
||||||
#[traversable(flatten)]
|
#[traversable(flatten)]
|
||||||
@@ -35,7 +35,7 @@ impl LazyValueFromHeightLast {
|
|||||||
let v = version + VERSION;
|
let v = version + VERSION;
|
||||||
|
|
||||||
let height =
|
let height =
|
||||||
LazyValueHeight::from_block_source::<SatsTransform, BitcoinTransform, DollarsTransform>(name, source, v);
|
LazyValueFromHeight::from_block_source::<SatsTransform, BitcoinTransform, DollarsTransform>(name, source, v);
|
||||||
|
|
||||||
let rest =
|
let rest =
|
||||||
LazyValueHeightDerivedLast::from_block_source::<SatsTransform, BitcoinTransform, DollarsTransform>(
|
LazyValueHeightDerivedLast::from_block_source::<SatsTransform, BitcoinTransform, DollarsTransform>(
|
||||||
+8
-8
@@ -1,13 +1,15 @@
|
|||||||
mod by_unit;
|
mod by_unit;
|
||||||
mod constant;
|
mod constant;
|
||||||
mod cumulative;
|
mod cumulative;
|
||||||
mod cumulative_rolling_full;
|
mod cumulative_full;
|
||||||
mod cumulative_rolling_sum;
|
mod cumulative_sum;
|
||||||
mod distribution;
|
mod distribution;
|
||||||
mod full;
|
mod full;
|
||||||
mod last;
|
mod last;
|
||||||
mod lazy_computed_full;
|
mod lazy_computed_full;
|
||||||
|
mod lazy_computed_value_cumulative;
|
||||||
mod lazy_last;
|
mod lazy_last;
|
||||||
|
mod lazy_value_last;
|
||||||
mod percentiles;
|
mod percentiles;
|
||||||
mod price;
|
mod price;
|
||||||
mod ratio;
|
mod ratio;
|
||||||
@@ -18,20 +20,20 @@ mod value_ema;
|
|||||||
mod value_full;
|
mod value_full;
|
||||||
mod value_last;
|
mod value_last;
|
||||||
mod value_last_rolling;
|
mod value_last_rolling;
|
||||||
mod value_lazy_computed_cumulative;
|
|
||||||
mod value_lazy_last;
|
|
||||||
mod value_sum_cumulative;
|
mod value_sum_cumulative;
|
||||||
|
|
||||||
pub use by_unit::*;
|
pub use by_unit::*;
|
||||||
pub use constant::*;
|
pub use constant::*;
|
||||||
pub use cumulative::*;
|
pub use cumulative::*;
|
||||||
pub use cumulative_rolling_full::*;
|
pub use cumulative_full::*;
|
||||||
pub use cumulative_rolling_sum::*;
|
pub use cumulative_sum::*;
|
||||||
pub use distribution::*;
|
pub use distribution::*;
|
||||||
pub use full::*;
|
pub use full::*;
|
||||||
pub use last::*;
|
pub use last::*;
|
||||||
pub use lazy_computed_full::*;
|
pub use lazy_computed_full::*;
|
||||||
|
pub use lazy_computed_value_cumulative::*;
|
||||||
pub use lazy_last::*;
|
pub use lazy_last::*;
|
||||||
|
pub use lazy_value_last::*;
|
||||||
pub use percentiles::*;
|
pub use percentiles::*;
|
||||||
pub use price::*;
|
pub use price::*;
|
||||||
pub use ratio::*;
|
pub use ratio::*;
|
||||||
@@ -42,6 +44,4 @@ pub use value_ema::*;
|
|||||||
pub use value_full::*;
|
pub use value_full::*;
|
||||||
pub use value_last::*;
|
pub use value_last::*;
|
||||||
pub use value_last_rolling::*;
|
pub use value_last_rolling::*;
|
||||||
pub use value_lazy_computed_cumulative::*;
|
|
||||||
pub use value_lazy_last::*;
|
|
||||||
pub use value_sum_cumulative::*;
|
pub use value_sum_cumulative::*;
|
||||||
+2
-2
@@ -12,13 +12,13 @@ const VERSION: Version = Version::ZERO;
|
|||||||
///
|
///
|
||||||
/// All fields are lazy transforms from existing sources - no storage.
|
/// All fields are lazy transforms from existing sources - no storage.
|
||||||
#[derive(Clone, Traversable)]
|
#[derive(Clone, Traversable)]
|
||||||
pub struct LazyValueHeight {
|
pub struct LazyValueFromHeight {
|
||||||
pub sats: LazyVecFrom1<Height, Sats, Height, Sats>,
|
pub sats: LazyVecFrom1<Height, Sats, Height, Sats>,
|
||||||
pub btc: LazyVecFrom1<Height, Bitcoin, Height, Sats>,
|
pub btc: LazyVecFrom1<Height, Bitcoin, Height, Sats>,
|
||||||
pub usd: LazyVecFrom1<Height, Dollars, Height, Dollars>,
|
pub usd: LazyVecFrom1<Height, Dollars, Height, Dollars>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl LazyValueHeight {
|
impl LazyValueFromHeight {
|
||||||
pub(crate) fn from_block_source<SatsTransform, BitcoinTransform, DollarsTransform>(
|
pub(crate) fn from_block_source<SatsTransform, BitcoinTransform, DollarsTransform>(
|
||||||
name: &str,
|
name: &str,
|
||||||
source: &ValueFromHeightLast,
|
source: &ValueFromHeightLast,
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
mod cumulative_full;
|
mod cumulative_full;
|
||||||
mod last;
|
mod last;
|
||||||
mod lazy_last;
|
mod lazy_last;
|
||||||
mod value_lazy_last;
|
mod lazy_value_last;
|
||||||
|
|
||||||
pub use cumulative_full::*;
|
pub use cumulative_full::*;
|
||||||
pub use last::*;
|
pub use last::*;
|
||||||
pub use lazy_last::*;
|
pub use lazy_last::*;
|
||||||
pub use value_lazy_last::*;
|
pub use lazy_value_last::*;
|
||||||
@@ -1,22 +1,34 @@
|
|||||||
mod compute;
|
mod compute;
|
||||||
mod distribution_stats;
|
mod distribution_stats;
|
||||||
mod eager_indexes;
|
mod eager_indexes;
|
||||||
|
mod from_height;
|
||||||
|
mod from_tx;
|
||||||
|
mod group;
|
||||||
|
mod height;
|
||||||
|
mod height_derived;
|
||||||
mod indexes;
|
mod indexes;
|
||||||
mod lazy_eager_indexes;
|
mod lazy_eager_indexes;
|
||||||
mod multi;
|
mod rolling;
|
||||||
mod single;
|
|
||||||
pub(crate) mod sliding_window;
|
pub(crate) mod sliding_window;
|
||||||
mod traits;
|
mod traits;
|
||||||
mod transform;
|
mod transform;
|
||||||
|
mod tx_derived;
|
||||||
|
mod vec;
|
||||||
mod windows;
|
mod windows;
|
||||||
|
|
||||||
pub(crate) use compute::*;
|
pub(crate) use compute::*;
|
||||||
pub(crate) use distribution_stats::*;
|
pub(crate) use distribution_stats::*;
|
||||||
pub(crate) use eager_indexes::*;
|
pub(crate) use eager_indexes::*;
|
||||||
|
pub(crate) use from_height::*;
|
||||||
|
pub(crate) use from_tx::*;
|
||||||
|
pub(crate) use group::*;
|
||||||
|
pub(crate) use height::*;
|
||||||
|
pub(crate) use height_derived::*;
|
||||||
pub(crate) use indexes::*;
|
pub(crate) use indexes::*;
|
||||||
pub(crate) use lazy_eager_indexes::*;
|
pub(crate) use lazy_eager_indexes::*;
|
||||||
pub(crate) use multi::*;
|
pub(crate) use rolling::*;
|
||||||
pub(crate) use single::*;
|
|
||||||
pub(crate) use traits::*;
|
pub(crate) use traits::*;
|
||||||
pub use transform::*;
|
pub use transform::*;
|
||||||
|
pub(crate) use tx_derived::*;
|
||||||
|
pub(crate) use vec::*;
|
||||||
pub(crate) use windows::*;
|
pub(crate) use windows::*;
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
//! Multi-index composite types.
|
|
||||||
|
|
||||||
mod from_height;
|
|
||||||
mod from_tx;
|
|
||||||
mod height_derived;
|
|
||||||
mod tx_derived;
|
|
||||||
|
|
||||||
pub use from_height::*;
|
|
||||||
pub use from_tx::*;
|
|
||||||
pub use height_derived::*;
|
|
||||||
pub use tx_derived::*;
|
|
||||||
-2
@@ -1,10 +1,8 @@
|
|||||||
mod block_windows;
|
|
||||||
mod distribution;
|
mod distribution;
|
||||||
mod full;
|
mod full;
|
||||||
mod value_windows;
|
mod value_windows;
|
||||||
mod windows;
|
mod windows;
|
||||||
|
|
||||||
pub use block_windows::*;
|
|
||||||
pub use distribution::*;
|
pub use distribution::*;
|
||||||
pub use full::*;
|
pub use full::*;
|
||||||
pub use value_windows::*;
|
pub use value_windows::*;
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
//! Single-index types and primitives.
|
|
||||||
|
|
||||||
mod group;
|
|
||||||
mod height;
|
|
||||||
mod rolling;
|
|
||||||
mod vec;
|
|
||||||
|
|
||||||
pub use group::*;
|
|
||||||
pub use height::*;
|
|
||||||
pub use rolling::*;
|
|
||||||
pub use vec::*;
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
//! Block-count-based rolling distribution — 6-block window.
|
|
||||||
|
|
||||||
use brk_error::Result;
|
|
||||||
use brk_traversable::Traversable;
|
|
||||||
use brk_types::Height;
|
|
||||||
use schemars::JsonSchema;
|
|
||||||
use vecdb::{Database, Rw, StorageMode, Version};
|
|
||||||
|
|
||||||
use crate::internal::{ComputedVecValue, Distribution, NumericValue};
|
|
||||||
|
|
||||||
/// Single 6-block rolling window distribution with 8 distribution stat vecs.
|
|
||||||
#[derive(Traversable)]
|
|
||||||
pub struct BlockRollingDistribution<T, M: StorageMode = Rw>
|
|
||||||
where
|
|
||||||
T: ComputedVecValue + PartialOrd + JsonSchema,
|
|
||||||
{
|
|
||||||
#[traversable(rename = "6b")]
|
|
||||||
pub _6b: Distribution<Height, T, M>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> BlockRollingDistribution<T>
|
|
||||||
where
|
|
||||||
T: NumericValue + JsonSchema,
|
|
||||||
{
|
|
||||||
pub(crate) fn forced_import(
|
|
||||||
db: &Database,
|
|
||||||
name: &str,
|
|
||||||
version: Version,
|
|
||||||
) -> Result<Self> {
|
|
||||||
Ok(Self {
|
|
||||||
_6b: Distribution::forced_import(db, &format!("{name}_6b"), version)?,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+26
-3
@@ -13,11 +13,34 @@ use vecdb::{Database, Exit, ReadableVec, Rw, StorageMode, Version};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ComputeIndexes, indexes,
|
ComputeIndexes, indexes,
|
||||||
internal::{
|
internal::{ComputedVecValue, Distribution, NumericValue},
|
||||||
BlockRollingDistribution, ComputedVecValue, Distribution, NumericValue,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// 6-block rolling window distribution with 8 distribution stat vecs.
|
||||||
|
#[derive(Traversable)]
|
||||||
|
pub struct BlockRollingDistribution<T, M: StorageMode = Rw>
|
||||||
|
where
|
||||||
|
T: ComputedVecValue + PartialOrd + JsonSchema,
|
||||||
|
{
|
||||||
|
#[traversable(rename = "6b")]
|
||||||
|
pub _6b: Distribution<Height, T, M>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> BlockRollingDistribution<T>
|
||||||
|
where
|
||||||
|
T: NumericValue + JsonSchema,
|
||||||
|
{
|
||||||
|
pub(crate) fn forced_import(
|
||||||
|
db: &Database,
|
||||||
|
name: &str,
|
||||||
|
version: Version,
|
||||||
|
) -> Result<Self> {
|
||||||
|
Ok(Self {
|
||||||
|
_6b: Distribution::forced_import(db, &format!("{name}_6b"), version)?,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Traversable)]
|
#[derive(Traversable)]
|
||||||
pub struct TxDerivedDistribution<T, M: StorageMode = Rw>
|
pub struct TxDerivedDistribution<T, M: StorageMode = Rw>
|
||||||
where
|
where
|
||||||
Reference in New Issue
Block a user