nautechsystems/nautilus_trader · error · anyhow::Error
submit algo order failed
Error message
submit algo order failed
What it means
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).
Source
Thrown at crates/adapters/okx/src/execution.rs:952
match result {
Ok(response) => {
dispatch_state.bind_algo_parent(
client_order_id,
VenueOrderId::new(response.algo_id.as_str()),
);
}
Err(e) => {
let failure = classify_okx_http_failure(&e);
dispatch_state.resolve_algo_submit_failure(client_order_id, &failure);
emit_submit_failure(
failure,
&emitter,
clock,
strategy_id,
instrument_id,
client_order_id,
);
return Err(anyhow::Error::new(e).context("submit algo order failed"));
}
}
Ok(())
});
Ok(())
}
fn cancel_ws_order(&self, cmd: &CancelOrder) {
self.ensure_order_identity(cmd.client_order_id, cmd.strategy_id, cmd.instrument_id);
let ws_private = self.ws_private.clone();
let mut command = cmd.clone();
command.venue_order_id = self
.ws_dispatch_state
.order_venue_binding(cmd.client_order_id)
.map(|(venue_order_id, _)| venue_order_id)View on GitHub (pinned to 18893faf8b)
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.
Example fix
// before: TrailingStopMarket without offset
context.submit_order(TrailingStopMarket(...))
// after: supply supported trailing offset
let order = factory.trailing_stop_market(
instrument_id, OrderSide::Sell, Quantity::from(1),
Price::from("25000.0"),
TrailingOffset::from(Decimal::from(100)),
TrailingOffsetType::BasisPoints,
); Defensive patterns
Strategy: validation
Validate before calling
// Validate algo order inputs before submit
if order.order_type() == OrderType::TrailingStopMarket {
assert!(order.trailing_offset().is_some(), "trailing_offset required");
assert!(matches!(order.trailing_offset_type(), Some(TrailingOffsetType::BasisPoints) | Some(TrailingOffsetType::Price)), "unsupported offset type");
}
assert!(trigger_price_side_valid(instrument, side, trigger_price), "trigger price on wrong side of market"); Try / catch
// Rust: match on submit result and inspect the anyhow chain
if let Err(e) = trader.submit_order(order) {
log::error!("algo submit failed: {e:?}"); // full chain incl. OKX code
// react to the emitted OrderRejected event rather than blind retry
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- cancel order failed
- mass cancel orders failed
- {failure_prefix}; outcome is unknown after possible transmis
- {e}
- Failed to probe market closure for {failed_chunks} of {total
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/a19db520b34db5cf.
Report an issue: GitHub.