nautechsystems/nautilus_trader · error · anyhow::Error
BitMEX only supports PRICE trailing offset type, was {offset
Error message
BitMEX only supports PRICE trailing offset type, was {offset_type:?} What it means
submit_order rejects trailing stop orders whose TrailingOffsetType is anything but PRICE: BitMEX pegs the order with an absolute trailing-stop offset (TrailingStopPeg) and cannot express basis-point or tick offsets.
Source
Thrown at crates/adapters/bitmex/src/http/client.rs:1704
if let Some(display_qty) = display_qty {
params.display_qty(quantity_to_u32(&display_qty, &instrument));
}
if let Some(order_list_id) = order_list_id {
params.cl_ord_link_id(order_list_id.as_str());
}
let is_trailing_stop = matches!(
order_type,
OrderType::TrailingStopMarket | OrderType::TrailingStopLimit
);
if is_trailing_stop && let Some(offset) = trailing_offset {
if let Some(offset_type) = trailing_offset_type
&& offset_type != TrailingOffsetType::Price
{
anyhow::bail!(
"BitMEX only supports PRICE trailing offset type, was {offset_type:?}"
);
}
params.peg_price_type(BitmexPegPriceType::TrailingStopPeg);
// BitMEX requires negative offset for stop-sell orders
let signed_offset = match order_side {
OrderSide::Sell => -offset.abs(),
OrderSide::Buy => offset.abs(),
};
params.peg_offset_value(signed_offset);
}
// Pegged orders (BBO) via params override
if peg_price_type.is_none() && peg_offset_value.is_some() {
anyhow::bail!("`peg_offset_value` requires `peg_price_type`");
}View on GitHub (pinned to 18893faf8b)
Solutions
- Set TrailingOffsetType::Price on the trailing stop order
- Configure the strategy/venue defaults to use PRICE offsets for BitMEX
- Translate percent/tick offsets into price offsets before submitting
Example fix
// before .trailing_offset_type(TrailingOffsetType::Percent) // after .trailing_offset_type(TrailingOffsetType::Price)
Defensive patterns
Strategy: validation
Validate before calling
if order.trailing_offset_type().is_some_and(|t| t != TrailingOffsetType::Price) {
return Err(anyhow::anyhow!("BitMEX trailing stops require TrailingOffsetType::Price"));
} Prevention
- Use TrailingOffsetType::Price for all BitMEX trailing orders
- Set venue defaults in strategy config
- Convert percent/tick offsets to price offsets upstream
When it happens
Trigger: Calling submit_order with a trailing-stop order whose trailing_offset_type is Some(t) where t != TrailingOffsetType::Price.
Common situations: Reusing a strategy configured for another venue that defaults to percent or tick trailing offsets; constructing orders from config that names a different TrailingOffsetType.
Related errors
- BitMEX only supports PRICE trailing offset type, was {offset
- `peg_offset_value` requires `peg_price_type`
- Pegged orders only supported for LIMIT order type, was {orde
- `peg_offset_value` requires `peg_price_type`
- Pegged orders only supported for LIMIT order type, was {orde
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/498c221db9dd4d71.
Report an issue: GitHub.