bybit/models/trade_stream_event.rs
1use crate::prelude::*;
2
3/// Structure for trade stream events received via WebSocket.
4///
5/// Contains real-time trade stream data, including order status updates and API rate limit metadata. Bots use this for high-frequency trading and low-latency order monitoring in perpetual futures markets.
6#[derive(Serialize, Deserialize, Debug, Clone)]
7#[serde(rename_all = "camelCase")]
8pub struct TradeStreamEvent {
9 /// The request ID for the trade stream event (optional).
10 ///
11 /// A unique identifier for the request that triggered this event, if applicable. Bots use this to correlate events with specific requests.
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub req_id: Option<String>,
14
15 /// The return code for the event.
16 ///
17 /// Indicates the status of the event (e.g., `0` for success). Bots should check this to handle errors or confirm successful updates.
18 pub ret_code: i32,
19
20 /// A message describing the event.
21 ///
22 /// Provides context for the `ret_code`, such as `"OK"` or an error description. Bots should log this for debugging.
23 pub ret_msg: String,
24
25 /// The operation type (e.g., "trade").
26 ///
27 /// Specifies the type of trade stream event, typically `"trade"`. Bots use this to confirm the event type.
28 pub op: String,
29
30 /// The order status data for the event.
31 ///
32 /// Contains detailed order status updates, such as filled or cancelled orders. Bots use this to track order progress in real time.
33 pub data: OrderStatus,
34
35 /// The API response header.
36 ///
37 /// Contains rate limit and timing metadata for the API response. Bots use this to manage API usage and ensure compliance with rate limits.
38 pub header: Header,
39
40 /// The WebSocket connection ID.
41 ///
42 /// A unique identifier for the WebSocket connection. Bots use this to track specific connections in multi-connection setups.
43 pub conn_id: String,
44}