{"record":{"id":"7aacc6f2ee223371","repo":"nautechsystems/nautilus_trader","slug":"invalid-fee-amount-for-taker-fee-fee-and-notio","errorCode":null,"errorMessage":"invalid fee amount for taker_fee='{fee}' and notional='{notional}': multiplication overflow","messagePattern":"invalid fee amount for taker_fee='(.+?)' and notional='(.+?)': multiplication overflow","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs","lineNumber":192,"sourceCode":"        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\n///\n/// Returns an error if report construction fails.\n#[expect(clippy::too_many_arguments)]\npub fn parse_futures_order_update_to_fill(\n    msg: &BinanceFuturesOrderUpdateMsg,","sourceCodeStart":174,"sourceCodeEnd":210,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs#L174-L210","documentation":"In `resolve_commission`'s taker-fee branch, after notional is computed, the fee amount = taker_fee × notional is calculated with `checked_mul`. This error is raised when that multiplication overflows the `Decimal` type, meaning the resulting fee value cannot be represented and the fill's commission cannot be derived from the rate.","triggerScenarios":"A Trade-type futures order update with `taker_fee` present (and no `commission`) where `fee.checked_mul(notional)` returns None — an unusually large notional combined with a high fee rate exceeds Decimal capacity during `parse_futures_order_update_to_fill`.","commonSituations":"Corrupted or adversarial WS payloads with absurd taker_fee or quantity/price values; unit-test payloads with extreme numbers; essentially never with realistic venue data.","solutions":["Inspect the logged `taker_fee` and `notional` values for implausible magnitude.","Bound-check taker_fee (e.g. must be within 0..1) before multiplying.","Fall back to the REST user-trades endpoint to fetch the actual commission for the fill.","If huge notionals are legitimate for your products, refactor to a wider numeric representation upstream."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Rust: sanity-check taker_fee rate before multiplying\nfn fee_rate_valid(fee: &rust_decimal::Decimal) -> bool {\n    fee > &rust_decimal::Decimal::ZERO && fee < &rust_decimal::Decimal::ONE\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Bound-check fee rates to (0, 1) before use","Treat overflow on fee math as a data-corruption signal and fall back to REST fees","Log fee and notional values to make diagnosing overflow trivial"],"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"}