{"record":{"id":"13bbd9f72a0eab55","repo":"nautechsystems/nautilus_trader","slug":"use-quote-for-inverse-is-not-applicable-for-bett","errorCode":null,"errorMessage":"`use_quote_for_inverse` is not applicable for betting accounts","messagePattern":"`use_quote_for_inverse` is not applicable for betting accounts","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/accounts/betting.rs","lineNumber":206,"sourceCode":"        }\n\n        self.base_apply(event);\n        Ok(())\n    }\n\n    fn calculate_balance_locked(\n        &self,\n        instrument: &InstrumentAny,\n        side: OrderSide,\n        quantity: Quantity,\n        price: Price,\n        use_quote_for_inverse: Option<bool>,\n    ) -> anyhow::Result<Money> {\n        anyhow::ensure!(\n            instrument.instrument_class() == InstrumentClass::SportsBetting,\n            \"BettingAccount requires a sports betting instrument\"\n        );\n        anyhow::ensure!(\n            use_quote_for_inverse != Some(true),\n            \"`use_quote_for_inverse` is not applicable for betting accounts\"\n        );\n\n        let locked = match side {\n            OrderSide::Sell => quantity.as_decimal(),\n            OrderSide::Buy => quantity.as_decimal() * (price.as_decimal() - Decimal::ONE),\n        };\n\n        Ok(Money::from_decimal(locked, instrument.quote_currency())?)\n    }\n\n    fn calculate_pnls(\n        &self,\n        instrument: &InstrumentAny,\n        fill: &OrderFilled,\n        position: Option<Position>,\n    ) -> anyhow::Result<Vec<Money>> {","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/accounts/betting.rs#L188-L224","documentation":"`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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncalculate_balance_locked(instrument, side, qty, px, Some(true))\n// after\ncalculate_balance_locked(instrument, side, qty, px, None)","handlingStrategy":"validation","validationCode":"if account.is_betting_account and use_quote_for_inverse is True:\n    raise ValueError(\"use_quote_for_inverse not applicable for betting accounts\")","typeGuard":null,"tryCatchPattern":"try:\n    locked = account.calculate_balance_locked(instrument, side, qty, px, use_quote_for_inverse)\nexcept Exception as e:\n    log.warning(f\"balance locked calc failed: {e}\")","preventionTips":["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"],"tags":["rust","betting","argument-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}