Skip to main content

parse_ws_liquidation

Function parse_ws_liquidation 

Source
pub fn parse_ws_liquidation(
    liquidation: &BybitWsLiquidation,
    instrument: &InstrumentAny,
    ts_init: UnixNanos,
) -> Result<BybitLiquidation>
Expand description

Parses a WebSocket liquidation entry into a BybitLiquidation.

Bybit reports the side of the liquidated position, so Buy maps to [PositionSide::Long] and Sell maps to [PositionSide::Short].

ยงErrors

Returns an error if the side is neither Buy nor Sell, or if the price, size, or timestamp cannot be parsed.