nautechsystems/nautilus_trader · error · anyhow::Error
dYdX only supports L2_MBP order book deltas, received {:?}
Error message
dYdX only supports L2_MBP order book deltas, received {:?} What it means
dYdX's WebSocket order book stream provides only depth-2 market-by-price (L2_MBP) data. subscribe_book_deltas validates the requested BookType and bails if the client asks for L3_MBP, ensuring the adapter never subscribes to a book depth the exchange cannot deliver.
Source
Thrown at crates/adapters/dydx/src/data.rs:518
fn subscribe_instrument(&mut self, cmd: SubscribeInstrument) -> anyhow::Result<()> {
if let Some(instrument) = self.instrument_cache.get(&cmd.instrument_id) {
log::debug!("Sending cached instrument for {}", cmd.instrument_id);
if let Err(e) = self.data_sender.send(DataEvent::Instrument(instrument)) {
log::warn!("Failed to send instrument {}: {e}", cmd.instrument_id);
}
} else {
log::warn!(
"Instrument {} not found in cache (available: {})",
cmd.instrument_id,
self.instrument_cache.len()
);
}
Ok(())
}
fn subscribe_book_deltas(&mut self, cmd: SubscribeBookDeltas) -> anyhow::Result<()> {
if cmd.book_type != BookType::L2_MBP {
anyhow::bail!(
"dYdX only supports L2_MBP order book deltas, received {:?}",
cmd.book_type
);
}
self.ensure_order_book(cmd.instrument_id, BookType::L2_MBP);
self.active_delta_subs.insert(cmd.instrument_id);
let ws = self.ws_client.clone();
let instrument_id = cmd.instrument_id;
self.spawn_ws(
async move {
ws.subscribe_orderbook(instrument_id)
.await
.context("orderbook subscription")
},
"dYdX orderbook subscription",View on GitHub (pinned to 18893faf8b)
Solutions
- Set the book type to L2_MBP for dYdX order book subscriptions
- Remove L3 book subscriptions for dYdX instruments
- Use a different data source if L3 depth is required
Example fix
// before
let cmd = SubscribeBookDeltas { book_type: BookType::L3_MBP, .. };
// after
let cmd = SubscribeBookDeltas { book_type: BookType::L2_MBP, .. }; Defensive patterns
Strategy: validation
Validate before calling
if book_type != BookType::L2_MBP {
return Err(format!("dYdX requires L2_MBP, got {book_type:?}"));
} Prevention
- Always use BookType::L2_MBP for dYdX order book subscriptions
- Validate book depth settings per venue in config loading
When it happens
Trigger: Subscribing to order book deltas for a dYdX instrument with a SubscriptionBookType/book_type other than BookType::L2_MBP (e.g. L3_MBP).
Common situations: Copying an order book subscription config from a venue that supports L3 depth; a config file specifying full-depth books for all venues.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- {e}
- Binance Spot supports L1_MBP and L2_MBP order book subscript
- Bybit only supports L2_MBP order book deltas
- Coinbase only supports L2_MBP order book deltas
- Unsupported bar aggregation: {:?}
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/7369a724fcd55ccd.
Report an issue: GitHub.