nautechsystems/nautilus_trader · error

Index prices not available for Spot instruments

Error message

Index prices not available for Spot instruments

What it means

This error is raised when subscribing to index prices for a Spot instrument on Bybit. Index prices are only defined for derivatives (they track an underlying index), so Bybit does not offer an index-price stream for Spot and the adapter bails out before sending the WebSocket subscription.

Source

Thrown at crates/adapters/bybit/src/data.rs:1205

                async move {
                    ws.subscribe_ticker(instrument_id)
                        .await
                        .context("ticker subscription for mark prices")
                },
                "mark price subscription",
            );
        }
        Ok(())
    }

    fn subscribe_index_prices(&mut self, cmd: SubscribeIndexPrices) -> anyhow::Result<()> {
        let instrument_id = cmd.instrument_id;
        let product_type = self
            .get_product_type_for_instrument(instrument_id)
            .unwrap_or(BybitProductType::Linear);

        if product_type == BybitProductType::Spot {
            anyhow::bail!("Index prices not available for Spot instruments");
        }

        let mut should_subscribe = false;
        self.ticker_subs.rcu(|m| {
            let entry = m.entry(instrument_id).or_default();
            should_subscribe = entry.is_empty();
            entry.insert("index_prices");
        });

        if should_subscribe {
            let ws = self
                .get_ws_client_for_product(product_type)
                .context("no WebSocket client for product type")?
                .clone();

            self.spawn_ws(
                async move {
                    ws.subscribe_ticker(instrument_id)

View on GitHub (pinned to 18893faf8b)

Solutions

  1. Subscribe to index prices only for Linear/Inverse/Option instruments
  2. Use Spot ticker/quote data instead of index prices for Spot pairs
  3. Check the instrument's product type before subscribing and branch accordingly

Example fix

// before
data_engine.subscribe_index_prices(InstrumentId::from("ETHUSDT.SBYBIT")); // Spot -> error
// after
let instrument = cache.instrument(&instrument_id).unwrap();
if instrument.product_type() != ProductType::SPOT { // guard
data_engine.subscribe_index_prices(instrument_id);
}
Defensive patterns

Strategy: validation

Validate before calling

let instrument = cache.instrument(&instrument_id).expect("instrument not found");
if is_spot_product(&instrument) {
    // use last_price/quote for spot instead of index price
    return Ok(());
}
data_engine.subscribe_index_prices(instrument_id)?;

Try / catch

match data_engine.subscribe_index_prices(instrument_id) {
    Err(e) if e.to_string().contains("Index prices not available for Spot") => {
        // fallback: subscribe to quotes for the spot pair
    }
    r => r?,
}

Prevention

When it happens

Trigger: Calling subscribe_index_prices with an instrument_id that resolves to BybitProductType::Spot via get_product_type_for_instrument (or the symbol suffix).

Common situations: Subscribing to index prices for a Spot pair by mistake; generic pricing pipelines that subscribe to every price feed for every instrument regardless of asset class.

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


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