Skip to main content

LookbackCache

Struct LookbackCache 

Source
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 TradeSnapshot

Fields§

§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: f64

OHLC bounds

§high: f64§low: f64§close: f64§first_volume: f64

First volume value

§total_volume: f64

Total volume (pre-summed for Kyle Lambda, moments, etc.)

§all_prices_finite: bool

Issue #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: bool

Issue #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

Source§

fn clone(&self) -> LookbackCache

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for LookbackCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.