{"record":{"id":"15b964ae5034c13c","repo":"nautechsystems/nautilus_trader","slug":"invalid-price-value-at-precision-precision-15b964","errorCode":null,"errorMessage":"invalid price `{value}` at precision {precision}: {e}","messagePattern":"invalid price `(.+?)` at precision (.+?): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/common/parse.rs","lineNumber":99,"sourceCode":"        anyhow::anyhow!(\"Quantity overflow for ticks={ticks}, decimals={decimals}: {e}\")\n    })\n}\n\n/// Converts a decimal string into a Nautilus [`Price`] at the requested precision.\n///\n/// # Errors\n///\n/// Returns an error if the string is not a decimal, if `precision` exceeds\n/// [`MAX_DECIMALS`], or if the resulting value is out of range.\npub fn parse_price(value: &str, precision: u8) -> anyhow::Result<Price> {\n    anyhow::ensure!(\n        precision <= MAX_DECIMALS,\n        \"price precision {precision} exceeds maximum {MAX_DECIMALS}\",\n    );\n    let decimal =\n        Decimal::from_str(value).map_err(|e| anyhow::anyhow!(\"invalid price `{value}`: {e}\"))?;\n    Price::from_decimal_dp(decimal, precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid price `{value}` at precision {precision}: {e}\"))\n}\n\n/// Converts a decimal string into a non-negative Nautilus [`Quantity`].\n///\n/// Zero is allowed because Lighter sends zero-size book levels to delete\n/// existing orders.\n///\n/// # Errors\n///\n/// Returns an error if the string is not a decimal, if `precision` exceeds\n/// [`MAX_DECIMALS`], if the value is negative, or if the resulting quantity\n/// is out of range.\npub fn parse_quantity(value: &str, precision: u8) -> anyhow::Result<Quantity> {\n    anyhow::ensure!(\n        precision <= MAX_DECIMALS,\n        \"size precision {precision} exceeds maximum {MAX_DECIMALS}\",\n    );\n    let decimal =","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/common/parse.rs#L81-L117","documentation":"After the string parses as a Decimal, parse_price calls Price::from_decimal_dp to build a Nautilus Price at the requested precision. This error means the decimal value is out of Price's representable range at that precision (or the precision conversion itself failed) — e.g. a price far beyond the fixed-precision mantissa capacity, or more fractional digits than the requested precision can hold without loss. The value and precision are included in the message.","triggerScenarios":"Calling parse_price with a valid decimal string whose magnitude overflows Price's fixed-point range (astronomically large value), or a value with more decimal places than the requested precision in contexts where from_decimal_dp rejects the conversion.","commonSituations":"A corrupt or malicious feed payload with a 30-digit price; misconfigured precision (e.g. precision=2 for a value like \"0.000001\"); test cases probing Price bounds with f64::MAX-style literals.","solutions":["Check that the precision argument matches the market's actual price_decimals from orderBookDetails.","Validate the price against the instrument's price band / plausible range before parsing and reject absurd values upstream.","Verify the raw payload — a value this large usually indicates a corrupted or fabricated message; drop the update and log the raw string.","If legitimate values are being rejected, confirm you are not accidentally passing an exponent-scaled mantissa instead of the human-readable price."],"exampleFix":"// before\nlet price = parse_price(value_str, precision)?;\n// after\nlet price = parse_price(value_str, market.price_decimals)?;\nanyhow::ensure!(price > Price::zero(), \"price {} out of band\", price);","handlingStrategy":"validation","validationCode":"fn price_plausible(value: &str, max_price: f64) -> bool {\n    value.parse::<f64>().map(|v| v.is_finite() && v > 0.0 && v <= max_price).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match parse_price(raw, precision) {\n    Ok(p) => p,\n    Err(e) if e.to_string().contains(\"at precision\") => {\n        tracing::error!(raw = %raw, \"price out of Price range; dropping update\");\n        return Ok(());\n    }\n    Err(e) => return Err(e.into()),\n}","preventionTips":["Range-check prices against the instrument's tick/price band before conversion","Confirm precision matches the market's price_decimals from orderBookDetails","Treat astronomically large values as corrupted payloads and drop the message","Do not pass exponent-scaled mantissas where human-readable decimals are expected"],"tags":["rust","parsing","overflow","price"],"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"}