bybit/models/order_book.rs
1use crate::prelude::*;
2
3/// Represents the order book for a trading pair.
4///
5/// Contains the current bid and ask levels, along with metadata like the update ID. Bots use this to analyze market depth and liquidity in perpetual futures.
6#[derive(Serialize, Deserialize, Clone, Debug)]
7pub struct OrderBook {
8 /// The trading pair symbol (e.g., "BTCUSDT").
9 ///
10 /// Confirms the trading pair for the order book. Bots should verify this matches the requested symbol.
11 #[serde(rename = "s")]
12 pub symbol: String,
13
14 /// A list of ask (sell) orders.
15 ///
16 /// Contains the current ask prices and quantities. Bots use this to assess selling pressure and determine resistance levels in perpetual futures.
17 #[serde(rename = "a")]
18 pub asks: Vec<Ask>,
19
20 /// A list of bid (buy) orders.
21 ///
22 /// Contains the current bid prices and quantities. Bots use this to assess buying support and determine support levels in perpetual futures.
23 #[serde(rename = "b")]
24 pub bids: Vec<Bid>,
25
26 /// The timestamp of the order book snapshot (Unix timestamp in milliseconds).
27 ///
28 /// Indicates when the order book data was captured. Bots should use this to ensure the data is recent, as stale order book data can lead to poor trading decisions.
29 #[serde(rename = "ts")]
30 pub timestamp: u64,
31
32 /// The update ID of the order book.
33 ///
34 /// A unique identifier for the order book snapshot. Bots can use this to track updates and ensure they’re processing the latest data, especially in WebSocket streams.
35 #[serde(rename = "u")]
36 pub update_id: u64,
37}