{"record":{"id":"8a2d06ffd9c98f77","repo":"nautechsystems/nautilus_trader","slug":"size-decimals-decimals-exceeds-maximum-max-deci","errorCode":null,"errorMessage":"size decimals {decimals} exceeds maximum {MAX_DECIMALS}","messagePattern":"size decimals (.+?) exceeds maximum (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/common/parse.rs","lineNumber":74,"sourceCode":"}\n\n/// Converts a Lighter base-amount tick count into a Nautilus [`Quantity`].\n///\n/// Order sizes on the wire are signed `i64` multiples of `10^-decimals`\n/// base-asset units. Nautilus [`Quantity`] is non-negative, so a negative\n/// `ticks` value is rejected: callers (e.g. position parsers) extract the\n/// sign separately before invoking this parser.\n///\n/// Conversion routes through [`Decimal`] and [`Quantity::from_decimal_dp`]\n/// so out-of-range tick counts return an error rather than panicking inside\n/// the unchecked mantissa-exponent constructor.\n///\n/// # Errors\n///\n/// Returns an error if `decimals` exceeds [`MAX_DECIMALS`], if `ticks` is\n/// negative, or if the resulting value exceeds the [`Quantity`] range.\npub fn parse_quantity_from_ticks(ticks: i64, decimals: u8) -> anyhow::Result<Quantity> {\n    anyhow::ensure!(\n        decimals <= MAX_DECIMALS,\n        \"size decimals {decimals} exceeds maximum {MAX_DECIMALS}\",\n    );\n    anyhow::ensure!(ticks >= 0, \"negative tick count {ticks} for Quantity\");\n    let decimal = Decimal::new(ticks, u32::from(decimals));\n    Quantity::from_decimal_dp(decimal, decimals).map_err(|e| {\n        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!(","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/common/parse.rs#L56-L92","documentation":"`parse_quantity_from_ticks` converts an integer tick count and decimal count into a Nautilus `Quantity`. It fails if `decimals` exceeds `MAX_DECIMALS`; this specific error indicates the size precision requested is more granular than the supported maximum (additional errors exist for negative ticks and range overflow).","triggerScenarios":"Calling `parse_quantity_from_ticks(ticks, decimals)` with `decimals > MAX_DECIMALS`, e.g. parsing a Lighter instrument's size precision that exceeds the adapter limit.","commonSituations":"Markets configured with very high quantity precision; reusing decimal constants from another venue's instrument definitions; copy-paste of price decimals into size decimals.","solutions":["Verify the market's size precision is <= MAX_DECIMALS before parsing.","Round/quantize the size to a supported precision consistent with the instrument's `size_increment`.","Check for swapped arguments (e.g. passing price decimals where size decimals are expected)."],"exampleFix":"// before\nlet qty = parse_quantity_from_ticks(ticks, 20)?;\n// after\nensure!(decimals <= MAX_DECIMALS, \"size precision not supported\");\nlet qty = parse_quantity_from_ticks(ticks, decimals)?;","handlingStrategy":"validation","validationCode":"if decimals > lighter::parse::MAX_DECIMALS {\n    return Err(anyhow!(\"size precision {decimals} unsupported\"));\n}\nif ticks < 0 {\n    return Err(anyhow!(\"negative ticks {ticks}\"));\n}","typeGuard":"fn size_precision_supported(d: u8) -> bool { d <= lighter::parse::MAX_DECIMALS }","tryCatchPattern":"let qty = parse_quantity_from_ticks(ticks, decimals)\n    .map_err(|e| { eprintln!(\"quantity parse failed: {e}\"); e })?;","preventionTips":["Validate size decimals against MAX_DECIMALS before parsing instrument sizes.","Quantize sizes to the instrument's size_increment.","Double-check argument order — ticks first, decimals second."],"tags":["quantity","precision","validation","lighter"],"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"}