bybit/models/
ws_order_book.rs

1use crate::prelude::*;
2
3/// Structure for WebSocket order book data.
4///
5/// Contains the bids, asks, and sequence numbers for a trading pair’s order book. Bots use this to maintain an up-to-date view of market depth and liquidity.
6#[derive(Serialize, Deserialize, Debug, Clone)]
7#[serde(rename_all = "camelCase")]
8pub struct WsOrderBook {
9    /// The trading pair symbol (e.g., "BTCUSDT").
10    ///
11    /// Identifies the perpetual futures contract for the order book. Bots use this to verify the correct market.
12    #[serde(rename = "s")]
13    pub symbol: String,
14
15    /// A list of ask prices and quantities.
16    ///
17    /// Contains the current ask levels in the order book, sorted by price. Bots use this to assess selling pressure and liquidity on the ask side.
18    #[serde(rename = "a")]
19    pub asks: Vec<Ask>,
20
21    /// A list of bid prices and quantities.
22    ///
23    /// Contains the current bid levels in the order book, sorted by price. Bots use this to assess buying pressure and liquidity on the bid side.
24    #[serde(rename = "b")]
25    pub bids: Vec<Bid>,
26
27    /// The update ID for the order book.
28    ///
29    /// A unique identifier for the order book update. Bots use this to ensure updates are processed in the correct order.
30    #[serde(rename = "u")]
31    pub update_id: u64,
32
33    /// The sequence number for the update.
34    ///
35    /// A monotonically increasing number for ordering updates. Bots use this to detect missing or out-of-order updates and maintain order book consistency.
36    pub seq: u64,
37}