{"record":{"id":"a19db520b34db5cf","repo":"nautechsystems/nautilus_trader","slug":"submit-algo-order-failed","errorCode":null,"errorMessage":"submit algo order failed","messagePattern":"submit algo order failed","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/execution.rs","lineNumber":952,"sourceCode":"            match result {\n                Ok(response) => {\n                    dispatch_state.bind_algo_parent(\n                        client_order_id,\n                        VenueOrderId::new(response.algo_id.as_str()),\n                    );\n                }\n                Err(e) => {\n                    let failure = classify_okx_http_failure(&e);\n                    dispatch_state.resolve_algo_submit_failure(client_order_id, &failure);\n                    emit_submit_failure(\n                        failure,\n                        &emitter,\n                        clock,\n                        strategy_id,\n                        instrument_id,\n                        client_order_id,\n                    );\n                    return Err(anyhow::Error::new(e).context(\"submit algo order failed\"));\n                }\n            }\n\n            Ok(())\n        });\n\n        Ok(())\n    }\n\n    fn cancel_ws_order(&self, cmd: &CancelOrder) {\n        self.ensure_order_identity(cmd.client_order_id, cmd.strategy_id, cmd.instrument_id);\n\n        let ws_private = self.ws_private.clone();\n        let mut command = cmd.clone();\n        command.venue_order_id = self\n            .ws_dispatch_state\n            .order_venue_binding(cmd.client_order_id)\n            .map(|(venue_order_id, _)| venue_order_id)","sourceCodeStart":934,"sourceCodeEnd":970,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/execution.rs#L934-L970","documentation":"The OKX adapter failed to place an algo (conditional/trigger) order via the OKX private HTTP endpoint. The HTTP client returned an error (transport failure, auth problem, or OKX rejection), the adapter emitted an order submit failure event to the strategy, and the spawned task surfaces the underlying error with this context. It is the routed path in submit_order for algo order types (stop, trailing-stop, conditional orders).","triggerScenarios":"submit_order routed to submit_conditional_order (OrderCommandRoute::AlgoHttp) and http_client.place_algo_order_with_domain_types returned Err: network/timeout to OKX REST, invalid API credentials, invalid trigger price/quantity/trailing parameters rejected by OKX, unsupported trailing_offset_type, or missing trailing_offset for TrailingStopMarket.","commonSituations":"Trading a stop-limit/stop-market or TrailingStopMarket order; misconfigured OKX API key/passphrase; trigger price on the wrong side of the market for the chosen trigger type; basis-points vs price trailing offset mismatch; OKX 51000-series parameter rejection codes; connectivity loss to okx.com.","solutions":["Inspect the chained anyhow source (log shows 'submit algo order failed' with :? of the full chain) for the OKX error code and fix the offending order parameters (trigger price side, trailing offset type).","Verify OKX API credentials and passphrase are valid and that the key has trade permission for the account (live vs demo domain).","Check network reachability/proxy settings to OKX REST and retry after confirming the order was not actually placed (check reconcile/open orders).","For TrailingStopMarket, ensure trailing_offset and a supported TrailingOffsetType (BasisPoints or Price) are supplied before submitting.","Handle the OrderRejected/submit-failure event emitted to the strategy and re-submit a corrected order."],"exampleFix":"// before: TrailingStopMarket without offset\ncontext.submit_order(TrailingStopMarket(...))\n// after: supply supported trailing offset\nlet order = factory.trailing_stop_market(\n    instrument_id, OrderSide::Sell, Quantity::from(1),\n    Price::from(\"25000.0\"),\n    TrailingOffset::from(Decimal::from(100)),\n    TrailingOffsetType::BasisPoints,\n);","handlingStrategy":"validation","validationCode":"// Validate algo order inputs before submit\nif order.order_type() == OrderType::TrailingStopMarket {\n    assert!(order.trailing_offset().is_some(), \"trailing_offset required\");\n    assert!(matches!(order.trailing_offset_type(), Some(TrailingOffsetType::BasisPoints) | Some(TrailingOffsetType::Price)), \"unsupported offset type\");\n}\nassert!(trigger_price_side_valid(instrument, side, trigger_price), \"trigger price on wrong side of market\");","typeGuard":null,"tryCatchPattern":"// Rust: match on submit result and inspect the anyhow chain\nif let Err(e) = trader.submit_order(order) {\n    log::error!(\"algo submit failed: {e:?}\"); // full chain incl. OKX code\n    // react to the emitted OrderRejected event rather than blind retry\n}","preventionTips":["Pre-validate trigger price relative to last price for the chosen trigger type.","Always set a supported TrailingOffsetType for trailing stop orders.","Keep OKX API credentials and live/demo flags correct per environment.","Monitor emitted OrderRejected events instead of assuming submits succeed."],"tags":["okx","http","order-submission","trading","network"],"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"}