nautechsystems/nautilus_trader · error

invalid Futures kline

Error message

invalid Futures kline {}: {e}

What it means

Wraps a failure to parse a Futures kline's price fields. This instance (line 3283 area) corresponds to the low (or an adjacent OHLC) field failing parse_required_price_at_precision. The message interpolates kline.open_time, so the offending bar is identifiable. It means the kline OHLC string cannot be represented at the configured price precision.

Solutions

  1. Confirm the instrument's price_precision matches the symbol's tick size from exchangeInfo
  2. Log the failing kline field and raw value identified by kline.open_time
  3. Check the BarType specification (symbol, precision) matches the instrument being used
  4. Skip or re-fetch the affected kline rather than failing the entire historical request

Example fix

// before
let low = parse_required_price_at_precision(&kline.low, price_precision, "kline.low")
    .map_err(|e| anyhow::anyhow!("invalid Futures kline {}: {e}", kline.open_time))?;
// after
let price_precision = instrument.price_precision; // derive from instrument definition
let low = parse_required_price_at_precision(&kline.low, price_precision, "kline.low")?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_ohlc(k: &Kline, precision: u8) -> bool {
    [(&k.open, "open"), (&k.high, "high"), (&k.low, "low"), (&k.close, "close")]
        .iter().all(|(v, _)| v.parse::<f64>().map(|x| x > 0.0).unwrap_or(false))
}

Try / catch

let bar = match parse_futures_kline(&kline, bar_type, instrument) {
    Ok(b) => b,
    Err(e) => { warn!("skipping kline {}: {e}", kline.open_time); continue; }
};

Prevention

When it happens

Trigger: Calling the futures kline-to-BinanceBar conversion when any of parse_required_price_at_precision calls on kline.open/high/low/close fails — e.g. value has more decimals than price_precision or is non-numeric/empty.

Common situations: Instrument price_precision mismatch with the trading pair's quote precision; klines fetched with wrong interval/symbol params from a misconfigured bar_type; corrupted historical data from the API.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/futures/http/client.rs:3283

    };
    parse_futures_trade_tick(
        &trade,
        instrument_id,
        price_precision,
        size_precision,
        ts_init,
    )
}

fn parse_futures_kline_binance_bar(
    kline: &BinanceFuturesKline,
    bar_type: BarType,
    price_precision: u8,
    size_precision: u8,
    ts_init: UnixNanos,
) -> anyhow::Result<BinanceBar> {
    let open = parse_required_price_at_precision(&kline.open, price_precision, "kline.open")
        .map_err(|e| anyhow::anyhow!("invalid Futures kline {}: {e}", kline.open_time))?;
    let high = parse_required_price_at_precision(&kline.high, price_precision, "kline.high")
        .map_err(|e| anyhow::anyhow!("invalid Futures kline {}: {e}", kline.open_time))?;
    let low = parse_required_price_at_precision(&kline.low, price_precision, "kline.low")
        .map_err(|e| anyhow::anyhow!("invalid Futures kline {}: {e}", kline.open_time))?;
    let close = parse_required_price_at_precision(&kline.close, price_precision, "kline.close")
        .map_err(|e| anyhow::anyhow!("invalid Futures kline {}: {e}", kline.open_time))?;
    let volume =
        parse_required_quantity_at_precision(&kline.volume, size_precision, "kline.volume")
            .map_err(|e| anyhow::anyhow!("invalid Futures kline {}: {e}", kline.open_time))?;
    let ts_event = parse_millis(kline.close_time, "Futures kline close time")?;

    let quote_volume = kline.quote_volume.parse::<Decimal>().map_err(|e| {
        anyhow::anyhow!(
            "invalid Futures kline {} quote volume: {e}",
            kline.open_time
        )
    })?;
    let taker_buy_base_volume = kline

View on GitHub (pinned to 18893faf8b)