{"record":{"id":"d814b4173dfb97e0","repo":"nautechsystems/nautilus_trader","slug":"field-value-must-be-greater-than-zero-and-less","errorCode":null,"errorMessage":"{field} {value} 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":293,"sourceCode":"            value >= Decimal::ZERO,\n            \"{field} {value} must be non-negative\"\n        );\n    } else {\n        anyhow::ensure!(value > Decimal::ZERO, \"{field} {value} must be positive\");\n    }\n\n    let quantity = Quantity::from_decimal_dp(value, precision).with_context(|| {\n        format!(\"failed to represent {field} {value} with quantity precision {precision}\")\n    })?;\n    anyhow::ensure!(\n        quantity.as_decimal() == value,\n        \"{field} {value} is not exactly representable with quantity precision {precision}\",\n    );\n    Ok(())\n}\n\nfn validate_price_evidence(value: Decimal, precision: u8, field: &str) -> anyhow::Result<()> {\n    anyhow::ensure!(\n        value > Decimal::ZERO && value < Decimal::ONE,\n        \"{field} {value} must be greater than zero and less than one\",\n    );\n    let price = Price::from_decimal_dp(value, precision).with_context(|| {\n        format!(\"failed to represent {field} {value} with price precision {precision}\")\n    })?;\n    anyhow::ensure!(\n        price.as_decimal() == value,\n        \"{field} {value} is not exactly representable with price precision {precision}\",\n    );\n    Ok(())\n}\n\nfn validate_historical_price_evidence(value: Decimal, field: &str) -> anyhow::Result<Price> {\n    anyhow::ensure!(\n        value > Decimal::ZERO && value < Decimal::ONE,\n        \"{field} {value} must be greater than zero and less than one\",\n    );","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reconciliation.rs#L275-L311","documentation":"Polymarket binary-market prices are probabilities and must lie strictly between 0 and 1. validate_price_evidence rejects any price evidence that is zero, negative, one, or greater than one before it can become a domain Price.","triggerScenarios":"validate_order_row_values -> validate_price_evidence is called with a price Decimal <= 0 or >= 1 — e.g. a price of 0 on a cancelled row, 1.0 on a resolved market, or a raw-cents value like 55 instead of 0.55.","commonSituations":"Sending prices in cents (0–100) instead of probability decimals (0–1); prices captured after market resolution at 0 or 1; provider returning 0-price placeholder rows.","solutions":["Check unit conventions: convert cent prices to decimals (divide by 100) if your code works in cents.","Confirm the market has not resolved; 0/1 prices are normal post-resolution but invalid for active reconciliation.","Skip zero-price rows (often placeholders for cancellations) before validation.","Verify the price field being passed is actually a price, not size or another quantity."],"exampleFix":"// before\nvalidate_price_evidence(row.price, precision, \"price\")?;\n// after\nlet price = if row.price > Decimal::ONE { row.price / Decimal::from(100) } else { row.price }; // cents -> probability\nvalidate_price_evidence(price, precision, \"price\")?;","handlingStrategy":"validation","validationCode":"fn is_valid_probability(p: Decimal) -> bool { p > Decimal::ZERO && p < Decimal::ONE }","typeGuard":"fn as_probability(v: Decimal) -> Option<Decimal> {\n    is_valid_probability(v).then_some(v)\n}","tryCatchPattern":"match validate_price_evidence(price, precision, \"price\") {\n    Err(e) if e.to_string().contains(\"less than one\") => { skip_row(row_id); Ok(()) }\n    other => other,\n}","preventionTips":["Decide on one price unit (probability 0-1) and convert cent values at the API boundary","Skip 0-price placeholder rows from cancellations","Detect resolved markets (prices pinned at 0/1) and stop reconciling them"],"tags":["rust","validation","price","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"}