nautechsystems/nautilus_trader · error · anyhow::Error
No instrument cached for market '{}'. Available: {:?}
Error message
No instrument cached for market '{}'. Available: {:?} What it means
parse_ws_fill_report resolves the instrument for a dYdX fill by looking up ws_fill.market in the instrument cache. If the market is not cached, the fill cannot be converted to a FillReport and this error is thrown, including the list of currently cached market symbols for diagnosis.
Source
Thrown at crates/adapters/dydx/src/websocket/parse.rs:295
/// - HTTP parser fails.
pub fn parse_ws_fill_report(
ws_fill: &DydxWsFillSubaccountMessageContents,
instrument_cache: &InstrumentCache,
order_id_map: &DashMap<String, (u32, u32)>,
order_contexts: &DashMap<u32, OrderContext>,
encoder: &ClientOrderIdEncoder,
account_id: AccountId,
ts_init: UnixNanos,
) -> anyhow::Result<FillReport> {
let instrument = instrument_cache
.get_by_market(&ws_fill.market)
.ok_or_else(|| {
let available: Vec<String> = instrument_cache
.all_instruments()
.into_iter()
.map(|inst| inst.id().symbol.to_string())
.collect();
anyhow::anyhow!(
"No instrument cached for market '{}'. Available: {:?}",
ws_fill.market,
available
)
})?;
let http_fill = convert_ws_fill_to_http(ws_fill)?;
let mut report = parse_fill_report(&http_fill, &instrument, account_id, ts_init)?;
// Correlate fill to order via order_id → (client_id, client_metadata) → client_order_id
if let Some(ref order_id) = ws_fill.order_id {
if let Some(entry) = order_id_map.get(order_id) {
let (client_id, client_metadata) = *entry.value();
if let Some(ctx) = order_contexts.get(&client_id) {
report.client_order_id = Some(ctx.client_order_id);
} else if let Some(client_order_id) =
encoder.decode_if_known(client_id, client_metadata)
{View on GitHub (pinned to 18893faf8b)
Solutions
- Load/refresh all instruments into the cache before starting the WS stream handler
- Read the 'Available: [...]' list in the message to see which markets are cached and add the missing one
- Restrict WS subscriptions to cached markets or dynamically load instruments for new markets on demand
- Restart with refreshed instruments if the cache is stale
Example fix
// before spawn_ws_stream_handler(stream) // only partial instruments loaded // after refresh_instruments(&mut instrument_cache).await?; spawn_ws_stream_handler(stream);
Defensive patterns
Strategy: validation
Validate before calling
if instrument_cache.get_by_market(&ws_fill.market).is_none() {
eprintln!("market {} not cached; load instruments before streaming fills", ws_fill.market);
return;
} Type guard
fn is_market_cached(cache: &InstrumentCache, market: &str) -> bool {
cache.all_instruments().iter().any(|i| i.id().symbol.to_string() == market)
} Try / catch
match parse_ws_fill_report(...) {
Err(e) if e.to_string().contains("No instrument cached for market") => {
warn!("fill on uncached market ignored");
}
Err(e) => return Err(e),
Ok(r) => publish(r),
} Prevention
- Load all instruments into the cache before starting WS streams
- Check the 'Available' list in the error to align subscriptions with cached markets
- Refresh the cache on new market listings
When it happens
Trigger: Receiving a WebSocket fill (trade) event for a market whose instrument is not in the cache — fills on markets not subscribed/loaded, or cache not populated before the WS stream started.
Common situations: Trading a newly listed market while the cached instrument set is stale; WS stream started before instrument loading completed; fills arriving for markets outside the configured instrument universe.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
- No instrument cached for clob_pair_id {clob_pair_id}
- Missing required field: client_metadata
- Missing required field: order_id
- slots lock poisoned
- subscription state lock poisoned
AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08).
Data as JSON: /api/errors/1718ff3f371fd2cd.
Report an issue: GitHub.