pub struct BinanceFuturesProvider { /* private fields */ }Expand description
Binance Futures exchange provider implementation
Implementations§
Source§impl BinanceFuturesProvider
impl BinanceFuturesProvider
Sourcepub fn new(
config: ConnectionConfig,
market_type: BinanceFuturesMarketType,
) -> Self
pub fn new( config: ConnectionConfig, market_type: BinanceFuturesMarketType, ) -> Self
Create a new Binance Futures provider
Source§impl BinanceFuturesProvider
impl BinanceFuturesProvider
Sourcepub async fn disconnect(&mut self) -> Result<()>
pub async fn disconnect(&mut self) -> Result<()>
Disconnect from WebSocket
Sourcepub async fn subscribe_orderbook(
&mut self,
instrument_id: &InstrumentId,
depth: usize,
) -> Result<()>
pub async fn subscribe_orderbook( &mut self, instrument_id: &InstrumentId, depth: usize, ) -> Result<()>
Subscribe to orderbook updates
Sourcepub async fn subscribe_trades(
&mut self,
instrument_id: &InstrumentId,
) -> Result<()>
pub async fn subscribe_trades( &mut self, instrument_id: &InstrumentId, ) -> Result<()>
Subscribe to trade updates
Sourcepub async fn unsubscribe_orderbook(
&mut self,
instrument_id: &InstrumentId,
) -> Result<()>
pub async fn unsubscribe_orderbook( &mut self, instrument_id: &InstrumentId, ) -> Result<()>
Unsubscribe from orderbook updates
Sourcepub async fn unsubscribe_trades(
&mut self,
instrument_id: &InstrumentId,
) -> Result<()>
pub async fn unsubscribe_trades( &mut self, instrument_id: &InstrumentId, ) -> Result<()>
Unsubscribe from trade updates
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Check if connected
Sourcepub fn connection_stats(&self) -> ConnectionStats
pub fn connection_stats(&self) -> ConnectionStats
Get connection statistics
Sourcepub async fn run_with_handler(
&mut self,
handler: Box<dyn DataHandler + Send + Sync>,
) -> Result<()>
pub async fn run_with_handler( &mut self, handler: Box<dyn DataHandler + Send + Sync>, ) -> Result<()>
Run with data handler
Sourcepub async fn fetch_instruments(&self) -> Result<Vec<Box<dyn Instrument>>>
pub async fn fetch_instruments(&self) -> Result<Vec<Box<dyn Instrument>>>
Fetch available instruments
Trait Implementations§
Source§impl Debug for BinanceFuturesProvider
impl Debug for BinanceFuturesProvider
Source§impl HttpClientProvider for BinanceFuturesProvider
impl HttpClientProvider for BinanceFuturesProvider
Source§fn http_client(&self) -> &Client
fn http_client(&self) -> &Client
Returns a reference to the HTTP client
Source§fn create_http_client(config: &ConnectionConfig) -> Client
fn create_http_client(config: &ConnectionConfig) -> Client
Create a new HTTP client with appropriate settings from config
Source§impl MonitorExt for BinanceFuturesProvider
MonitorExt implementation for BinanceFuturesProvider
impl MonitorExt for BinanceFuturesProvider
MonitorExt implementation for BinanceFuturesProvider
Provides advanced monitoring capabilities for HFT trading systems
Source§fn get_instrument_metrics<'life0, 'life1, 'async_trait>(
&'life0 self,
instrument_id: &'life1 InstrumentId,
) -> Pin<Box<dyn Future<Output = Result<InstrumentMetrics>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_instrument_metrics<'life0, 'life1, 'async_trait>(
&'life0 self,
instrument_id: &'life1 InstrumentId,
) -> Pin<Box<dyn Future<Output = Result<InstrumentMetrics>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves comprehensive real-time metrics for a specific trading instrument Read more
Source§fn get_aggregated_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AggregatedMetrics>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_aggregated_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<AggregatedMetrics>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves aggregated metrics across all actively monitored instruments Read more
Source§fn register_metrics_collector<'life0, 'async_trait>(
&'life0 mut self,
_collector: Box<dyn MetricsCollector>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn register_metrics_collector<'life0, 'async_trait>(
&'life0 mut self,
_collector: Box<dyn MetricsCollector>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Registers a custom metrics collector for domain-specific monitoring Read more
Source§fn enable_alert<'life0, 'async_trait>(
&'life0 mut self,
alert_config: AlertConfig,
) -> Pin<Box<dyn Future<Output = Result<AlertHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn enable_alert<'life0, 'async_trait>(
&'life0 mut self,
alert_config: AlertConfig,
) -> Pin<Box<dyn Future<Output = Result<AlertHandle>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Enables a real-time alert for specific monitoring conditions Read more
Source§fn disable_alert<'life0, 'async_trait>(
&'life0 mut self,
_handle: AlertHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn disable_alert<'life0, 'async_trait>(
&'life0 mut self,
_handle: AlertHandle,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Disables an active alert using its handle Read more
Source§fn get_health_status<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HealthStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_health_status<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<HealthStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Retrieves the current health status with detailed component diagnostics Read more
Source§fn start_anomaly_detection<'life0, 'async_trait>(
&'life0 mut self,
_config: AnomalyConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn start_anomaly_detection<'life0, 'async_trait>(
&'life0 mut self,
_config: AnomalyConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Starts anomaly detection for trading patterns and system behavior Read more
Source§fn stop_anomaly_detection<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn stop_anomaly_detection<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Stops all active anomaly detection algorithms Read more
Source§fn get_latency_distribution<'life0, 'life1, 'async_trait>(
&'life0 self,
_instrument_id: &'life1 InstrumentId,
) -> Pin<Box<dyn Future<Output = Result<LatencyDistribution>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_latency_distribution<'life0, 'life1, 'async_trait>(
&'life0 self,
_instrument_id: &'life1 InstrumentId,
) -> Pin<Box<dyn Future<Output = Result<LatencyDistribution>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves detailed latency distribution statistics for an instrument Read more
Source§fn export_prometheus_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn export_prometheus_metrics<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Exports all metrics in Prometheus exposition format Read more
Source§fn reset_statistics<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset_statistics<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Resets all monitoring statistics to their initial state Read more
Source§fn get_trading_metrics<'life0, 'life1, 'async_trait>(
&'life0 self,
_instrument_id: &'life1 InstrumentId,
) -> Pin<Box<dyn Future<Output = Result<TradingMetrics>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_trading_metrics<'life0, 'life1, 'async_trait>(
&'life0 self,
_instrument_id: &'life1 InstrumentId,
) -> Pin<Box<dyn Future<Output = Result<TradingMetrics>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Retrieves advanced trading-specific metrics for an instrument Read more
Source§impl Provider for BinanceFuturesProvider
Provider trait implementation for Binance Futures
impl Provider for BinanceFuturesProvider
Provider trait implementation for Binance Futures
Source§type TradeMessage = AggTradeMessage
type TradeMessage = AggTradeMessage
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 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 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 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 BinanceFuturesProvider
impl !RefUnwindSafe for BinanceFuturesProvider
impl Send for BinanceFuturesProvider
impl Sync for BinanceFuturesProvider
impl Unpin for BinanceFuturesProvider
impl !UnwindSafe for BinanceFuturesProvider
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