pub struct LookbackCache {
pub prices: SmallVec<[f64; 256]>,
pub volumes: SmallVec<[f64; 256]>,
pub open: f64,
pub high: f64,
pub low: f64,
pub close: f64,
pub first_volume: f64,
pub total_volume: f64,
pub all_prices_finite: bool,
pub all_volumes_finite: bool,
}Expand description
Memoized lookback trade data (Issue #96 Task #99: Float conversion memoization)
Pre-computes all float conversions from fixed-point trades in a single pass.
This cache is reused across all 16 inter-bar feature functions, eliminating
400-2000 redundant .to_f64() calls per bar when inter-bar features enabled.
§Performance Impact
- Single-pass extraction: O(n) fixed cost (not per-feature)
- Eliminated redundant conversions: 2-5% speedup when Tier 1/2 features enabled
- Memory: ~5KB for typical lookback (100-500 trades)
§Example
let cache = extract_lookback_cache(&lookback);
let kyle = compute_kyle_lambda_cached(&cache);
let burstiness = compute_burstiness_scalar(&lookback); // Still uses TradeSnapshotFields§
§prices: SmallVec<[f64; 256]>Pre-computed f64 prices (avoids 400-2000 .price.to_f64() calls)
volumes: SmallVec<[f64; 256]>Pre-computed f64 volumes (avoids 400-2000 .volume.to_f64() calls)
open: f64OHLC bounds
high: f64§low: f64§close: f64§first_volume: f64First volume value
total_volume: f64Total volume (pre-summed for Kyle Lambda, moments, etc.)
all_prices_finite: boolIssue #96 Task #45: All prices are finite (no NaN/Inf) Pre-computed during extraction to eliminate O(n) scan in Tier 3
all_volumes_finite: boolIssue #96 Task #49: All volumes are finite (no NaN/Inf) Pre-computed during extraction for volume moments validation
Trait Implementations§
Source§impl Clone for LookbackCache
impl Clone for LookbackCache
Source§fn clone(&self) -> LookbackCache
fn clone(&self) -> LookbackCache
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for LookbackCache
impl RefUnwindSafe for LookbackCache
impl Send for LookbackCache
impl Sync for LookbackCache
impl Unpin for LookbackCache
impl UnsafeUnpin for LookbackCache
impl UnwindSafe for LookbackCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more