{"record":{"id":"1718ff3f371fd2cd","repo":"nautechsystems/nautilus_trader","slug":"no-instrument-cached-for-market-available","errorCode":null,"errorMessage":"No instrument cached for market '{}'. Available: {:?}","messagePattern":"No instrument cached for market '(.+?)'\\. Available: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/adapters/dydx/src/websocket/parse.rs","lineNumber":295,"sourceCode":"/// - HTTP parser fails.\npub fn parse_ws_fill_report(\n    ws_fill: &DydxWsFillSubaccountMessageContents,\n    instrument_cache: &InstrumentCache,\n    order_id_map: &DashMap<String, (u32, u32)>,\n    order_contexts: &DashMap<u32, OrderContext>,\n    encoder: &ClientOrderIdEncoder,\n    account_id: AccountId,\n    ts_init: UnixNanos,\n) -> anyhow::Result<FillReport> {\n    let instrument = instrument_cache\n        .get_by_market(&ws_fill.market)\n        .ok_or_else(|| {\n            let available: Vec<String> = instrument_cache\n                .all_instruments()\n                .into_iter()\n                .map(|inst| inst.id().symbol.to_string())\n                .collect();\n            anyhow::anyhow!(\n                \"No instrument cached for market '{}'. Available: {:?}\",\n                ws_fill.market,\n                available\n            )\n        })?;\n\n    let http_fill = convert_ws_fill_to_http(ws_fill)?;\n    let mut report = parse_fill_report(&http_fill, &instrument, account_id, ts_init)?;\n\n    // Correlate fill to order via order_id → (client_id, client_metadata) → client_order_id\n    if let Some(ref order_id) = ws_fill.order_id {\n        if let Some(entry) = order_id_map.get(order_id) {\n            let (client_id, client_metadata) = *entry.value();\n            if let Some(ctx) = order_contexts.get(&client_id) {\n                report.client_order_id = Some(ctx.client_order_id);\n            } else if let Some(client_order_id) =\n                encoder.decode_if_known(client_id, client_metadata)\n            {","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/dydx/src/websocket/parse.rs#L277-L313","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nspawn_ws_stream_handler(stream) // only partial instruments loaded\n// after\nrefresh_instruments(&mut instrument_cache).await?;\nspawn_ws_stream_handler(stream);","handlingStrategy":"validation","validationCode":"if instrument_cache.get_by_market(&ws_fill.market).is_none() {\n    eprintln!(\"market {} not cached; load instruments before streaming fills\", ws_fill.market);\n    return;\n}","typeGuard":"fn is_market_cached(cache: &InstrumentCache, market: &str) -> bool {\n    cache.all_instruments().iter().any(|i| i.id().symbol.to_string() == market)\n}","tryCatchPattern":"match parse_ws_fill_report(...) {\n    Err(e) if e.to_string().contains(\"No instrument cached for market\") => {\n        warn!(\"fill on uncached market ignored\");\n    }\n    Err(e) => return Err(e),\n    Ok(r) => publish(r),\n}","preventionTips":["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"],"tags":["rust","dydx","websocket","cache"],"backgroundTag":"record-not-found","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}