{"record":{"id":"948e10dc159cd6fe","repo":"nautechsystems/nautilus_trader","slug":"historical-field-value-exceeds-the-maximum-rep","errorCode":null,"errorMessage":"historical {field} {value} exceeds the maximum representable price precision of {FIXED_PRECISION} decimals","messagePattern":"historical (.+?) (.+?) exceeds the maximum representable price precision of (.+?) decimals","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/execution/reconciliation.rs","lineNumber":313,"sourceCode":"        \"{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}\"))?;\n    anyhow::ensure!(\n        price.as_decimal() == value,\n        \"historical {field} {value} is not exactly representable as a price\",\n    );\n    Ok(price)\n}\n\n#[derive(Clone, Copy, Debug)]\nstruct ValidatedOrderRow {\n    venue_order_id: VenueOrderId,\n    ts_accepted: UnixNanos,\n    expire_time: Option<UnixNanos>,\n}","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/execution/reconciliation.rs#L295-L331","documentation":"After confirming the value is in (0, 1), validate_historical_price_evidence normalizes the Decimal and requires its scale (decimal places) to be <= FIXED_PRECISION, the adapter's fixed price precision. Historical evidence that needs more decimals cannot be represented exactly as a Polymarket fixed-precision price, so this anyhow error is raised.","triggerScenarios":"A historical price Decimal with more decimal places than FIXED_PRECISION (after normalize(), so trailing zeros do not help) is passed through validate_trade_values -> validate_historical_price_evidence, e.g. 0.1234567 with a 6-decimal FIXED_PRECISION.","commonSituations":"Aggregating or averaging fills produces long repeating decimals (e.g. average price 0.5033333333); importing prices from an exchange/export with higher tick precision; version change where FIXED_PRECISION was lowered.","solutions":["Round or quantize the historical value to FIXED_PRECISION decimals before validation, accepting the rounding explicitly.","Recompute the historical evidence from raw fills using exact tick-size multiples so it naturally fits the precision.","If higher precision is genuinely needed, adjust FIXED_PRECISION in the adapter — only with awareness of the venue's tick constraints."],"exampleFix":"// before\nlet avg = Decimal::new(5033333333, 10); // 0.5033333333 -> scale 10\nvalidate_historical_price_evidence(avg, \"avg_price\")?;\n// after\nlet avg = avg.round_dp(u32::from(FIXED_PRECISION));\nvalidate_historical_price_evidence(avg, \"avg_price\")?;","handlingStrategy":"validation","validationCode":"use rust_decimal::prelude::*;\nfn fits_fixed_precision(v: rust_decimal::Decimal, dp: u32) -> bool {\n    v.normalize().scale() <= dp\n}\nlet value = avg.round_dp(u32::from(FIXED_PRECISION));","typeGuard":"fn is_representable(v: &rust_decimal::Decimal, fixed_precision: u32) -> bool {\n    v.normalize().scale() <= fixed_precision\n}","tryCatchPattern":"match validate_historical_price_evidence(value, field) {\n    Err(e) if e.to_string().contains(\"exceeds the maximum representable price precision\") => {\n        let snapped = value.round_dp(u32::from(FIXED_PRECISION));\n        validate_historical_price_evidence(snapped, field)?\n    }\n    r => r?,\n}","preventionTips":["Quantize averages/derived prices to FIXED_PRECISION immediately after computing them","Keep raw fill data so derived evidence can be recomputed at the venue's tick precision","Pin FIXED_PRECISION expectations when importing data from external exports"],"tags":["polymarket","reconciliation","precision","decimal"],"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"}