{"record":{"id":"4ce4821a8db55d72","repo":"nautechsystems/nautilus_trader","slug":"failed-to-resolve-positive-quantity-for-current-or","errorCode":null,"errorMessage":"failed to resolve positive quantity for current order {} (order_type={:?}, persistence_type={:?}, price_size={}, bsp_liability={}, size_matched={}, size_remaining={}, size_cancelled={}, size_lapsed={}, size_voided={})","messagePattern":"failed to resolve positive quantity for current order (.+?) \\(order_type=(.+?), persistence_type=(.+?), price_size=(.+?), bsp_liability=(.+?), size_matched=(.+?), size_remaining=(.+?), size_cancelled=(.+?), size_lapsed=(.+?), size_voided=(.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/betfair/src/http/parse.rs","lineNumber":85,"sourceCode":"        OrderStatus::Voided\n    } else {\n        resolve_order_status(order.status, size_matched, size_closed)\n    };\n\n    // Prefer lifecycle sum when price_size.size is zero. Use bsp_liability for\n    // on-close orders that report liability without stake/size.\n    let total_size = order.price_size.size;\n    let lifecycle_qty = size_matched + size_remaining + size_cancelled + size_lapsed + size_voided;\n    let qty = if total_size > Decimal::ZERO {\n        total_size\n    } else if lifecycle_qty > Decimal::ZERO {\n        lifecycle_qty\n    } else if uses_liability_based_quantity(order) && order.bsp_liability > Decimal::ZERO {\n        order.bsp_liability\n    } else {\n        Decimal::ZERO\n    };\n    anyhow::ensure!(\n        qty > Decimal::ZERO,\n        \"failed to resolve positive quantity for current order {} \\\n         (order_type={:?}, persistence_type={:?}, price_size={}, bsp_liability={}, \\\n         size_matched={}, size_remaining={}, size_cancelled={}, size_lapsed={}, size_voided={})\",\n        order.bet_id,\n        order.order_type,\n        order.persistence_type,\n        order.price_size.size,\n        order.bsp_liability,\n        size_matched,\n        size_remaining,\n        size_cancelled,\n        size_lapsed,\n        size_voided,\n    );\n    let quantity = parse_betfair_quantity(qty)?;\n    let filled_qty = parse_betfair_quantity(size_matched)?;\n","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/betfair/src/http/parse.rs#L67-L103","documentation":"While converting a Betfair CurrentOrderSummary (from listCurrentOrders) into an OrderStatusReport, quantity resolution found no positive value: price_size.size, the lifecycle sum (matched+remaining+cancelled+lapsed+voided), and bsp_liability (for liability-based on-close orders) were all zero. The parser refuses to emit a zero-quantity report and errors, including the bet id and every size field for diagnosis.","triggerScenarios":"An OCM order-status or fill poll returns a current order whose every size field is zero or absent (absent fields default to Decimal::ZERO) — e.g. a fully voided BSP bet with zero liability, or venue data anomalies for on-close orders.","commonSituations":"Accounts with historical or cancelled orders reporting all-zero sizes; Betfair API changes omitting size for certain order classes; querying wide time ranges that pull in anomalous stale records.","solutions":["Capture the bet id from the message and inspect the raw record via listCurrentOrders to see its actual fields.","Narrow the order status query window so anomalous stale orders fall outside the request.","File an adapter issue with the logged field values so handling for that order shape can be added."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"for order in &response.current_orders {\n    match parse_current_order_report(order, account_id, currency, ts_init) {\n        Ok(report) => reports.push(report),\n        Err(e) => {\n            // log with bet id and continue so one anomalous order does not stall reconciliation\n            log::warn!(\"skipping unparseable current order: {e}\");\n        }\n    }\n}","preventionTips":["Keep order-status query windows narrow so anomalous historical records are excluded.","Log the full field dump included in the error for postmortem analysis.","Report recurring bet-id shapes to adapter maintainers so the parser grows coverage."],"tags":["betfair","order-parsing","quantity","venue-data","ocm"],"backgroundTag":"venue-data-parse-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}