{"record":{"id":"0add0d1c47ed7257","repo":"nautechsystems/nautilus_trader","slug":"ws-modify-order-failed-e-0add0d","errorCode":null,"errorMessage":"WS modify order failed: {e}","messagePattern":"WS modify order failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/binance/src/spot/execution.rs","lineNumber":1663,"sourceCode":"                request_id.clone(),\n                PendingRequest {\n                    client_order_id: command.client_order_id,\n                    venue_order_id: command.venue_order_id,\n                    operation: PendingOperation::Modify,\n                },\n            );\n\n            self.spawn_task(\"modify_order_ws\", async move {\n                if let Err(e) = ws_client\n                    .cancel_replace_order_with_id(request_id.clone(), params)\n                    .await\n                {\n                    dispatch_state.pending_requests.remove(&request_id);\n                    log::warn!(\n                        \"WS modify request failed for {}, awaiting reconciliation: {e}\",\n                        command.client_order_id\n                    );\n                    anyhow::bail!(\"WS modify order failed: {e}\");\n                }\n                Ok(())\n            });\n        } else {\n            let command = cmd;\n            let http_client = self.http_client.clone();\n            log::debug!(\"WS trading not active, falling back to HTTP for modify_order\");\n\n            self.spawn_task(\"modify_order_http\", async move {\n                let result = match command.venue_order_id {\n                    Some(venue_order_id) => {\n                        http_client\n                            .modify_order(\n                                account_id,\n                                command.instrument_id,\n                                venue_order_id,\n                                command.client_order_id,\n                                order_side,","sourceCodeStart":1645,"sourceCodeEnd":1681,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/a4b06ed870971b5671d12754ea138a3ab99b1dec/crates/adapters/binance/src/spot/execution.rs#L1645-L1681","documentation":"The Binance Spot WebSocket trading client's cancel-replace request (`cancel_replace_order_with_id`) returned an error while handling a ModifyOrder command. Binance Spot has no native amend, so modification is a cancel-replace over WS; when the send fails, the adapter removes the entry from `pending_requests`, logs a warning, and bails so the task fails — leaving the modification to be resolved by reconciliation.","triggerScenarios":"A `ModifyOrder` command arrives while the WS order transport is active (`ws_order_transport_active()`) and `ws_client.cancel_replace_order_with_id()` errors — e.g. the WS connection dropped or is mid-reconnect, the session is not fully authenticated, the request could not be serialized/sent, or the underlying client timed out awaiting a response.","commonSituations":"Flaky or high-latency network to Binance; modifying during the WS reconnect/ServerShutdown window; Binance WS API maintenance; firing a modify immediately after submit before the order is acknowledged. The order keeps its previous quantity/price until reconciliation reports the true state.","solutions":["Inspect the inner `{e}` in the preceding log line ('WS modify request failed for {client_order_id}, awaiting reconciliation') — it identifies the transport-level cause","Wait for (or trigger) reconciliation to fetch the authoritative order state before assuming the modify landed or not","After reconciliation confirms the order is still open with old parameters, resubmit the ModifyOrder","If failures recur, disable WS trading so modify_order takes the HTTP cancel-replace path, and check network stability/firewall/proxy to the Binance WS endpoints"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# Python: only modify orders that are live in the cache before sending\norder = self.cache.order(order.cl_ord_id if False else order.client_order_id)  # cached order\nif order is None or not order.is_open:\n    self.log.info(f\"Skip modify, order {order.client_order_id if order else '?'} not open\")\n    return","typeGuard":null,"tryCatchPattern":"// Strategy-side: WS modify failures emit no rejection event; rely on reconciliation.\n// Resubmit only after reconciliation confirms the order is still open:\nself.subscribe_report(ReportType.ORDER_STATUS)\n# on next OrderStatusReport / reconcile: if report leaves old qty/price in place,\n# resend modify_order with the intended parameters.","preventionTips":["Treat a WS modify as 'outcome unknown' — always wait for reconciliation before resubmitting to avoid double-amends","Avoid modifying during known reconnect windows (subscribe to the WS status/reconnect logs and pause submissions)","Watch for 'WS modify request failed' warnings and alert on them so silent dropped modifies are noticed quickly","If the network path to Binance is unstable, run modify_order over HTTP (disable WS trading) where structured rejections are emitted"],"tags":["binance-spot","websocket","modify-order","cancel-replace","nautilustrader","reconciliation"],"backgroundTag":"websocket-request-failed","analyzedSha":"a4b06ed870971b5671d12754ea138a3ab99b1dec","analyzedAt":"2026-08-16T22:54:50.089Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}