nautechsystems/nautilus_trader · error

invalid Futures kline

Error message

invalid Futures kline {} taker buy quote volume: {e}

What it means

Raised when kline.taker_buy_quote_volume cannot be parsed into a Decimal during Futures kline -> BinanceBar conversion. As with the other volume fields, Binance sends them as strings; anything that is not a valid decimal literal produces this error, tagged with the kline open_time.

Solutions

  1. Fetch the raw kline for the reported open_time and inspect taker_buy_quote_volume.
  2. Correct fixtures/mocks to supply a numeric string (e.g. "9876.54").
  3. Pin/upgrade the adapter to match the live Binance futures kline schema.
  4. Skip and log unparseable candles in ingestion pipelines to avoid stalling historical backfills.

Example fix

// before (fixture)
"takerBuyQuoteVolume": ""
// after
"takerBuyQuoteVolume": "9876.54"
Defensive patterns

Strategy: validation

Validate before calling

let _tbq: Decimal = kline.taker_buy_quote_volume.parse()
    .map_err(|_| format!("bad taker_buy_quote_volume: {}", kline.taker_buy_quote_volume))?;

Try / catch

match convert_kline(&kline) {
    Ok(bar) => emit(bar),
    Err(e) if e.to_string().contains("taker buy quote volume") => skip_and_log(e),
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Futures kline response containing an empty or non-numeric taker_buy_quote_volume string; triggered by the parse at client.rs:3314 during REST kline ingestion.

Common situations: Stale fixtures or mocked endpoints omitting the field, Binance schema changes, intermediary proxies mangling response bodies.

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

Appendix: source

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

        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!(
                "invalid Futures kline {} taker buy quote volume: {e}",
                kline.open_time
            )
        })?;
    let count = u64::try_from(kline.num_trades).map_err(|_| {
        anyhow::anyhow!(
            "invalid Futures kline {} negative trade count",
            kline.open_time
        )
    })?;

    Ok(BinanceBar::new(
        bar_type,
        open,
        high,
        low,
        close,
        volume,

View on GitHub (pinned to 18893faf8b)