Skip to main content

bybit/models/
liquidation_data.rs

1use crate::prelude::*;
2
3/// Contains the details of a liquidation event.
4///
5/// This struct provides specific information about a liquidated position, including the time, symbol, side, size, and price.
6///
7/// # Bybit API Reference
8/// Liquidation data is part of the WebSocket liquidation stream (https://bybit-exchange.github.io/docs/v5/websocket/public/liquidation).
9///
10/// # Perpetual Futures Context
11/// Liquidation data helps bots understand the size and direction of forced closures, which can indicate market sentiment or trigger stop-loss cascades.
12#[derive(Serialize, Deserialize, Debug, Clone)]
13#[serde(rename_all = "camelCase")]
14pub struct LiquidationData {
15    /// The timestamp when the liquidation was updated (in milliseconds).
16    ///
17    /// Indicates the exact time of the liquidation event. Bots can use this to align liquidation data with price or volume spikes.
18    pub updated_time: u64,
19
20    /// The trading pair symbol (e.g., "BTCUSDT").
21    ///
22    /// Specifies the market where the liquidation occurred. Bots filter by symbol to focus on relevant markets.
23    pub symbol: String,
24
25    /// The side of the liquidated position ("Buy" or "Sell").
26    ///
27    /// Indicates whether the liquidated position was long (Buy) or short (Sell). A high volume of liquidations on one side can signal a potential price reversal, which bots can exploit.
28    pub side: String,
29
30    /// The size of the liquidated position (in contracts or base currency).
31    ///
32    /// Represents the volume of the position closed. Large liquidations can cause significant price movements, and bots should monitor this to anticipate volatility.
33    #[serde(with = "string_to_float")]
34    pub size: f64,
35
36    /// The price at which the position was liquidated.
37    ///
38    /// This is the market price at which the position was forcibly closed. Bots can use this to identify liquidation price levels, which often act as support or resistance zones.
39    #[serde(with = "string_to_float")]
40    pub price: f64,
41}