{"record":{"id":"7dfc788dc8439a28","repo":"nautechsystems/nautilus_trader","slug":"invalid-fee-notional-for-last-qty-last-qty-and","errorCode":null,"errorMessage":"invalid fee notional for last_qty='{last_qty}' and last_px='{last_px}': multiplication overflow","messagePattern":"invalid fee notional for last_qty='(.+?)' and last_px='(.+?)': multiplication overflow","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs","lineNumber":187,"sourceCode":"    taker_fee: Option<Decimal>,\n    quote_currency: Option<Currency>,\n    bnfcr_currency: Currency,\n) -> anyhow::Result<Money> {\n    if order.commission.is_some() || order.commission_asset.is_some() {\n        let raw_commission = order.commission.as_deref().unwrap_or(\"0\");\n        let amount = parse_required_decimal(raw_commission, \"commission\")?;\n        let currency = order.commission_asset.as_ref().map_or(bnfcr_currency, |a| {\n            normalize_futures_asset(a.as_str(), bnfcr_currency)\n        });\n        Money::from_decimal(amount, currency)\n            .map_err(|e| anyhow::anyhow!(\"invalid commission='{raw_commission}': {e}\"))\n    } else if let Some(fee) = taker_fee {\n        let currency = quote_currency.unwrap_or_else(Currency::USDT);\n        let notional = last_qty\n            .as_decimal()\n            .checked_mul(last_px.as_decimal())\n            .ok_or_else(|| {\n                anyhow::anyhow!(\n                    \"invalid fee notional for last_qty='{last_qty}' and last_px='{last_px}': multiplication overflow\",\n                )\n            })?;\n        let amount = fee.checked_mul(notional).ok_or_else(|| {\n            anyhow::anyhow!(\n                \"invalid fee amount for taker_fee='{fee}' and notional='{notional}': multiplication overflow\"\n            )\n        })?;\n        Money::from_decimal(amount, currency)\n            .map_err(|e| anyhow::anyhow!(\"invalid fee amount='{amount}': {e}\"))\n    } else {\n        Ok(Money::zero(Currency::USDT()))\n    }\n}\n\n/// Converts a Binance Futures order update (Trade type) to a Nautilus fill report.\n///\n/// # Errors","sourceCodeStart":169,"sourceCodeEnd":205,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs#L169-L205","documentation":"When a futures order update has no explicit commission but provides a `takerFee` rate, `resolve_commission` computes the fee as taker_fee × notional, where notional = last_qty × last_px. This error is raised when the `checked_mul` of quantity and price overflows the `Decimal` capacity, so the notional cannot be represented and the fee cannot be computed safely.","triggerScenarios":"`parse_futures_order_update_to_fill` handles a Trade update with `taker_fee` set but no `commission` field, and `last_qty.as_decimal().checked_mul(last_px.as_decimal())` returns None (combined magnitude/digits exceed Decimal limits).","commonSituations":"Extremely large fills (huge COIN-M quantities × high prices) or values with excessive decimal places produced by a bad/mocked payload; corrupted or adversarial venue data rather than normal trading.","solutions":["Check `last_qty` and `last_px` in the surrounding log for implausible magnitude or precision.","Validate/sanitize quantity and price against the instrument's tick size and max quantity before fee computation.","Reconcile the fee from the REST user-trades endpoint for that fill instead of computing from rate.","If legitimate large notional is expected, widen the decimal representation used before this call."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust: bound-check qty/px before fee computation\nfn notional_computable(qty: &rust_decimal::Decimal, px: &rust_decimal::Decimal) -> bool {\n    qty.is_sign_positive() && px.is_sign_positive()\n        && qty.mantissa().checked_mul(px.mantissa()).is_some()\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate quantity and price against instrument limits before use","Reject/flag WS payloads with implausible magnitudes","Prefer REST-sourced commissions over rate-derived computation for large fills"],"tags":["arithmetic-overflow","decimal","fee-calculation","binance-futures"],"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-23T08:17:48.524Z"}