{"record":{"id":"a282c9cb8fc4afa4","repo":"nautechsystems/nautilus_trader","slug":"submit-order-failed","errorCode":null,"errorMessage":"submit order failed","messagePattern":"submit order failed","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/execution.rs","lineNumber":774,"sourceCode":"                    px_vol,\n                    outcome,\n                    slippage_pct,\n                    rpi,\n                    rpi_taker_access,\n                    rpi_px_round,\n                )\n                .await;\n\n            if let Err(e) = result {\n                emit_submit_failure(\n                    classify_okx_ws_failure(&e),\n                    &emitter,\n                    clock,\n                    strategy_id,\n                    instrument_id,\n                    client_order_id,\n                );\n                return Err(anyhow::Error::new(e).context(\"submit order failed\"));\n            }\n\n            Ok(())\n        });\n\n        Ok(())\n    }\n\n    fn submit_order_http(&self, cmd: &SubmitOrder) -> anyhow::Result<()> {\n        let order = {\n            let cache = self.core.cache();\n            cache.try_order_owned(&cmd.client_order_id)?\n        };\n        let http_client = self.http_client.clone();\n        let trade_mode = self.trade_mode_for_order(cmd.instrument_id, &cmd.params);\n\n        let emitter = self.emitter.clone();\n        let clock = self.clock;","sourceCodeStart":756,"sourceCodeEnd":792,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/execution.rs#L756-L792","documentation":"OKX execution client's WebSocket-path order submission: submit_regular_order spawns a task that calls place_order_with_domain_types over the WS. If the placement fails, a submit-failure event is emitted for the strategy and the task returns 'submit order failed' wrapping the underlying OKX error. Note submit_order itself returns Ok immediately since the work is spawned.","triggerScenarios":"submit_order routing to the WS path where the OKX place-order WS request fails — rejected order params (invalid px/sz/tif), post-only would-cross rejection, insufficient balance/margin, rate limit, or WS dropped mid-request.","commonSituations":"Trading instruments with wrong tick/lot sizes, submitting during OKX WS disconnects, insufficient funds, or FOK orders that cannot fill; failures surface asynchronously in the spawned task, not from submit_order's return.","solutions":["Subscribe to the emitted order-denied/submit-failure events; the underlying OKX error there names the rejection reason.","Validate price/quantity against the instrument's tick size and lot size before submitting.","Check account balance/margin and position mode (net vs long/short) matches the order side.","Ensure the WS connection is healthy (heartbeats, reconnect logic) when using the WS submission path."],"exampleFix":"// before\nclient.submit_order(cmd)?; // returns Ok even if WS place fails later\n// after\nclient.submit_order(cmd)?; // also handle OrderDenied/submit-failure event for the real OKX error","handlingStrategy":"try-catch","validationCode":"// Rust: validate against instrument rules before submit\ndebug_assert_eq!(qty.as_decimal() % instrument.lot_size().as_decimal(), Decimal::ZERO);\ndebug_assert!((price.as_decimal() % instrument.tick_size().as_decimal()).is_zero());","typeGuard":null,"tryCatchPattern":"client.submit_order(&cmd)?; // Ok means spawned, not filled\n// handle the async failure via actor events:\n// on_event(OrderDenied { reason, .. }) => log okx rejection code and adjust order\n// on_event(OrderRejected { .. }) => reconcile state","preventionTips":["Subscribe to order event stream; WS-path failures arrive asynchronously","Validate tick/lot/min sizes against the instrument before submit","Match position mode (net vs long/short hedging) in OKX account settings","Keep WS heartbeats/reconnect healthy on the WS submission path"],"tags":["rust","okx","order-submission","websocket"],"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-14T05:17:10.506Z"}