{"record":{"id":"e95228a9af8e440b","repo":"nautechsystems/nautilus_trader","slug":"error-no-bid-orders-for-best-bid-size","errorCode":null,"errorMessage":"Error: No bid orders for best bid size","messagePattern":"Error: No bid orders for best bid size","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/model/src/ffi/orderbook/book.rs","lineNumber":285,"sourceCode":"/// Panics if there are no ask orders for best ask price.\n#[unsafe(no_mangle)]\n#[cfg_attr(feature = \"high-precision\", allow(improper_ctypes_definitions))]\npub extern \"C\" fn orderbook_best_ask_price(book: &mut OrderBook) -> Price {\n    abort_on_panic(|| {\n        book.best_ask_price()\n            .expect(\"Error: No ask orders for best ask price\")\n    })\n}\n\n/// # Panics\n///\n/// Panics if there are no bid orders for best bid size.\n#[unsafe(no_mangle)]\n#[cfg_attr(feature = \"high-precision\", allow(improper_ctypes_definitions))]\npub extern \"C\" fn orderbook_best_bid_size(book: &mut OrderBook) -> Quantity {\n    abort_on_panic(|| {\n        book.best_bid_size()\n            .expect(\"Error: No bid orders for best bid size\")\n    })\n}\n\n/// # Panics\n///\n/// Panics if there are no ask orders for best ask size.\n#[unsafe(no_mangle)]\n#[cfg_attr(feature = \"high-precision\", allow(improper_ctypes_definitions))]\npub extern \"C\" fn orderbook_best_ask_size(book: &mut OrderBook) -> Quantity {\n    abort_on_panic(|| {\n        book.best_ask_size()\n            .expect(\"Error: No ask orders for best ask size\")\n    })\n}\n\n/// # Panics\n///\n/// Panics if unable to calculate spread (requires at least one bid and one ask).","sourceCodeStart":267,"sourceCodeEnd":303,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/model/src/ffi/orderbook/book.rs#L267-L303","documentation":"This panic occurs in the FFI wrapper `orderbook_best_bid_size` when `OrderBook::best_bid_size()` returns None because there are no bid orders at the best bid level (or anywhere on the bid side). The `abort_on_panic` wrapper makes this a process abort, not a catchable FFI error.","triggerScenarios":"Calling `orderbook_best_bid_size(book)` when the bid side is empty or size information has not been populated (e.g. price-only book updates without volume).","commonSituations":"Books built from data sources lacking bid size; querying immediately after a clear/reset; L1 feed gaps where the bid row vanished; calling before the first quote arrives.","solutions":["Check the book has bid orders (non-empty bids / has_orders) before calling the FFI getter.","Feed the book quote or depth data that includes bid sizes before querying sizes.","Return None from caller-side logic when the book has no bids instead of calling the panicking FFI function.","Validate data feed configuration so bid volume is present for the instrument."],"exampleFix":"// before (Python FFI caller)\nbid_size = orderbook_best_bid_size(book)\n// after\nif has_bid_orders(book):\n    bid_size = orderbook_best_bid_size(book)\nelse:\n    bid_size = None","handlingStrategy":"validation","validationCode":"def can_get_best_bid_size(book) -> bool:\n    return book.has_orders() and book.bids_len() > 0","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm the data feed includes bid volume, not price-only levels","Gate size queries on a book-initialized flag","Treat empty books as an expected state and query optional accessors instead of FFI panicking ones","Remember FFI panics abort the process — they cannot be caught as exceptions"],"tags":["rust","ffi","orderbook","panic","process-abort"],"backgroundTag":"empty-result-set","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"}