{"record":{"id":"fa675b3f34250a15","repo":"nautechsystems/nautilus_trader","slug":"failed-to-resolve-positive-quantity-for-stream-ord","errorCode":null,"errorMessage":"failed to resolve positive quantity for stream order update {} (order_type={:?}, persistence_type={:?}, size={}, bsp_liability={:?}, size_matched={:?}, size_remaining={:?}, size_cancelled={:?}, size_lapsed={:?}, size_voided={:?})","messagePattern":"failed to resolve positive quantity for stream order update (.+?) \\(order_type=(.+?), persistence_type=(.+?), size=(.+?), bsp_liability=(.+?), size_matched=(.+?), size_remaining=(.+?), size_cancelled=(.+?), size_lapsed=(.+?), size_voided=(.+?)\\)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/betfair/src/stream/parse.rs","lineNumber":829,"sourceCode":"    let size_matched = uo.sm.unwrap_or(Decimal::ZERO);\n    let size_cancelled = uo.sc.unwrap_or(Decimal::ZERO);\n    let size_lapsed = uo.sl.unwrap_or(Decimal::ZERO);\n    let size_voided = uo.sv.unwrap_or(Decimal::ZERO);\n\n    // Include lapsed/voided in the closed quantity for status resolution\n    let size_closed = size_cancelled + size_lapsed + size_voided;\n    let order_status = if uo.status == StreamingOrderStatus::ExecutionComplete\n        && size_voided > Decimal::ZERO\n        && size_cancelled.is_zero()\n        && size_lapsed.is_zero()\n    {\n        OrderStatus::Voided\n    } else {\n        resolve_streaming_order_status(uo.status, size_matched, size_closed)\n    };\n\n    let quantity_decimal = stream_order_quantity(uo);\n    anyhow::ensure!(\n        quantity_decimal > Decimal::ZERO,\n        \"failed to resolve positive quantity for stream order update {} \\\n         (order_type={:?}, persistence_type={:?}, size={}, bsp_liability={:?}, \\\n         size_matched={:?}, size_remaining={:?}, size_cancelled={:?}, size_lapsed={:?}, size_voided={:?})\",\n        uo.id,\n        uo.ot,\n        uo.pt,\n        uo.s,\n        uo.bsp,\n        uo.sm,\n        uo.sr,\n        uo.sc,\n        uo.sl,\n        uo.sv,\n    );\n    let quantity = parse_betfair_quantity(quantity_decimal)?;\n    let filled_qty = parse_betfair_quantity(size_matched)?;\n","sourceCodeStart":811,"sourceCodeEnd":847,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/betfair/src/stream/parse.rs#L811-L847","documentation":"Stream-path counterpart of the OCM quantity check: while converting a stream OrderChangeMessage into report data, stream_order_quantity found size (s), bsp liability (bsp), and matched/remaining/cancelled/lapsed/voided (sm/sr/sc/sl/sv) all zero or absent, so the parser refuses to build a report. The error carries the update id and every raw size field for diagnosis.","triggerScenarios":"An order stream (OCM) update whose every quantity field is zero/None — e.g. a voided BSP bet at market closure, or venue data anomalies where size fields are omitted.","commonSituations":"Accounts subscribed to order streams with BSP bets that got voided; API changes omitting size fields for certain order classes.","solutions":["Correlate the logged uo.id with listCurrentOrders output to see the venue's record for that bet.","Capture the raw OCM message and file an adapter issue so the shape can be handled.","If isolated to specific markets/bets, exclude them from the order stream subscription as a workaround."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"for uo in &order_changes {\n    match parse_stream_order_update(uo, account_id, currency, ts_init) {\n        Ok(report) => reports.push(report),\n        Err(e) => {\n            // log the update id and continue so one bad OCM message does not kill the stream handler\n            log::warn!(\"skipping unparseable stream order update: {e}\");\n        }\n    }\n}","preventionTips":["Capture raw OCM frames in debug tooling when anomalous bets are suspected.","Correlate failing update ids with listCurrentOrders records before reporting.","Keep the adapter updated so parser coverage for unusual venue payloads improves."],"tags":["betfair","streaming","order-parsing","quantity","venue-data"],"backgroundTag":"venue-data-parse-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}