{"record":{"id":"04e63fd81777d636","repo":"nautechsystems/nautilus_trader","slug":"failed-to-create-quantity-from-orig-sz-e","errorCode":null,"errorMessage":"Failed to create quantity from orig_sz: {e}","messagePattern":"Failed to create quantity from orig_sz: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/hyperliquid/src/http/parse.rs","lineNumber":967,"sourceCode":"            _ => OrderType::Limit,\n        }\n    } else {\n        OrderType::Limit\n    };\n\n    let time_in_force = order\n        .tif\n        .map_or(TimeInForce::Gtc, hyperliquid_time_in_force_to_nautilus);\n    let order_status = OrderStatus::from(*status);\n\n    let price_precision = instrument.price_precision();\n    let size_precision = instrument.size_precision();\n\n    let orig_sz = order.orig_sz;\n    let current_sz = order.sz;\n\n    let quantity = Quantity::from_decimal_dp(orig_sz.abs(), size_precision)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create quantity from orig_sz: {e}\"))?;\n    let filled_sz = orig_sz.abs() - current_sz.abs();\n    let filled_qty = Quantity::from_decimal_dp(filled_sz, size_precision)\n        .map_err(|e| anyhow::anyhow!(\"Failed to create quantity from filled_sz: {e}\"))?;\n\n    let ts_accepted = UnixNanos::from(order.timestamp * 1_000_000);\n    let ts_last = ts_accepted;\n    let report_id = UUID4::new();\n\n    let mut report = OrderStatusReport::new(\n        account_id,\n        instrument_id,\n        None, // client_order_id - will be set if present\n        venue_order_id,\n        order_side.into(),\n        order_type,\n        time_in_force,\n        order_status,\n        quantity,","sourceCodeStart":949,"sourceCodeEnd":985,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/hyperliquid/src/http/parse.rs#L949-L985","documentation":"parse_order_status_report_from_basic() converts the exchange-reported original size (order.orig_sz) into a domain Quantity rounded to the instrument's size_precision; it fails when the value cannot be represented at that precision (e.g. too many decimal digits or out of range for Quantity).","triggerScenarios":"Parsing an order status report (HTTP or WS) whose orig_sz has more decimal places than the configured instrument size_precision, or a value outside the Quantity representable range (e.g. a builder-deployed market whose instrument metadata mismatches the sizes reported).","commonSituations":"Stale or wrong instrument definitions where size_precision is smaller than what Hyperliquid returns for that market; HIP-3 builder-deployed markets with unusual size decimals; instrument definition changed on the venue while cached definitions are outdated.","solutions":["Reload/refresh instrument definitions so size_precision matches the venue's current tick/size rules for that symbol","Check orig_sz in the raw payload ({e} details) for unexpected magnitude or precision","Update the adapter/instrument parsing if a new market type (HIP-3) reports sizes incompatible with current precision handling","Re-fetch instruments at connect time rather than relying on cached definitions"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// before parsing, confirm instrument precision accommodates the venue size\nlet dp = orig_sz.abs().fract().to_string().split('.').nth(1).map(|f| f.len()).unwrap_or(0);\nif dp > instrument.size_precision() as usize { refresh_instrument_definition(); }","typeGuard":null,"tryCatchPattern":"match parse_order_status_report_from_basic(instrument, order, ...) { Err(e) if e.to_string().contains(\"Failed to create quantity from orig_sz\") => { refresh_instruments(); reparse(); }, other => other }","preventionTips":["Refresh instrument definitions at connect time; never cache across sessions with stale precision","Verify size_precision matches Hyperliquid's market metadata for the symbol","Watch for HIP-3 builder-deployed markets with unusual size decimals","Compare raw orig_sz values in logs when the error appears to detect precision drift"],"tags":["parsing","quantity","precision","order-status"],"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-14T05:17:10.506Z"}