nautechsystems/nautilus_trader · error

WS modify order failed: {e}

Error message

WS modify order failed: {e}

What it means

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.

Source

Thrown at crates/adapters/binance/src/spot/execution.rs:1663

                request_id.clone(),
                PendingRequest {
                    client_order_id: command.client_order_id,
                    venue_order_id: command.venue_order_id,
                    operation: PendingOperation::Modify,
                },
            );

            self.spawn_task("modify_order_ws", async move {
                if let Err(e) = ws_client
                    .cancel_replace_order_with_id(request_id.clone(), params)
                    .await
                {
                    dispatch_state.pending_requests.remove(&request_id);
                    log::warn!(
                        "WS modify request failed for {}, awaiting reconciliation: {e}",
                        command.client_order_id
                    );
                    anyhow::bail!("WS modify order failed: {e}");
                }
                Ok(())
            });
        } else {
            let command = cmd;
            let http_client = self.http_client.clone();
            log::debug!("WS trading not active, falling back to HTTP for modify_order");

            self.spawn_task("modify_order_http", async move {
                let result = match command.venue_order_id {
                    Some(venue_order_id) => {
                        http_client
                            .modify_order(
                                account_id,
                                command.instrument_id,
                                venue_order_id,
                                command.client_order_id,
                                order_side,

View on GitHub (pinned to a4b06ed870)

Solutions

  1. 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
  2. Wait for (or trigger) reconciliation to fetch the authoritative order state before assuming the modify landed or not
  3. After reconciliation confirms the order is still open with old parameters, resubmit the ModifyOrder
  4. 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
Defensive patterns

Strategy: retry

Validate before calling

# Python: only modify orders that are live in the cache before sending
order = self.cache.order(order.cl_ord_id if False else order.client_order_id)  # cached order
if order is None or not order.is_open:
    self.log.info(f"Skip modify, order {order.client_order_id if order else '?'} not open")
    return

Try / catch

// Strategy-side: WS modify failures emit no rejection event; rely on reconciliation.
// Resubmit only after reconciliation confirms the order is still open:
self.subscribe_report(ReportType.ORDER_STATUS)
# on next OrderStatusReport / reconcile: if report leaves old qty/price in place,
# resend modify_order with the intended parameters.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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