Skip to main content

AllLiquidationData

Struct AllLiquidationData 

Source
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: u64

The 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: String

The trading pair symbol (e.g., “BTCUSDT”).

Specifies the market where the liquidation occurred. Bots can filter by symbol to focus on relevant markets.

§side: String

The 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: f64

The 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: f64

The 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

Source

pub fn new( symbol: &str, side: &str, size: f64, price: f64, updated_time: u64, ) -> Self

Constructs a new AllLiquidationData with specified parameters.

Source

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.

Source

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.

Source

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.

Source

pub fn updated_datetime(&self) -> DateTime<Utc>

Returns the updated time as a chrono DateTime.

Source

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.

Source

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.

Source

pub fn to_display_string(&self) -> String

Returns a string representation of the liquidation.

Source

pub fn as_tuple(&self) -> (&str, &str, f64, f64, u64)

Returns the liquidation as a tuple for easy pattern matching.

Source

pub fn is_symbol(&self, symbol: &str) -> bool

Returns true if this liquidation is for a specific symbol.

Source

pub fn side_enum(&self) -> LiquidationSide

Returns the side as an enum-like value.

Source

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).

Source

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

Source§

fn clone(&self) -> AllLiquidationData

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AllLiquidationData

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for AllLiquidationData

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for AllLiquidationData

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,