nautechsystems/nautilus_trader · error

Trade bin missing high price for {instrument_id}

Error message

Trade bin missing high price for {instrument_id}

What it means

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.

Source

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

///
/// # Errors
///
/// Returns an error when required OHLC fields are missing from the payload.
pub fn parse_trade_bin(
    bin: &BitmexTradeBin,
    instrument: &InstrumentAny,
    bar_type: &BarType,
    ts_init: UnixNanos,
) -> anyhow::Result<Bar> {
    let instrument_id = bar_type.instrument_id();
    let price_precision = instrument.price_precision();

    let open = bin
        .open
        .ok_or_else(|| anyhow::anyhow!("Trade bin missing open price for {instrument_id}"))?;
    let high = bin
        .high
        .ok_or_else(|| anyhow::anyhow!("Trade bin missing high price for {instrument_id}"))?;
    let low = bin
        .low
        .ok_or_else(|| anyhow::anyhow!("Trade bin missing low price for {instrument_id}"))?;
    let close = bin
        .close
        .ok_or_else(|| anyhow::anyhow!("Trade bin missing close price for {instrument_id}"))?;

    let open = Price::new(open, price_precision);
    let high = Price::new(high, price_precision);
    let low = Price::new(low, price_precision);
    let close = Price::new(close, price_precision);

    let (open, high, low, close) =
        normalize_trade_bin_prices(open, high, low, close, &bin.symbol, Some(bar_type));

    let volume_contracts = normalize_trade_bin_volume(bin.volume, &bin.symbol);
    let volume = parse_contracts_quantity(volume_contracts, instrument);
    let ts_event = UnixNanos::from(bin.timestamp);

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Request only completed bins (exclude the latest in-progress bin from the requested range).
  2. Retry the request shortly after; finalized bins include all OHLC values.
  3. Filter out bins with any null OHLC field client-side before calling parse_trade_bin.
  4. Check BitMEX system status / data completeness for the symbol and timeframe.

Example fix

// before
let bar = parse_trade_bin(&bin, instrument_id, price_precision)?;
// after
if bin.open.is_none() || bin.high.is_none() || bin.low.is_none() || bin.close.is_none() {
    return Ok(None); // skip incomplete bin
}
let bar = parse_trade_bin(&bin, instrument_id, price_precision)?;
Defensive patterns

Strategy: validation

Validate before calling

fn bin_is_complete(bin: &BitmexTradeBin) -> bool {
    bin.open.is_some() && bin.high.is_some() && bin.low.is_some() && bin.close.is_some()
}
// call request_bars only on bins where bin_is_complete(&bin)

Type guard

fn has_ohlc(bin: &BitmexTradeBin) -> Option<(f64, f64, f64, f64)> {
    Some((bin.open?, bin.high?, bin.low?, bin.close?))
}

Try / catch

match parse_trade_bin(&bin, instrument_id, precision) {
    Ok(bar) => push(bar),
    Err(e) => log::warn!("Skipping bin: {e}"),
}

Prevention

When it happens

Trigger: 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.

Common situations: 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>).

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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