{"record":{"id":"b76c5f47206b5db2","repo":"nautechsystems/nautilus_trader","slug":"non-positive-candle-low","errorCode":null,"errorMessage":"non-positive candle low `{}`","messagePattern":"non-positive candle low `(.+?)`","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/lighter/src/http/parse.rs","lineNumber":197,"sourceCode":"///\n/// Returns an error if any price, volume, or timestamp field cannot be converted.\npub fn parse_candle_bar(\n    candle: &LighterCandle,\n    bar_type: BarType,\n    instrument: &InstrumentAny,\n    ts_init: UnixNanos,\n) -> anyhow::Result<Bar> {\n    anyhow::ensure!(\n        candle.open > Decimal::ZERO,\n        \"non-positive candle open `{}`\",\n        candle.open\n    );\n    anyhow::ensure!(\n        candle.high > Decimal::ZERO,\n        \"non-positive candle high `{}`\",\n        candle.high\n    );\n    anyhow::ensure!(\n        candle.low > Decimal::ZERO,\n        \"non-positive candle low `{}`\",\n        candle.low\n    );\n    anyhow::ensure!(\n        candle.close > Decimal::ZERO,\n        \"non-positive candle close `{}`\",\n        candle.close\n    );\n\n    let timestamp_ms =\n        u64::try_from(candle.timestamp).context(\"negative Lighter candle timestamp\")?;\n    let ts_event = parse_millis_to_nanos(timestamp_ms)?;\n    let price_precision = instrument.price_precision();\n    let size_precision = instrument.size_precision();\n\n    let open = Price::from_decimal_dp(candle.open, price_precision)\n        .map_err(|e| anyhow::anyhow!(\"invalid candle open: {e}\"))?;","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/lighter/src/http/parse.rs#L179-L215","documentation":"parse_candle_bar enforces that a candle's low price is strictly positive. Since OHLC values must be representable as positive Prices, a non-positive low flags invalid upstream candle data. The offending value is included in the message.","triggerScenarios":"parse_candle_bar receiving a LighterCandle with low <= 0 via parse_bars when parsing the Lighter candles endpoint response.","commonSituations":"Zero-filled candles for markets with no trades in the window; broken upstream data; synthetic fixtures with placeholder zeros.","solutions":["Drop candles with low <= 0 before calling parse_candle_bar","Query a different time range or market where real trades exist","Inspect the raw API payload for corrupted candle entries","Fix test fixtures to use positive low values"],"exampleFix":"// before\nlet bar = parse_candle_bar(&candle, bar_type, &inst, ts_init)?;\n// after\nanyhow::ensure!(candle.low > Decimal::ZERO, \"skip invalid candle\");\nlet bar = parse_candle_bar(&candle, bar_type, &inst, ts_init)?;","handlingStrategy":"validation","validationCode":"if candle.low <= Decimal::ZERO {\n    return Err(anyhow::anyhow!(\"skip candle: non-positive low {}\", candle.low));\n}","typeGuard":"fn has_positive_ohlc(c: &LighterCandle) -> bool {\n    c.open > Decimal::ZERO && c.high > Decimal::ZERO && c.low > Decimal::ZERO && c.close > Decimal::ZERO\n}","tryCatchPattern":"let bar = match parse_candle_bar(&candle, bar_type, instrument, ts_init) {\n    Ok(b) => b,\n    Err(e) if e.to_string().contains(\"non-positive candle low\") => continue,\n    Err(e) => return Err(e),\n};","preventionTips":["Validate the full OHLC tuple for positivity before parsing","Confirm the requested time window contains actual trades","Keep fixtures realistic (positive lows)","Handle unparseable candles by skipping rather than aborting the batch"],"tags":["rust","data-validation","candles","adapter"],"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-14T00:17:10.932Z"}