Struct BinanceFuturesProvider

Source
pub struct BinanceFuturesProvider { /* private fields */ }
Expand description

Binance Futures exchange provider implementation

Implementations§

Source§

impl BinanceFuturesProvider

Source

pub fn new( config: ConnectionConfig, market_type: BinanceFuturesMarketType, ) -> Self

Create a new Binance Futures provider

Source§

impl BinanceFuturesProvider

Source

pub const fn name(&self) -> &str

Get provider name

Source

pub const fn venue(&self) -> Venue

Get venue

Source

pub async fn connect(&mut self) -> Result<()>

Connect to WebSocket

Source

pub async fn disconnect(&mut self) -> Result<()>

Disconnect from WebSocket

Source

pub async fn subscribe_orderbook( &mut self, instrument_id: &InstrumentId, depth: usize, ) -> Result<()>

Subscribe to orderbook updates

Source

pub async fn subscribe_trades( &mut self, instrument_id: &InstrumentId, ) -> Result<()>

Subscribe to trade updates

Source

pub async fn unsubscribe_orderbook( &mut self, instrument_id: &InstrumentId, ) -> Result<()>

Unsubscribe from orderbook updates

Source

pub async fn unsubscribe_trades( &mut self, instrument_id: &InstrumentId, ) -> Result<()>

Unsubscribe from trade updates

Source

pub fn is_connected(&self) -> bool

Check if connected

Source

pub fn connection_stats(&self) -> ConnectionStats

Get connection statistics

Source

pub async fn run_with_handler( &mut self, handler: Box<dyn DataHandler + Send + Sync>, ) -> Result<()>

Run with data handler

Source

pub async fn fetch_instruments(&self) -> Result<Vec<Box<dyn Instrument>>>

Fetch available instruments

Trait Implementations§

Source§

impl Debug for BinanceFuturesProvider

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl HttpClientProvider for BinanceFuturesProvider

Source§

fn http_client(&self) -> &Client

Returns a reference to the HTTP client
Source§

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

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Retrieves advanced trading-specific metrics for an instrument Read more
Source§

impl Provider for BinanceFuturesProvider

Provider trait implementation for Binance Futures

Source§

type TradeMessage = AggTradeMessage

Exchange-specific raw message type for trades from WebSocket
Source§

type DepthMessage = OrderbookMessage

Exchange-specific raw message type for orderbook updates from WebSocket
Source§

type InstrumentMessage = Value

Exchange-specific raw message type for instrument info
Source§

fn name(&self) -> &'static str

Returns the exchange name as a static String
Source§

fn venue(&self) -> Venue

Returns the venue enum value for this provider
Source§

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

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,

Reset connection (force reconnect) Default implementation does nothing - exchanges should override
Source§

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,

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,

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,

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,

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,

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,

Check if provider is operational Returns true if the provider is functioning correctly
Source§

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>

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

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,