pub struct SpreadQuoteAggregator { /* private fields */ }Expand description
Spread quote aggregator: builds synthetic quotes from leg quotes (Cython parity).
Quote-driven mode (update_interval_seconds == None): emits when all legs have quotes.
Timer-driven mode: emits on timer fire when _has_update is true.
Historical mode: defers timer event at ts_init until after the update.
Implementations§
Source§impl SpreadQuoteAggregator
impl SpreadQuoteAggregator
Sourcepub fn new(
spread_instrument_id: InstrumentId,
legs: &[(InstrumentId, i64)],
is_futures_spread: bool,
price_precision: u8,
size_precision: u8,
handler: Box<dyn FnMut(QuoteTick)>,
clock: Rc<RefCell<dyn Clock>>,
historical_mode: bool,
update_interval_seconds: Option<u64>,
quote_build_delay: u64,
vega_provider: Option<Box<dyn VegaProvider>>,
price_rounder: Option<Box<dyn SpreadPriceRounder>>,
) -> Self
pub fn new( spread_instrument_id: InstrumentId, legs: &[(InstrumentId, i64)], is_futures_spread: bool, price_precision: u8, size_precision: u8, handler: Box<dyn FnMut(QuoteTick)>, clock: Rc<RefCell<dyn Clock>>, historical_mode: bool, update_interval_seconds: Option<u64>, quote_build_delay: u64, vega_provider: Option<Box<dyn VegaProvider>>, price_rounder: Option<Box<dyn SpreadPriceRounder>>, ) -> Self
Creates a new SpreadQuoteAggregator.
§Panics
Panics if legs has fewer than 2 entries or any ratio is zero.
Sourcepub fn set_aggregator_weak(&mut self, weak: Weak<RefCell<Self>>)
pub fn set_aggregator_weak(&mut self, weak: Weak<RefCell<Self>>)
Sets the weak reference to this aggregator (used when starting the timer so the callback can call back).
Prefer Self::prepare_for_timer_mode so the owner passes the owning Rc in one step.
Sourcepub fn prepare_for_timer_mode(&mut self, self_rc: &Rc<RefCell<Self>>)
pub fn prepare_for_timer_mode(&mut self, self_rc: &Rc<RefCell<Self>>)
One-step setup for timer-driven mode (live or historical). Call this with the Rc that owns
this aggregator before feeding any quotes when update_interval_seconds is set. The timer
callback will use the stored weak reference to call back into this aggregator; without this,
Self::start_timer will panic in historical mode or when called with None.
Sourcepub fn set_historical_mode(
&mut self,
historical_mode: bool,
handler: Box<dyn FnMut(QuoteTick)>,
vega_provider: Option<Box<dyn VegaProvider>>,
)
pub fn set_historical_mode( &mut self, historical_mode: bool, handler: Box<dyn FnMut(QuoteTick)>, vega_provider: Option<Box<dyn VegaProvider>>, )
Sets historical mode and handler (and optionally greeks provider when switching).
pub fn set_running(&mut self, is_running: bool)
pub fn set_clock(&mut self, clock: Rc<RefCell<dyn Clock>>)
Sourcepub fn start_timer(&mut self, aggregator_rc: Option<Rc<RefCell<Self>>>)
pub fn start_timer(&mut self, aggregator_rc: Option<Rc<RefCell<Self>>>)
Starts the timer when update_interval_seconds is set (timer-driven mode).
In live mode pass Some(rc) so the weak is set and the timer can call back.
In historical mode the owner must have called Self::prepare_for_timer_mode with the
owning Rc before any quote is processed, then call with None here.
§Panics
Panics if called with None in timer mode without a prior Self::prepare_for_timer_mode call.
Sourcepub fn on_timer_fire(&mut self, ts_event: UnixNanos)
pub fn on_timer_fire(&mut self, ts_event: UnixNanos)
Called when the timer fires (live mode). Builds and sends a spread quote using the timer event timestamp.
Sourcepub fn stop_timer(&mut self)
pub fn stop_timer(&mut self)
Stops the timer when in timer-driven mode.
Sourcepub fn handle_quote_tick(&mut self, tick: QuoteTick)
pub fn handle_quote_tick(&mut self, tick: QuoteTick)
Handles an incoming leg quote (Cython handle_quote_tick).
Sourcepub fn flush_pending_historical_quote(&mut self)
pub fn flush_pending_historical_quote(&mut self)
Flushes the deferred historical timer event, if any.
This is intended for historical request finalization, where we know no more historical quotes will arrive for the requested range and should not require a later live tick just to release the final same-timestamp spread quote.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SpreadQuoteAggregator
impl !RefUnwindSafe for SpreadQuoteAggregator
impl !Send for SpreadQuoteAggregator
impl !Sync for SpreadQuoteAggregator
impl Unpin for SpreadQuoteAggregator
impl UnsafeUnpin for SpreadQuoteAggregator
impl !UnwindSafe for SpreadQuoteAggregator
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