nautechsystems/nautilus_trader · error
Cancel all orders failed: {e}
Error message
Cancel all orders failed: {e} What it means
cancel_all_orders issues a bulk cancel for a given instrument via ws_client.cancel_all_orders inside a spawned task; any failure from Deribit is logged with the instrument_id and re-raised as 'Cancel all orders failed: {e}'. The public method returns Ok(()) immediately; the failure occurs asynchronously.
Source
Thrown at crates/adapters/deribit/src/execution.rs:994
});
Ok(())
}
fn cancel_all_orders(&self, cmd: CancelAllOrders) -> anyhow::Result<()> {
let instrument_id = cmd.instrument_id;
// Without a side filter, use efficient bulk cancel via Deribit API
let Some(order_side) = cmd.order_side else {
log::debug!(
"Cancelling all orders: instrument={instrument_id}, order_side=None (bulk)"
);
let ws_client = self.ws_client.clone();
self.spawn_task("cancel_all_orders", async move {
if let Err(e) = ws_client.cancel_all_orders(instrument_id, None).await {
log::error!("Cancel all orders failed for instrument {instrument_id}: {e}");
anyhow::bail!("Cancel all orders failed: {e}");
}
Ok(())
});
return Ok(());
};
// For specific side (Buy/Sell), filter from cache and cancel individually
// Deribit API doesn't support side filtering, so we implement it locally
log::debug!(
"Cancelling orders by side: instrument={instrument_id}, order_side={order_side}"
);
let orders_to_cancel: Vec<_> = {
let cache = self.core.cache();
let open_orders = cache.orders_open(None, Some(&instrument_id), None, None, None);
open_ordersView on GitHub (pinned to 18893faf8b)
Solutions
- Check the logged inner error and instrument_id for the venue rejection reason
- Verify the WebSocket connection and auth state before relying on bulk cancel for risk reduction
- Confirm the instrument_id is a valid, currently listed Deribit instrument
- Fall back to per-order cancels if bulk cancel is repeatedly rejected
Example fix
// before
if let Err(e) = ws_client.cancel_all_orders(instrument_id, None).await {
anyhow::bail!("Cancel all orders failed: {e}");
}
// after
if let Err(e) = ws_client.cancel_all_orders(instrument_id, None).await {
log::error!("bulk cancel failed for {instrument_id}, falling back to per-order cancel: {e}");
for order_id in open_order_ids(instrument_id) {
let _ = ws_client.cancel_order(Some(order_id), None).await;
}
} Defensive patterns
Strategy: try-catch
Validate before calling
// Verify instrument validity before bulk cancel
let valid = instrument_cache.contains(&instrument_id);
assert!(valid, "unknown instrument {instrument_id}"); Try / catch
match client.cancel_all_orders(instrument_id, None).await {
Ok(()) => {}, // failure surfaces in the spawned task
Err(e) => log::error!("cancel_all dispatch failed: {e}"),
}
// on failure, fall back to per-order cancels for risk reduction Prevention
- Never rely solely on bulk cancel for risk reduction; add per-order fallback
- Confirm WebSocket auth/session health before volatile market periods
- Cache and validate instrument_ids against the venue's active instruments
- Log and alert on any bulk-cancel failure — it is a risk event
When it happens
Trigger: Calling cancel_all_orders(instrument_id) when the Deribit bulk cancel-by-instrument request fails — instrument not recognized, no active session/auth, connection drop, or Deribit-side rejection.
Common situations: Flatten-all risk flows during volatility when the WebSocket is degraded; using an instrument_id not currently listed on Deribit; unauthenticated private session after reconnect.
Related errors
- Modify order failed: {e}
- Cancel order failed: {e}
- Batch cancel order failed: {e}
- {reason}
- InstrumentState channel requires kind and currency parameter
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/c7a13dee0ab998a1.
Report an issue: GitHub.