{"record":{"id":"7360ee5d61feed61","repo":"nautechsystems/nautilus_trader","slug":"modify-order-failed","errorCode":null,"errorMessage":"modify order failed","messagePattern":"modify order failed","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/execution.rs","lineNumber":2469,"sourceCode":"                    command.venue_order_id,\n                    new_px_usd,\n                    new_px_vol,\n                    rpi_taker_access,\n                    rpi_px_round,\n                )\n                .await;\n\n            if let Err(e) = result {\n                emit_modify_failure(\n                    classify_okx_ws_failure(&e),\n                    &emitter,\n                    clock,\n                    command.strategy_id,\n                    command.instrument_id,\n                    command.client_order_id,\n                    command.venue_order_id,\n                );\n                return Err(anyhow::Error::new(e).context(\"modify order failed\"));\n            }\n\n            Ok(())\n        });\n\n        Ok(())\n    }\n\n    fn cancel_order(&self, mut cmd: CancelOrder) -> anyhow::Result<()> {\n        let venue_binding = self\n            .ws_dispatch_state\n            .order_venue_binding(cmd.client_order_id);\n        let route = {\n            let cache = self.core.cache();\n            let order_state = cache\n                .order(&cmd.client_order_id)\n                .map(|order| (order.order_type(), order.is_triggered()));\n            self.cancel_order_route(","sourceCodeStart":2451,"sourceCodeEnd":2487,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/execution.rs#L2451-L2487","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Verify the order is open and amendable, and that new values respect precision\nlet ok = cache.order(&cid)\n    .map(|o| !o.is_closed() && price_fits_tick(new_price, &instrument) && qty_fits_step(new_qty, &instrument))\n    .unwrap_or(false);\nif !ok { return; }","typeGuard":null,"tryCatchPattern":"// Treat modify rejection as terminal unless transport-level\nif let Err(e) = trader.modify_order(cmd) {\n    log::warn!(\"modify failed: {e:?}\");\n    // the adapter emits OrderModifyRejected; resubmit only if order still open\n}","preventionTips":["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."],"tags":["okx","websocket","modify-order","amend","venue-rejection"],"backgroundTag":"api-error-response","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}