{"record":{"id":"614bfd909eee7168","repo":"nautechsystems/nautilus_trader","slug":"field-value-is-not-exactly-representable-with-614bfd","errorCode":null,"errorMessage":"{field} {value} is not exactly representable with price precision {precision}","messagePattern":"(.+?) (.+?) is not exactly representable with price precision (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reconciliation.rs","lineNumber":300,"sourceCode":"    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    );\n    let evidence = value.normalize();\n    anyhow::ensure!(\n        evidence.scale() <= u32::from(FIXED_PRECISION),\n        \"historical {field} {value} exceeds the maximum representable price precision of {FIXED_PRECISION} decimals\",\n    );\n    let price = Price::from_decimal(evidence)\n        .with_context(|| format!(\"failed to represent historical {field} {value}\"))?;","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reconciliation.rs#L282-L318","documentation":"Domain Price values have fixed precision. After converting with Price::from_decimal_dp, the code checks the round-trip is exact; this error fires when the price decimal has more fractional digits than the configured price precision (e.g. 0.525 with precision 2).","triggerScenarios":"validate_price_evidence (from validate_order_row_values) gets a Decimal whose fractional scale exceeds the instrument's price precision, so price.as_decimal() != value.","commonSituations":"Polymarket tick sizes of 0.001 while instrument price precision is configured as 2; provider price strings with more decimals after a tick-size change; parsing artifacts adding float noise.","solutions":["Check the market's tick_size from Polymarket metadata and set the instrument price precision to match (e.g. 3 for 0.001 ticks).","Refetch market metadata — Polymarket can change tick size dynamically during a market's life.","Parse prices from the provider's string fields with Decimal directly to avoid float noise.","Round only with explicit confirmation that the venue accepts the rounded tick."],"exampleFix":"// before\nlet precision = 2u8;\nvalidate_price_evidence(row.price, precision, \"price\")?;\n// after\nlet precision = u8::try_from(market.tick_size_decimals).expect(\"tick precision\");\nvalidate_price_evidence(row.price, precision, \"price\")?;","handlingStrategy":"validation","validationCode":"fn fits_price_precision(p: Decimal, precision: u8) -> bool {\n    p.fract().scale() <= precision as u32\n}","typeGuard":"fn exactly_representable_price(v: Decimal, precision: u8) -> Option<Price> {\n    Price::from_decimal_dp(v, precision).ok().filter(|p| p.as_decimal() == v)\n}","tryCatchPattern":"match validate_price_evidence(price, precision, \"price\") {\n    Ok(()) => (),\n    Err(e) if e.to_string().contains(\"representable\") => reload_tick_size_and_retry(&market_id)?,\n    Err(e) => return Err(e),\n}","preventionTips":["Derive price precision from the market's tick_size metadata, not a hardcoded constant","Refetch metadata when Polymarket changes a market's tick size dynamically","Parse provider price strings directly into Decimal to avoid float artifacts"],"tags":["rust","validation","price","precision"],"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"}