{"record":{"id":"89806d5bcf687d22","repo":"nautechsystems/nautilus_trader","slug":"invalid-field-raw-at-precision-precision","errorCode":null,"errorMessage":"invalid {field}='{raw}' at precision {precision}: {e}","messagePattern":"invalid (.+?)='(.+?)' at precision (.+?): (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/common/parse.rs","lineNumber":225,"sourceCode":"    }\n\n    Price::from_decimal_dp(decimal, precision).ok()\n}\n\n/// Parses a required venue decimal string.\npub(crate) fn parse_required_decimal(raw: &str, field: &str) -> anyhow::Result<Decimal> {\n    Decimal::from_str(raw).map_err(|e| anyhow::anyhow!(\"invalid {field}='{raw}': {e}\"))\n}\n\n/// Parses a required venue quantity string into a `Quantity` at the given precision.\npub(crate) fn parse_required_quantity_at_precision(\n    raw: &str,\n    precision: u8,\n    field: &str,\n) -> anyhow::Result<Quantity> {\n    let decimal = parse_required_decimal(raw, field)?;\n    Quantity::from_decimal_dp(decimal, precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid {field}='{raw}' at precision {precision}: {e}\"))\n}\n\n/// Parses a required venue price string into a `Price` at the given precision.\npub(crate) fn parse_required_price_at_precision(\n    raw: &str,\n    precision: u8,\n    field: &str,\n) -> anyhow::Result<Price> {\n    let decimal = parse_required_decimal(raw, field)?;\n    Price::from_decimal_dp(decimal, precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid {field}='{raw}' at precision {precision}: {e}\"))\n}\n\n/// Re-precisions an existing `Quantity` to the given precision via `Decimal`.\n#[must_use]\npub(crate) fn quantity_at_precision(quantity: Quantity, precision: u8) -> Option<Quantity> {\n    Quantity::from_decimal_dp(quantity.as_decimal(), precision).ok()\n}","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/common/parse.rs#L207-L243","documentation":"The venue quantity string parsed into a Decimal but could not be converted into a `Quantity` at the instrument's specified precision — typically because the value has more decimal places than the precision allows or falls outside the Quantity range. The message names the field, raw value, and precision.","triggerScenarios":"Order updates, book snapshots, trade ticks, klines, or fill events (handle_ws_message, request_book_snapshot, parse_futures_trade_tick, parse_futures_kline_binance_bar, dispatch_order_update, parse_order_fill_event_fields) where a quantity string like \"0.001234567\" is re-precised to the instrument's quantityPrecision (e.g. 3).","commonSituations":"Binance emitting quantities with more decimals than the instrument's stated precision (exchange-info drift); mismatched instrument definitions loaded for a different market; kline volume fields with higher precision than expected.","solutions":["Refresh instrument definitions so quantityPrecision matches current exchange-info","Round/truncate the raw decimal to the instrument precision before constructing the Quantity","Check that the instrument being used matches the symbol's actual market (spot vs futures)","Update the adapter if the precision contract changed"],"exampleFix":"// before\nlet qty = parse_required_quantity_at_precision(raw, precision, \"origQty\")?;\n// after\nlet dec = Decimal::from_str(raw)?;\nlet qty = Quantity::from_decimal_dp(dec.round_dp(precision as u32), precision)\n    .map_err(|e| anyhow::anyhow!(\"invalid origQty='{raw}' at precision {precision}: {e}\"))?;","handlingStrategy":"validation","validationCode":"let dec = Decimal::from_str(raw)?; assert!(dec.round_dp(0) == dec || dec.fract().dp() <= precision as u32, \"qty exceeds precision {precision}\");","typeGuard":null,"tryCatchPattern":"match parse_required_quantity_at_precision(raw, precision, field) { Ok(q) => q, Err(e) => { warn!(\"precision mismatch, rounding: {e}\"); Quantity::from_decimal_dp(Decimal::from_str(raw)?.round_dp(precision as u32), precision)? } }","preventionTips":["Keep instrument definitions refreshed from exchange-info","Match market type (spot/futures) with the correct instrument set","Round venue values to instrument precision defensively"],"tags":["rust","precision","quantity","binance"],"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-23T08:17:48.524Z"}