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
- Pass None (or False) for use_quote_for_inverse when using a BettingAccount
- 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
- Pass None for use_quote_for_inverse unless handling inverse instruments
- Avoid unconditionally forwarding flags through generic calculation helpers
- Document flag applicability per account type in shared code
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
- {e}
- {e}
- start must not be later than end
- limit must be greater than zero
- Liability-based betting is only applicable for Lay side.
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/13bbd9f72a0eab55.
Report an issue: GitHub.