Skip to main content

bybit/models/
websocket_events.rs

1use crate::prelude::*;
2
3/// Enum representing various WebSocket event types.
4///
5/// Encapsulates different types of WebSocket events, such as order book updates, trades, and position changes, received from Bybit’s WebSocket API. Bots use this to handle real-time market and account data for trading strategies.
6#[derive(Debug, Serialize, Deserialize, Clone)]
7#[serde(untagged)]
8pub enum WebsocketEvents {
9    /// An order book update event.
10    ///
11    /// Contains real-time updates to the order book for a trading pair. Bots use this for market depth analysis and liquidity monitoring.
12    OrderBookEvent(OrderBookUpdate),
13
14    /// An RPI (Real-time Price Improvement) order book update event.
15    ///
16    /// Contains real-time updates to the RPI order book for a trading pair, including RPI sizes.
17    /// RPI orders can provide price improvement for takers. Bots use this for market depth analysis
18    /// with RPI information and improved liquidity monitoring.
19    RPIOrderBookEvent(RPIOrderbookUpdate),
20
21    /// A trade event.
22    ///
23    /// Contains details of executed trades in the market. Bots use this for price discovery and trade signal generation.
24    TradeEvent(TradeUpdate),
25
26    /// A ticker event.
27    ///
28    /// Contains real-time ticker data, such as last price and volume. Bots use this for monitoring market conditions and technical analysis.
29    TickerEvent(WsTicker),
30
31    /// A liquidation event.
32    ///
33    /// Contains details of liquidation events in the market. Bots use this to assess market risk and volatility.
34    LiquidationEvent(Liquidation),
35
36    /// An all liquidation event.
37    ///
38    /// Contains details of all liquidation events occurring across Bybit markets.
39    /// This stream covers USDT contracts, USDC contracts, and inverse contracts.
40    /// Bots use this for comprehensive market risk assessment and volatility monitoring.
41    AllLiquidationEvent(AllLiquidationUpdate),
42
43    /// A kline (candlestick) event.
44    ///
45    /// Contains real-time candlestick data for a trading pair. Bots use this for technical analysis and trend detection.
46    KlineEvent(WsKline),
47
48    /// An insurance pool update event.
49    ///
50    /// Contains real-time updates to insurance pool balances for various symbols.
51    /// Insurance pools are used to cover losses when positions are liquidated below bankruptcy price.
52    /// Bots use this to monitor exchange stability and counterparty risk.
53    InsurancePoolEvent(InsurancePoolUpdate),
54
55    /// A price limit update event.
56    ///
57    /// Contains real-time updates to order price limits for trading symbols.
58    /// These limits define the highest bid price (buyLmt) and lowest ask price (sellLmt) allowed.
59    /// Bots use this for risk management and order validation.
60    PriceLimitEvent(PriceLimitUpdate),
61
62    /// An ADL (Auto-Deleveraging) alert update event.
63    ///
64    /// Contains real-time ADL alert information for various trading pairs.
65    /// ADL is a risk management mechanism that automatically closes positions when
66    /// insurance pool balance reaches certain thresholds to prevent systemic risk.
67    /// Bots use this to monitor market stability and potential forced liquidations.
68    ADLAlertEvent(ADLAlertUpdate),
69
70    /// A position update event.
71    ///
72    /// Contains updates to the account's positions. Bots use this to track position changes and manage risk in real time.
73    PositionEvent(PositionEvent),
74
75    /// An execution event.
76    ///
77    /// Contains details of order executions for the account. Bots use this to confirm trade executions and update order status.
78    ExecutionEvent(Execution),
79
80    /// An order update event.
81    ///
82    /// Contains updates to the account's orders. Bots use this to monitor order status and implement dynamic order management.
83    OrderEvent(OrderEvent),
84
85    /// A wallet update event.
86    ///
87    /// Contains updates to the account's wallet balance and margin. Bots use this to monitor account health and manage capital.
88    Wallet(WalletEvent),
89
90    /// A trade stream event.
91    ///
92    /// Contains real-time trade stream data, typically for high-frequency trading. Bots use this for low-latency trade monitoring.
93    TradeStream(TradeStreamEvent),
94
95    /// A fast execution event.
96    ///
97    /// Contains minimal execution data for low-latency processing. Bots use this for high-frequency trading and rapid execution confirmation.
98    FastExecEvent(FastExecution),
99
100    /// A system status update event.
101    ///
102    /// Contains real-time system status and maintenance information from Bybit.
103    /// Bots use this to monitor platform health, maintenance schedules, and service incidents.
104    SystemStatusEvent(SystemStatusUpdate),
105}