pub struct AllLiquidationUpdate {
pub topic: String,
pub event_type: String,
pub timestamp: u64,
pub data: Vec<AllLiquidationData>,
}Expand description
Represents a WebSocket “all liquidation” update event.
Contains real-time liquidation events that occur across all Bybit markets. This stream pushes all liquidations that occur on Bybit, covering:
- USDT contracts (Perpetual and Delivery)
- USDC contracts (Perpetual and Delivery)
- Inverse contracts
Push frequency: 500ms
§Bybit API Reference
Topic: allLiquidation.{symbol} (e.g., allLiquidation.BTCUSDT)
Fields§
§topic: StringThe WebSocket topic for the event (e.g., “allLiquidation.BTCUSDT”).
Specifies the data stream for the liquidation update. Bots use this to determine which symbol the update belongs to.
event_type: StringThe event type (e.g., “snapshot”).
All liquidation updates are snapshot type, containing the latest liquidation events.
timestamp: u64The timestamp of the event in milliseconds.
Indicates when the liquidation update was generated by the system. Bots use this to ensure data freshness and time-based analysis.
data: Vec<AllLiquidationData>The liquidation data.
Contains a list of liquidation entries. Each entry represents a single liquidation event that occurred on Bybit.
Implementations§
Source§impl AllLiquidationUpdate
impl AllLiquidationUpdate
Sourcepub fn symbol_from_topic(&self) -> Option<&str>
pub fn symbol_from_topic(&self) -> Option<&str>
Extracts the symbol from the topic.
Parses the WebSocket topic to extract the trading symbol. Example: “allLiquidation.BTCUSDT” -> “BTCUSDT”
Sourcepub fn is_snapshot(&self) -> bool
pub fn is_snapshot(&self) -> bool
Returns true if this is a snapshot update.
All liquidation updates are snapshot type.
Sourcepub fn timestamp_datetime(&self) -> DateTime<Utc>
pub fn timestamp_datetime(&self) -> DateTime<Utc>
Returns the timestamp as a chrono DateTime.
Sourcepub fn age_ms(&self) -> u64
pub fn age_ms(&self) -> u64
Returns the age of the update in milliseconds.
Calculates how old this update is relative to the current time.
Sourcepub fn is_stale(&self) -> bool
pub fn is_stale(&self) -> bool
Returns true if the update is stale (older than 1 second).
Since liquidation updates are pushed every 500ms, data older than 1 second might be considered stale for real-time trading decisions.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if there are no liquidation entries in this update.
Sourcepub fn total_notional_value(&self) -> f64
pub fn total_notional_value(&self) -> f64
Returns the total notional value of all liquidations in this update.
Sums the notional values of all liquidation entries. Useful for assessing the overall market impact of liquidations.
Sourcepub fn total_long_size(&self) -> f64
pub fn total_long_size(&self) -> f64
Returns the total size of long liquidations.
Sourcepub fn total_short_size(&self) -> f64
pub fn total_short_size(&self) -> f64
Returns the total size of short liquidations.
Sourcepub fn total_long_notional(&self) -> f64
pub fn total_long_notional(&self) -> f64
Returns the total notional value of long liquidations.
Sourcepub fn total_short_notional(&self) -> f64
pub fn total_short_notional(&self) -> f64
Returns the total notional value of short liquidations.
Sourcepub fn net_imbalance(&self) -> f64
pub fn net_imbalance(&self) -> f64
Returns the net liquidation imbalance.
Calculated as (total_long_notional - total_short_notional). A positive value indicates more long liquidations (bearish pressure). A negative value indicates more short liquidations (bullish pressure).
Sourcepub fn net_imbalance_percentage(&self) -> f64
pub fn net_imbalance_percentage(&self) -> f64
Returns the net liquidation imbalance as a percentage of total notional.
Sourcepub fn average_price(&self) -> Option<f64>
pub fn average_price(&self) -> Option<f64>
Returns the average price of all liquidations.
Sourcepub fn weighted_average_price(&self) -> Option<f64>
pub fn weighted_average_price(&self) -> Option<f64>
Returns the weighted average price (by size) of liquidations.
Sourcepub fn filter_by_side(&self, side: &str) -> Vec<&AllLiquidationData>
pub fn filter_by_side(&self, side: &str) -> Vec<&AllLiquidationData>
Returns all liquidation entries for a specific side.
Sourcepub fn long_liquidations(&self) -> Vec<&AllLiquidationData>
pub fn long_liquidations(&self) -> Vec<&AllLiquidationData>
Returns all long liquidation entries.
Sourcepub fn short_liquidations(&self) -> Vec<&AllLiquidationData>
pub fn short_liquidations(&self) -> Vec<&AllLiquidationData>
Returns all short liquidation entries.
Sourcepub fn most_recent(&self) -> Option<&AllLiquidationData>
pub fn most_recent(&self) -> Option<&AllLiquidationData>
Returns the most recent liquidation entry (by updated_time).
Sourcepub fn oldest(&self) -> Option<&AllLiquidationData>
pub fn oldest(&self) -> Option<&AllLiquidationData>
Returns the oldest liquidation entry (by updated_time).
Sourcepub fn to_summary_string(&self) -> String
pub fn to_summary_string(&self) -> String
Returns a summary string for this liquidation update.
Sourcepub fn is_valid_for_trading(&self) -> bool
pub fn is_valid_for_trading(&self) -> bool
Validates the update for trading use.
Returns true if:
- The update is not stale (≤ 1 second old)
- The symbol can be extracted from the topic
- The update is a snapshot (all liquidation updates should be snapshots)
Sourcepub fn latency_ms(&self, other_timestamp: u64) -> i64
pub fn latency_ms(&self, other_timestamp: u64) -> i64
Returns the update latency in milliseconds.
For comparing with other market data timestamps.
Sourcepub fn group_by_symbol(&self) -> HashMap<String, Vec<&AllLiquidationData>>
pub fn group_by_symbol(&self) -> HashMap<String, Vec<&AllLiquidationData>>
Groups liquidations by symbol (useful for multi-symbol topics if supported).
Sourcepub fn estimated_total_market_impact(&self, impact_coefficient: f64) -> f64
pub fn estimated_total_market_impact(&self, impact_coefficient: f64) -> f64
Returns the estimated total market impact of all liquidations.
Using a simplified model: total_impact = sum(impact_coefficient * sqrt(notional_value))
Sourcepub fn largest_liquidation(&self) -> Option<&AllLiquidationData>
pub fn largest_liquidation(&self) -> Option<&AllLiquidationData>
Returns the liquidation with the largest notional value.
Sourcepub fn smallest_liquidation(&self) -> Option<&AllLiquidationData>
pub fn smallest_liquidation(&self) -> Option<&AllLiquidationData>
Returns the liquidation with the smallest notional value.
Trait Implementations§
Source§impl Clone for AllLiquidationUpdate
impl Clone for AllLiquidationUpdate
Source§fn clone(&self) -> AllLiquidationUpdate
fn clone(&self) -> AllLiquidationUpdate
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more