{"record":{"id":"1539dc51f5962ed6","repo":"nautechsystems/nautilus_trader","slug":"binance-futures-trade-limit-must-not-exceed-1000","errorCode":null,"errorMessage":"Binance Futures trade limit must not exceed 1000","messagePattern":"Binance Futures trade limit must not exceed 1000","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/data.rs","lineNumber":2909,"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 Futures 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 Futures\") {\n                Ok(trades) => {\n                    let response = DataResponse::Trades(TradesResponse::new(\n                        request_id,\n                        client_id,\n                        instrument_id,","sourceCodeStart":2891,"sourceCodeEnd":2927,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/futures/data.rs#L2891-L2927","documentation":"Historical trade requests are forwarded to Binance's trades/aggTrades endpoints, whose server-side maximum result limit is 1000. The adapter validates `limit <= 1000` before spawning the fetch and rejects larger values up front rather than silently clamping or truncating results.","triggerScenarios":"`request_trades` with `limit` set above 1000, e.g. `limit=5000` (a value valid on some other venues' trade endpoints). Omitting limit (None) is fine — the check is `limit.is_none_or(|value| value <= 1000)`.","commonSituations":"Porting trade-history configs from venues allowing 5000+ per request; wanting a large backfill in one call; generic pagination code assuming uniform limits across adapters.","solutions":["Set limit to 1000 or less","For more history, paginate with start/end time windows (the request supports start and end), requesting at most 1000 trades per call"],"exampleFix":"# before\nactor.request_trades(instrument_id, start=start_ts, limit=5000)\n\n# after: cap each call, paginate by time window\nactor.request_trades(instrument_id, start=start_ts, end=window_end, limit=1000)","handlingStrategy":"validation","validationCode":"BINANCE_TRADE_LIMIT = 1000\n\ndef clamp_trade_limit(limit: int | None) -> int | None:\n    if limit is not None and limit > BINANCE_TRADE_LIMIT:\n        raise ValueError(\n            f'limit {limit} exceeds Binance max {BINANCE_TRADE_LIMIT}; paginate with start/end windows instead'\n        )\n    return limit","typeGuard":"def is_valid_binance_trade_limit(limit) -> bool:\n    return limit is None or limit <= 1000","tryCatchPattern":"try:\n    actor.request_trades(instrument_id, start=start_ts, limit=limit)\nexcept Exception as e:\n    if 'trade limit must not exceed 1000' in str(e):\n        actor.request_trades(instrument_id, start=start_ts, limit=1000)  # then paginate forward by last trade time\n    else:\n        raise","preventionTips":["Cap trade-history requests at 1000 and paginate by time window for larger backfills","Do not assume a limit valid on one venue transfers to another — Binance futures max is 1000"],"tags":["binance","futures","trades","limit","request-validation"],"backgroundTag":"request-limit-exceeded","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}