{"record":{"id":"0baa375628b4a7ec","repo":"nautechsystems/nautilus_trader","slug":"trade-bin-missing-high-price-for-instrument-id","errorCode":null,"errorMessage":"Trade bin missing high price for {instrument_id}","messagePattern":"Trade bin missing high price for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bitmex/src/http/parse.rs","lineNumber":742,"sourceCode":"///\n/// # Errors\n///\n/// Returns an error when required OHLC fields are missing from the payload.\npub fn parse_trade_bin(\n    bin: &BitmexTradeBin,\n    instrument: &InstrumentAny,\n    bar_type: &BarType,\n    ts_init: UnixNanos,\n) -> anyhow::Result<Bar> {\n    let instrument_id = bar_type.instrument_id();\n    let price_precision = instrument.price_precision();\n\n    let open = bin\n        .open\n        .ok_or_else(|| anyhow::anyhow!(\"Trade bin missing open price for {instrument_id}\"))?;\n    let high = bin\n        .high\n        .ok_or_else(|| anyhow::anyhow!(\"Trade bin missing high price for {instrument_id}\"))?;\n    let low = bin\n        .low\n        .ok_or_else(|| anyhow::anyhow!(\"Trade bin missing low price for {instrument_id}\"))?;\n    let close = bin\n        .close\n        .ok_or_else(|| anyhow::anyhow!(\"Trade bin missing close price for {instrument_id}\"))?;\n\n    let open = Price::new(open, price_precision);\n    let high = Price::new(high, price_precision);\n    let low = Price::new(low, price_precision);\n    let close = Price::new(close, price_precision);\n\n    let (open, high, low, close) =\n        normalize_trade_bin_prices(open, high, low, close, &bin.symbol, Some(bar_type));\n\n    let volume_contracts = normalize_trade_bin_volume(bin.volume, &bin.symbol);\n    let volume = parse_contracts_quantity(volume_contracts, instrument);\n    let ts_event = UnixNanos::from(bin.timestamp);","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bitmex/src/http/parse.rs#L724-L760","documentation":"parse_trade_bin converts a BitMEX trade bin (OHLCV candle) into a Bar. BitMEX may omit optional numeric fields in the bin JSON (they arrive as null), so this guard fires when the `high` field is absent. Without a high price no valid Bar can be constructed, since Bar requires a well-formed OHLC quartet.","triggerScenarios":"Calling request_bars for a BitMEX symbol whose returned trade bin entries have `high: null` — typically partial/just-opened bins or bins delivered before the exchange finalizes OHLC values.","commonSituations":"Requesting bars that include the current in-progress bin; BitMEX API partial responses during degraded exchange data quality; deserializing raw REST responses where nulls were allowed by the serde types (Option<f64>).","solutions":["Request only completed bins (exclude the latest in-progress bin from the requested range).","Retry the request shortly after; finalized bins include all OHLC values.","Filter out bins with any null OHLC field client-side before calling parse_trade_bin.","Check BitMEX system status / data completeness for the symbol and timeframe."],"exampleFix":"// before\nlet bar = parse_trade_bin(&bin, instrument_id, price_precision)?;\n// after\nif bin.open.is_none() || bin.high.is_none() || bin.low.is_none() || bin.close.is_none() {\n    return Ok(None); // skip incomplete bin\n}\nlet bar = parse_trade_bin(&bin, instrument_id, price_precision)?;","handlingStrategy":"validation","validationCode":"fn bin_is_complete(bin: &BitmexTradeBin) -> bool {\n    bin.open.is_some() && bin.high.is_some() && bin.low.is_some() && bin.close.is_some()\n}\n// call request_bars only on bins where bin_is_complete(&bin)","typeGuard":"fn has_ohlc(bin: &BitmexTradeBin) -> Option<(f64, f64, f64, f64)> {\n    Some((bin.open?, bin.high?, bin.low?, bin.close?))\n}","tryCatchPattern":"match parse_trade_bin(&bin, instrument_id, precision) {\n    Ok(bar) => push(bar),\n    Err(e) => log::warn!(\"Skipping bin: {e}\"),\n}","preventionTips":["Never treat the latest in-progress bin as final data.","Always null-check optional OHLC fields before Bar construction.","Refetch bins after their interval closes to get finalized values."],"tags":["bitmex","bars","missing-data","null-field"],"backgroundTag":"missing-required-argument","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}