{"record":{"id":"c547fbb74a240b2e","repo":"nautechsystems/nautilus_trader","slug":"cancel-all-orders-failed","errorCode":null,"errorMessage":"Cancel all orders failed: {}","messagePattern":"Cancel all orders failed: (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/futures/http/client.rs","lineNumber":2448,"sourceCode":"    /// # Errors\n    ///\n    /// Returns an error if the request fails.\n    pub async fn cancel_all_orders(\n        &self,\n        instrument_id: InstrumentId,\n    ) -> anyhow::Result<Vec<VenueOrderId>> {\n        let symbol = format_binance_symbol(&instrument_id);\n\n        let params = BinanceCancelAllOrdersParams {\n            symbol,\n            recv_window: None,\n        };\n\n        let response = self.inner.cancel_all_orders(&params).await?;\n        if response.code == 200 {\n            Ok(vec![])\n        } else {\n            anyhow::bail!(\"Cancel all orders failed: {}\", response.msg);\n        }\n    }\n\n    /// Cancels all open algo orders for a symbol.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the request fails.\n    pub async fn cancel_all_algo_orders(&self, instrument_id: InstrumentId) -> anyhow::Result<()> {\n        let symbol = format_binance_symbol(&instrument_id);\n\n        let params = BinanceCancelAllAlgoOrdersParams {\n            symbol,\n            recv_window: None,\n        };\n\n        let response = self.inner.cancel_all_algo_orders(&params).await?;\n        if response.code == 200 {","sourceCodeStart":2430,"sourceCodeEnd":2466,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/futures/http/client.rs#L2430-L2466","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the embedded msg: 'Unknown order sent' style errors usually mean wrong symbol/market — verify the InstrumentId venue and symbol formatting","Confirm the API key has futures trading (write) permission and matches the testnet/mainnet base URL the client was built with","Retry once after a short backoff for transient venue-side codes before surfacing the failure","If canceling everything on the account, iterate cached open orders instead of relying on per-symbol cancel-all when the symbol is uncertain"],"exampleFix":"// before\nclient.cancel_all_orders(instrument_id).await?;\n\n// after\nmatch client.cancel_all_orders(instrument_id).await {\n    Ok(_) => {}\n    Err(e) => {\n        log::error!(\"cancel-all rejected for {instrument_id}: {e}\");\n        // fall back to canceling individually known open orders\n        for report in client.request_open_orders(Some(instrument_id)).await? {\n            let _ = client\n                .cancel_order(instrument_id, Some(report.venue_order_id), None)\n                .await;\n        }\n    }\n}","handlingStrategy":"fallback","validationCode":"// verify the symbol trades on this market before cancel-all\nif client.get_size_precision(&symbol).is_err() {\n    log::warn!(\"symbol {symbol} not loaded; skipping cancel_all\");\n    return Ok(());\n}","typeGuard":null,"tryCatchPattern":"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.","preventionTips":["Verify instrument_id venue/symbol matches the client's market type (UsdM vs CoinM)","Confirm API key has futures write permission before wiring the live node","Run cancel-all at session start and on symbol teardown, and log response messages for audit"],"tags":["binance","futures","order-cancel","cancel-all","rust","nautilustrader"],"backgroundTag":"order-cancel-rejected","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}