{"record":{"id":"b0837c91bfc19c99","repo":"nautechsystems/nautilus_trader","slug":"invalid-commission-raw-commission-e","errorCode":null,"errorMessage":"invalid commission='{raw_commission}': {e}","messagePattern":"invalid commission='(.+?)': (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/websocket/streams/dispatch.rs","lineNumber":765,"sourceCode":"        }\n    };\n\n    Ok((last_qty, last_px, commission_currency, commission))\n}\n\nfn parse_order_commission(\n    order: &OrderUpdateData,\n    bnfcr_currency: Currency,\n) -> anyhow::Result<(Currency, Option<Money>)> {\n    let currency = order_commission_currency(order, bnfcr_currency);\n\n    let Some(raw_commission) = order.commission.as_deref() else {\n        return Ok((currency, None));\n    };\n\n    let amount = parse_required_decimal(raw_commission, \"commission\")?;\n    let commission = Money::from_decimal(amount, currency)\n        .map_err(|e| anyhow::anyhow!(\"invalid commission='{raw_commission}': {e}\"))?;\n\n    Ok((currency, Some(commission)))\n}\n\nfn order_commission_currency(order: &OrderUpdateData, bnfcr_currency: Currency) -> Currency {\n    order\n        .commission_asset\n        .as_ref()\n        .map_or(bnfcr_currency, |asset| {\n            normalize_futures_asset(asset.as_str(), bnfcr_currency)\n        })\n}\n\nfn parse_order_terminal_quantities(order: &OrderUpdateData) -> anyhow::Result<(Decimal, Decimal)> {\n    let original_qty = parse_required_decimal(&order.original_qty, \"original_qty\")?;\n    let cumulative_filled_qty =\n        parse_required_decimal(&order.cumulative_filled_qty, \"cumulative_filled_qty\")?;\n","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/websocket/streams/dispatch.rs#L747-L783","documentation":"Binance Futures order fill parsing wraps a failure from `Money::from_decimal` when converting the raw commission string of an ORDER_TRADE_UPDATE fill into a Nautilus `Money` value. The underlying `e` typically indicates the amount has more decimal places than the currency's precision allows, or the amount is otherwise unrepresentable (e.g. negative, NaN). The raw string is included so the offending exchange payload can be inspected.","triggerScenarios":"A Binance Futures ORDER_TRADE_UPDATE event carries a `commission` field (e.g. \"0.00000123\" for BNB fee discount) whose decimal precision exceeds the precision of the resolved commission currency, or a malformed/negative value. Raised inside `parse_order_commission`, called from `parse_order_fill_event_fields` during WS fill dispatch.","commonSituations":"BNB fee-discount commissions with 8+ decimals against a 2-decimal fiat currency; venue sending commission in an asset whose precision disagrees with the local currency definition; a venue schema change or a test/mocked payload with an arbitrary commission string.","solutions":["Check the log's `raw_commission` value and compare its decimal places with the currency's precision; round/truncate the commission to currency precision at the adapter boundary if the venue sends extra digits.","Verify the resolved commission currency (commissionAsset mapped through `order_commission_currency`) is correct — a wrong currency with lower precision causes the rejection.","If the payload is genuinely malformed, report/disclose the message and skip or reconcile the fill via REST instead of treating it as a code bug.","Update the local `Currency` precision definition if the venue has changed precision for that asset."],"exampleFix":"// before\nlet commission = Money::from_decimal(amount, currency)\n    .map_err(|e| anyhow::anyhow!(\"invalid commission='{raw_commission}': {e}\"))?;\n// after\nlet amount = amount.round_to_currency_precision(currency); // truncate venue-supplied extra precision\nlet commission = Money::from_decimal(amount, currency)\n    .map_err(|e| anyhow::anyhow!(\"invalid commission='{raw_commission}': {e}\"))?;","handlingStrategy":"validation","validationCode":"// Rust: check commission fits currency precision before dispatch/handling\nfn commission_fits(raw: &str, currency: &Currency) -> bool {\n    raw.parse::<rust_decimal::Decimal>()\n        .map(|d| d.scale() <= currency.precision as u32 && d > rust_decimal::Decimal::ZERO)\n        .unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep local Currency precision definitions in sync with Binance asset specs","Round venue-supplied commissions to currency precision at the adapter boundary","Monitor for BNB fee-discount fills, which have higher-precision commissions","Alert on this error and reconcile affected fills via REST user-trades"],"tags":["decimal-precision","parsing","websocket","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"}