{"record":{"id":"881581741dbcd531","repo":"nautechsystems/nautilus_trader","slug":"invalid-fee-amount-amount-e","errorCode":null,"errorMessage":"invalid fee amount='{amount}': {e}","messagePattern":"invalid fee amount='(.+?)': (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs","lineNumber":197,"sourceCode":"        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,\n    account_id: AccountId,\n    instrument_id: InstrumentId,\n    price_precision: u8,\n    size_precision: u8,\n    taker_fee: Option<Decimal>,","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/websocket/streams/parse_exec.rs#L179-L215","documentation":"After the taker_fee × notional product succeeds, `resolve_commission` converts the fee amount into a `Money` via `Money::from_decimal(amount, currency)`. This error is wrapped when that conversion fails — most commonly the amount's decimal precision exceeds the quote currency's precision (default USDT), or the value is otherwise invalid (negative/zero-scale issues).","triggerScenarios":"Trade-type futures order update with `taker_fee` where fee × notional yields more fractional digits than the quote currency (USDT unless `quote_currency` provided) allows, during `parse_futures_order_update_to_fill`.","commonSituations":"High-precision fee rates (e.g. 0.0004) multiplied by large quantities producing amounts with more decimals than USDT's precision; a non-USDT quote asset not passed as `quote_currency` so precision defaults mismatch.","solutions":["Pass the correct `quote_currency` for the symbol so the right precision is used.","Round the computed fee amount to the currency's precision before `Money::from_decimal`.","Verify the fee rate's decimal places; truncate excess precision at parse time.","Reconcile the actual fee via REST user-trades if the computed value keeps failing."],"exampleFix":"// before\nMoney::from_decimal(amount, currency)\n    .map_err(|e| anyhow::anyhow!(\"invalid fee amount='{amount}': {e}\"))\n// after\nlet amount = amount.rescale(currency.precision);\nMoney::from_decimal(amount, currency)\n    .map_err(|e| anyhow::anyhow!(\"invalid fee amount='{amount}': {e}\"))","handlingStrategy":"validation","validationCode":"// Rust: rescale computed fee to currency precision before conversion\nlet amount = amount.rescale(currency.precision as u32);\ndebug_assert!(amount.scale() <= currency.precision as u32);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass the correct quote_currency so precision matches the symbol","Truncate fee amounts to currency precision before Money conversion","Reconcile fees against REST user-trades to catch precision drift"],"tags":["decimal-precision","fee-calculation","binance-futures","money-conversion"],"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-23T08:17:48.524Z"}