{"record":{"id":"d1118d7d0ee1c9ea","repo":"nautechsystems/nautilus_trader","slug":"currency-commission-total-exceeds-money-bounds","errorCode":null,"errorMessage":"{currency} commission total exceeds Money bounds","messagePattern":"(.+?) commission total exceeds Money bounds","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/model/src/accounts/base.rs","lineNumber":216,"sourceCode":"\n    /// Updates the account commissions with the provided amount.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the accumulated commission exceeds [`Money`] bounds.\n    pub fn try_update_commissions(&mut self, commission: Money) -> anyhow::Result<()> {\n        // TODO: Remove once from_raw enforces canonical precision alignment (v2)\n        let commission = commission.normalized();\n        if commission.is_zero() {\n            return Ok(());\n        }\n        let currency = commission.currency;\n        let total = self\n            .commissions\n            .get(&currency)\n            .copied()\n            .map_or(Some(commission), |total| total.checked_add(commission))\n            .ok_or_else(|| anyhow::anyhow!(\"{currency} commission total exceeds Money bounds\"))?;\n        self.commissions.insert(currency, total);\n        Ok(())\n    }\n\n    /// Returns the total commission for the specified currency.\n    #[must_use]\n    pub fn commission(&self, currency: &Currency) -> Option<Money> {\n        self.commissions.get(currency).copied()\n    }\n\n    /// Returns a map of all commissions by currency.\n    #[must_use]\n    pub fn commissions(&self) -> AHashMap<Currency, Money> {\n        self.commissions.clone()\n    }\n\n    /// Checks the event belongs to this account.\n    ///","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/accounts/base.rs#L198-L234","documentation":"The account accumulates per-currency commission totals using fixed-precision Money arithmetic; if adding a commission would overflow the Money representation, the update is rejected so the existing total is preserved rather than corrupted. The account's commission total for that currency is left unchanged.","triggerScenarios":"Calling `update_commissions` (via `try_update_commissions`) with a commission whose checked_add against the existing total for that currency overflows Money's bounds.","commonSituations":"Extremely large fill quantities/prices producing astronomical commissions, accumulating commissions over a very long-lived account, or a bug feeding gross notional values instead of commission amounts.","solutions":["Verify commission amounts passed to update_commissions are plausible per-fill values","Check whether commission rates/notional calculations are correct upstream","Persist/reset account state if the accumulated total is genuinely at its bound"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"from decimal import Decimal\nassert 0 < commission.as_decimal() < Decimal('1e18'), 'commission implausibly large'","typeGuard":null,"tryCatchPattern":"try:\n    account.update_commissions(commission)\nexcept Exception as e:\n    log.warning(f\"commission update rejected: {e}\")  # total preserved","preventionTips":["Sanity-check commission magnitude against notional before applying","Keep commission rates as fractions, not percentages","Reset/reconcile long-lived account state periodically"],"tags":["rust","overflow","money-arithmetic"],"backgroundTag":"value-out-of-range","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}