Skip to main content

OptionChainAggregator

Struct OptionChainAggregator 

Source
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

Source

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.

Source

pub fn atm_tracker_mut(&mut self) -> &mut AtmTracker

Returns a mutable reference to the ATM tracker.

Source

pub fn instrument_ids(&self) -> Vec<InstrumentId>

Returns the currently active instrument IDs.

Source

pub fn active_ids(&self) -> &HashSet<InstrumentId>

Returns a reference to the active instrument ID set.

Source

pub fn series_id(&self) -> OptionSeriesId

Returns the series ID.

Source

pub fn is_expired(&self, now_ns: UnixNanos) -> bool

Returns true if the given timestamp is at or past the series expiration.

Source

pub fn instruments(&self) -> &HashMap<InstrumentId, (Price, OptionKind)>

Returns a reference to the full instrument set.

Source

pub fn all_instrument_ids(&self) -> Vec<InstrumentId>

Returns all instrument IDs in the full set.

Source

pub fn is_catalog_empty(&self) -> bool

Returns true if the instrument catalog is empty.

Source

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.

Source

pub fn atm_tracker(&self) -> &AtmTracker

Returns a reference to the ATM tracker.

Source

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.

Source

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.

Source

pub fn update_quote(&mut self, quote: &QuoteTick)

Handles an incoming quote tick by updating the accumulator buffers.

Source

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.

Source

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).

Source

pub fn is_buffer_empty(&self) -> bool

Returns true if both buffers are empty.

Source

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.

Source

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§

Source§

impl Debug for OptionChainAggregator

Source§

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

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Ungil for T
where T: Send,