nautechsystems/nautilus_trader · error

invalid callback_rate=

Error message

invalid callback_rate='{raw}': multiplication overflow

What it means

Raised when converting a parsed callback_rate decimal to a percentage fails because Decimal checked multiplication overflows (rate * 100 cannot be represented). callback_rate (Binance take-profit/stop orders) is stored in basis-point-compatible form; the parser multiplies by 100 and rejects values extreme enough to overflow Decimal. Indicates a corrupted or absurd callback_rate string rather than normal market data.

Solutions

  1. Inspect the raw callback_rate string reported in the error; valid Binance values are small percentages (e.g. "1.0"–"5.0" range, 0.1%–5% limits).
  2. Fix fixtures/mocks to emit realistic callback rates.
  3. Validate the range (Binance enforces 0.1 <= rate <= 5 for futures TP/SL) before conversion.
  4. If the unit changed upstream, update the conversion instead of relying on *100.

Example fix

// before (fixture)
callback_rate: "99999999999999999999999999999999999"
// after
callback_rate: "1.5" // 1.5%
Defensive patterns

Strategy: validation

Validate before calling

let rate: Decimal = raw.parse()?;
if rate < Decimal::new(1, 1) || rate > Decimal::new(5, 0) {
    return Err(format!("callback_rate {raw} outside Binance range 0.1..5"));
}

Try / catch

match parse_callback_rate_basis_points(&raw) {
    Ok(Some(pct)) => use(pct),
    Ok(None) => {},
    Err(e) if e.to_string().contains("multiplication overflow") => {
        log::error!("implausible callback_rate, rejecting: {e}");
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: parse_callback_rate_basis_points in futures/http/models.rs:1779 receives a raw string that parses to a finite decimal but overflows when multiplied by 100 — e.g. values near Decimal::MAX from a bad fixture, mocked endpoint, or corrupted response.

Common situations: Hand-written test fixtures with sentinel values like "99999999999999999999999999999999999", proxy/mock bugs emitting garbage numbers, or upstream schema changes changing the callback_rate unit.

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

Appendix: source

Thrown at crates/adapters/binance/src/futures/http/models.rs:1779

    let decimal = parse_required_decimal(raw, field)?;
    if decimal <= Decimal::ZERO {
        return Ok(None);
    }

    Price::from_decimal_dp(decimal, precision)
        .map(Some)
        .map_err(|e| anyhow::anyhow!("invalid {field} precision: {e}"))
}

fn parse_callback_rate_basis_points(raw: &str) -> anyhow::Result<Option<Decimal>> {
    let rate = parse_required_decimal(raw, "callback_rate")?;
    if rate <= Decimal::ZERO {
        return Ok(None);
    }

    rate.checked_mul(Decimal::from(100))
        .map(Some)
        .ok_or_else(|| anyhow::anyhow!("invalid callback_rate='{raw}': multiplication overflow"))
}

fn parse_working_type(working_type: Option<BinanceWorkingType>) -> TriggerType {
    match working_type {
        Some(BinanceWorkingType::ContractPrice) => TriggerType::LastPrice,
        Some(BinanceWorkingType::MarkPrice) => TriggerType::MarkPrice,
        Some(BinanceWorkingType::Unknown) | None => TriggerType::Default,
    }
}

fn requires_algo_trigger_price(order_type: BinanceFuturesOrderType) -> bool {
    matches!(
        order_type,
        BinanceFuturesOrderType::Stop
            | BinanceFuturesOrderType::StopMarket
            | BinanceFuturesOrderType::TakeProfit
            | BinanceFuturesOrderType::TakeProfitMarket
            | BinanceFuturesOrderType::TrailingStopMarket

View on GitHub (pinned to 18893faf8b)