mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 07:09:59 -07:00
global: snapshot
This commit is contained in:
@@ -7,7 +7,7 @@ use brk_types::Version;
|
||||
use schemars::JsonSchema;
|
||||
use vecdb::{LazyVecFrom1, UnaryTransform, VecIndex};
|
||||
|
||||
use crate::internal::{ComputedVecValue, Full};
|
||||
use crate::internal::{ComputedVecValue, Distribution, Full};
|
||||
|
||||
use super::LazyPercentiles;
|
||||
|
||||
@@ -61,4 +61,33 @@ where
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_distribution<F: UnaryTransform<S1T, T>>(
|
||||
name: &str,
|
||||
version: Version,
|
||||
source: &Distribution<I, S1T>,
|
||||
) -> Self {
|
||||
Self {
|
||||
average: LazyVecFrom1::transformed::<F>(
|
||||
&format!("{name}_average"),
|
||||
version,
|
||||
source.boxed_average(),
|
||||
),
|
||||
min: LazyVecFrom1::transformed::<F>(
|
||||
&format!("{name}_min"),
|
||||
version,
|
||||
source.boxed_min(),
|
||||
),
|
||||
max: LazyVecFrom1::transformed::<F>(
|
||||
&format!("{name}_max"),
|
||||
version,
|
||||
source.boxed_max(),
|
||||
),
|
||||
percentiles: LazyPercentiles::from_percentiles::<F>(
|
||||
name,
|
||||
version,
|
||||
&source.percentiles,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
use brk_types::{Cents, Dollars};
|
||||
use vecdb::UnaryTransform;
|
||||
|
||||
pub struct CentsToDollars;
|
||||
|
||||
impl UnaryTransform<Cents, Dollars> for CentsToDollars {
|
||||
#[inline(always)]
|
||||
fn apply(cents: Cents) -> Dollars {
|
||||
Dollars::from(cents)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
mod cents_to_dollars;
|
||||
mod close_price_times_ratio;
|
||||
mod close_price_times_sats;
|
||||
mod difference_f32;
|
||||
@@ -37,6 +38,7 @@ mod volatility_sqrt365;
|
||||
mod volatility_sqrt7;
|
||||
mod weight_to_fullness;
|
||||
|
||||
pub use cents_to_dollars::*;
|
||||
pub use close_price_times_ratio::*;
|
||||
pub use close_price_times_sats::*;
|
||||
pub use difference_f32::*;
|
||||
|
||||
Reference in New Issue
Block a user