nautechsystems/nautilus_trader · error
Unsupported trailing_offset_type for OKX: {offset_type:?}
Error message
Unsupported trailing_offset_type for OKX: {offset_type:?} What it means
When building an OKX trailing-stop algo order, the adapter maps `TrailingOffsetType` to OKX callback parameters. Only `BasisPoints`, `Price`, and (per surrounding code) ratio-based variants are supported; any other `TrailingOffsetType` (e.g. a type OKX has no analog for) causes `anyhow::bail!` in `submit_conditional_order`.
Source
Thrown at crates/adapters/okx/src/execution.rs:904
Some(is_reduce_only)
};
let (callback_ratio, callback_spread) = if order_type == OrderType::TrailingStopMarket {
let offset = trailing_offset
.ok_or_else(|| anyhow::anyhow!("TrailingStopMarket requires trailing_offset"))?;
let offset_type = trailing_offset_type.ok_or_else(|| {
anyhow::anyhow!("TrailingStopMarket requires trailing_offset_type")
})?;
match offset_type {
TrailingOffsetType::BasisPoints => {
// Convert basis points to ratio (e.g., 100 bps = 0.01)
let ratio = offset / Decimal::from(10000);
(Some(ratio.to_string()), None)
}
TrailingOffsetType::Price => (None, Some(offset.to_string())),
_ => {
anyhow::bail!("Unsupported trailing_offset_type for OKX: {offset_type:?}");
}
}
} else {
(None, None)
};
self.ws_dispatch_state.track_order_context(context);
let dispatch_state = Arc::clone(&self.ws_dispatch_state);
self.spawn_task("submit_algo_order", async move {
let result = http_client
.place_algo_order_with_domain_types(
instrument_id,
trade_mode,
client_order_id,
order_side,
order_type,
quantity,View on GitHub (pinned to 18893faf8b)
Solutions
- Set the order's trailing offset type to `TrailingOffsetType::BasisPoints` or `TrailingOffsetType::Price`, which the adapter maps to OKX callback params.
- Convert your desired offset into basis points before submitting (e.g. a percent offset as bps).
- Guard in strategy config: validate the trailing offset type against OKX support before order construction.
Example fix
// before order.trailing_offset_type = TrailingOffsetType::Ticks; // after order.trailing_offset_type = TrailingOffsetType::BasisPoints; // OKX-supported
Defensive patterns
Strategy: validation
Validate before calling
const OKX_SUPPORTED: &[TrailingOffsetType] = &[TrailingOffsetType::BasisPoints, TrailingOffsetType::Price];
if !OKX_SUPPORTED.contains(&order.trailing_offset_type()) {
return Err(anyhow::anyhow!("trailing_offset_type not supported by OKX"));
} Prevention
- Use only BasisPoints or Price trailing offset types for OKX.
- Convert percent/tick offsets to basis points before order construction.
- Validate trailing-stop config against venue support in strategy setup.
When it happens
Trigger: Submitting a trailing-stop conditional order whose `TrailingOffsetType` is not one of the OKX-supported variants (e.g. a basis/price/percent type outside the matched arms, or a venue-specific offset type) — i.e. the `_` catch-all arm is reached.
Common situations: Configuring a trailing stop with an offset type taken from another adapter's docs; a generic strategy builder that exposes all `TrailingOffsetType` variants without venue filtering.
Related errors
- Trigger/conditional orders ({order_type:?}) are not supporte
- Trigger/conditional orders ({order_type:?}) are not supporte
- TrailingStopMarket requires trailing_offset
- TrailingStopMarket requires trailing_offset_type
- instrument update lock poisoned
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/833c90eee361aa93.
Report an issue: GitHub.