Skip to main content

parse_order_status_report

Function parse_order_status_report 

Source
pub fn parse_order_status_report(
    order: &BitmexOrder,
    instrument: &InstrumentAny,
    order_type_cache: &DashMap<ClientOrderId, OrderType>,
    ts_init: UnixNanos,
) -> Result<OrderStatusReport>
Expand description

Parse a BitMEX order into a Nautilus OrderStatusReport.

§BitMEX Response Quirks

BitMEX may omit ord_status in responses for completed orders. When this occurs, the parser defensively infers the status from leaves_qty and cum_qty:

  • leaves_qty=0, cum_qty>0 -> Filled
  • leaves_qty=0, cum_qty<=0 -> Canceled
  • Otherwise -> Returns error (unparsable)

§Errors

Returns an error if:

  • Order is missing ord_status and status cannot be inferred from quantity fields.
  • Order is missing order_qty and cannot be reconstructed from cum_qty + leaves_qty.