nautechsystems/nautilus_trader · error · anyhow::Error

Binance Futures trade limit must not exceed 1000

Error message

Binance Futures trade limit must not exceed 1000

What it means

The Binance Futures trades endpoint (GET /fapi/v1/trades) accepts a maximum limit of 1000 results per request, so the data client validates the caller-supplied limit in request_trades before spawning the HTTP command. Values above 1000 would be rejected by the exchange or silently truncated.

Solutions

  1. Cap the limit at 1000 in the request params
  2. Omit the limit (None) and rely on start/end time pagination
  3. Split the time range into chunks each requesting at most 1000 trades

Example fix

// before
let limit = Some(10_000);
client.request_trades(request);
// after
let limit = Some(1000);
client.request_trades(request);
Defensive patterns

Strategy: validation

Validate before calling

let capped = limit.map(|v: u32| v.min(1000));

Prevention

When it happens

Trigger: Calling request_trades (historical trades request through the Binance Futures data client) with request.params containing Some(limit) greater than 1000.

Common situations: Porting code from another adapter whose trades endpoint allows larger limits (e.g. 5000), or hardcoding a 'get everything' limit like u32::MAX/i64::MAX to page through a long backfill window.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/1539dc51f5962ed6. Report an issue: GitHub.

Appendix: source

Thrown at crates/adapters/binance/src/futures/data.rs:2955

        });

        Ok(())
    }

    fn request_trades(&self, request: RequestTrades) -> anyhow::Result<()> {
        let http = self.http_client.clone();
        let sender = self.data_sender.clone();
        let instrument_id = request.instrument_id;
        let limit = request.limit.map(|n| n.get() as u32);
        let request_id = request.request_id;
        let client_id = request.client_id.unwrap_or(self.client_id);
        let params = request.params;
        let clock = self.clock;
        let start_nanos = datetime_to_unix_nanos(request.start);
        let end_nanos = datetime_to_unix_nanos(request.end);
        let start = request.start;
        let end = request.end;
        anyhow::ensure!(
            limit.is_none_or(|value| value <= 1000),
            "Binance Futures trade limit must not exceed 1000"
        );

        self.spawn_command(async move {
            let result = if start.is_some() || end.is_some() {
                http.request_agg_trades(instrument_id, start, end, limit)
                    .await
            } else {
                http.request_trades(instrument_id, limit).await
            };

            match result.context("failed to request trades from Binance Futures") {
                Ok(trades) => {
                    let response = DataResponse::Trades(TradesResponse::new(
                        request_id,
                        client_id,
                        instrument_id,

View on GitHub (pinned to 18893faf8b)