nautechsystems/nautilus_trader · error

`use_quote_for_inverse` is not applicable for betting accoun

Error message

`use_quote_for_inverse` is not applicable for betting accounts

What it means

`use_quote_for_inverse` (converting notional via the quote currency for inverse instruments) is meaningless for sports betting instruments, so BettingAccount explicitly rejects it. This is an argument validation guard in calculate_balance_locked.

Source

Thrown at crates/model/src/accounts/betting.rs:206

        }

        self.base_apply(event);
        Ok(())
    }

    fn calculate_balance_locked(
        &self,
        instrument: &InstrumentAny,
        side: OrderSide,
        quantity: Quantity,
        price: Price,
        use_quote_for_inverse: Option<bool>,
    ) -> anyhow::Result<Money> {
        anyhow::ensure!(
            instrument.instrument_class() == InstrumentClass::SportsBetting,
            "BettingAccount requires a sports betting instrument"
        );
        anyhow::ensure!(
            use_quote_for_inverse != Some(true),
            "`use_quote_for_inverse` is not applicable for betting accounts"
        );

        let locked = match side {
            OrderSide::Sell => quantity.as_decimal(),
            OrderSide::Buy => quantity.as_decimal() * (price.as_decimal() - Decimal::ONE),
        };

        Ok(Money::from_decimal(locked, instrument.quote_currency())?)
    }

    fn calculate_pnls(
        &self,
        instrument: &InstrumentAny,
        fill: &OrderFilled,
        position: Option<Position>,
    ) -> anyhow::Result<Vec<Money>> {

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Pass None (or False) for use_quote_for_inverse when using a BettingAccount
  2. Make the calling code conditionally omit the flag for betting instruments

Example fix

// before
calculate_balance_locked(instrument, side, qty, px, Some(true))
// after
calculate_balance_locked(instrument, side, qty, px, None)
Defensive patterns

Strategy: validation

Validate before calling

if account.is_betting_account and use_quote_for_inverse is True:
    raise ValueError("use_quote_for_inverse not applicable for betting accounts")

Try / catch

try:
    locked = account.calculate_balance_locked(instrument, side, qty, px, use_quote_for_inverse)
except Exception as e:
    log.warning(f"balance locked calc failed: {e}")

Prevention

When it happens

Trigger: Calling BettingAccount.calculate_balance_locked with use_quote_for_inverse=Some(true), often by generic code that forwards the flag unconditionally for all account types.

Common situations: Shared position/balance calculation code that passes use_quote_for_inverse for every instrument type, or copy-pasted calls from inverse-futures code paths into betting flows.

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