nautechsystems/nautilus_trader · error

invalid Futures kline

Error message

invalid Futures kline {} quote volume: {e}

What it means

Raised when kline.quote_volume cannot be parsed into a Decimal while building a Futures bar. Unlike OHLCV fields this is a direct Decimal parse without precision clamping, so it fails only when the string is empty, non-numeric, or otherwise not a valid decimal literal. The kline open_time is included to locate the offending candle.

Solutions

  1. Dump the raw kline JSON for the reported open_time and check the quote_volume field.
  2. Ensure the client targets the current fapi.binance.com futures endpoint and schema.
  3. Fix test fixtures/mocks to include quote_volume as a numeric string.
  4. If data genuinely missing, skip that candle and log rather than treating it as a hard failure in ingestion loops.

Example fix

// before (fixture)
{"openTime": 1700000000000, "open": "1.0", "close": "1.1"}
// after
{"openTime": 1700000000000, "open": "1.0", "close": "1.1", "quoteVolume": "1234.56", "volume": "1000", ...}
Defensive patterns

Strategy: validation

Validate before calling

if kline.quote_volume.is_empty() { return Err("quote_volume missing"); }
let _qv: Decimal = kline.quote_volume.parse().map_err(|_| format!("bad quote_volume: {}", kline.quote_volume))?;

Try / catch

match convert_kline(&kline) {
    Ok(bar) => emit(bar),
    Err(e) if e.to_string().contains("quote volume") => log::warn!("bad quote_volume, skipping: {e}"),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Binance futures kline response where quote_volume is absent, empty (""), or contains an unexpected token instead of a decimal number string; triggered during any futures kline -> BinanceBar conversion.

Common situations: API schema changes or a broken/misconfigured endpoint (e.g. pointing the client at a mock or an older API version that omits quote_volume), corrupted response bodies from proxies, or tests feeding hand-written fixtures with missing fields.

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/b90564dd8337b5c7. Report an issue: GitHub.

Appendix: source

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

    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
        .taker_buy_base_volume
        .parse::<Decimal>()
        .map_err(|e| {
            anyhow::anyhow!(
                "invalid Futures kline {} taker buy base volume: {e}",
                kline.open_time
            )
        })?;
    let taker_buy_quote_volume = kline
        .taker_buy_quote_volume
        .parse::<Decimal>()
        .map_err(|e| {
            anyhow::anyhow!(

View on GitHub (pinned to 18893faf8b)