{"record":{"id":"503d0857adc7d8b0","repo":"nautechsystems/nautilus_trader","slug":"price-field-price-must-be-greater-than-zero-an","errorCode":null,"errorMessage":"{price_field} {price} must be greater than zero and less than one","messagePattern":"(.+?) (.+?) must be greater than zero and less than one","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reconciliation.rs","lineNumber":422,"sourceCode":"    size_precision: u8,\n    quantity_field: &str,\n    price_field: &str,\n) -> anyhow::Result<Price> {\n    validate_quantity_evidence(quantity, size_precision, quantity_field, false)?;\n    validate_historical_price_evidence(price, price_field)\n}\n\nfn validate_pending_trade_values(\n    quantity: Decimal,\n    price: Decimal,\n    quantity_field: &str,\n    price_field: &str,\n) -> anyhow::Result<()> {\n    anyhow::ensure!(\n        quantity > Decimal::ZERO,\n        \"{quantity_field} {quantity} must be positive\"\n    );\n    anyhow::ensure!(\n        price > Decimal::ZERO && price < Decimal::ONE,\n        \"{price_field} {price} must be greater than zero and less than one\",\n    );\n    Ok(())\n}\n\nfn require_trade_timestamp(\n    ts_event: Option<UnixNanos>,\n    trade: &PolymarketTradeReport,\n) -> anyhow::Result<UnixNanos> {\n    ts_event.with_context(|| {\n        format!(\n            \"selected trade {} has invalid match_time {}\",\n            trade.id, trade.match_time,\n        )\n    })\n}\n","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reconciliation.rs#L404-L440","documentation":"The second half of validate_pending_trade_values asserts the price Decimal is a valid probability: strictly greater than zero and strictly less than one. Any value outside the open interval (0, 1) triggers this anyhow error with the caller-provided field label.","triggerScenarios":"classify_target_trade passes a pending trade price <= 0 or >= 1 into validate_pending_trade_values — e.g. a provider price of exactly 1.0, 0, a percentage value like 55 (instead of 0.55), or a mis-scaled raw integer.","commonSituations":"Provider feeds returning prices as whole percentages; price 1.0 for resolved/100%-likely outcomes; swapping price and size columns when parsing provider exports.","solutions":["Normalize provider prices: divide percentages by 100 so the value lies in (0, 1) before validation.","Exclude resolved or fully-determined markets where the price is 0 or 1 from pending-trade reconciliation.","Verify the correct column/field is passed as price rather than quantity."],"exampleFix":"// before\nlet price = Decimal::from(55); // 55% as integer\nvalidate_pending_trade_values(qty, price, \"size\", \"price\")?;\n// after\nlet price = Decimal::from(55) / Decimal::from(100); // 0.55\nvalidate_pending_trade_values(qty, price, \"size\", \"price\")?;","handlingStrategy":"validation","validationCode":"fn is_probability(v: rust_decimal::Decimal) -> bool {\n    v > rust_decimal::Decimal::ZERO && v < rust_decimal::Decimal::ONE\n}\nlet price = if raw_price > Decimal::ONE { raw_price / Decimal::from(100) } else { raw_price }; // de-percentize","typeGuard":"fn is_valid_pending_price(p: &rust_decimal::Decimal) -> bool {\n    *p > rust_decimal::Decimal::ZERO && *p < rust_decimal::Decimal::ONE\n}","tryCatchPattern":"match validate_pending_trade_values(qty, price, \"size\", \"price\") {\n    Err(e) if e.to_string().contains(\"greater than zero and less than one\") => {\n        let normalized = price / Decimal::from(100); // handle percent-encoded feeds\n        validate_pending_trade_values(qty, normalized, \"size\", \"price\")?\n    }\n    other => other?,\n}","preventionTips":["Detect and convert whole-number percentage feeds at ingestion","Exclude resolved markets (price 0 or 1) from pending-trade reconciliation","Assert price < 1 in your own order-submission layer so bad data never reaches reconciliation"],"tags":["polymarket","reconciliation","price-validation","probability"],"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-14T00:17:10.932Z"}