{"record":{"id":"15f0989aaa18bb54","repo":"nautechsystems/nautilus_trader","slug":"invalid-candle-high-e-15f098","errorCode":null,"errorMessage":"invalid candle high: {e}","messagePattern":"invalid candle high: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/websocket/parse.rs","lineNumber":402,"sourceCode":"/// Parses a Lighter WebSocket candle into a Nautilus [`Bar`] with `ts_event` set to the bar open.\n///\n/// # Errors\n///\n/// Returns an error if the OHLCV decimals overflow the instrument's precision, or if the\n/// timestamp cannot be converted.\npub 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)","sourceCodeStart":384,"sourceCodeEnd":420,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/websocket/parse.rs#L384-L420","documentation":"parse_ws_bar converts the candle's high decimal into a Price at the instrument's price_precision via Price::from_decimal_dp. When that conversion fails the error is wrapped as 'invalid candle high', indicating the venue value cannot be represented at the configured precision.","triggerScenarios":"Candle high decimal with more fractional digits than price_precision, or otherwise invalid (negative/malformed) high value in the WebSocket candle message.","commonSituations":"Instrument precision configured too low; venue changing tick formatting; wrong instrument mapped to the candle stream.","solutions":["Align instrument price_precision with the venue's real precision","Pre-round candle.h to price_precision before conversion","Inspect candle.h and the wrapped error to find the bad value","Verify the instrument registration matches the subscribed market"],"exampleFix":"// before\nlet high = Price::from_decimal_dp(candle.h, price_precision)?;\n// after\nlet high = Price::from_decimal_dp(candle.h.round_dp(price_precision as u32), price_precision)?;","handlingStrategy":"validation","validationCode":"let high = candle.h.round_dp(instrument.price_precision() as u32);","typeGuard":null,"tryCatchPattern":"match parse_ws_bar(candle, instrument, ...) {\n    Err(e) if e.to_string().contains(\"invalid candle high\") => {\n        log::warn!(\"bad candle high {}, skipping bar: {e}\", candle.h);\n    }\n    other => other?,\n}","preventionTips":["Align price_precision with venue metadata","Pre-quantize candle.h before Price construction","Log raw candle payloads on parse failure"],"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"}