nautechsystems/nautilus_trader · error

Invalid multiplier divisor {divisor} for {bitmex_currency}

Error message

Invalid multiplier divisor {divisor} for {bitmex_currency}

What it means

After converting the quanto multiplier to Decimal, parse_instrument_multiplier divides it by the currency divisor for the settlement currency (falling back to quote currency). If the division yields None (e.g. the divisor is zero because bitmex_currency_divisor returned an unknown/0 value for the currency), this error names the divisor and currency.

Source

Thrown at crates/adapters/bitmex/src/http/parse.rs:570

}

fn parse_instrument_multiplier(
    definition: &BitmexInstrument,
    settlement_currency: Currency,
) -> anyhow::Result<Quantity> {
    if !definition.is_quanto {
        return Quantity::new_checked(definition.multiplier.abs(), 0).map_err(Into::into);
    }

    let raw = Decimal::try_from(definition.multiplier.abs())
        .map_err(|e| anyhow::anyhow!("Invalid multiplier {}: {e}", definition.multiplier))?;
    let bitmex_currency = definition
        .settl_currency
        .as_ref()
        .unwrap_or(&definition.quote_currency);
    let divisor = bitmex_currency_divisor(bitmex_currency.as_str());
    let value = raw.checked_div(divisor).ok_or_else(|| {
        anyhow::anyhow!("Invalid multiplier divisor {divisor} for {bitmex_currency}")
    })?;

    Quantity::from_decimal_dp(value, settlement_currency.precision).map_err(Into::into)
}

/// Parse a BitMEX futures spread instrument into a Nautilus `InstrumentAny`.
///
/// # Errors
///
/// Returns an error if values are out of valid range or cannot be parsed.
///
/// # Panics
///
/// Panics if the constructed instrument fails validation.
pub fn parse_crypto_futures_spread_instrument(
    definition: &BitmexInstrument,
    ts_init: UnixNanos,
) -> anyhow::Result<InstrumentAny> {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Check which currency produced the bad divisor and add/update its entry in bitmex_currency_divisor.
  2. Verify settl_currency on the BitMEX instrument definition for that symbol.
  3. Skip the unsupported symbol when loading instruments and log it.
  4. Update the adapter to a version whose currency divisor table includes the new BitMEX currency.

Example fix

// before
let divisor = bitmex_currency_divisor(bitmex_currency.as_str());
let value = raw.checked_div(divisor).ok_or_else(|| ...)?;
// after: ensure the currency is supported before dividing
let divisor = bitmex_currency_divisor(bitmex_currency.as_str());
anyhow::ensure!(!divisor.is_zero(), "Unsupported BitMEX currency {bitmex_currency}: zero divisor");
let value = raw.checked_div(divisor).ok_or_else(|| ...)?;
Defensive patterns

Strategy: validation

Validate before calling

let currency = definition.settl_currency.as_ref().unwrap_or(&definition.quote_currency);
if bitmex_currency_divisor(currency.as_str()).is_zero() {
    log::warn!("unsupported BitMEX currency {currency}; skipping {}", definition.symbol);
    return Ok(None);
}

Try / catch

match parse_futures_instrument(&definition, ...) {
    Ok(inst) => Some(inst),
    Err(e) if e.to_string().contains("divisor") => {
        log::warn!("currency divisor unsupported: {e}"); None
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Parsing a quanto instrument whose settl_currency (or quote_currency) maps to an invalid/zero divisor from bitmex_currency_divisor, making checked_div fail.

Common situations: A new BitMEX settlement currency not yet covered by the adapter's divisor table; a typo/unsupported currency code in the instrument definition; adapter and venue currency list out of sync.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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