nautechsystems/nautilus_trader · error

invalid Futures trade id

Error message

invalid Futures trade id {}: {e}

What it means

Wraps a failure to parse the Futures trade tick's price (trade.price) at the instrument's configured price precision into the error message. Despite the message text saying 'trade id', the underlying {e} comes from price parsing (parse_required_price_at_precision). It indicates the trade price string cannot be converted to a valid Price at the given precision.

Solutions

  1. Check the instrument definition's price_precision matches the actual symbol tick size from Binance exchangeInfo
  2. Log the raw trade.price string and the configured precision to see the mismatch
  3. Verify the instrument_id corresponds to the symbol the trades were requested for
  4. If the payload is malformed, drop the tick and continue rather than aborting the request

Example fix

// before
let price = parse_required_price_at_precision(&trade.price, price_precision, "trade.price")
    .map_err(|e| anyhow::anyhow!("invalid Futures trade id {}: {e}", trade.id))?;
// after: align precision with instrument definition
let price_precision = instrument.price_precision; // from the loaded Instrument, not hardcoded
let price = parse_required_price_at_precision(&trade.price, price_precision, "trade.price")?;
Defensive patterns

Strategy: validation

Validate before calling

fn valid_price(s: &str, precision: u8) -> bool {
    match s.parse::<f64>() { Ok(v) => v > 0.0 && decimals_ok(s, precision), Err(_) => false }
}

Try / catch

let trade_tick = match parse_futures_trade(&trade, instrument) {
    Ok(t) => t,
    Err(e) => { warn!("dropping trade {}: {e}", trade.id); continue; }
};

Prevention

When it happens

Trigger: Calling the futures trade-tick conversion function (build TradeTick from REST trade) when parse_required_price_at_precision(&trade.price, price_precision, "trade.price") fails — e.g. price string has more decimal places than price_precision, is empty, or is not a number.

Common situations: Instrument configured with wrong price_precision for the symbol (e.g. precision 2 for a symbol quoted at 4 decimals); corrupted or unexpected trade payload from the API; using precision from a different instrument.

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

Appendix: source

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

                &rate,
                instrument_id,
                ts_init,
            )?);
        }

        Ok(result)
    }
}

fn parse_futures_trade_tick(
    trade: &BinanceFuturesTrade,
    instrument_id: InstrumentId,
    price_precision: u8,
    size_precision: u8,
    ts_init: UnixNanos,
) -> anyhow::Result<TradeTick> {
    let price = parse_required_price_at_precision(&trade.price, price_precision, "trade.price")
        .map_err(|e| anyhow::anyhow!("invalid Futures trade id {}: {e}", trade.id))?;
    let size = parse_required_quantity_at_precision(&trade.qty, size_precision, "trade.qty")
        .map_err(|e| anyhow::anyhow!("invalid Futures trade id {}: {e}", trade.id))?;
    let ts_event = parse_millis(trade.time, "Futures trade time")?;

    let aggressor_side = if trade.is_buyer_maker {
        AggressorSide::Sell
    } else {
        AggressorSide::Buy
    };

    Ok(TradeTick::new(
        instrument_id,
        price,
        size,
        aggressor_side,
        TradeId::new(trade.id.to_string()),
        ts_event,
        ts_init,

View on GitHub (pinned to 18893faf8b)