pub struct FeatureCalculator { /* private fields */ }Expand description
High-performance feature calculator
Implementations§
Source§impl FeatureCalculator
impl FeatureCalculator
Sourcepub fn add_trade(&mut self, trade: &TradeTick)
pub fn add_trade(&mut self, trade: &TradeTick)
Add a trade tick to the internal buffer for feature calculation.
This method maintains a sliding window of trades by:
- Adding the new trade to the buffer
- Keeping the buffer size at most 2x the window size
- When the buffer exceeds 2x window size, it drains the oldest trades
(removes
window_sizetrades from the beginning)
This approach ensures we always have enough historical data for feature calculations while limiting memory usage. The 2x window size allows for efficient batch removal instead of removing one trade at a time.
§Arguments
trade- The trade tick to add to the buffer
Sourcepub fn add_orderbook(&mut self, snapshot: &OrderBookSnapshot)
pub fn add_orderbook(&mut self, snapshot: &OrderBookSnapshot)
Add order book snapshot and calculate features
Sourcepub fn on_orderbook(
&mut self,
snapshot: &OrderBookSnapshot,
) -> OrderBookFeatures
pub fn on_orderbook( &mut self, snapshot: &OrderBookSnapshot, ) -> OrderBookFeatures
Alias for add_orderbook() to maintain backward compatibility
Sourcepub fn on_trade(&mut self, trade: &TradeTick) -> Option<TradeFeatures>
pub fn on_trade(&mut self, trade: &TradeTick) -> Option<TradeFeatures>
Alias for add_trade() to maintain backward compatibility
Sourcepub fn get_features(&self) -> FeatureSnapshot
pub fn get_features(&self) -> FeatureSnapshot
Get current features based on accumulated data
Auto Trait Implementations§
impl Freeze for FeatureCalculator
impl RefUnwindSafe for FeatureCalculator
impl Send for FeatureCalculator
impl Sync for FeatureCalculator
impl Unpin for FeatureCalculator
impl UnwindSafe for FeatureCalculator
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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