pub trait WsExchange: Send + Sync {
Show 15 methods
// Required methods
fn ws_connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ws_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ws_is_connected(&self) -> bool;
fn ws_state(&self) -> WsConnectionState;
fn watch_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Ticker>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn watch_tickers<'life0, 'life1, 'async_trait>(
&'life0 self,
symbols: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Vec<Ticker>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn watch_order_book<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<OrderBook>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn watch_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Vec<Trade>>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn watch_ohlcv<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
timeframe: Timeframe,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Ohlcv>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn watch_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Balance>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn watch_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Order>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn watch_my_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Trade>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
channel: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
channel: &'life1 str,
symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn subscriptions(&self) -> Vec<String>;
}Expand description
WebSocket exchange trait for real-time data streaming
This trait defines the WebSocket API that exchanges can implement for real-time market data and account updates.
§Thread Safety
All implementations must be Send + Sync to allow safe usage across
thread boundaries.
§Example
use ccxt_core::ws_exchange::WsExchange;
async fn check_connection(exchange: &dyn WsExchange) {
if !exchange.ws_is_connected() {
exchange.ws_connect().await.unwrap();
}
println!("Connection state: {:?}", exchange.ws_state());
}Required Methods§
Sourcefn ws_connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ws_connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Connect to the WebSocket server
Establishes a WebSocket connection to the exchange. If already connected, this may be a no-op or reconnect.
§Errors
Returns an error if the connection fails.
Sourcefn ws_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ws_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Disconnect from the WebSocket server
Closes the WebSocket connection gracefully.
§Errors
Returns an error if disconnection fails.