bybit/models/order_book_update.rs
1use crate::prelude::*;
2
3/// Structure for WebSocket order book update events.
4///
5/// Contains real-time updates to the order book for a trading pair, including bids, asks, and sequence numbers. Bots use this for market depth analysis and liquidity monitoring in perpetual futures trading.
6#[derive(Serialize, Deserialize, Debug, Clone)]
7#[serde(rename_all = "camelCase")]
8pub struct OrderBookUpdate {
9 /// The WebSocket topic for the event (e.g., "orderbook.50.BTCUSDT").
10 ///
11 /// Specifies the data stream for the order book update, including depth and symbol. Bots use this to verify the correct market and depth level.
12 #[serde(rename = "topic")]
13 pub topic: String,
14
15 /// The event type (e.g., "snapshot", "delta").
16 ///
17 /// Indicates whether the update is a full snapshot or incremental delta. Bots use this to initialize or update their order book state.
18 #[serde(rename = "type")]
19 pub event_type: String,
20
21 /// The timestamp of the event in milliseconds.
22 ///
23 /// Indicates when the order book update was generated. Bots use this to ensure data freshness and align with other market data.
24 #[serde(rename = "ts")]
25 pub timestamp: u64,
26
27 /// The order book data.
28 ///
29 /// Contains the bids, asks, and sequence numbers for the order book. Bots use this to update their internal order book representation.
30 pub data: WsOrderBook,
31
32 /// The creation timestamp in milliseconds.
33 ///
34 /// Indicates when the order book update was created by Bybit’s server. Bots use this to measure latency and ensure data consistency.
35 pub cts: u64,
36}