{"record":{"id":"3dd5d8976dda2259","repo":"nautechsystems/nautilus_trader","slug":"invalid-binance-futures-order-book-depth-depth","errorCode":null,"errorMessage":"invalid Binance Futures order-book depth {depth}; valid values are {BINANCE_BOOK_DEPTHS:?}","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/data.rs","lineNumber":3090,"sourceCode":"                        end_nanos,\n                        clock.get_time_ns(),\n                        params,\n                    ));\n\n                    if let Err(e) = sender.send(DataEvent::Response(response)) {\n                        log::error!(\"Failed to send bars response: {e}\");\n                    }\n                }\n                Err(e) => log::error!(\"Bar request failed: {e:?}\"),\n            }\n        });\n\n        Ok(())\n    }\n\n    fn request_book_snapshot(&self, request: RequestBookSnapshot) -> anyhow::Result<()> {\n        let depth = request.depth.map_or(1000, |value| value.get() as u32);\n        anyhow::ensure!(\n            BINANCE_BOOK_DEPTHS.contains(&depth),\n            \"invalid Binance Futures order-book depth {depth}; valid values are {BINANCE_BOOK_DEPTHS:?}\"\n        );\n        let http = self.http_client.clone();\n        let sender = self.data_sender.clone();\n        let instrument_id = request.instrument_id;\n        let request_id = request.request_id;\n        let client_id = request.client_id.unwrap_or(self.client_id);\n        let params = request.params;\n        let clock = self.clock;\n\n        self.spawn_command(async move {\n            match http.request_book_snapshot(instrument_id, Some(depth)).await {\n                Ok(book) => {\n                    let response = DataResponse::Book(BookResponse::new(\n                        request_id,\n                        client_id,\n                        instrument_id,","sourceCodeStart":3072,"sourceCodeEnd":3108,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/binance/src/futures/data.rs#L3072-L3108","documentation":"Binance Futures depth endpoints only accept specific depth values (the BINANCE_BOOK_DEPTHS set, e.g. 5, 10, 20, 50, 100, 500, 1000), so request_book_snapshot validates the requested depth against that set. The depth defaults to 1000 when not specified.","triggerScenarios":"Calling request_book_snapshot (order-book snapshot request via the Binance Futures data client) with request.depth set to a value not in BINANCE_BOOK_DEPTHS, e.g. 25, 200, or 1500.","commonSituations":"Configuring a generic depth value like 20 works on one venue but fails on Binance Futures if 20 is not in the supported set; or copying depth settings from the spot adapter, which supports different depth tiers.","solutions":["Set the request depth to one of the values listed in the error message (from BINANCE_BOOK_DEPTHS)","Omit depth so the default of 1000 is used","Clamp/snap the configured depth to the nearest supported value before requesting"],"exampleFix":"// before\nlet depth = NonZeroUsize::new(150).unwrap();\nrequest_book_snapshot(RequestBookSnapshot { depth: Some(depth), .. });\n// after\nlet depth = NonZeroUsize::new(100).unwrap(); // nearest supported value in BINANCE_BOOK_DEPTHS\nrequest_book_snapshot(RequestBookSnapshot { depth: Some(depth), .. });","handlingStrategy":"validation","validationCode":"let depth = depth.unwrap_or(1000);\nassert!(BINANCE_BOOK_DEPTHS.contains(&(depth as u32)), \"depth {depth} unsupported\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Snap configured depths to the nearest supported Binance tier","Omit depth to accept the default 1000"],"tags":["binance","order-book","depth","validation"],"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"}