bybit/models/order_event.rs
1use crate::prelude::*;
2
3/// Represents an event containing order updates from Bybit’s WebSocket API.
4///
5/// This struct is used to receive real-time order updates via Bybit’s private WebSocket stream (https://bybit-exchange.github.io/docs/v5/websocket/private/order).
6/// In perpetual futures trading, real-time order events are critical for bots to react to market changes, manage positions, and execute strategies dynamically.
7#[derive(Serialize, Deserialize, Debug, Clone)]
8#[serde(rename_all = "camelCase")]
9pub struct OrderEvent {
10 /// Unique identifier for the WebSocket event.
11 ///
12 /// This ID allows bots to track and correlate WebSocket messages, ensuring no events are missed or duplicated.
13 /// **Bot Implication**: Bots use `id` to maintain message integrity and debug WebSocket connectivity issues.
14 pub id: String,
15
16 /// The WebSocket topic, e.g., "order".
17 ///
18 /// This identifies the type of data in the event, allowing bots to route messages to the appropriate handler (https://bybit-exchange.github.io/docs/v5/websocket/private/order).
19 /// **Bot Implication**: Bots filter on `topic` to process order updates efficiently, ignoring irrelevant streams.
20 pub topic: String,
21
22 /// Timestamp of the event, in milliseconds since Unix epoch.
23 ///
24 /// This records when the event was generated by Bybit, critical for latency analysis and event sequencing (https://bybit-exchange.github.io/docs/v5/websocket/private/order).
25 /// **Bot Implication**: Bots use `creation_time` to measure system performance and ensure timely processing of order updates.
26 pub creation_time: u64,
27
28 /// List of order data updates included in the event.
29 ///
30 /// This contains one or more `OrderData` structs, each representing an updated order (https://bybit-exchange.github.io/docs/v5/websocket/private/order).
31 /// **Bot Implication**: Bots iterate through `data` to process multiple order updates in a single event, optimizing performance in high-frequency trading.
32 pub data: Vec<OrderData>,
33}