nautechsystems/nautilus_trader · error

No Lighter market_index registered for {instrument_id}

Error message

No Lighter market_index registered for {instrument_id}

What it means

perp_market_stats_channel looks up the instrument's Lighter market_index in the adapter's registry after confirming it is a perpetual. If the registry has no market index registered for that InstrumentId, the channel cannot be built and this error is raised.

Source

Thrown at crates/adapters/lighter/src/data/mod.rs:795

    }

    fn perp_market_stats_channel(
        &self,
        instrument_id: InstrumentId,
        label: &str,
    ) -> anyhow::Result<LighterWsChannel> {
        let instrument = self
            .instruments
            .get_cloned(&instrument_id)
            .ok_or_else(|| InstrumentLookupError::not_found(instrument_id))?;

        anyhow::ensure!(
            matches!(instrument, InstrumentAny::CryptoPerpetual(_)),
            "Lighter {label} subscriptions require a perpetual instrument: {instrument_id}",
        );

        let market_index = self.registry.market_index(&instrument_id).ok_or_else(|| {
            anyhow::anyhow!("No Lighter market_index registered for {instrument_id}")
        })?;

        Ok(LighterWsChannel::MarketStats(
            LighterMarketSelection::Market(market_index),
        ))
    }

    fn index_market_stats_channel(
        &self,
        instrument_id: InstrumentId,
    ) -> anyhow::Result<LighterWsChannel> {
        let instrument = self
            .instruments
            .get_cloned(&instrument_id)
            .ok_or_else(|| InstrumentLookupError::not_found(instrument_id))?;
        let market_index = self.registry.market_index(&instrument_id).ok_or_else(|| {
            anyhow::anyhow!("No Lighter market_index registered for {instrument_id}")
        })?;

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Ensure the Lighter adapter's instrument loading/registration ran so every tradable perp has a market_index in the registry.
  2. Verify the InstrumentId's venue and symbol actually belong to the Lighter adapter.
  3. Reconnect/re-initialize the data client to rebuild the registry if it appears incomplete.

Example fix

// before
// subscribing before adapter instruments were registered
await data_engine.subscribe_funding_rates(instrument_id)
// after
await lighter_data_client.connect(); // loads and registers instruments + market indices
await data_engine.subscribe_funding_rates(instrument_id)
Defensive patterns

Strategy: validation

Validate before calling

let idx = registry.market_index(&instrument_id);
if idx.is_none() {
    return Err(anyhow::anyhow!("{instrument_id} not registered with Lighter"));
}

Type guard

fn registered(registry: &MarketRegistry, id: &InstrumentId) -> bool { registry.market_index(id).is_some() }

Try / catch

match subscribe_mark_prices(instrument_id) {
    Err(e) if e.to_string().contains("market_index registered") => {
        warn!("re-initializing Lighter client to register instruments");
        client.reconnect().await?;
        client.subscribe_mark_prices(instrument_id).await
    }
    other => other,
}

Prevention

When it happens

Trigger: Calling subscribe_mark_prices or subscribe_funding_rates for an instrument that exists in the instrument cache but was never registered with a Lighter market_index — e.g. the instrument was loaded outside the Lighter adapter's initialization or the registry was not populated for that market.

Common situations: Subscribing to an instrument from another venue or an instrument injected manually into the cache; adapter initialization that skipped instrument registration for some markets; a typo'd instrument ID that happens to match a cached instrument without registry entry.

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


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