{"record":{"id":"bf3e32b66f028706","repo":"nautechsystems/nautilus_trader","slug":"failed-to-parse-filled-quantity-for-ord-id-acc","errorCode":null,"errorMessage":"Failed to parse filled quantity for ord_id={}, acc_fill_sz='{}': {e}","messagePattern":"Failed to parse filled quantity for ord_id=(.+?), acc_fill_sz='(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/common/parse.rs","lineNumber":795,"sourceCode":"            log::warn!(\n                \"Cannot convert quote quantity to base without price, using raw sz: \\\n                 ord_id={}, sz={}, px='{}', avg_px='{}'\",\n                order.ord_id.as_str(),\n                order.sz,\n                order.px,\n                order.avg_px\n            );\n            Quantity::from_str(&order.sz).map_err(|e| {\n                anyhow::anyhow!(\n                    \"Failed to parse fallback quantity for ord_id={}, sz='{}': {e}\",\n                    order.ord_id.as_str(),\n                    order.sz\n                )\n            })?\n        };\n\n        let filled_qty_dec = parse_quantity(&order.acc_fill_sz, size_precision).map_err(|e| {\n            anyhow::anyhow!(\n                \"Failed to parse filled quantity for ord_id={}, acc_fill_sz='{}': {e}\",\n                order.ord_id.as_str(),\n                order.acc_fill_sz\n            )\n        })?;\n\n        (quantity_base, filled_qty_dec)\n    } else {\n        // Base-quantity order: both sz and acc_fill_sz are in base currency\n        let quantity_dec = parse_quantity(&order.sz, size_precision).map_err(|e| {\n            anyhow::anyhow!(\n                \"Failed to parse base quantity for ord_id={}, sz='{}': {e}\",\n                order.ord_id.as_str(),\n                order.sz\n            )\n        })?;\n        let filled_qty_dec = parse_quantity(&order.acc_fill_sz, size_precision).map_err(|e| {\n            anyhow::anyhow!(","sourceCodeStart":777,"sourceCodeEnd":813,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/common/parse.rs#L777-L813","documentation":"parse_order_status_report parses the accumulated filled size acc_fill_sz (always base currency on OKX) via parse_quantity with the instrument's size precision. This error means acc_fill_sz was not a valid decimal number representable at that precision, so the order status report cannot be built.","triggerScenarios":"OKX returns an acc_fill_sz that is empty, non-numeric, or has precision beyond size_precision for any order being parsed into an OrderStatusReport.","commonSituations":"Cancelled orders where OKX returns empty acc_fill_sz; adapter/instrument definition precision mismatch vs lotSz; OKX API changes to field formatting; corrupted recorded payloads.","solutions":["Log the raw acc_fill_sz for the failing ord_id","Treat empty acc_fill_sz as zero before parsing (normalize upstream)","Check the instrument's size_precision matches OKX lotSz for the instrument","Upgrade the adapter in case a newer version normalizes this field"],"exampleFix":"// before\nlet filled = parse_quantity(&order.acc_fill_sz, size_precision)?;\n// after\nlet acc = if order.acc_fill_sz.trim().is_empty() { \"0\" } else { order.acc_fill_sz.as_str() };\nlet filled = parse_quantity(acc, size_precision)?;","handlingStrategy":"validation","validationCode":"let acc = order.acc_fill_sz.trim();\nif acc.is_empty() || rust_decimal::Decimal::from_str(acc).is_err() { /* normalize to \"0\" or skip */ }","typeGuard":"fn parseable_at_precision(s: &str, precision: u8) -> bool {\n    match rust_decimal::Decimal::from_str(s.trim()) {\n        Ok(d) => d.fract_digits() as u8 <= precision,\n        Err(_) => false,\n    }\n}","tryCatchPattern":"match parse_order_status_report(&order, &instrument, ts_init) {\n    Ok(r) => handle(r),\n    Err(e) if e.to_string().contains(\"filled quantity\") => log::warn!(\"bad acc_fill_sz for {}: {e}\", order.ord_id),\n    Err(e) => return Err(e),\n}","preventionTips":["Normalize empty acc_fill_sz to \"0\" before parsing","Verify size_precision equals OKX lotSz decimals","Test fixtures with empty and zero acc_fill_sz","Monitor OKX API changelogs for field format changes"],"tags":["okx","rust","parsing","quantity","decimal"],"backgroundTag":"invalid-argument-format","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"}