Skip to main content

QuoteSource

Trait QuoteSource 

Source
pub trait QuoteSource: Send + Sync {
    // Required methods
    fn poll_quotes<'life0, 'life1, 'async_trait>(
        &'life0 self,
        instruments: &'life1 [InstrumentId],
    ) -> Pin<Box<dyn Future<Output = Vec<Quote>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn last_quote(&self, instrument: &InstrumentId) -> Option<Quote>;
    fn set_time(&mut self, time_ms: i64);
    fn current_time_ms(&self) -> i64;
}
Expand description

Trait for providing quote data.

This abstraction allows different quote sources to be plugged in:

  • Mock quotes for testing
  • Live quotes from real exchange
  • Historical quotes from CSV

Required Methods§

Source

fn poll_quotes<'life0, 'life1, 'async_trait>( &'life0 self, instruments: &'life1 [InstrumentId], ) -> Pin<Box<dyn Future<Output = Vec<Quote>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get current quotes for the given instruments

Source

fn last_quote(&self, instrument: &InstrumentId) -> Option<Quote>

Get the last known quote for an instrument (if cached)

Source

fn set_time(&mut self, time_ms: i64)

Update time (for simulation purposes)

Source

fn current_time_ms(&self) -> i64

Get current time

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§