MarketDataProvider

Trait MarketDataProvider 

Source
pub trait MarketDataProvider: Send + Sync {
    // Required methods
    fn subscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        symbols: &'life1 [Symbol],
    ) -> Pin<Box<dyn Future<Output = Result<Receiver<MarketTick>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn unsubscribe<'life0, 'life1, 'async_trait>(
        &'life0 self,
        symbols: &'life1 [Symbol],
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_latest_quote<'life0, 'life1, 'async_trait>(
        &'life0 self,
        symbol: &'life1 Symbol,
    ) -> Pin<Box<dyn Future<Output = Result<MarketTick>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn get_bars<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        symbol: &'life1 Symbol,
        start: DateTime<Utc>,
        end: DateTime<Utc>,
        timeframe: &'life2 str,
    ) -> Pin<Box<dyn Future<Output = Result<Vec<Bar>>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn get_order_book<'life0, 'life1, 'async_trait>(
        &'life0 self,
        symbol: &'life1 Symbol,
    ) -> Pin<Box<dyn Future<Output = Result<OrderBook>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn is_connected<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

Trait for market data providers (Alpaca, Polygon, IEX, etc.)

Implementations should handle connection management, authentication, and data normalization.

Required Methods§

Source

fn subscribe<'life0, 'life1, 'async_trait>( &'life0 self, symbols: &'life1 [Symbol], ) -> Pin<Box<dyn Future<Output = Result<Receiver<MarketTick>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Subscribe to real-time market data for given symbols

Returns a receiver channel that will receive market ticks as they arrive. The provider should handle reconnection and error recovery internally.

§Arguments
  • symbols - List of symbols to subscribe to
§Returns

Receiver channel for market ticks

Source

fn unsubscribe<'life0, 'life1, 'async_trait>( &'life0 self, symbols: &'life1 [Symbol], ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Unsubscribe from market data for given symbols

Source

fn get_latest_quote<'life0, 'life1, 'async_trait>( &'life0 self, symbol: &'life1 Symbol, ) -> Pin<Box<dyn Future<Output = Result<MarketTick>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get latest quote for a symbol

Source

fn get_bars<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, symbol: &'life1 Symbol, start: DateTime<Utc>, end: DateTime<Utc>, timeframe: &'life2 str, ) -> Pin<Box<dyn Future<Output = Result<Vec<Bar>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Get historical bars for a symbol

§Arguments
  • symbol - Trading symbol
  • start - Start timestamp
  • end - End timestamp
  • timeframe - Bar timeframe (e.g., “1Min”, “1Hour”, “1Day”)
Source

fn get_order_book<'life0, 'life1, 'async_trait>( &'life0 self, symbol: &'life1 Symbol, ) -> Pin<Box<dyn Future<Output = Result<OrderBook>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get order book snapshot for a symbol

Source

fn is_connected<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = bool> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Check if the provider is connected and healthy

Implementors§