nautechsystems/nautilus_trader · error

{currency} commission total exceeds Money bounds

Error message

{currency} commission total exceeds Money bounds

What it means

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.

Source

Thrown at crates/model/src/accounts/base.rs:216

    /// Updates the account commissions with the provided amount.
    ///
    /// # Errors
    ///
    /// Returns an error if the accumulated commission exceeds [`Money`] bounds.
    pub fn try_update_commissions(&mut self, commission: Money) -> anyhow::Result<()> {
        // TODO: Remove once from_raw enforces canonical precision alignment (v2)
        let commission = commission.normalized();
        if commission.is_zero() {
            return Ok(());
        }
        let currency = commission.currency;
        let total = self
            .commissions
            .get(&currency)
            .copied()
            .map_or(Some(commission), |total| total.checked_add(commission))
            .ok_or_else(|| anyhow::anyhow!("{currency} commission total exceeds Money bounds"))?;
        self.commissions.insert(currency, total);
        Ok(())
    }

    /// Returns the total commission for the specified currency.
    #[must_use]
    pub fn commission(&self, currency: &Currency) -> Option<Money> {
        self.commissions.get(currency).copied()
    }

    /// Returns a map of all commissions by currency.
    #[must_use]
    pub fn commissions(&self) -> AHashMap<Currency, Money> {
        self.commissions.clone()
    }

    /// Checks the event belongs to this account.
    ///

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Verify commission amounts passed to update_commissions are plausible per-fill values
  2. Check whether commission rates/notional calculations are correct upstream
  3. Persist/reset account state if the accumulated total is genuinely at its bound
Defensive patterns

Strategy: try-catch

Validate before calling

from decimal import Decimal
assert 0 < commission.as_decimal() < Decimal('1e18'), 'commission implausibly large'

Try / catch

try:
    account.update_commissions(commission)
except Exception as e:
    log.warning(f"commission update rejected: {e}")  # total preserved

Prevention

When it happens

Trigger: Calling `update_commissions` (via `try_update_commissions`) with a commission whose checked_add against the existing total for that currency overflows Money's bounds.

Common situations: 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.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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