{"record":{"id":"9ab787a816c1088e","repo":"nautechsystems/nautilus_trader","slug":"index-prices-not-available-for-spot-instruments","errorCode":null,"errorMessage":"Index prices not available for Spot instruments","messagePattern":"Index prices not available for Spot instruments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/bybit/src/data.rs","lineNumber":1205,"sourceCode":"                async move {\n                    ws.subscribe_ticker(instrument_id)\n                        .await\n                        .context(\"ticker subscription for mark prices\")\n                },\n                \"mark price subscription\",\n            );\n        }\n        Ok(())\n    }\n\n    fn subscribe_index_prices(&mut self, cmd: SubscribeIndexPrices) -> anyhow::Result<()> {\n        let instrument_id = cmd.instrument_id;\n        let product_type = self\n            .get_product_type_for_instrument(instrument_id)\n            .unwrap_or(BybitProductType::Linear);\n\n        if product_type == BybitProductType::Spot {\n            anyhow::bail!(\"Index prices not available for Spot instruments\");\n        }\n\n        let mut should_subscribe = false;\n        self.ticker_subs.rcu(|m| {\n            let entry = m.entry(instrument_id).or_default();\n            should_subscribe = entry.is_empty();\n            entry.insert(\"index_prices\");\n        });\n\n        if should_subscribe {\n            let ws = self\n                .get_ws_client_for_product(product_type)\n                .context(\"no WebSocket client for product type\")?\n                .clone();\n\n            self.spawn_ws(\n                async move {\n                    ws.subscribe_ticker(instrument_id)","sourceCodeStart":1187,"sourceCodeEnd":1223,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/bybit/src/data.rs#L1187-L1223","documentation":"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.","triggerScenarios":"Calling subscribe_index_prices with an instrument_id that resolves to BybitProductType::Spot via get_product_type_for_instrument (or the symbol suffix).","commonSituations":"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.","solutions":["Subscribe to index prices only for Linear/Inverse/Option instruments","Use Spot ticker/quote data instead of index prices for Spot pairs","Check the instrument's product type before subscribing and branch accordingly"],"exampleFix":"// before\ndata_engine.subscribe_index_prices(InstrumentId::from(\"ETHUSDT.SBYBIT\")); // Spot -> error\n// after\nlet instrument = cache.instrument(&instrument_id).unwrap();\nif instrument.product_type() != ProductType::SPOT { // guard\ndata_engine.subscribe_index_prices(instrument_id);\n}","handlingStrategy":"validation","validationCode":"let instrument = cache.instrument(&instrument_id).expect(\"instrument not found\");\nif is_spot_product(&instrument) {\n    // use last_price/quote for spot instead of index price\n    return Ok(());\n}\ndata_engine.subscribe_index_prices(instrument_id)?;","typeGuard":null,"tryCatchPattern":"match data_engine.subscribe_index_prices(instrument_id) {\n    Err(e) if e.to_string().contains(\"Index prices not available for Spot\") => {\n        // fallback: subscribe to quotes for the spot pair\n    }\n    r => r?,\n}","preventionTips":["Index prices exist only for derivatives; check product type first","Use a helper that routes subscriptions by product type","Avoid blanket 'subscribe to all feeds' loops over mixed instrument sets"],"tags":["bybit","spot","index-prices","websocket","unsupported-instrument"],"backgroundTag":"unsupported-operation","analyzedSha":"18893faf8b356be3320add8de2f861b0b647cf06","analyzedAt":"2026-09-08T20:49:34.690Z","contentChangedAt":"2026-09-08T20:49:34.690Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}