pub struct BinanceSpotProvider { /* private fields */ }Expand description
Binance Spot exchange provider implementation
Implementations§
Source§impl BinanceSpotProvider
impl BinanceSpotProvider
Sourcepub fn with_config(config: Option<ConnectionConfig>) -> Self
pub fn with_config(config: Option<ConnectionConfig>) -> Self
Create a new Binance Spot provider with custom configuration
Trait Implementations§
Source§impl Debug for BinanceSpotProvider
impl Debug for BinanceSpotProvider
Source§impl Default for BinanceSpotProvider
impl Default for BinanceSpotProvider
Source§impl Provider for BinanceSpotProvider
impl Provider for BinanceSpotProvider
Source§type TradeMessage = TradeMessage
type TradeMessage = TradeMessage
Exchange-specific raw message type for trades from WebSocket
Source§type DepthMessage = OrderbookMessage
type DepthMessage = OrderbookMessage
Exchange-specific raw message type for orderbook updates from WebSocket
Source§type InstrumentMessage = Value
type InstrumentMessage = Value
Exchange-specific raw message type for instrument info
Source§fn config(&self) -> &ConnectionConfig
fn config(&self) -> &ConnectionConfig
Returns reference to the connection configuration
Source§fn init<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn init<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Initialize the provider with any necessary setup steps
This method should be called before using other methods
Source§fn shutdown<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn shutdown<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Close all connections and clean up resources
Source§fn subscribe_trades<'life0, 'async_trait>(
&'life0 self,
symbols: SmallVec<[String; 8]>,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::TradeMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_trades<'life0, 'async_trait>(
&'life0 self,
symbols: SmallVec<[String; 8]>,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::TradeMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribe to trade data stream for multiple symbols
Returns a channel receiver for trade messages
Uses SmallVec to avoid heap allocations for small numbers of symbols
Source§fn unsubscribe_trades<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn unsubscribe_trades<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Unsubscribe from trade data
Source§fn subscribe_orderbook<'life0, 'async_trait>(
&'life0 self,
symbols: SmallVec<[String; 8]>,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::DepthMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_orderbook<'life0, 'async_trait>(
&'life0 self,
symbols: SmallVec<[String; 8]>,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::DepthMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribe to orderbook depth data for multiple symbols
Returns a channel receiver for depth messages
Uses SmallVec to avoid heap allocations for small numbers of symbols
Source§fn unsubscribe_orderbook<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn unsubscribe_orderbook<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Unsubscribe from orderbook depth data
Source§fn get_instruments<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Box<dyn Instrument>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_instruments<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Vec<Box<dyn Instrument>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get all available trading instruments from the exchange
Source§fn get_historical_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: &'life1 str,
_limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<MarketTrade>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_historical_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: &'life1 str,
_limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<Vec<MarketTrade>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get historical trades for a symbol
Optionally limit the number of trades returned
Source§fn get_orderbook_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
depth: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<OrderBookSnapshot>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_orderbook_snapshot<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
depth: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<OrderBookSnapshot>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get current orderbook snapshot for a symbol
Optionally specify the depth of the orderbook
Source§fn get_realtime_orderbook<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<SharedSimdOrderBook>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_realtime_orderbook<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<SharedSimdOrderBook>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Get realtime shared orderbook for a symbol
Returns a thread-safe shared orderbook that’s kept up-to-date
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,
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 provider is connected to exchange
Default implementation returns false - exchanges should override
Source§fn connection_status<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ConnectionState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn connection_status<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ConnectionState> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get detailed connection status
Default implementation returns Disconnected - exchanges should override
Source§fn get_stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ConnectionStats> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_stats<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ConnectionStats> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get connection statistics for monitoring
Default implementation returns empty stats - exchanges should override
Source§fn ping<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ping<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<u64>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Ping the exchange to keep the connection alive
Returns round-trip time in nanoseconds
Default implementation returns 0 - exchanges should override
Source§fn reset_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset_connection<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reset connection (force reconnect)
Default implementation does nothing - exchanges should override
Source§fn get_rate_limits(&self) -> Vec<RateLimit>
fn get_rate_limits(&self) -> Vec<RateLimit>
Get the exchange-specific rate limits
Default implementation returns empty vector - exchanges should override
Source§fn start_provide_depth<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::DepthMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start_provide_depth<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::DepthMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start providing depth data
Returns a receiver for depth messages
Default implementation returns error - exchanges should override
Source§fn stop_provide_depth<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_provide_depth<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop providing depth data
Default implementation does nothing
Source§fn start_provide_trade<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::TradeMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start_provide_trade<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Receiver<Self::TradeMessage>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Start providing trade data
Returns a receiver for trade messages
Default implementation returns error - exchanges should override
Source§fn stop_provide_trade<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_provide_trade<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stop providing trade data
Default implementation does nothing
Source§fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Check if provider is operational
Returns true if the provider is functioning correctly
Source§fn convert_exchange_timestamp(&self, exchange_timestamp: u64) -> u64
fn convert_exchange_timestamp(&self, exchange_timestamp: u64) -> u64
High-performance timestamp conversion method
Uses cached timestamp conversions when possible and provides optimized conversion
when timestamps are a known format. Read more
Source§fn convert_iso8601_timestamp(&self, iso_timestamp: &str) -> Option<u64>
fn convert_iso8601_timestamp(&self, iso_timestamp: &str) -> Option<u64>
Convert ISO8601 timestamp String to nanoseconds with caching for frequent values
This method should be used for exchanges that provide timestamps as ISO8601 strings
such as Coinbase.
Source§fn current_time_nanos(&self) -> u64
fn current_time_nanos(&self) -> u64
Get current time in nanoseconds from the provider’s clock
This method uses the shared clock to ensure consistent timekeeping
across all parts of the exchange provider.
Auto Trait Implementations§
impl Freeze for BinanceSpotProvider
impl !RefUnwindSafe for BinanceSpotProvider
impl Send for BinanceSpotProvider
impl Sync for BinanceSpotProvider
impl Unpin for BinanceSpotProvider
impl !UnwindSafe for BinanceSpotProvider
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
Mutably borrows from an owned value. Read more