nautechsystems/nautilus_trader · error · anyhow::Error
cancel advance algo orders failed
Error message
cancel advance algo orders failed
What it means
The batch cancel of ADVANCE algo orders (e.g. TWAP/ Iceberg-class OKX advanced algo orders) over OKX REST failed. dispatch_algo_cancels routes advance-group orders to http_client.cancel_advance_algo_orders; an Err from that call is wrapped with this context. Per-item venue rejections on a successful response are handled separately.
Source
Thrown at crates/adapters/okx/src/execution.rs:1250
}
if !advance_requests.is_empty() {
let client = self.http_client.clone();
let emitter = self.emitter.clone();
let clock = self.clock;
self.spawn_task("cancel_advance_algo_orders", async move {
match client.cancel_advance_algo_orders(advance_requests).await {
Ok(responses) => {
emit_algo_cancel_rejections(&responses, &advance_contexts, &emitter, clock);
}
Err(e) => {
log_algo_batch_cancel_failure(
classify_okx_http_failure(&e),
&advance_contexts,
);
return Err(
anyhow::Error::new(e).context("cancel advance algo orders failed")
);
}
}
Ok(())
});
}
}
fn begin_generation_shutdown(&self) {
self.pending_tasks.begin_shutdown();
self.session_tasks.begin_shutdown();
self.ws_private.begin_shutdown();
self.ws_business.begin_shutdown();
self.core.set_disconnected();
}
/// Polls the cache until the account is registered or timeout is reached.
async fn await_account_registered(&self, timeout_secs: f64) -> anyhow::Result<()> {View on GitHub (pinned to 18893faf8b)
Solutions
- Inspect the chained cause and logged advance_contexts to identify the failed orders.
- Verify the OKX account has advance algo orders enabled and the API key can trade them.
- Back off and retry if rate-limited; re-dispatch cancels for the orders listed in the failure log.
- Reconcile algo order state before retrying so stale algo ids are not resubmitted.
Defensive patterns
Strategy: validation
Validate before calling
// Only cancel advance algo orders if the account supports them and they are open
let is_advance_open = cache.order(&cid)
.map(|o| is_advance_algo_order(o.order_type()) && !o.is_closed())
.unwrap_or(false);
if !is_advance_open { return; } Try / catch
// Handle the advance-group failure distinctly from the regular group
if let Err(e) = trader.batch_cancel_orders(batch) {
if format!("{e:#}").contains("cancel advance algo orders failed") {
retry_advance_cancels(advance_contexts);
}
} Prevention
- Confirm the OKX account has advance algo orders enabled before placing them.
- Only route advance-class order types to the advance cancel endpoint.
- Reconcile algo state before batch cancels to avoid stale algo ids.
- Watch rate limits on the advance algo endpoints separately from regular ones.
When it happens
Trigger: cancel_all_orders or batch_cancel_orders containing advance algo orders; http_client.cancel_advance_algo_orders returned Err: transport failure, non-2xx OKX response, auth error, rate limit, or the account lacking advance-algo trading entitlements.
Common situations: Canceling advanced algo orders placed outside this trader instance; OKX account not enabled for advance algo products; batch size/rate limiting on the advance endpoint; stale algo ids after process restart.
Related errors
- cancel algo orders failed
- Batch cancel failed: {error_msg}
- {e}
- VIP level {vip} insufficient for 50 depth subscription (requ
- submit algo order failed
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/9d31caba371af83b.
Report an issue: GitHub.