nautechsystems/nautilus_trader · error · anyhow::Error
batch_add requires at least one order
Error message
batch_add requires at least one order
What it means
Raised in `batch_add_via_ws` when the caller passes an empty order list: `orders.first()` is `None`, so the client rejects the batch with "batch_add requires at least one order". Kraken's batch add WS operation is only meaningful with at least one order, and the symbol is derived from the first order.
Source
Thrown at crates/adapters/kraken/src/execution/spot.rs:935
ts_event,
due_post_only,
);
}
}
}
Ok(())
});
}
fn batch_add_via_ws(&self, orders: &[OrderAny], leverage: Option<u16>) -> anyhow::Result<()> {
let token = self
.ws
.auth_token_blocking()
.ok_or_else(|| anyhow::anyhow!("missing WS auth token"))?;
let first = orders
.first()
.ok_or_else(|| anyhow::anyhow!("batch_add requires at least one order"))?;
let symbol = first.instrument_id().symbol.inner().to_string();
let mut batch_orders = Vec::with_capacity(orders.len());
let mut client_order_ids = Vec::with_capacity(orders.len());
for order in orders {
batch_orders.push(build_batch_order(order, leverage)?);
client_order_ids.push(order.client_order_id());
}
let venue_order_ids = vec![None; orders.len()];
let params = KrakenWsBatchAddParams {
symbol,
orders: batch_orders,
token,
};
let identity = PendingRequest {
operation: PendingOperation::BatchAdd,
client_order_ids,View on GitHub (pinned to 18893faf8b)
Solutions
- Guard the caller: skip `submit_order_list` entirely when the order collection is empty.
- Fix batch-building logic so it either collects at least one order or does not submit.
- Filter out invalid/duplicate orders before batching and check the resulting count.
- If empty batches are expected, fall back to per-order submission only when non-empty.
Example fix
// before
exec_client.submit_order_list(batch)?; // batch may be empty
// after
if !batch.is_empty() {
exec_client.submit_order_list(batch)?;
} Defensive patterns
Strategy: validation
Validate before calling
// Rust
if orders.is_empty() {
log::debug!("no orders in batch; skipping submit_order_list");
return Ok(());
} Try / catch
if !batch.orders.is_empty() {
exec_client.submit_order_list(batch)?;
} else {
log::debug!("empty batch suppressed");
} Prevention
- Never call submit_order_list with an empty collection; early-return instead.
- Assert batch non-emptiness in strategy tests that exercise batching paths.
- Fix batch builders that filter out all orders yet still submit.
- Treat zero-order signals as legitimate no-ops in event handlers.
When it happens
Trigger: Calling `submit_order_list` with an empty slice/empty `OrderList` — e.g. a strategy that builds batches conditionally and submits an empty batch when no orders qualify.
Common situations: Batching logic with off-by-one or filtering that removes all orders; passing an uninitialized order collection during strategy warm-up; a data-driven flow where a signal produces zero orders.
Understand the failure class
Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.
Related errors
- Cannot batch modify empty order list
- Cannot batch cancel empty order list
- No symbols provided
- limit_price is required for batch order type {order_type:?}
- Conditional order type {order_type:?} requires trigger_price
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/f6edb2d972736e13.
Report an issue: GitHub.