nautechsystems/nautilus_trader · error · anyhow::Error
BitMEX only supports L2_MBP order book deltas
Error message
BitMEX only supports L2_MBP order book deltas
What it means
subscribe_book_deltas capability check: BitMEX's WebSocket book feed only provides L2 market-by-price data, so a SubscribeBookDeltas command with any other BookType (e.g. L1_MBP or L3_MBO) is rejected at subscription time.
Source
Thrown at crates/adapters/bitmex/src/data.rs:784
log::warn!("Instrument {instrument_id} not found in BitMEX cache");
let ws = self.ws_client()?.clone();
self.spawn_ws(
async move {
ws.subscribe_instrument(instrument_id)
.await
.map_err(|e| anyhow::anyhow!(e))
},
"BitMEX instrument subscription",
);
Ok(())
}
fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> anyhow::Result<()> {
if cmd.book_type != BookType::L2_MBP {
anyhow::bail!("BitMEX only supports L2_MBP order book deltas");
}
let instrument_id = cmd.instrument_id;
let depth = cmd.depth.map_or(0, |d| d.get());
let channel = if depth > 0 && depth <= 25 {
if depth != 25 {
log::debug!(
"BitMEX only supports depth 25 for L2 deltas, using L2_25 for requested depth {depth}"
);
}
BitmexBookChannel::OrderBookL2_25
} else {
BitmexBookChannel::OrderBookL2
};
let ws = self.ws_client()?.clone();
let book_channels = Arc::clone(&self.book_channels);
View on GitHub (pinned to 18893faf8b)
Solutions
- Set book_type to L2_MBP in the subscription request / data client config for BitMEX
- Request a supported depth (<=25 selects the orderBookL2_25 channel, otherwise orderBook10)
- Route L3_MBO subscriptions to a venue that supports them instead of BitMEX
Example fix
// before
client.subscribe_book_deltas(SubscribeBookDeltas { book_type: BookType::L3_MBO, ... })
// after
client.subscribe_book_deltas(SubscribeBookDeltas { book_type: BookType::L2_MBP, ... }) Defensive patterns
Strategy: validation
Validate before calling
if book_type != BookType::L2_MBP {
return Err("BitMEX data subscriptions require BookType::L2_MBP");
} Type guard
fn is_l2_mbp(bt: BookType) -> bool { matches!(bt, BookType::L2_MBP) } Prevention
- Set book_type=L2_MBP in BitMEX data client configs
- Keep depth within supported channels (<=25 or orderBook10)
- Centralize per-venue data capability checks
When it happens
Trigger: Calling subscribe_book_deltas with cmd.book_type != BookType::L2_MBP, e.g. requesting L3_MBO order book data from the BitMEX data client.
Common situations: Configs that request L3 data because another venue adapter supports it, or depth/book-type defaults carried over from a different venue's data client configuration.
Related errors
- Binance Futures supports L1_MBP and L2_MBP order book subscr
- Deribit only supports L2_MBP order book deltas
- Deribit only supports L2_MBP order book depth
- Derive only supports L2_MBP order book deltas
- Derive only supports L2_MBP order book depth
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/5e075a57789aa03e.
Report an issue: GitHub.