pub trait DataClient {
Show 62 methods
// Required methods
fn client_id(&self) -> ClientId;
fn venue(&self) -> Option<Venue>;
fn start(&mut self) -> Result<()>;
fn stop(&mut self) -> Result<()>;
fn reset(&mut self) -> Result<()>;
fn dispose(&mut self) -> Result<()>;
fn is_connected(&self) -> bool;
fn is_disconnected(&self) -> bool;
// Provided methods
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn subscribe(&mut self, cmd: SubscribeCustomData) -> Result<()> { ... }
fn subscribe_instruments(&mut self, cmd: SubscribeInstruments) -> Result<()> { ... }
fn subscribe_instrument(&mut self, cmd: SubscribeInstrument) -> Result<()> { ... }
fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> Result<()> { ... }
fn subscribe_book_depth10(
&mut self,
cmd: SubscribeBookDepth10,
) -> Result<()> { ... }
fn subscribe_quotes(&mut self, cmd: SubscribeQuotes) -> Result<()> { ... }
fn subscribe_trades(&mut self, cmd: SubscribeTrades) -> Result<()> { ... }
fn subscribe_mark_prices(&mut self, cmd: SubscribeMarkPrices) -> Result<()> { ... }
fn subscribe_index_prices(
&mut self,
cmd: SubscribeIndexPrices,
) -> Result<()> { ... }
fn subscribe_funding_rates(
&mut self,
cmd: SubscribeFundingRates,
) -> Result<()> { ... }
fn subscribe_bars(&mut self, cmd: SubscribeBars) -> Result<()> { ... }
fn subscribe_instrument_status(
&mut self,
cmd: SubscribeInstrumentStatus,
) -> Result<()> { ... }
fn subscribe_instrument_close(
&mut self,
cmd: SubscribeInstrumentClose,
) -> Result<()> { ... }
fn subscribe_option_greeks(
&mut self,
cmd: SubscribeOptionGreeks,
) -> Result<()> { ... }
fn subscribe_blocks(&mut self, cmd: SubscribeBlocks) -> Result<()> { ... }
fn subscribe_pool(&mut self, cmd: SubscribePool) -> Result<()> { ... }
fn subscribe_pool_swaps(&mut self, cmd: SubscribePoolSwaps) -> Result<()> { ... }
fn subscribe_pool_liquidity_updates(
&mut self,
cmd: SubscribePoolLiquidityUpdates,
) -> Result<()> { ... }
fn subscribe_pool_fee_collects(
&mut self,
cmd: SubscribePoolFeeCollects,
) -> Result<()> { ... }
fn subscribe_pool_flash_events(
&mut self,
cmd: SubscribePoolFlashEvents,
) -> Result<()> { ... }
fn unsubscribe(&mut self, cmd: &UnsubscribeCustomData) -> Result<()> { ... }
fn unsubscribe_instruments(
&mut self,
cmd: &UnsubscribeInstruments,
) -> Result<()> { ... }
fn unsubscribe_instrument(
&mut self,
cmd: &UnsubscribeInstrument,
) -> Result<()> { ... }
fn unsubscribe_book_deltas(
&mut self,
cmd: &UnsubscribeBookDeltas,
) -> Result<()> { ... }
fn unsubscribe_book_depth10(
&mut self,
cmd: &UnsubscribeBookDepth10,
) -> Result<()> { ... }
fn unsubscribe_quotes(&mut self, cmd: &UnsubscribeQuotes) -> Result<()> { ... }
fn unsubscribe_trades(&mut self, cmd: &UnsubscribeTrades) -> Result<()> { ... }
fn unsubscribe_mark_prices(
&mut self,
cmd: &UnsubscribeMarkPrices,
) -> Result<()> { ... }
fn unsubscribe_index_prices(
&mut self,
cmd: &UnsubscribeIndexPrices,
) -> Result<()> { ... }
fn unsubscribe_funding_rates(
&mut self,
cmd: &UnsubscribeFundingRates,
) -> Result<()> { ... }
fn unsubscribe_bars(&mut self, cmd: &UnsubscribeBars) -> Result<()> { ... }
fn unsubscribe_instrument_status(
&mut self,
cmd: &UnsubscribeInstrumentStatus,
) -> Result<()> { ... }
fn unsubscribe_instrument_close(
&mut self,
cmd: &UnsubscribeInstrumentClose,
) -> Result<()> { ... }
fn unsubscribe_option_greeks(
&mut self,
cmd: &UnsubscribeOptionGreeks,
) -> Result<()> { ... }
fn unsubscribe_blocks(&mut self, cmd: &UnsubscribeBlocks) -> Result<()> { ... }
fn unsubscribe_pool(&mut self, cmd: &UnsubscribePool) -> Result<()> { ... }
fn unsubscribe_pool_swaps(
&mut self,
cmd: &UnsubscribePoolSwaps,
) -> Result<()> { ... }
fn unsubscribe_pool_liquidity_updates(
&mut self,
cmd: &UnsubscribePoolLiquidityUpdates,
) -> Result<()> { ... }
fn unsubscribe_pool_fee_collects(
&mut self,
cmd: &UnsubscribePoolFeeCollects,
) -> Result<()> { ... }
fn unsubscribe_pool_flash_events(
&mut self,
cmd: &UnsubscribePoolFlashEvents,
) -> Result<()> { ... }
fn request_data(&self, request: RequestCustomData) -> Result<()> { ... }
fn request_instruments(&self, request: RequestInstruments) -> Result<()> { ... }
fn request_instrument(&self, request: RequestInstrument) -> Result<()> { ... }
fn request_book_snapshot(&self, request: RequestBookSnapshot) -> Result<()> { ... }
fn request_quotes(&self, request: RequestQuotes) -> Result<()> { ... }
fn request_trades(&self, request: RequestTrades) -> Result<()> { ... }
fn request_funding_rates(&self, request: RequestFundingRates) -> Result<()> { ... }
fn request_forward_prices(
&self,
request: RequestForwardPrices,
) -> Result<()> { ... }
fn request_bars(&self, request: RequestBars) -> Result<()> { ... }
fn request_book_depth(&self, request: RequestBookDepth) -> Result<()> { ... }
fn request_book_deltas(&self, request: RequestBookDeltas) -> Result<()> { ... }
fn request_pool_snapshot(&self, request: RequestPoolSnapshot) -> Result<()> { ... }
}Expand description
Defines the interface for a data client, managing connections, subscriptions, and requests.
§Thread Safety
Client instances are not intended to be sent across threads. The ?Send bound
allows implementations to hold non-Send state for any Python interop.
Required Methods§
Sourcefn is_connected(&self) -> bool
fn is_connected(&self) -> bool
Returns true if the client is currently connected.
Sourcefn is_disconnected(&self) -> bool
fn is_disconnected(&self) -> bool
Returns true if the client is currently disconnected.
Provided Methods§
Sourcefn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Connects the client to the data provider.
For live clients, this triggers the actual connection to external APIs. For backtest clients, this is a no-op.
§Errors
Returns an error if the connection fails.
Sourcefn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disconnect<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Disconnects the client from the data provider.
For live clients, this closes connections to external APIs. For backtest clients, this is a no-op.
§Errors
Returns an error if the disconnection fails.
Sourcefn subscribe(&mut self, cmd: SubscribeCustomData) -> Result<()>
fn subscribe(&mut self, cmd: SubscribeCustomData) -> Result<()>
Subscribes to custom data types according to the command.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_instruments(&mut self, cmd: SubscribeInstruments) -> Result<()>
fn subscribe_instruments(&mut self, cmd: SubscribeInstruments) -> Result<()>
Subscribes to instruments list for the specified venue.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_instrument(&mut self, cmd: SubscribeInstrument) -> Result<()>
fn subscribe_instrument(&mut self, cmd: SubscribeInstrument) -> Result<()>
Subscribes to data for a single instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> Result<()>
fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> Result<()>
Subscribes to order book delta updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_book_depth10(&mut self, cmd: SubscribeBookDepth10) -> Result<()>
fn subscribe_book_depth10(&mut self, cmd: SubscribeBookDepth10) -> Result<()>
Subscribes to top 10 order book depth updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_quotes(&mut self, cmd: SubscribeQuotes) -> Result<()>
fn subscribe_quotes(&mut self, cmd: SubscribeQuotes) -> Result<()>
Subscribes to quote updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_trades(&mut self, cmd: SubscribeTrades) -> Result<()>
fn subscribe_trades(&mut self, cmd: SubscribeTrades) -> Result<()>
Subscribes to trade updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_mark_prices(&mut self, cmd: SubscribeMarkPrices) -> Result<()>
fn subscribe_mark_prices(&mut self, cmd: SubscribeMarkPrices) -> Result<()>
Subscribes to mark price updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_index_prices(&mut self, cmd: SubscribeIndexPrices) -> Result<()>
fn subscribe_index_prices(&mut self, cmd: SubscribeIndexPrices) -> Result<()>
Subscribes to index price updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_funding_rates(&mut self, cmd: SubscribeFundingRates) -> Result<()>
fn subscribe_funding_rates(&mut self, cmd: SubscribeFundingRates) -> Result<()>
Subscribes to funding rate updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_bars(&mut self, cmd: SubscribeBars) -> Result<()>
fn subscribe_bars(&mut self, cmd: SubscribeBars) -> Result<()>
Subscribes to bar updates of the specified bar type.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_instrument_status(
&mut self,
cmd: SubscribeInstrumentStatus,
) -> Result<()>
fn subscribe_instrument_status( &mut self, cmd: SubscribeInstrumentStatus, ) -> Result<()>
Subscribes to status updates for the specified instrument.
§Errors
Returns an error if the subscribe operation fails.
Sourcefn subscribe_instrument_close(
&mut self,
cmd: SubscribeInstrumentClose,
) -> Result<()>
fn subscribe_instrument_close( &mut self, cmd: SubscribeInstrumentClose, ) -> Result<()>
Subscribes to instrument close events for the specified instrument.
§Errors
Returns an error if the subscription operation fails.
Sourcefn subscribe_option_greeks(&mut self, cmd: SubscribeOptionGreeks) -> Result<()>
fn subscribe_option_greeks(&mut self, cmd: SubscribeOptionGreeks) -> Result<()>
Subscribes to exchange-provided option greeks for the specified instrument.
§Errors
Returns an error if the subscription operation fails.
Sourcefn subscribe_blocks(&mut self, cmd: SubscribeBlocks) -> Result<()>
fn subscribe_blocks(&mut self, cmd: SubscribeBlocks) -> Result<()>
Subscribes to blocks for a specified blockchain.
§Errors
Returns an error if the subscription operation fails.
Sourcefn subscribe_pool(&mut self, cmd: SubscribePool) -> Result<()>
fn subscribe_pool(&mut self, cmd: SubscribePool) -> Result<()>
Subscribes to pool definition updates for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn subscribe_pool_swaps(&mut self, cmd: SubscribePoolSwaps) -> Result<()>
fn subscribe_pool_swaps(&mut self, cmd: SubscribePoolSwaps) -> Result<()>
Subscribes to pool swaps for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn subscribe_pool_liquidity_updates(
&mut self,
cmd: SubscribePoolLiquidityUpdates,
) -> Result<()>
fn subscribe_pool_liquidity_updates( &mut self, cmd: SubscribePoolLiquidityUpdates, ) -> Result<()>
Subscribes to pool liquidity updates for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn subscribe_pool_fee_collects(
&mut self,
cmd: SubscribePoolFeeCollects,
) -> Result<()>
fn subscribe_pool_fee_collects( &mut self, cmd: SubscribePoolFeeCollects, ) -> Result<()>
Subscribes to pool fee collects for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn subscribe_pool_flash_events(
&mut self,
cmd: SubscribePoolFlashEvents,
) -> Result<()>
fn subscribe_pool_flash_events( &mut self, cmd: SubscribePoolFlashEvents, ) -> Result<()>
Subscribes to pool flash loan events for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn unsubscribe(&mut self, cmd: &UnsubscribeCustomData) -> Result<()>
fn unsubscribe(&mut self, cmd: &UnsubscribeCustomData) -> Result<()>
Unsubscribes from custom data types according to the command.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_instruments(
&mut self,
cmd: &UnsubscribeInstruments,
) -> Result<()>
fn unsubscribe_instruments( &mut self, cmd: &UnsubscribeInstruments, ) -> Result<()>
Unsubscribes from instruments list for the specified venue.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_instrument(&mut self, cmd: &UnsubscribeInstrument) -> Result<()>
fn unsubscribe_instrument(&mut self, cmd: &UnsubscribeInstrument) -> Result<()>
Unsubscribes from data for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_book_deltas(&mut self, cmd: &UnsubscribeBookDeltas) -> Result<()>
fn unsubscribe_book_deltas(&mut self, cmd: &UnsubscribeBookDeltas) -> Result<()>
Unsubscribes from order book delta updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_book_depth10(
&mut self,
cmd: &UnsubscribeBookDepth10,
) -> Result<()>
fn unsubscribe_book_depth10( &mut self, cmd: &UnsubscribeBookDepth10, ) -> Result<()>
Unsubscribes from top 10 order book depth updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_quotes(&mut self, cmd: &UnsubscribeQuotes) -> Result<()>
fn unsubscribe_quotes(&mut self, cmd: &UnsubscribeQuotes) -> Result<()>
Unsubscribes from quote updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_trades(&mut self, cmd: &UnsubscribeTrades) -> Result<()>
fn unsubscribe_trades(&mut self, cmd: &UnsubscribeTrades) -> Result<()>
Unsubscribes from trade updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_mark_prices(&mut self, cmd: &UnsubscribeMarkPrices) -> Result<()>
fn unsubscribe_mark_prices(&mut self, cmd: &UnsubscribeMarkPrices) -> Result<()>
Unsubscribes from mark price updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_index_prices(
&mut self,
cmd: &UnsubscribeIndexPrices,
) -> Result<()>
fn unsubscribe_index_prices( &mut self, cmd: &UnsubscribeIndexPrices, ) -> Result<()>
Unsubscribes from index price updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_funding_rates(
&mut self,
cmd: &UnsubscribeFundingRates,
) -> Result<()>
fn unsubscribe_funding_rates( &mut self, cmd: &UnsubscribeFundingRates, ) -> Result<()>
Unsubscribes from funding rate updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_bars(&mut self, cmd: &UnsubscribeBars) -> Result<()>
fn unsubscribe_bars(&mut self, cmd: &UnsubscribeBars) -> Result<()>
Unsubscribes from bar updates of the specified bar type.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_instrument_status(
&mut self,
cmd: &UnsubscribeInstrumentStatus,
) -> Result<()>
fn unsubscribe_instrument_status( &mut self, cmd: &UnsubscribeInstrumentStatus, ) -> Result<()>
Unsubscribes from instrument status updates for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_instrument_close(
&mut self,
cmd: &UnsubscribeInstrumentClose,
) -> Result<()>
fn unsubscribe_instrument_close( &mut self, cmd: &UnsubscribeInstrumentClose, ) -> Result<()>
Unsubscribes from instrument close events for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_option_greeks(
&mut self,
cmd: &UnsubscribeOptionGreeks,
) -> Result<()>
fn unsubscribe_option_greeks( &mut self, cmd: &UnsubscribeOptionGreeks, ) -> Result<()>
Unsubscribes from exchange-provided option greeks for the specified instrument.
§Errors
Returns an error if the unsubscribe operation fails.
Sourcefn unsubscribe_blocks(&mut self, cmd: &UnsubscribeBlocks) -> Result<()>
fn unsubscribe_blocks(&mut self, cmd: &UnsubscribeBlocks) -> Result<()>
Unsubscribes from blocks for a specified blockchain.
§Errors
Returns an error if the subscription operation fails.
Sourcefn unsubscribe_pool(&mut self, cmd: &UnsubscribePool) -> Result<()>
fn unsubscribe_pool(&mut self, cmd: &UnsubscribePool) -> Result<()>
Unsubscribes from pool definition updates for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn unsubscribe_pool_swaps(&mut self, cmd: &UnsubscribePoolSwaps) -> Result<()>
fn unsubscribe_pool_swaps(&mut self, cmd: &UnsubscribePoolSwaps) -> Result<()>
Unsubscribes from swaps for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn unsubscribe_pool_liquidity_updates(
&mut self,
cmd: &UnsubscribePoolLiquidityUpdates,
) -> Result<()>
fn unsubscribe_pool_liquidity_updates( &mut self, cmd: &UnsubscribePoolLiquidityUpdates, ) -> Result<()>
Unsubscribes from pool liquidity updates for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn unsubscribe_pool_fee_collects(
&mut self,
cmd: &UnsubscribePoolFeeCollects,
) -> Result<()>
fn unsubscribe_pool_fee_collects( &mut self, cmd: &UnsubscribePoolFeeCollects, ) -> Result<()>
Unsubscribes from pool fee collects for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn unsubscribe_pool_flash_events(
&mut self,
cmd: &UnsubscribePoolFlashEvents,
) -> Result<()>
fn unsubscribe_pool_flash_events( &mut self, cmd: &UnsubscribePoolFlashEvents, ) -> Result<()>
Unsubscribes from pool flash loan events for a specified AMM pool.
§Errors
Returns an error if the subscription operation fails.
Sourcefn request_data(&self, request: RequestCustomData) -> Result<()>
fn request_data(&self, request: RequestCustomData) -> Result<()>
Sourcefn request_instruments(&self, request: RequestInstruments) -> Result<()>
fn request_instruments(&self, request: RequestInstruments) -> Result<()>
Requests a list of instruments from the provider for a given venue.
§Errors
Returns an error if the instruments request fails.
Sourcefn request_instrument(&self, request: RequestInstrument) -> Result<()>
fn request_instrument(&self, request: RequestInstrument) -> Result<()>
Requests detailed data for a single instrument.
§Errors
Returns an error if the instrument request fails.
Sourcefn request_book_snapshot(&self, request: RequestBookSnapshot) -> Result<()>
fn request_book_snapshot(&self, request: RequestBookSnapshot) -> Result<()>
Requests a snapshot of the order book for a specified instrument.
§Errors
Returns an error if the book snapshot request fails.
Sourcefn request_quotes(&self, request: RequestQuotes) -> Result<()>
fn request_quotes(&self, request: RequestQuotes) -> Result<()>
Requests historical or streaming quote data for a specified instrument.
§Errors
Returns an error if the quotes request fails.
Sourcefn request_trades(&self, request: RequestTrades) -> Result<()>
fn request_trades(&self, request: RequestTrades) -> Result<()>
Requests historical or streaming trade data for a specified instrument.
§Errors
Returns an error if the trades request fails.
Sourcefn request_funding_rates(&self, request: RequestFundingRates) -> Result<()>
fn request_funding_rates(&self, request: RequestFundingRates) -> Result<()>
Requests historical or streaming funding rate data for a specified instrument.
§Errors
Returns an error if the trades request fails.
Sourcefn request_forward_prices(&self, request: RequestForwardPrices) -> Result<()>
fn request_forward_prices(&self, request: RequestForwardPrices) -> Result<()>
Requests forward/underlying prices for derivatives instruments.
§Errors
Returns an error if the forward prices request fails.
Sourcefn request_bars(&self, request: RequestBars) -> Result<()>
fn request_bars(&self, request: RequestBars) -> Result<()>
Requests historical or streaming bar data for a specified instrument and bar type.
§Errors
Returns an error if the bars request fails.
Sourcefn request_book_depth(&self, request: RequestBookDepth) -> Result<()>
fn request_book_depth(&self, request: RequestBookDepth) -> Result<()>
Requests historical order book depth data for a specified instrument.
§Errors
Returns an error if the order book depths request fails.
Sourcefn request_book_deltas(&self, request: RequestBookDeltas) -> Result<()>
fn request_book_deltas(&self, request: RequestBookDeltas) -> Result<()>
Requests historical order book delta data for a specified instrument.
§Errors
Returns an error if the order book deltas request fails.
Sourcefn request_pool_snapshot(&self, request: RequestPoolSnapshot) -> Result<()>
fn request_pool_snapshot(&self, request: RequestPoolSnapshot) -> Result<()>
Requests a snapshot of a specific AMM pool.
§Errors
Returns an error if the pool snapshot request fails.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".