bybit/models/wallet_event.rs
1use crate::prelude::*;
2
3/// Represents an event containing wallet updates from Bybit’s WebSocket API.
4///
5/// This struct delivers real-time wallet balance and margin updates via Bybit’s private WebSocket stream (https://bybit-exchange.github.io/docs/v5/websocket/private/wallet).
6/// In perpetual futures, wallet events are essential for monitoring account health, margin levels, and funding requirements, especially in leveraged trading.
7#[derive(Serialize, Deserialize, Debug, Clone)]
8#[serde(rename_all = "camelCase")]
9pub struct WalletEvent {
10 /// Unique identifier for the WebSocket event.
11 ///
12 /// Similar to `OrderEvent.id`, this tracks the event for debugging and message integrity.
13 /// **Bot Implication**: Bots use `id` to ensure all wallet updates are processed and to troubleshoot WebSocket issues.
14 pub id: String,
15
16 /// The WebSocket topic, e.g., "wallet".
17 ///
18 /// This identifies the event as a wallet update, allowing bots to route it to the appropriate handler (https://bybit-exchange.github.io/docs/v5/websocket/private/wallet).
19 /// **Bot Implication**: Bots filter on `topic` to prioritize wallet updates, critical for margin and risk management.
20 pub topic: String,
21
22 /// Timestamp of the event, in milliseconds since Unix epoch.
23 ///
24 /// This records when the wallet update was generated, aiding in latency and sequencing analysis (https://bybit-exchange.github.io/docs/v5/websocket/private/wallet).
25 /// **Bot Implication**: Bots use `creation_time` to ensure timely margin adjustments and to monitor system performance.
26 pub creation_time: u64,
27
28 /// List of wallet data updates included in the event.
29 ///
30 /// This contains one or more `WalletData` structs, each representing updated wallet metrics (https://bybit-exchange.github.io/docs/v5/websocket/private/wallet).
31 /// **Bot Implication**: Bots process `data` to update account balances and margin ratios, ensuring compliance with Bybit’s risk controls.
32 pub data: Vec<WalletData>,
33}