pub struct AllLiquidationData {
pub updated_time: u64,
pub symbol: String,
pub side: String,
pub size: f64,
pub price: f64,
}Expand description
Represents a single liquidation entry in the “all liquidation” WebSocket stream.
Contains details of a liquidation event that occurred on Bybit across all contract types. Liquidations happen when a trader’s position cannot meet margin requirements, leading to forced closure. This struct provides information about the size, price, and direction of liquidated positions.
§Bybit API Reference
The Bybit WebSocket API (https://bybit-exchange.github.io/docs/v5/websocket/public/all-liquidation) provides all liquidation data with a push frequency of 500ms.
Fields§
§updated_time: u64The timestamp when the liquidation was updated (in milliseconds).
Indicates the exact time when the liquidation event occurred. Bots can use this to correlate liquidation events with price movements.
symbol: StringThe trading pair symbol (e.g., “BTCUSDT”).
Specifies the market where the liquidation occurred. Bots can filter by symbol to focus on relevant markets.
side: StringThe side of the liquidated position (“Buy” or “Sell”).
Indicates whether the liquidated position was long (Buy) or short (Sell). When you receive a “Buy” update, this means that a long position has been liquidated. A high volume of liquidations on one side can signal a potential price reversal.
size: f64The executed size of the liquidated position.
Represents the volume of the position that was forcibly closed. Large liquidations can cause significant price movements and increased volatility.
price: f64The price at which the position was liquidated.
This is the bankruptcy price at which the position was forcibly closed. Liquidation price levels often act as support or resistance zones.
Implementations§
Source§impl AllLiquidationData
impl AllLiquidationData
Sourcepub fn new(
symbol: &str,
side: &str,
size: f64,
price: f64,
updated_time: u64,
) -> Self
pub fn new( symbol: &str, side: &str, size: f64, price: f64, updated_time: u64, ) -> Self
Constructs a new AllLiquidationData with specified parameters.
Sourcepub fn is_long(&self) -> bool
pub fn is_long(&self) -> bool
Returns true if the liquidated position was a long position.
Long positions are liquidated when prices fall below the liquidation price.
Sourcepub fn is_short(&self) -> bool
pub fn is_short(&self) -> bool
Returns true if the liquidated position was a short position.
Short positions are liquidated when prices rise above the liquidation price.
Sourcepub fn notional_value(&self) -> f64
pub fn notional_value(&self) -> f64
Returns the notional value of the liquidation.
Calculated as size * price. This represents the total value of the position
that was liquidated, useful for assessing the market impact.
Sourcepub fn updated_datetime(&self) -> DateTime<Utc>
pub fn updated_datetime(&self) -> DateTime<Utc>
Returns the updated time as a chrono DateTime.
Sourcepub fn age_ms(&self) -> u64
pub fn age_ms(&self) -> u64
Returns the age of the liquidation in milliseconds.
Calculates how long ago this liquidation occurred relative to current time.
Sourcepub fn is_recent(&self) -> bool
pub fn is_recent(&self) -> bool
Returns true if the liquidation is recent (≤ 1 second old).
Recent liquidations are more relevant for real-time trading decisions.
Sourcepub fn to_display_string(&self) -> String
pub fn to_display_string(&self) -> String
Returns a string representation of the liquidation.
Sourcepub fn as_tuple(&self) -> (&str, &str, f64, f64, u64)
pub fn as_tuple(&self) -> (&str, &str, f64, f64, u64)
Returns the liquidation as a tuple for easy pattern matching.
Sourcepub fn is_symbol(&self, symbol: &str) -> bool
pub fn is_symbol(&self, symbol: &str) -> bool
Returns true if this liquidation is for a specific symbol.
Sourcepub fn side_enum(&self) -> LiquidationSide
pub fn side_enum(&self) -> LiquidationSide
Returns the side as an enum-like value.
Sourcepub fn estimated_price_impact(&self, impact_coefficient: f64) -> f64
pub fn estimated_price_impact(&self, impact_coefficient: f64) -> f64
Returns the price impact assuming linear market impact model.
This is a simplified model: impact = k * sqrt(notional_value) where k is an impact coefficient (default 0.001).
Sourcepub fn estimated_price_impact_percentage(&self, impact_coefficient: f64) -> f64
pub fn estimated_price_impact_percentage(&self, impact_coefficient: f64) -> f64
Returns the percentage price impact relative to the liquidation price.
Trait Implementations§
Source§impl Clone for AllLiquidationData
impl Clone for AllLiquidationData
Source§fn clone(&self) -> AllLiquidationData
fn clone(&self) -> AllLiquidationData
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more