{"record":{"id":"790607daf5e1741f","repo":"nautechsystems/nautilus_trader","slug":"bybit-order-book-update-missing-bid-levels-and-no","errorCode":null,"errorMessage":"Bybit order book update missing bid levels and no previous quote provided","messagePattern":"Bybit order book update missing bid levels and no previous quote provided","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/websocket/parse.rs","lineNumber":347,"sourceCode":"    let size_precision = instrument.size_precision();\n\n    let get_best =\n        |levels: &[Vec<String>], label: &str| -> anyhow::Result<Option<(Price, Quantity)>> {\n            if let Some(values) = levels.first() {\n                parse_book_level(values, price_precision, size_precision, label).map(Some)\n            } else {\n                Ok(None)\n            }\n        };\n\n    let bids = get_best(&msg.data.b, \"bid\")?;\n    let asks = get_best(&msg.data.a, \"ask\")?;\n\n    let (bid_price, bid_size) = match (bids, last_quote) {\n        (Some(level), _) => level,\n        (None, Some(prev)) => (prev.bid_price, prev.bid_size),\n        (None, None) => {\n            anyhow::bail!(\n                \"Bybit order book update missing bid levels and no previous quote provided\"\n            );\n        }\n    };\n\n    let (ask_price, ask_size) = match (asks, last_quote) {\n        (Some(level), _) => level,\n        (None, Some(prev)) => (prev.ask_price, prev.ask_size),\n        (None, None) => {\n            anyhow::bail!(\n                \"Bybit order book update missing ask levels and no previous quote provided\"\n            );\n        }\n    };\n\n    QuoteTick::new_checked(\n        instrument.id(),\n        bid_price,","sourceCodeStart":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/websocket/parse.rs#L329-L365","documentation":"When building a `QuoteTick` from a Bybit order book message, no best bid could be extracted from `data.b` and no `last_quote` was supplied to fall back on. The adapter cannot produce a two-sided top-of-book quote, so it errors instead of emitting a one-sided quote.","triggerScenarios":"`parse_orderbook_quote` receives a delta update whose `b` list is empty (all bid levels deleted by the update) while `last_quote` is `None` — i.e. the first frame for a symbol is a delta with no snapshot and no cached prior quote.","commonSituations":"Starting a subscription and receiving a delta before the initial snapshot; reconnecting to the Bybit order book stream without re-seeding the cached last quote; a malformed message where the bid array is empty.","solutions":["Always cache the last parsed quote per symbol and pass it as `last_quote` so deltas can fall back to the previous bid.","Wait for the snapshot message (`orderbook.1.<symbol>` with full levels) before processing delta messages.","Skip delta frames received before the first snapshot instead of parsing them."],"exampleFix":"// before: feed deltas with no prior state\nlet quote = parse_orderbook_quote(&msg, None)?;\n// after: maintain per-symbol last quote\nlet quote = parse_orderbook_quote(&msg, last_quotes.get(&symbol))?;\nlast_quotes.insert(symbol, quote.clone());","handlingStrategy":"fallback","validationCode":"let has_bid = msg.data.b.iter().any(|l| !l.is_empty());\nlet has_prev = last_quote.is_some();\nif !has_bid && !has_prev {\n    return; // wait for snapshot\n}","typeGuard":null,"tryCatchPattern":"match parse_orderbook_quote(&msg, last_quote) {\n    Ok(quote) => publish(quote),\n    Err(e) if e.to_string().contains(\"missing bid levels\") => {\n        tracing::debug!(\"delta before snapshot; waiting for snapshot\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Cache the last parsed quote per symbol and pass it as `last_quote`","Process the order book snapshot before any delta","Drop deltas that arrive before the initial snapshot","Re-seed cached quotes after WS reconnects"],"tags":["bybit","websocket","orderbook","missing-data"],"backgroundTag":"empty-required-field","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"}