{"record":{"id":"b562ed2294b21c53","repo":"nautechsystems/nautilus_trader","slug":"invalid-binance-futures-order-book-depth-valid-va","errorCode":null,"errorMessage":"invalid Binance Futures order-book depth; valid values are {:?}","messagePattern":"invalid Binance Futures order-book depth; valid values are (.+?)","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/http/client.rs","lineNumber":3120,"sourceCode":"            .request_binance_bars(bar_type, start, end, limit)\n            .await?\n            .into_iter()\n            .map(|bar| bar.bar())\n            .collect())\n    }\n\n    /// Requests an explicit L2 order-book snapshot.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error for an invalid depth, missing instrument, request failure, or invalid level.\n    pub async fn request_book_snapshot(\n        &self,\n        instrument_id: InstrumentId,\n        depth: Option<u32>,\n    ) -> anyhow::Result<OrderBook> {\n        if depth.is_some_and(|value| !crate::common::consts::BINANCE_BOOK_DEPTHS.contains(&value)) {\n            anyhow::bail!(\n                \"invalid Binance Futures order-book depth; valid values are {:?}\",\n                crate::common::consts::BINANCE_BOOK_DEPTHS\n            );\n        }\n        let (symbol, price_precision, size_precision) =\n            self.cached_precisions_by_id(instrument_id)?;\n        let params = BinanceDepthParams {\n            symbol,\n            limit: depth,\n        };\n        let snapshot = self.inner.depth(&params).await?;\n        let ts_event = self.clock.get_time_ns();\n        let sequence = u64::try_from(snapshot.last_update_id)\n            .map_err(|_| anyhow::anyhow!(\"invalid negative order-book update ID\"))?;\n        let mut book = OrderBook::new(instrument_id, BookType::L2_MBP);\n        for (index, level) in snapshot.bids.iter().enumerate() {\n            let order = BookOrder::new(\n                OrderSide::Buy,","sourceCodeStart":3102,"sourceCodeEnd":3138,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/http/client.rs#L3102-L3138","documentation":"request_book_snapshot validates the requested order-book depth against BINANCE_BOOK_DEPTHS before calling the Binance Futures REST snapshot endpoint. Binance only serves depth snapshots at specific levels (5, 10, 20, 50, 100, 500, 1000), so any other value is rejected locally with anyhow::bail before any network call is made.","triggerScenarios":"Calling request_book_snapshot(instrument_id, Some(depth)) with a depth that is not contained in crate::common::consts::BINANCE_BOOK_DEPTHS, e.g. Some(7), Some(25), or Some(200). Passing None is fine (falls back to a default depth).","commonSituations":"A user config or strategy parameter supplies an arbitrary depth from a config file or CLI flag; code ported from another exchange adapter uses that exchange's depth granularity; a depth value is computed rather than picked from the allowed set.","solutions":["Set depth to one of the values listed in BINANCE_BOOK_DEPTHS (5, 10, 20, 50, 100, 500, 1000 for USD-M Futures).","Pass None to let the adapter use its default depth.","Clamp/snap arbitrary configured depths to the nearest valid value before calling."],"exampleFix":"// before\nlet book = client.request_book_snapshot(instrument_id, Some(7)).await?;\n// after\nlet book = client.request_book_snapshot(instrument_id, Some(10)).await?;","handlingStrategy":"validation","validationCode":"const VALID_DEPTHS: [u32; 7] = [5, 10, 20, 50, 100, 500, 1000];\nfn is_valid_depth(d: u32) -> bool { VALID_DEPTHS.contains(&d) }\nassert!(is_valid_depth(my_depth), \"depth {my_depth} unsupported by Binance Futures\");","typeGuard":"fn valid_depth(d: Option<u32>) -> bool { d.is_none() || VALID_DEPTHS.contains(&d.unwrap()) }","tryCatchPattern":null,"preventionTips":["Pick depth values only from the documented Binance depth tiers.","Snap user-configured depths to the nearest valid tier at config load time.","Pass None unless a specific depth tier is required."],"tags":["validation","orderbook","binance-futures","http"],"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-23T08:17:48.524Z"}