pub struct OkxWs { /* private fields */ }Expand description
OKX WebSocket client.
Provides real-time data streaming for OKX exchange.
Implementations§
Source§impl OkxWs
impl OkxWs
Sourcepub async fn disconnect(&self) -> Result<()>
pub async fn disconnect(&self) -> Result<()>
Disconnects from the WebSocket server.
Sourcepub fn state(&self) -> WsConnectionState
pub fn state(&self) -> WsConnectionState
Returns the current connection state.
Sourcepub fn is_connected(&self) -> bool
pub fn is_connected(&self) -> bool
Checks if the WebSocket is connected.
Sourcepub async fn subscribe_ticker(&self, symbol: &str) -> Result<()>
pub async fn subscribe_ticker(&self, symbol: &str) -> Result<()>
Subscribes to a ticker stream.
§Arguments
symbol- Trading pair symbol in OKX format (e.g., “BTC-USDT”)
Sourcepub async fn subscribe_tickers(&self, symbols: &[String]) -> Result<()>
pub async fn subscribe_tickers(&self, symbols: &[String]) -> Result<()>
Subscribes to multiple ticker streams.
§Arguments
symbols- List of trading pair symbols (e.g.,["BTC-USDT", "ETH-USDT"])
Sourcepub async fn watch_tickers(
&self,
symbols: &[String],
) -> Result<MessageStream<Vec<Ticker>>>
pub async fn watch_tickers( &self, symbols: &[String], ) -> Result<MessageStream<Vec<Ticker>>>
Sourcepub async fn subscribe_orderbook(&self, symbol: &str, depth: u32) -> Result<()>
pub async fn subscribe_orderbook(&self, symbol: &str, depth: u32) -> Result<()>
depth- Orderbook depth (5, 50, or 400)
Sourcepub async fn subscribe_trades(&self, symbol: &str) -> Result<()>
pub async fn subscribe_trades(&self, symbol: &str) -> Result<()>
Subscribes to a trades stream.
§Arguments
symbol- Trading pair symbol in OKX format (e.g., “BTC-USDT”)
Sourcepub async fn subscribe_kline(&self, symbol: &str, interval: &str) -> Result<()>
pub async fn subscribe_kline(&self, symbol: &str, interval: &str) -> Result<()>
Subscribes to a kline/candlestick stream.
§Arguments
symbol- Trading pair symbol in OKX format (e.g., “BTC-USDT”)interval- Kline interval (e.g., “1m”, “5m”, “1H”, “1D”)
Sourcepub async fn unsubscribe(&self, stream_name: String) -> Result<()>
pub async fn unsubscribe(&self, stream_name: String) -> Result<()>
Sourcepub async fn subscriptions(&self) -> Vec<String>
pub async fn subscriptions(&self) -> Vec<String>
Returns the list of active subscriptions.
Sourcepub async fn watch_ticker(
&self,
symbol: &str,
market: Option<Market>,
) -> Result<MessageStream<Ticker>>
pub async fn watch_ticker( &self, symbol: &str, market: Option<Market>, ) -> Result<MessageStream<Ticker>>
Sourcepub async fn watch_order_book(
&self,
symbol: &str,
limit: Option<u32>,
) -> Result<MessageStream<OrderBook>>
pub async fn watch_order_book( &self, symbol: &str, limit: Option<u32>, ) -> Result<MessageStream<OrderBook>>
Sourcepub async fn watch_trades(
&self,
symbol: &str,
market: Option<Market>,
) -> Result<MessageStream<Vec<Trade>>>
pub async fn watch_trades( &self, symbol: &str, market: Option<Market>, ) -> Result<MessageStream<Vec<Trade>>>
Auto Trait Implementations§
impl Freeze for OkxWs
impl !RefUnwindSafe for OkxWs
impl Send for OkxWs
impl Sync for OkxWs
impl Unpin for OkxWs
impl !UnwindSafe for OkxWs
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