nautechsystems/nautilus_trader · error

Instrument {instrument_id} not found and `auto_load_missing_

Error message

Instrument {instrument_id} not found and `auto_load_missing_instruments` is disabled

What it means

Before subscribing to any data stream, the adapter checks its local instrument cache. If the requested InstrumentId is not cached and config.auto_load_missing_instruments is false, it refuses to subscribe. The adapter will not silently fetch unknown instruments unless auto-loading was explicitly enabled.

Source

Thrown at crates/adapters/deribit/src/data.rs:457

    }

    /// Sends data to the data channel.
    fn send_data(sender: &tokio::sync::mpsc::UnboundedSender<DataEvent>, data: Data) {
        if let Err(e) = sender.send(DataEvent::Data(data)) {
            log::error!("Failed to send data: {e}");
        }
    }

    // Returns whether a subscribe should lazy-load the instrument before sending,
    // erroring up front when the instrument is missing and the flag is disabled
    // (so the WebSocket handler does not silently drop later frames).
    fn prepare_subscribe(&self, instrument_id: InstrumentId) -> anyhow::Result<bool> {
        if self.instruments.contains_key(&instrument_id) {
            return Ok(false);
        }

        if !self.config.auto_load_missing_instruments {
            anyhow::bail!(
                "Instrument {instrument_id} not found and `auto_load_missing_instruments` is disabled"
            );
        }
        Ok(true)
    }

    // Fetches an instrument over HTTP and seeds the local, HTTP, and WebSocket caches.
    async fn lazy_load_instrument(
        http_client: &DeribitHttpClient,
        ws: &DeribitWebSocketClient,
        instruments: &AtomicMap<InstrumentId, InstrumentAny>,
        instrument_id: InstrumentId,
    ) -> anyhow::Result<()> {
        let instrument = http_client
            .request_instrument(instrument_id)
            .await
            .with_context(|| format!("failed to lazy-load instrument {instrument_id}"))?;
        instruments.insert(instrument.id(), instrument.clone());

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Set auto_load_missing_instruments: true in DeribitDataClientConfig
  2. Load the instrument first (e.g. subscribe to/load instruments for the venue before subscribing to data)
  3. Verify the InstrumentId exactly matches a live Deribit instrument (case, expiry, underscore format)
  4. Check the instrument still exists on Deribit (not expired/delisted)

Example fix

// before
let config = DeribitDataClientConfig { /* auto_load_missing_instruments: false */ .. };
// after
let config = DeribitDataClientConfig {
    auto_load_missing_instruments: true,
    ..Default::default()
};
Defensive patterns

Strategy: validation

Validate before calling

if !config.auto_load_missing_instruments && !client.instruments.contains_key(&instrument_id) {
    return Err(anyhow::anyhow!("load instrument {instrument_id} first or enable auto_load_missing_instruments"));
}

Try / catch

match client.subscribe_quotes(cmd).await {
    Err(e) if e.to_string().contains("not found") => load_instrument_and_retry(),
    other => other,
}

Prevention

When it happens

Trigger: Calling subscribe_book_deltas / subscribe_book_depth10 / subscribe_quotes / subscribe_trades / subscribe_mark_prices / subscribe_index_prices with an InstrumentId that was never loaded via instrument loading (e.g. subscribe_instruments or config), while DeribitDataClientConfig.auto_load_missing_instruments is false (default).

Common situations: Using a symbol string with wrong case/format so the exact InstrumentId is not in the cache; subscribing before instruments were initialized; copying a config that disabled auto_load_missing_instruments; referencing a delisted or renamed Deribit instrument.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of nautechsystems/nautilus_trader@18893faf8b (2026-09-08). Data as JSON: /api/errors/78eebbafdcd1ffb7. Report an issue: GitHub.