nautechsystems/nautilus_trader · error

Cancel all orders failed: {}

Error message

Cancel all orders failed: {}

What it means

Thrown by BinanceFuturesHttpClient::cancel_all_orders when the DELETE /fapi/v1/allOpenOrders (or equivalent Coin-M endpoint) response has a code field other than 200. The request reached Binance and was authenticated, but the venue rejected the bulk cancel; response.msg carries Binance's own reason. On success the client returns an empty Vec<VenueOrderId> because Binance does not enumerate the canceled orders.

Source

Thrown at crates/adapters/binance/src/futures/http/client.rs:2448

    /// # Errors
    ///
    /// Returns an error if the request fails.
    pub async fn cancel_all_orders(
        &self,
        instrument_id: InstrumentId,
    ) -> anyhow::Result<Vec<VenueOrderId>> {
        let symbol = format_binance_symbol(&instrument_id);

        let params = BinanceCancelAllOrdersParams {
            symbol,
            recv_window: None,
        };

        let response = self.inner.cancel_all_orders(&params).await?;
        if response.code == 200 {
            Ok(vec![])
        } else {
            anyhow::bail!("Cancel all orders failed: {}", response.msg);
        }
    }

    /// Cancels all open algo orders for a symbol.
    ///
    /// # Errors
    ///
    /// Returns an error if the request fails.
    pub async fn cancel_all_algo_orders(&self, instrument_id: InstrumentId) -> anyhow::Result<()> {
        let symbol = format_binance_symbol(&instrument_id);

        let params = BinanceCancelAllAlgoOrdersParams {
            symbol,
            recv_window: None,
        };

        let response = self.inner.cancel_all_algo_orders(&params).await?;
        if response.code == 200 {

View on GitHub (pinned to a4b06ed870)

Solutions

  1. Read the embedded msg: 'Unknown order sent' style errors usually mean wrong symbol/market — verify the InstrumentId venue and symbol formatting
  2. Confirm the API key has futures trading (write) permission and matches the testnet/mainnet base URL the client was built with
  3. Retry once after a short backoff for transient venue-side codes before surfacing the failure
  4. If canceling everything on the account, iterate cached open orders instead of relying on per-symbol cancel-all when the symbol is uncertain

Example fix

// before
client.cancel_all_orders(instrument_id).await?;

// after
match client.cancel_all_orders(instrument_id).await {
    Ok(_) => {}
    Err(e) => {
        log::error!("cancel-all rejected for {instrument_id}: {e}");
        // fall back to canceling individually known open orders
        for report in client.request_open_orders(Some(instrument_id)).await? {
            let _ = client
                .cancel_order(instrument_id, Some(report.venue_order_id), None)
                .await;
        }
    }
}
Defensive patterns

Strategy: fallback

Validate before calling

// verify the symbol trades on this market before cancel-all
if client.get_size_precision(&symbol).is_err() {
    log::warn!("symbol {symbol} not loaded; skipping cancel_all");
    return Ok(());
}

Try / catch

Catch the anyhow error, log the embedded venue msg, and fall back to canceling individually known open orders from request_open_orders so a bulk rejection does not leave the book unflattened.

Prevention

When it happens

Trigger: Calling cancel_all_orders(instrument_id) with a symbol that is malformed, delisted, or not traded on the account's market type (e.g. a Coin-M symbol sent to the USD-M client); insufficient API-key trade permissions; trading-only symbols in reduce-only/hedge-mode conflicts; venue-side transient errors returned with a non-200 code in the JSON body while HTTP transport itself succeeded.

Common situations: Start-of-session flatten routines firing before instruments are correctly configured; a stale hardcoded InstrumentId (e.g. BINANCE_PERP_BTC_USDT vs BINANCE_COINM_BTCUSD_PERP) hitting the wrong instrument client; API key with read-only permission used by a live trading node.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@a4b06ed870 (2026-08-16). Data as JSON: /api/errors/c547fbb74a240b2e. Report an issue: GitHub.