{"record":{"id":"27aac0ec69ddee51","repo":"nautechsystems/nautilus_trader","slug":"order-price-must-be-in-0-1","errorCode":null,"errorMessage":"order price must be in (0, 1)","messagePattern":"order price must be in \\(0, 1\\)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/websocket/dispatch.rs","lineNumber":1376,"sourceCode":"\nfn build_ws_order_status_report(\n    order: &PolymarketUserOrder,\n    status: &PolymarketUserOrderStatus,\n    order_type: PolymarketOrderType,\n    instrument: &InstrumentAny,\n    account_id: AccountId,\n    ts_event: UnixNanos,\n    ts_init: UnixNanos,\n) -> anyhow::Result<OrderStatusReport> {\n    let venue_order_id = VenueOrderId::from(order.id.as_str());\n    let order_status =\n        crate::execution::parse::resolve_order_status(status.status, order.event_type);\n    let order_side = OrderSide::from(order.side);\n    let time_in_force = TimeInForce::from(order_type);\n    let size_precision = instrument.size_precision();\n    let price_precision = instrument.price_precision();\n    let price_dec = parse_decimal_exact(&order.price)?;\n    anyhow::ensure!(\n        price_dec > Decimal::ZERO && price_dec < Decimal::ONE,\n        \"order price must be in (0, 1)\"\n    );\n    let quantity_dec = parse_decimal_exact(&order.original_size)?;\n    // Unfilled FOK cancellations carry an empty size_matched in captured venue messages\n    let filled_dec = if order.size_matched.is_empty() {\n        Decimal::ZERO\n    } else {\n        parse_decimal_exact(&order.size_matched)?\n    };\n    anyhow::ensure!(\n        quantity_dec > Decimal::ZERO && filled_dec >= Decimal::ZERO,\n        \"invalid order quantity\"\n    );\n    let quantity = Quantity::from_decimal_dp(\n        original_size_to_shares(quantity_dec, price_dec, order.side, order_type)?,\n        size_precision,\n    )?;","sourceCodeStart":1358,"sourceCodeEnd":1394,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/websocket/dispatch.rs#L1358-L1394","documentation":"build_ws_order_status_report() converts a venue order-update message into an OrderStatusReport and enforces that the venue-reported order price, parsed as an exact decimal, lies strictly between 0 and 1 — Polymarket prices are probabilities in the open interval (0, 1). A price of 0, 1, or outside that range means the venue message is malformed, uses a placeholder price (e.g. for market orders), or a parsing assumption broke, so the report is rejected rather than propagated with bogus data.","triggerScenarios":"A Polymarket WebSocket order-update carrying price \"0\" or \"1\" (e.g. zero-price placeholder on certain market-order/FOK records), an unparseable or shifted field mapped into order.price, or a venue schema change that moves the real price elsewhere.","commonSituations":"Market/FOK orders whose captured message has no meaningful limit price; new venue message fields after an API update; asset-level data corruption on the feed; tests feeding edge-case fixtures with price 0/1.","solutions":["Log the full raw order message to see what venue actually sent for price","Skip/ignore reports for message types that legitimately carry no price (e.g. pure cancels) instead of building a report","Update the parsing/mapping in the adapter if the venue schema changed and price moved fields","If your own code produces the message (tests/fixtures), supply a valid price strictly between 0 and 1"],"exampleFix":"// before\nanyhow::ensure!(\n    price_dec > Decimal::ZERO && price_dec < Decimal::ONE,\n    \"order price must be in (0, 1)\"\n);\n// after — treat priceless message shapes as non-reportable upstream\nif order.price.is_empty() || order.price == \"0\" {\n    return Ok(None); // venue sent a placeholder price; no report to emit\n}\nanyhow::ensure!(\n    price_dec > Decimal::ZERO && price_dec < Decimal::ONE,\n    \"order price must be in (0, 1)\"\n);","handlingStrategy":"validation","validationCode":"// validate before accepting a venue order update into your book/state\nlet p: f64 = order.price.parse()?;\nif !(p > 0.0 && p < 1.0) {\n    // skip or quarantine the message; do not build a report\n    return Ok(None);\n}","typeGuard":"fn has_valid_venue_price(order: &WsOrder) -> bool {\n    order.price.parse::<f64>().map(|p| p > 0.0 && p < 1.0).unwrap_or(false)\n}","tryCatchPattern":"match build_ws_order_status_report(&instrument, &order, ...) {\n    Ok(report) => emit(report),\n    Err(e) if e.to_string().contains(\"order price must be in (0, 1)\") => {\n        log::warn!(\"skipping order update with invalid venue price {:?}: {e:#}\", order.price);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Treat venue prices as untrusted input; range-check before use","Recognize placeholder-price message shapes (market/FOK records) and skip them upstream","Log full raw payloads on rejection to catch venue schema changes early","Pin and review the adapter against Polymarket API version updates"],"tags":["rust","websocket","validation","order-report","polymarket"],"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"}