{"record":{"id":"161b1b8d6d51ade3","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-quantity-from-fill-sz-e","errorCode":null,"errorMessage":"Failed to create quantity from fill sz: {e}","messagePattern":"Failed to create quantity from fill sz: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/http/parse.rs","lineNumber":1188,"sourceCode":"    }\n\n    let trade_id = make_fill_trade_id(\n        &fill.hash,\n        fill.oid,\n        fill.px,\n        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(","sourceCodeStart":1170,"sourceCodeEnd":1206,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/http/parse.rs#L1170-L1206","documentation":"Raised in parse_fill_report when Quantity::from_decimal_dp fails converting fill.sz into a domain Quantity at the instrument's size precision. The code takes fill.sz.abs(), so failure is not from sign but from unrepresentable magnitude, excessive scale, or overflow in the fixed-point QuantityRaw conversion. It indicates the venue-reported fill size can't be represented for this instrument.","triggerScenarios":"Calling fill_reports_from_response for a fill whose sz has more decimal places than the instrument's size_precision, or whose scaled value exceeds QuantityRaw's range.","commonSituations":"Assets whose size decimals changed since instruments were loaded; extremely large fills near fixed-point limits; malformed/precision-heavy sz values from the venue API.","solutions":["Inspect the raw fill.sz and the instrument's size_precision; refresh instrument definitions if the venue changed lot size","Verify the coin-to-instrument mapping so the correct size_precision is applied","Normalize sz to the instrument precision before conversion or adjust the instrument definition","Process fills individually so a single unrepresentable fill doesn't discard the entire response"],"exampleFix":"// before\nlet 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// after\nlet 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}\", fill.sz))?;","handlingStrategy":"try-catch","validationCode":"# Python: check fill size against instrument size precision\nassert fill_sz > 0, \"fill size must be positive\"","typeGuard":null,"tryCatchPattern":"try:\n    fills = client.request_fill_reports(...)\nexcept ValueError as e:\n    if \"fill sz\" in str(e):\n        log.warning(\"skipping fill with unrepresentable size: %s\", e)\n    else:\n        raise","preventionTips":["Keep instrument size_precision synchronized with venue lot-size changes","Watch for fills near fixed-point limits on high-value assets","Process fills individually with per-item error handling"],"tags":["rust","hyperliquid","parsing","fills","quantity-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-14T00:17:10.932Z"}