nautechsystems/nautilus_trader · error

invalid fee amount for taker_fee=

Error message

invalid fee amount for taker_fee='{fee}' and notional='{notional}': multiplication overflow

What it means

In `resolve_commission`'s taker-fee branch, after notional is computed, the fee amount = taker_fee × notional is calculated with `checked_mul`. This error is raised when that multiplication overflows the `Decimal` type, meaning the resulting fee value cannot be represented and the fill's commission cannot be derived from the rate.

Solutions

  1. Inspect the logged `taker_fee` and `notional` values for implausible magnitude.
  2. Bound-check taker_fee (e.g. must be within 0..1) before multiplying.
  3. Fall back to the REST user-trades endpoint to fetch the actual commission for the fill.
  4. If huge notionals are legitimate for your products, refactor to a wider numeric representation upstream.
Defensive patterns

Strategy: validation

Validate before calling

// Rust: sanity-check taker_fee rate before multiplying
fn fee_rate_valid(fee: &rust_decimal::Decimal) -> bool {
    fee > &rust_decimal::Decimal::ZERO && fee < &rust_decimal::Decimal::ONE
}

Prevention

When it happens

Trigger: A Trade-type futures order update with `taker_fee` present (and no `commission`) where `fee.checked_mul(notional)` returns None — an unusually large notional combined with a high fee rate exceeds Decimal capacity during `parse_futures_order_update_to_fill`.

Common situations: Corrupted or adversarial WS payloads with absurd taker_fee or quantity/price values; unit-test payloads with extreme numbers; essentially never with realistic venue data.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs:192

        let raw_commission = order.commission.as_deref().unwrap_or("0");
        let amount = parse_required_decimal(raw_commission, "commission")?;
        let currency = order.commission_asset.as_ref().map_or(bnfcr_currency, |a| {
            normalize_futures_asset(a.as_str(), bnfcr_currency)
        });
        Money::from_decimal(amount, currency)
            .map_err(|e| anyhow::anyhow!("invalid commission='{raw_commission}': {e}"))
    } else if let Some(fee) = taker_fee {
        let currency = quote_currency.unwrap_or_else(Currency::USDT);
        let notional = last_qty
            .as_decimal()
            .checked_mul(last_px.as_decimal())
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "invalid fee notional for last_qty='{last_qty}' and last_px='{last_px}': multiplication overflow",
                )
            })?;
        let amount = fee.checked_mul(notional).ok_or_else(|| {
            anyhow::anyhow!(
                "invalid fee amount for taker_fee='{fee}' and notional='{notional}': multiplication overflow"
            )
        })?;
        Money::from_decimal(amount, currency)
            .map_err(|e| anyhow::anyhow!("invalid fee amount='{amount}': {e}"))
    } else {
        Ok(Money::zero(Currency::USDT()))
    }
}

/// Converts a Binance Futures order update (Trade type) to a Nautilus fill report.
///
/// # Errors
///
/// Returns an error if report construction fails.
#[expect(clippy::too_many_arguments)]
pub fn parse_futures_order_update_to_fill(
    msg: &BinanceFuturesOrderUpdateMsg,

View on GitHub (pinned to 18893faf8b)