{"record":{"id":"ca91bfc7844a2f92","repo":"nautechsystems/nautilus_trader","slug":"no-index-price-returned-from-okx","errorCode":null,"errorMessage":"No index price returned from OKX","messagePattern":"No index price returned from OKX","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/okx/src/http/client.rs","lineNumber":2875,"sourceCode":"    ) -> anyhow::Result<IndexPriceUpdate> {\n        // Index tickers endpoint requires base pair format (e.g., BTC-USDT)\n        let symbol = instrument_id.symbol.inner();\n        let (base, quote) = parse_base_quote_from_symbol(symbol.as_str())?;\n        let inst_id = format!(\"{base}-{quote}\");\n\n        let mut params = GetIndexTickerParamsBuilder::default();\n        params.inst_id(Ustr::from(&inst_id));\n        let params = params.build().map_err(|e| anyhow::anyhow!(e))?;\n\n        let resp = self\n            .inner\n            .get_index_tickers(params)\n            .await\n            .map_err(|e| anyhow::anyhow!(e))?;\n\n        let raw = resp\n            .first()\n            .ok_or_else(|| anyhow::anyhow!(\"No index price returned from OKX\"))?;\n        let inst = self.instrument_from_cache(instrument_id.symbol.inner())?;\n        let ts_init = self.generate_ts_init();\n\n        let index_price =\n            parse_index_price_update(raw, instrument_id, inst.price_precision(), ts_init)\n                .map_err(|e| anyhow::anyhow!(e))?;\n        Ok(index_price)\n    }\n\n    /// Requests an order book snapshot for the `instrument_id`.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the HTTP request fails or book parsing fails.\n    pub async fn request_book_snapshot(\n        &self,\n        instrument_id: InstrumentId,\n        depth: Option<u32>,","sourceCodeStart":2857,"sourceCodeEnd":2893,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/okx/src/http/client.rs#L2857-L2893","documentation":"request_index_price expects OKX's get_index_tickers to return at least one entry; an empty response array means the exchange returned no index price for the requested instId, so this ok_or_else error is raised instead of panicking on first().","triggerScenarios":"Requesting an index price for an instId that OKX does not recognize or that currently has no ticker data (e.g. a delisted index or a wrongly derived base-quote pair).","commonSituations":"Subscribing to an index price for a symbol whose base/quote were misparsed, using a recently delisted instrument, or OKX returning an empty data array for a temporarily suspended index.","solutions":["Verify the instrument id maps to a valid OKX index ticker (call /api/v5/market/index-tickers manually).","Check that parse_base_quote_from_symbol produced the correct inst_id for your symbol.","Confirm the instrument is not delisted/suspended on OKX.","Handle the empty case upstream by skipping the update instead of treating it as fatal."],"exampleFix":"// before\nlet raw = resp.first().ok_or_else(|| anyhow::anyhow!(\"No index price returned from OKX\"))?;\n// after\nlet Some(raw) = resp.first() else {\n    tracing::warn!(\"OKX returned no index ticker for {inst_id}; skipping update\");\n    return Ok(None);\n};","handlingStrategy":"fallback","validationCode":"let exists = okx_index_instruments.contains(inst_id.as_str());\nif !exists { return Ok(None); }","typeGuard":null,"tryCatchPattern":"let Some(raw) = resp.first() else {\n    tracing::warn!(\"no index ticker for {inst_id}\");\n    return Ok(None); // or retry\n};","preventionTips":["Validate the inst_id against OKX's index-tickers instrument list before requesting.","Skip updates for delisted/suspended instruments instead of erroring.","Alert on repeated empty index responses for a specific symbol — usually a mis-derived base-quote pair."],"tags":["okx","empty-response","index-price","exchange-api"],"backgroundTag":"empty-result-set","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"}