{"record":{"id":"eee82fbe4bfcae46","repo":"nautechsystems/nautilus_trader","slug":"binance-spot-trade-limit-must-not-exceed-1000","errorCode":null,"errorMessage":"Binance Spot trade limit must not exceed 1000","messagePattern":"Binance Spot trade limit must not exceed 1000","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/data.rs","lineNumber":2306,"sourceCode":"            }\n        });\n        Ok(())\n    }\n\n    fn request_trades(&self, request: RequestTrades) -> anyhow::Result<()> {\n        let http = self.http_client.clone();\n        let sender = self.data_sender.clone();\n        let instrument_id = request.instrument_id;\n        let limit = request.limit.map(|n| n.get() as u32);\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        let start_nanos = datetime_to_unix_nanos(request.start);\n        let end_nanos = datetime_to_unix_nanos(request.end);\n        let start = request.start;\n        let end = request.end;\n        anyhow::ensure!(\n            limit.is_none_or(|value| value <= 1000),\n            \"Binance Spot trade limit must not exceed 1000\"\n        );\n\n        get_runtime().spawn(async move {\n            let result = if start.is_some() || end.is_some() {\n                http.request_agg_trades(instrument_id, start, end, limit)\n                    .await\n            } else {\n                http.request_trades(instrument_id, limit).await\n            };\n\n            match result.context(\"failed to request trades from Binance\") {\n                Ok(trades) => {\n                    let response = DataResponse::Trades(TradesResponse::new(\n                        request_id,\n                        client_id,\n                        instrument_id,","sourceCodeStart":2288,"sourceCodeEnd":2324,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/data.rs#L2288-L2324","documentation":"Binance Spot GET /api/v3/trades and /api/v3/aggTrades cap the `limit` query parameter at 1000. The adapter validates the request's limit (converted to u32) before spawning the request task, so an over-limit value fails fast with a clear message instead of a venue-side 400 'Limit exceeds max limit'.","triggerScenarios":"Calling request_trade_ticks (RequestTradeTicks) with limit > 1000, with or without start/end timestamps: both the aggTrades and plain trades branches are gated by the same ensure! at spot/data.rs:2306.","commonSituations":"Copying a limit constant from a venue with a higher cap (some allow 5000-10000); backfill scripts that try to fetch 'as much as possible' in a single call; UIs defaulting to large page sizes.","solutions":["Set limit to 1000 or less (Binance's default is 500 when unset)","For larger backfills, paginate with start/end windows or fromId cursors via aggTrades and merge client-side","Clamp any user-supplied page size against the venue cap before constructing the request"],"exampleFix":"// before\nlet request = RequestTradeTicks { limit: Some(NonZeroU64::new(5000)?), .. };\n\n// after: Binance Spot caps trades/aggTrades at 1000\nlet request = RequestTradeTicks { limit: Some(NonZeroU64::new(1000)?), .. };","handlingStrategy":"validation","validationCode":"const BINANCE_SPOT_TRADE_LIMIT_MAX: u32 = 1000;\n\nfn clamp_trade_limit(limit: Option<u32>) -> Option<u32> {\n    limit.map(|l| l.min(BINANCE_SPOT_TRADE_LIMIT_MAX))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Centralize venue page-size caps in config instead of scattering literals","For backfills, plan pagination by time window or fromId cursor up front rather than one big limit","Remember the cap applies to both trades and aggTrades endpoints on Spot"],"tags":["binance","spot","trades","limit","pagination","validation"],"backgroundTag":"request-limit-exceeded","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}