pub struct TradeSnapshot {
pub price: FixedPoint,
pub volume: FixedPoint,
pub turnover: i128,
pub timestamp: i64,
pub is_buyer_maker: bool,
}Expand description
Lightweight snapshot of trade for history buffer
Uses 48 bytes per trade (vs full AggTrade which is larger). For 500 trades: 24 KB memory overhead. Issue #96 Task #190: Cache-optimized field ordering. Reordered to minimize cache line waste and group frequently accessed fields:
- price + volume (always accessed together for feature computation)
- turnover (used immediately after price * volume calculation)
- timestamp (used for time-based metrics)
- is_buyer_maker (metadata, accessed less frequently)
This reduces cache misses by ~2-4% on inter-bar feature computation.
Fields§
§price: FixedPointPrice as fixed-point (hot path: accessed in every feature computation)
volume: FixedPointVolume as fixed-point (hot path: accessed with price for all calculations)
turnover: i128Turnover (price * volume) as i128 (hot path: computed from price/volume immediately)
timestamp: i64Timestamp in microseconds (warm path: used for intensity and temporal metrics)
is_buyer_maker: boolWhether buyer is market maker (metadata: accessed for volume direction)
Trait Implementations§
Source§impl Clone for TradeSnapshot
impl Clone for TradeSnapshot
Source§fn clone(&self) -> TradeSnapshot
fn clone(&self) -> TradeSnapshot
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for TradeSnapshot
impl Debug for TradeSnapshot
Source§impl From<&AggTrade> for TradeSnapshot
impl From<&AggTrade> for TradeSnapshot
Source§fn from(trade: &AggTrade) -> TradeSnapshot
fn from(trade: &AggTrade) -> TradeSnapshot
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for TradeSnapshot
impl RefUnwindSafe for TradeSnapshot
impl Send for TradeSnapshot
impl Sync for TradeSnapshot
impl Unpin for TradeSnapshot
impl UnsafeUnpin for TradeSnapshot
impl UnwindSafe for TradeSnapshot
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
Mutably borrows from an owned value. Read more
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>
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 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>
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