{"record":{"id":"b77bcc3a712d4402","repo":"nautechsystems/nautilus_trader","slug":"instrument-instrument-id-is-expired-and-no-longe-b77bcc","errorCode":null,"errorMessage":"Instrument {instrument_id} is expired and no longer available for market data requests","messagePattern":"Instrument (.+?) is expired and no longer available for market data requests","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/adapters/polymarket/src/data/mod.rs","lineNumber":371,"sourceCode":"                \"Instrument {instrument_id} is expired and no longer available for live subscription\"\n            );\n        }\n\n        Ok(())\n    }\n\n    fn ensure_market_data_request_allowed(\n        &self,\n        instrument_id: InstrumentId,\n    ) -> anyhow::Result<InstrumentAny> {\n        let loaded = self.instruments.load();\n        let instrument = loaded\n            .get(&instrument_id)\n            .ok_or_else(|| InstrumentLookupError::not_found(instrument_id))?\n            .clone();\n\n        if is_instrument_expired_and_not_reported_open(&instrument, self.clock.get_time_ns()) {\n            anyhow::bail!(\n                \"Instrument {instrument_id} is expired and no longer available for market data requests\"\n            );\n        }\n\n        Ok(instrument)\n    }\n\n    fn add_live_subscription_intent(\n        &self,\n        instrument_id: InstrumentId,\n        subscriptions: &Arc<AtomicSet<InstrumentId>>,\n    ) -> bool {\n        self.add_live_subscription_intent_with_state(instrument_id, subscriptions, || {})\n    }\n\n    fn add_delta_subscription_intent(&self, instrument_id: InstrumentId) -> bool {\n        self.add_live_subscription_intent_with_state(instrument_id, &self.active_delta_subs, || {\n            if self.config.compute_effective_deltas {","sourceCodeStart":353,"sourceCodeEnd":389,"githubUrl":"https://github.com/nautechsystems/nautilus_trader/blob/18893faf8b356be3320add8de2f861b0b647cf06/crates/adapters/polymarket/src/data/mod.rs#L353-L389","documentation":"The Polymarket data client rejects historical/request-style market data calls (request_book_snapshot, request_trades) when the target instrument is expired and not reported open. Unlike live subscriptions, this path first resolves the instrument and then validates it is still tradeable/open before issuing the request. It prevents wasted REST calls against closed markets.","triggerScenarios":"Calling request_book_snapshot or request_trades for an InstrumentId whose cached instrument passes is_instrument_expired_and_not_reported_open at clock.get_time_ns().","commonSituations":"Backfill jobs or warm-up code requesting snapshots for markets that expired since the config was written; scheduled data pulls that keep running past a market's end date.","solutions":["Verify the market is open on Polymarket before issuing historical data requests.","Filter the request list to instruments whose end date is in the future.","If historical data for an expired market is needed, use a source that supports closed-market history rather than the live adapter's request path.","Refresh cached instrument metadata if the expiry recorded locally is stale or wrong."],"exampleFix":"// before\nlet book = client.request_book_snapshot(instrument_id)?;\n\n// after\nif instrument.expiration_ts_ns() > clock.get_time_ns() {\n    let book = client.request_book_snapshot(instrument_id)?;\n} else {\n    log::warn!(\"market {instrument_id} expired; skipping snapshot request\");\n}","handlingStrategy":"validation","validationCode":"if instrument.expiration_ns() <= clock.get_time_ns().as_u64() {\n    return Ok(None); // skip request for expired market\n}","typeGuard":null,"tryCatchPattern":"match client.request_book_snapshot(instrument_id) {\n    Ok(book) => Some(book),\n    Err(e) if e.to_string().contains(\"expired\") => { log::warn!(\"expired market {instrument_id}\"); None }\n    Err(e) => return Err(e),\n}","preventionTips":["Filter scheduled data pulls by market end date.","Drop finished markets from backfill job lists."],"tags":["polymarket","market-data","expired-instrument","request"],"backgroundTag":"invalid-state-transition","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"}