pub struct CoinApiDataClient { /* private fields */ }Expand description
CoinAPI data client streaming order books, quotes, trades, and OHLCV bars for configured native instruments.
Connecting loads the configured instruments, emits them, and retains the CoinAPI symbol_id
of each one for subscriptions and historical requests. Every subscription shares one WebSocket
connection, which replays its scope after a transport reconnect. Instrument refreshes update
precision and REST symbol IDs; subscriptions retain their connect-time symbol IDs until the
data client disconnects and connects again.
Book deltas stream from the full book channel for L2 books and from book_l3 for L3 books,
with sequence gap detection and recovery. Depth snapshots stream from the cheapest of book5,
book20, and book50 that lists the requested depth, ten levels by default. CoinAPI allows one
book channel per connection, so every book subscription must use the same channel.
Implementations§
Source§impl CoinApiDataClient
impl CoinApiDataClient
Sourcepub fn new(client_id: ClientId, config: CoinApiDataClientConfig) -> Result<Self>
pub fn new(client_id: ClientId, config: CoinApiDataClientConfig) -> Result<Self>
Creates a client without connecting.
§Errors
Returns an error if no valid API key resolves from the config or COINAPI_API_KEY, when an
instrument selection is empty, repeats an instrument, or names an instrument that does not
map to its exchange, or when the REST or WebSocket configuration is invalid.
§Panics
Panics if the data event sender is not initialized on this thread.
Trait Implementations§
Source§impl DataClient for CoinApiDataClient
impl DataClient for CoinApiDataClient
Source§fn is_connected(&self) -> bool
fn is_connected(&self) -> bool
true if the client is currently connected.Source§fn is_disconnected(&self) -> bool
fn is_disconnected(&self) -> bool
true if the client is currently disconnected.Source§fn 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,
Source§fn 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,
Source§fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> Result<()>
fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> Result<()>
Source§fn subscribe_book_depth(&mut self, cmd: SubscribeBookDepth) -> Result<()>
fn subscribe_book_depth(&mut self, cmd: SubscribeBookDepth) -> Result<()>
Source§fn subscribe_quotes(&mut self, cmd: SubscribeQuotes) -> Result<()>
fn subscribe_quotes(&mut self, cmd: SubscribeQuotes) -> Result<()>
Source§fn subscribe_trades(&mut self, cmd: SubscribeTrades) -> Result<()>
fn subscribe_trades(&mut self, cmd: SubscribeTrades) -> Result<()>
Source§fn subscribe_bars(&mut self, cmd: SubscribeBars) -> Result<()>
fn subscribe_bars(&mut self, cmd: SubscribeBars) -> Result<()>
Source§fn unsubscribe_book_deltas(&mut self, cmd: &UnsubscribeBookDeltas) -> Result<()>
fn unsubscribe_book_deltas(&mut self, cmd: &UnsubscribeBookDeltas) -> Result<()>
Source§fn unsubscribe_book_depth(&mut self, cmd: &UnsubscribeBookDepth) -> Result<()>
fn unsubscribe_book_depth(&mut self, cmd: &UnsubscribeBookDepth) -> Result<()>
Source§fn unsubscribe_quotes(&mut self, cmd: &UnsubscribeQuotes) -> Result<()>
fn unsubscribe_quotes(&mut self, cmd: &UnsubscribeQuotes) -> Result<()>
Source§fn unsubscribe_trades(&mut self, cmd: &UnsubscribeTrades) -> Result<()>
fn unsubscribe_trades(&mut self, cmd: &UnsubscribeTrades) -> Result<()>
Source§fn unsubscribe_bars(&mut self, cmd: &UnsubscribeBars) -> Result<()>
fn unsubscribe_bars(&mut self, cmd: &UnsubscribeBars) -> Result<()>
Source§fn request_instruments(&self, request: RequestInstruments) -> Result<()>
fn request_instruments(&self, request: RequestInstruments) -> Result<()>
Source§fn request_instrument(&self, request: RequestInstrument) -> Result<()>
fn request_instrument(&self, request: RequestInstrument) -> Result<()>
Source§fn request_book_snapshot(&self, request: RequestBookSnapshot) -> Result<()>
fn request_book_snapshot(&self, request: RequestBookSnapshot) -> Result<()>
Source§fn request_quotes(&self, request: RequestQuotes) -> Result<()>
fn request_quotes(&self, request: RequestQuotes) -> Result<()>
Source§fn request_trades(&self, request: RequestTrades) -> Result<()>
fn request_trades(&self, request: RequestTrades) -> Result<()>
Source§fn request_bars(&self, request: RequestBars) -> Result<()>
fn request_bars(&self, request: RequestBars) -> Result<()>
§fn subscribe(&mut self, cmd: SubscribeCustomData) -> Result<(), Error>
fn subscribe(&mut self, cmd: SubscribeCustomData) -> Result<(), Error>
§fn subscribe_instruments(
&mut self,
cmd: SubscribeInstruments,
) -> Result<(), Error>
fn subscribe_instruments( &mut self, cmd: SubscribeInstruments, ) -> Result<(), Error>
§fn subscribe_instrument(
&mut self,
cmd: SubscribeInstrument,
) -> Result<(), Error>
fn subscribe_instrument( &mut self, cmd: SubscribeInstrument, ) -> Result<(), Error>
§fn subscribe_mark_prices(
&mut self,
cmd: SubscribeMarkPrices,
) -> Result<(), Error>
fn subscribe_mark_prices( &mut self, cmd: SubscribeMarkPrices, ) -> Result<(), Error>
§fn subscribe_index_prices(
&mut self,
cmd: SubscribeIndexPrices,
) -> Result<(), Error>
fn subscribe_index_prices( &mut self, cmd: SubscribeIndexPrices, ) -> Result<(), Error>
§fn subscribe_funding_rates(
&mut self,
cmd: SubscribeFundingRates,
) -> Result<(), Error>
fn subscribe_funding_rates( &mut self, cmd: SubscribeFundingRates, ) -> Result<(), Error>
§fn subscribe_instrument_status(
&mut self,
cmd: SubscribeInstrumentStatus,
) -> Result<(), Error>
fn subscribe_instrument_status( &mut self, cmd: SubscribeInstrumentStatus, ) -> Result<(), Error>
§fn subscribe_instrument_close(
&mut self,
cmd: SubscribeInstrumentClose,
) -> Result<(), Error>
fn subscribe_instrument_close( &mut self, cmd: SubscribeInstrumentClose, ) -> Result<(), Error>
§fn subscribe_option_greeks(
&mut self,
cmd: SubscribeOptionGreeks,
) -> Result<(), Error>
fn subscribe_option_greeks( &mut self, cmd: SubscribeOptionGreeks, ) -> Result<(), Error>
§fn subscribe_blocks(&mut self, cmd: SubscribeBlocks) -> Result<(), Error>
fn subscribe_blocks(&mut self, cmd: SubscribeBlocks) -> Result<(), Error>
§fn subscribe_pool(&mut self, cmd: SubscribePool) -> Result<(), Error>
fn subscribe_pool(&mut self, cmd: SubscribePool) -> Result<(), Error>
§fn subscribe_pool_swaps(&mut self, cmd: SubscribePoolSwaps) -> Result<(), Error>
fn subscribe_pool_swaps(&mut self, cmd: SubscribePoolSwaps) -> Result<(), Error>
§fn subscribe_pool_liquidity_updates(
&mut self,
cmd: SubscribePoolLiquidityUpdates,
) -> Result<(), Error>
fn subscribe_pool_liquidity_updates( &mut self, cmd: SubscribePoolLiquidityUpdates, ) -> Result<(), Error>
§fn subscribe_pool_fee_collects(
&mut self,
cmd: SubscribePoolFeeCollects,
) -> Result<(), Error>
fn subscribe_pool_fee_collects( &mut self, cmd: SubscribePoolFeeCollects, ) -> Result<(), Error>
§fn subscribe_pool_flash_events(
&mut self,
cmd: SubscribePoolFlashEvents,
) -> Result<(), Error>
fn subscribe_pool_flash_events( &mut self, cmd: SubscribePoolFlashEvents, ) -> Result<(), Error>
§fn unsubscribe(&mut self, cmd: &UnsubscribeCustomData) -> Result<(), Error>
fn unsubscribe(&mut self, cmd: &UnsubscribeCustomData) -> Result<(), Error>
§fn unsubscribe_instruments(
&mut self,
cmd: &UnsubscribeInstruments,
) -> Result<(), Error>
fn unsubscribe_instruments( &mut self, cmd: &UnsubscribeInstruments, ) -> Result<(), Error>
§fn unsubscribe_instrument(
&mut self,
cmd: &UnsubscribeInstrument,
) -> Result<(), Error>
fn unsubscribe_instrument( &mut self, cmd: &UnsubscribeInstrument, ) -> Result<(), Error>
§fn unsubscribe_mark_prices(
&mut self,
cmd: &UnsubscribeMarkPrices,
) -> Result<(), Error>
fn unsubscribe_mark_prices( &mut self, cmd: &UnsubscribeMarkPrices, ) -> Result<(), Error>
§fn unsubscribe_index_prices(
&mut self,
cmd: &UnsubscribeIndexPrices,
) -> Result<(), Error>
fn unsubscribe_index_prices( &mut self, cmd: &UnsubscribeIndexPrices, ) -> Result<(), Error>
§fn unsubscribe_funding_rates(
&mut self,
cmd: &UnsubscribeFundingRates,
) -> Result<(), Error>
fn unsubscribe_funding_rates( &mut self, cmd: &UnsubscribeFundingRates, ) -> Result<(), Error>
§fn unsubscribe_instrument_status(
&mut self,
cmd: &UnsubscribeInstrumentStatus,
) -> Result<(), Error>
fn unsubscribe_instrument_status( &mut self, cmd: &UnsubscribeInstrumentStatus, ) -> Result<(), Error>
§fn unsubscribe_instrument_close(
&mut self,
cmd: &UnsubscribeInstrumentClose,
) -> Result<(), Error>
fn unsubscribe_instrument_close( &mut self, cmd: &UnsubscribeInstrumentClose, ) -> Result<(), Error>
§fn unsubscribe_option_greeks(
&mut self,
cmd: &UnsubscribeOptionGreeks,
) -> Result<(), Error>
fn unsubscribe_option_greeks( &mut self, cmd: &UnsubscribeOptionGreeks, ) -> Result<(), Error>
§fn unsubscribe_blocks(&mut self, cmd: &UnsubscribeBlocks) -> Result<(), Error>
fn unsubscribe_blocks(&mut self, cmd: &UnsubscribeBlocks) -> Result<(), Error>
§fn unsubscribe_pool(&mut self, cmd: &UnsubscribePool) -> Result<(), Error>
fn unsubscribe_pool(&mut self, cmd: &UnsubscribePool) -> Result<(), Error>
§fn unsubscribe_pool_swaps(
&mut self,
cmd: &UnsubscribePoolSwaps,
) -> Result<(), Error>
fn unsubscribe_pool_swaps( &mut self, cmd: &UnsubscribePoolSwaps, ) -> Result<(), Error>
§fn unsubscribe_pool_liquidity_updates(
&mut self,
cmd: &UnsubscribePoolLiquidityUpdates,
) -> Result<(), Error>
fn unsubscribe_pool_liquidity_updates( &mut self, cmd: &UnsubscribePoolLiquidityUpdates, ) -> Result<(), Error>
§fn unsubscribe_pool_fee_collects(
&mut self,
cmd: &UnsubscribePoolFeeCollects,
) -> Result<(), Error>
fn unsubscribe_pool_fee_collects( &mut self, cmd: &UnsubscribePoolFeeCollects, ) -> Result<(), Error>
§fn unsubscribe_pool_flash_events(
&mut self,
cmd: &UnsubscribePoolFlashEvents,
) -> Result<(), Error>
fn unsubscribe_pool_flash_events( &mut self, cmd: &UnsubscribePoolFlashEvents, ) -> Result<(), Error>
§fn request_data(&self, request: RequestCustomData) -> Result<(), Error>
fn request_data(&self, request: RequestCustomData) -> Result<(), Error>
§fn request_funding_rates(
&self,
request: RequestFundingRates,
) -> Result<(), Error>
fn request_funding_rates( &self, request: RequestFundingRates, ) -> Result<(), Error>
§fn request_option_chain_reference_price(
&self,
request: RequestOptionChainReferencePrice,
) -> Result<(), Error>
fn request_option_chain_reference_price( &self, request: RequestOptionChainReferencePrice, ) -> Result<(), Error>
§fn request_book_depth(&self, request: RequestBookDepth) -> Result<(), Error>
fn request_book_depth(&self, request: RequestBookDepth) -> Result<(), Error>
Auto Trait Implementations§
impl !RefUnwindSafe for CoinApiDataClient
impl !UnwindSafe for CoinApiDataClient
impl Freeze for CoinApiDataClient
impl Send for CoinApiDataClient
impl Sync for CoinApiDataClient
impl Unpin for CoinApiDataClient
impl UnsafeUnpin for CoinApiDataClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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