pub struct OptionChainAggregator { /* private fields */ }Expand description
Per-series aggregator that accumulates quotes and greeks between snapshots.
Owns mutable accumulator buffers and produces immutable OptionChainSlice
snapshots on each timer tick.
Implementations§
Source§impl OptionChainAggregator
impl OptionChainAggregator
Sourcepub fn new(
series_id: OptionSeriesId,
strike_range: StrikeRange,
atm_tracker: AtmTracker,
instruments: HashMap<InstrumentId, (Price, OptionKind)>,
) -> Self
pub fn new( series_id: OptionSeriesId, strike_range: StrikeRange, atm_tracker: AtmTracker, instruments: HashMap<InstrumentId, (Price, OptionKind)>, ) -> Self
Creates a new aggregator for the given series.
instruments contains ALL instruments for the series. The initial
active_ids subset is resolved from the strike range and the current
ATM price (if available). When no ATM price is set for ATM-based
ranges, all instruments are active.
Sourcepub fn atm_tracker_mut(&mut self) -> &mut AtmTracker
pub fn atm_tracker_mut(&mut self) -> &mut AtmTracker
Returns a mutable reference to the ATM tracker.
Sourcepub fn instrument_ids(&self) -> Vec<InstrumentId>
pub fn instrument_ids(&self) -> Vec<InstrumentId>
Returns the currently active instrument IDs.
Sourcepub fn active_ids(&self) -> &HashSet<InstrumentId>
pub fn active_ids(&self) -> &HashSet<InstrumentId>
Returns a reference to the active instrument ID set.
Sourcepub fn series_id(&self) -> OptionSeriesId
pub fn series_id(&self) -> OptionSeriesId
Returns the series ID.
Sourcepub fn is_expired(&self, now_ns: UnixNanos) -> bool
pub fn is_expired(&self, now_ns: UnixNanos) -> bool
Returns true if the given timestamp is at or past the series expiration.
Sourcepub fn instruments(&self) -> &HashMap<InstrumentId, (Price, OptionKind)>
pub fn instruments(&self) -> &HashMap<InstrumentId, (Price, OptionKind)>
Returns a reference to the full instrument set.
Sourcepub fn all_instrument_ids(&self) -> Vec<InstrumentId>
pub fn all_instrument_ids(&self) -> Vec<InstrumentId>
Returns all instrument IDs in the full set.
Sourcepub fn is_catalog_empty(&self) -> bool
pub fn is_catalog_empty(&self) -> bool
Returns true if the instrument catalog is empty.
Sourcepub fn remove_instrument(&mut self, instrument_id: &InstrumentId) -> bool
pub fn remove_instrument(&mut self, instrument_id: &InstrumentId) -> bool
Permanently removes an instrument from the catalog.
Removes from instruments, active_ids, pending_greeks, and cleans
buffer entries (only if no other instrument shares the same strike+kind).
Returns true if the instrument was found and removed.
Sourcepub fn atm_tracker(&self) -> &AtmTracker
pub fn atm_tracker(&self) -> &AtmTracker
Returns a reference to the ATM tracker.
Sourcepub fn recompute_active_set(&mut self) -> Vec<InstrumentId>
pub fn recompute_active_set(&mut self) -> Vec<InstrumentId>
Recomputes the active instrument set from the current ATM price.
Returns the new active instrument IDs. Used during bootstrap when the first ATM price arrives after deferred subscription setup.
Sourcepub fn add_instrument(
&mut self,
instrument_id: InstrumentId,
strike: Price,
kind: OptionKind,
) -> bool
pub fn add_instrument( &mut self, instrument_id: InstrumentId, strike: Price, kind: OptionKind, ) -> bool
Adds a newly discovered instrument to the series.
Returns true if the instrument was newly inserted. Returns false
if it was already known (no-op). When the new instrument’s strike
falls within the current active range, it is immediately added to
active_ids.
Sourcepub fn update_quote(&mut self, quote: &QuoteTick)
pub fn update_quote(&mut self, quote: &QuoteTick)
Handles an incoming quote tick by updating the accumulator buffers.
Sourcepub fn update_greeks(&mut self, greeks: &OptionGreeks)
pub fn update_greeks(&mut self, greeks: &OptionGreeks)
Handles incoming greeks by updating the accumulator buffers.
If no quote has arrived yet for this instrument (no buffer entry),
the greeks are stored in pending_greeks and will be attached when
the first quote arrives.
Sourcepub fn snapshot(&self, ts_init: UnixNanos) -> OptionChainSlice
pub fn snapshot(&self, ts_init: UnixNanos) -> OptionChainSlice
Creates a point-in-time snapshot from accumulated buffers, applying strike filtering.
Buffers are preserved (keep-latest semantics) so instruments that didn’t quote since the last tick are still included in subsequent snapshots.
§Panics
Panics if strike prices cannot be compared (NaN values).
Sourcepub fn is_buffer_empty(&self) -> bool
pub fn is_buffer_empty(&self) -> bool
Returns true if both buffers are empty.
Sourcepub fn check_rebalance(&self, now_ns: UnixNanos) -> Option<RebalanceAction>
pub fn check_rebalance(&self, now_ns: UnixNanos) -> Option<RebalanceAction>
Checks whether the instrument set should be rebalanced around the current ATM.
Returns None when no rebalancing is needed (fixed ranges, no ATM price,
ATM strike unchanged, hysteresis not exceeded, or cooldown not elapsed).
Returns Some(RebalanceAction) with instrument add/remove lists when the
closest ATM strike shifts past the hysteresis threshold.
Sourcepub fn apply_rebalance(&mut self, action: &RebalanceAction, now_ns: UnixNanos)
pub fn apply_rebalance(&mut self, action: &RebalanceAction, now_ns: UnixNanos)
Applies a rebalance action: updates the active ID set, cleans stale buffers, and records the rebalance timestamp.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for OptionChainAggregator
impl RefUnwindSafe for OptionChainAggregator
impl Send for OptionChainAggregator
impl Sync for OptionChainAggregator
impl Unpin for OptionChainAggregator
impl UnsafeUnpin for OptionChainAggregator
impl UnwindSafe for OptionChainAggregator
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
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