{"record":{"id":"394af79282db01cc","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-commission-from-fee-e","errorCode":null,"errorMessage":"Failed to create commission from fee: {e}","messagePattern":"Failed to create commission from fee: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/http/parse.rs","lineNumber":1194,"sourceCode":"        fill.sz,\n        fill.time,\n        fill.start_position,\n    );\n    let order_side = parse_fill_side(&fill.side);\n\n    let price_precision = instrument.price_precision();\n    let size_precision = instrument.size_precision();\n\n    let last_px = Price::from_decimal_dp(fill.px, price_precision)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create price from fill px: {e}\"))?;\n    let last_qty = Quantity::from_decimal_dp(fill.sz.abs(), size_precision)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create quantity from fill sz: {e}\"))?;\n\n    let fee_amount = fill.fee;\n\n    let fee_currency = resolve_fee_currency(fill.fee_token.as_str(), fee_amount, instrument)?;\n    let commission = Money::from_decimal(fee_amount, fee_currency)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create commission from fee: {e}\"))?;\n\n    // Determine liquidity side based on 'crossed' flag\n    let liquidity_side = if fill.crossed {\n        LiquiditySide::Taker\n    } else {\n        LiquiditySide::Maker\n    };\n\n    let ts_event = UnixNanos::from(fill.time * 1_000_000);\n    let report_id = UUID4::new();\n\n    let report = FillReport::new(\n        account_id,\n        instrument_id,\n        venue_order_id,\n        trade_id,\n        order_side,\n        last_qty,","sourceCodeStart":1176,"sourceCodeEnd":1212,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/http/parse.rs#L1176-L1212","documentation":"Raised in parse_fill_report when Money::from_decimal fails creating the commission Money from fill.fee in the resolved fee currency. Money::from_decimal fails when the value cannot be scaled to the currency's precision without overflow or exceeds the MoneyRaw range. The fee currency is resolved via resolve_fee_currency (the instrument's quote currency or the fee_token), so a mismatch between the fee's decimal scale and the currency precision, or an extreme fee value, triggers this.","triggerScenarios":"Calling fill_reports_from_response for a fill whose fee magnitude overflows the raw Money representation at the fee currency's precision, or whose decimal scale can't be converted (e.g. fee denominated in a token resolved to a currency with fewer decimals and huge magnitude).","commonSituations":"Fees paid in a non-quote token whose currency has low precision while the fee value is large; unusual fee values during volatility spikes; resolve_fee_currency returning a currency whose precision doesn't match the fee_token's decimals.","solutions":["Log the fee value and resolved fee currency; verify resolve_fee_currency picked the right currency for fill.fee_token","Confirm the fee magnitude is sane for the currency's precision; refresh currency definitions if the token's decimals are wrong","Scale/round the fee to the currency precision before Money::from_decimal, or fix the currency's precision in its definition","Handle the error per-fill to avoid failing the entire fills response"],"exampleFix":"// before\nlet commission = Money::from_decimal(fee_amount, fee_currency)\n    .map_err(|e| anyhow::anyhow!(\"Failed to create commission from fee: {e}\"))?;\n// after\nlet commission = Money::from_decimal(fee_amount, fee_currency)\n    .map_err(|e| anyhow::anyhow!(\"Failed to create commission from fee {} {}: {e}\", fee_amount, fee_currency.code))?;","handlingStrategy":"try-catch","validationCode":"# Python: sanity-check fee magnitude relative to fill notional\nif abs(fee) > fill_notional:\n    log.warning(\"suspicious fee %s for fill notional %s\", fee, fill_notional)","typeGuard":null,"tryCatchPattern":"try:\n    fills = client.request_fill_reports(...)\nexcept ValueError as e:\n    if \"commission\" in str(e):\n        log.warning(\"fee not representable as Money, skipping fill: %s\", e)\n    else:\n        raise","preventionTips":["Verify fee_token resolution picks the correct currency and precision","Keep currency definitions (decimals/precision) accurate for all fee tokens","Round fees to the currency precision before Money conversion in custom pipelines"],"tags":["rust","hyperliquid","parsing","fills","money-conversion","fees"],"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-14T05:17:10.506Z"}