{"record":{"id":"44631fc54ea4b908","repo":"nautechsystems/nautilus_trader","slug":"invalid-candle-volume-e-44631f","errorCode":null,"errorMessage":"invalid candle volume: {e}","messagePattern":"invalid candle volume: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/parse.rs","lineNumber":408,"sourceCode":"pub fn parse_ws_bar(\n    instrument: &InstrumentAny,\n    candle: &LighterWsCandle,\n    resolution: LighterCandleResolution,\n    ts_init: UnixNanos,\n) -> anyhow::Result<Bar> {\n    let price_precision = instrument.price_precision();\n    let size_precision = instrument.size_precision();\n\n    let open = Price::from_decimal_dp(candle.o, price_precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid candle open: {e}\"))?;\n    let high = Price::from_decimal_dp(candle.h, price_precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid candle high: {e}\"))?;\n    let low = Price::from_decimal_dp(candle.l, price_precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid candle low: {e}\"))?;\n    let close = Price::from_decimal_dp(candle.c, price_precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid candle close: {e}\"))?;\n    let volume = Quantity::from_decimal_dp(candle.v, size_precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid candle volume: {e}\"))?;\n\n    let t_ms = u64::try_from(candle.t)\n        .map_err(|_| anyhow::anyhow!(\"negative candle timestamp: {}\", candle.t))?;\n    let ts_event = parse_millis_to_nanos(t_ms)?;\n\n    let bar_type = BarType::new(\n        instrument.id(),\n        resolution.to_bar_spec(),\n        AggregationSource::External,\n    );\n\n    Bar::new_checked(bar_type, open, high, low, close, volume, ts_event, ts_init)\n        .map_err(|e| anyhow::anyhow!(\"invalid candle bar: {e}\"))\n}\n\nfn parse_book_level_delta(\n    level: &LighterPriceLevel,\n    instrument: &InstrumentAny,","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/parse.rs#L390-L426","documentation":"parse_ws_bar converts the candle's volume decimal into a Quantity at the instrument's size_precision via Quantity::from_decimal_dp. Failure is wrapped as 'invalid candle volume', meaning the venue's volume value cannot be represented at the configured size precision.","triggerScenarios":"Candle volume decimal with more fractional digits than size_precision or otherwise failing Quantity construction from the WebSocket candle payload.","commonSituations":"Instrument size_precision misconfigured (too few decimals); venue emitting higher-precision volumes; base/quote sizing mix-up on the instrument definition.","solutions":["Correct the instrument's size_precision to match venue volume precision","Round candle.v to size_precision before constructing the Quantity","Log the offending volume value and root error","Verify the instrument definition's size precision against venue metadata"],"exampleFix":"// before\nlet volume = Quantity::from_decimal_dp(candle.v, size_precision)?;\n// after\nlet volume = Quantity::from_decimal_dp(candle.v.round_dp(size_precision as u32), size_precision)?;","handlingStrategy":"validation","validationCode":"let volume = candle.v.round_dp(instrument.size_precision() as u32);","typeGuard":null,"tryCatchPattern":"match parse_ws_bar(candle, instrument, ...) {\n    Err(e) if e.to_string().contains(\"invalid candle volume\") => {\n        log::warn!(\"bad candle volume {}, skipping bar: {e}\", candle.v);\n    }\n    other => other?,\n}","preventionTips":["Set size_precision from venue instrument metadata","Pre-quantize candle.v before Quantity construction","Verify base/quote volume units on the instrument definition"],"tags":["rust","websocket","candles","precision"],"backgroundTag":"invalid-argument-value","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"}