nautechsystems/nautilus_trader · error

Order missing ord_status and cannot infer (order_id={}, clie

Error message

Order missing ord_status and cannot infer (order_id={}, client_order_id={:?}, leaves_qty={:?}, cum_qty={:?}, working_indicator={:?}, order_json={})

What it means

Raised by parse_order_status_report when a BitmexOrder has no ordStatus and the adapter's inference fallbacks (via leaves_qty, cum_qty, and working_indicator, handled in preceding match arms) also cannot determine the order's state. Without a resolvable status the adapter cannot build a valid OrderStatusReport, so it fails with full diagnostic context including the raw order JSON.

Source

Thrown at crates/adapters/bitmex/src/http/parse.rs:887

                    "Inferred Canceled from missing ordStatus (leaves_qty=0, cum_qty<=0): order_id={:?}, client_order_id={:?}, cum_qty={:?}",
                    order.order_id,
                    order.cl_ord_id,
                    order.cum_qty,
                );
                OrderStatus::Canceled
            }
            // BitMEX cancel responses may omit all quantity fields but include working_indicator
            (None, None, Some(false)) => {
                log::debug!(
                    "Inferred Canceled from missing ordStatus with working_indicator=false: order_id={:?}, client_order_id={:?}",
                    order.order_id,
                    order.cl_ord_id,
                );
                OrderStatus::Canceled
            }
            _ => {
                let order_json = serde_json::to_string(order)?;
                anyhow::bail!(
                    "Order missing ord_status and cannot infer (order_id={}, client_order_id={:?}, leaves_qty={:?}, cum_qty={:?}, working_indicator={:?}, order_json={})",
                    order.order_id,
                    order.cl_ord_id,
                    order.leaves_qty,
                    order.cum_qty,
                    order.working_indicator,
                    order_json
                );
            }
        }
    };

    // Try to get order_qty, or reconstruct from cum_qty + leaves_qty
    let (quantity, filled_qty) = if let Some(qty) = order.order_qty {
        let quantity = parse_signed_contracts_quantity(qty, instrument);
        let filled_qty = parse_signed_contracts_quantity(order.cum_qty.unwrap_or(0), instrument);
        (quantity, filled_qty)
    } else if let (Some(cum), Some(leaves)) = (order.cum_qty, order.leaves_qty) {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Inspect the order_json embedded in the error to see exactly which fields BitMEX returned
  2. Re-query the order via query_order or request_order_status_report to fetch a payload with ordStatus populated
  3. Check for BitMEX API updates that may have made ordStatus optional or renamed fields
  4. If reproducible, file an issue so the inference logic in parse.rs can cover the new payload shape

Example fix

null
Defensive patterns

Strategy: try-catch

Try / catch

match client.request_order_status_report(instrument_id, client_order_id, venue_order_id).await {
    Ok(report) => { /* handle */ }
    Err(e) if e.to_string().contains("Order missing ord_status") => {
        // extract order_json from message, re-query after a short delay
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Receiving an order payload from a submit/cancel/modify/query response with ordStatus=null AND none of the inference conditions matching (e.g. no leaves/cum quantity hints and no working indicator). Occurs with partial or malformed BitMEX responses.

Common situations: BitMEX websocket/REST payload edge cases (orders created without status during transient states); API version drift changing which fields are populated; custom or mocked endpoints returning minimal order objects.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/31f382b373369c75. Report an issue: GitHub.