nautechsystems/nautilus_trader · error · anyhow::Error
modify order failed
Error message
modify order failed
What it means
Modifying (amending) a live order over the OKX private WebSocket failed. ws_private.modify_order returned Err; the adapter emits an order modify rejected event to the strategy with the classified failure, and the task logs/returns 'modify order failed' with the cause chained.
Source
Thrown at crates/adapters/okx/src/execution.rs:2469
command.venue_order_id,
new_px_usd,
new_px_vol,
rpi_taker_access,
rpi_px_round,
)
.await;
if let Err(e) = result {
emit_modify_failure(
classify_okx_ws_failure(&e),
&emitter,
clock,
command.strategy_id,
command.instrument_id,
command.client_order_id,
command.venue_order_id,
);
return Err(anyhow::Error::new(e).context("modify order failed"));
}
Ok(())
});
Ok(())
}
fn cancel_order(&self, mut cmd: CancelOrder) -> anyhow::Result<()> {
let venue_binding = self
.ws_dispatch_state
.order_venue_binding(cmd.client_order_id);
let route = {
let cache = self.core.cache();
let order_state = cache
.order(&cmd.client_order_id)
.map(|order| (order.order_type(), order.is_triggered()));
self.cancel_order_route(View on GitHub (pinned to 18893faf8b)
Solutions
- Inspect the chained WS error/OKX code; if the order is already terminal, cancel the modify request and let reconciliation update state.
- Ensure the order has a venue_order_id binding (submit via this trader or reconcile) so the amend can be identified on the venue.
- Verify new price/quantity respect the instrument precision and tick size before modifying.
- Check WS connection health; retry the modify after reconnect if the failure was transport-level.
Defensive patterns
Strategy: validation
Validate before calling
// Verify the order is open and amendable, and that new values respect precision
let ok = cache.order(&cid)
.map(|o| !o.is_closed() && price_fits_tick(new_price, &instrument) && qty_fits_step(new_qty, &instrument))
.unwrap_or(false);
if !ok { return; } Try / catch
// Treat modify rejection as terminal unless transport-level
if let Err(e) = trader.modify_order(cmd) {
log::warn!("modify failed: {e:?}");
// the adapter emits OrderModifyRejected; resubmit only if order still open
} Prevention
- Reconcile after restarts so venue bindings exist for WS amends.
- Check the order is still open before modifying (fills/cancels race).
- Round new price/quantity to instrument tick/step before the request.
- Do not attempt modify on spread instruments — the adapter rejects them by design.
When it happens
Trigger: modify_order on a non-spread instrument; ws_private.modify_order returned Err: WS transport failure/timeout, no venue_order_id binding and an unknown client_order_id, OKX rejecting the amend (order filled/canceled, price/size precision), or unsupported amend for the order type.
Common situations: Modifying an order that was filled or canceled concurrently; modifying orders loaded from reconciliation where no WS venue binding exists; adjusting spread-leg-independent prices with wrong precision; OKX rejecting amend on orders in a non-amendable state; WS disconnects.
Related errors
- WS modify order failed: {e}
- modify order rejected: {reason}
- Invalid `BarSpecification` for channel, was {bar_spec}
- errors.join("; ")
- {reason}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/7360ee5d61feed61.
Report an issue: GitHub.