nautechsystems/nautilus_trader · error

KrakenHttpError (cloned per-order batch failure)

Error message

KrakenHttpError (cloned per-order batch failure)

What it means

Same pattern as the Kraken Futures client: in the Kraken Spot batch submit path, if a batch HTTP call fails, every order in that batch receives a clone of the KrakenHttpError, and every later batch is marked NotAttempted before breaking out of the loop.

Source

Thrown at crates/adapters/kraken/src/http/spot/client.rs:2838

                // AddOrderBatch returns result items in request order, so exact cardinality makes
                // positional correlation unambiguous.
                Ok(response) if response.orders.len() == batch.len() => {
                    for ((idx, _), order) in batch.iter().zip(response.orders) {
                        results[*idx] = Some(Ok(order));
                    }
                }
                Ok(response) => {
                    for (idx, _) in batch {
                        results[*idx] = Some(Err(KrakenBatchOrderError::ResponseCount {
                            expected: batch.len(),
                            actual: response.orders.len(),
                        }
                        .into()));
                    }
                }
                Err(e) => {
                    for (idx, _) in batch {
                        results[*idx] = Some(Err(anyhow::Error::new(e.clone())));
                    }

                    for later_batch in &batches[batch_index + 1..] {
                        for (idx, _) in later_batch {
                            results[*idx] = Some(Err(KrakenBatchOrderError::NotAttempted.into()));
                        }
                    }
                    break;
                }
            }
        }

        results
            .into_iter()
            .map(|result| result.unwrap_or_else(|| Err(KrakenBatchOrderError::NotAttempted.into())))
            .collect()
    }

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Unwrap the cloned KrakenHttpError to read status code and message.
  2. Retry failed and NotAttempted batches with exponential backoff, respecting Retry-After on 429.
  3. Validate API credentials and endpoint permissions up front.
  4. Keep batch sizes small so a single failure doesn't mark many orders NotAttempted.

Example fix

// before
let results = client.submit_orders_batch(orders).await; // later batches NotAttempted after one failure
// after
for batch in orders.chunks(15) { match client.submit_orders_batch(batch.to_vec()).await { /* per-batch retry */ } }
Defensive patterns

Strategy: retry

Validate before calling

// ensure each batch is within Kraken spot limits before send
assert!(batch.len() <= MAX_BATCH_SIZE);

Try / catch

for r in client.submit_orders_batch(orders).await {
    if let Err(e) = r {
        if !format!("{e}").contains("NotAttempted") { /* retry with backoff */ }
    }
}

Prevention

When it happens

Trigger: submit_orders_batch() where inner.submit_orders_batch(batch) returns Err — HTTP/network failure, auth rejection, or rate limit on Kraken Spot's batch order endpoint.

Common situations: Burst order submission during outages or rate-limit windows, invalid/expired API keys, or connectivity loss between the client and Kraken Spot.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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