{"record":{"id":"0a1147a9c172e449","repo":"QuantConnect/Lean","slug":"regression-test-failed-open-interest-is-zero-for","errorCode":null,"errorMessage":"Regression test failed: open interest is zero for all contracts","messagePattern":"Regression test failed: open interest is zero for all contracts","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/OptionOpenInterestRegressionAlgorithm.py","lineNumber":61,"sourceCode":"\n                        history = self.history(OpenInterest, contract.symbol, timedelta(1))[\"openinterest\"]\n                        if len(history.index) == 0 or 0 in history.values:\n                            raise ValueError(\"Regression test failed: open interest history request is empty\")\n\n                        security = self.securities[contract.symbol]\n                        open_interest_cache = security.cache.get_data(OpenInterest)\n                        if open_interest_cache == None:\n                            raise ValueError(\"Regression test failed: current open interest isn't in the security cache\")\n                        if slice.time.date() == datetime(2014, 6, 5).date() and (contract.open_interest != 50 or security.open_interest != 50):\n                            raise ValueError(\"Regression test failed: current open interest was not correctly loaded and is not equal to 50\")\n                        if slice.time.date() == datetime(2014, 6, 6).date() and (contract.open_interest != 70 or security.open_interest != 70):\n                            raise ValueError(\"Regression test failed: current open interest was not correctly loaded and is not equal to 70\")\n                        if slice.time.date() == datetime(2014, 6, 6).date():\n                            self.market_order(contract.symbol, 1)\n                            self.market_on_close_order(contract.symbol, -1)\n\n                if all(contract.open_interest == 0 for contract in chain.value):\n                    raise ValueError(\"Regression test failed: open interest is zero for all contracts\")\n\n    def on_order_event(self, order_event):\n        self.log(str(order_event))\n","sourceCodeStart":43,"sourceCodeEnd":65,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/OptionOpenInterestRegressionAlgorithm.py#L43-L65","documentation":"Guarantee check: it must never be the case that every contract in the option chain has zero open interest. If all(chain contract.open_interest == 0), open-interest data is entirely missing/zero for the whole chain, indicating a broad data or subscription failure (worse than a single-contract value error).","triggerScenarios":"all(contract.open_interest == 0 for contract in chain.value) is True for a given slice's option chain.","commonSituations":"Open-interest data files missing for the whole chain date; the open-interest subscription type disabled/not registered for the option; data feed regression dropping all OI points.","solutions":["Confirm open-interest data files exist for the option underlying/expiry on the regression dates.","Verify the option subscription includes the OpenInterest data type (not just quote/trade).","Trace the data feed for the option symbol to ensure OI points reach the chain contracts."],"exampleFix":"// before: option subscription without open interest type\nAddOptionContract(symbol, Resolution.MINUTE);  // OI not subscribed\n// after: include open interest\nAddOptionContract(symbol, new[] { typeof(OpenInterest) }, Resolution.MINUTE);","handlingStrategy":"validation","validationCode":"# detect a fully-zero chain early instead of relying on per-contract checks\nif chain.value and all(c.open_interest == 0 for c in chain.value):\n    self.debug(f\"all contracts zero OI for {kvp.key} at {slice.time}; check OI data files and subscription type\")","typeGuard":"def chain_has_open_interest(chain) -> bool:\n    return any(c.open_interest != 0 for c in chain.value)","tryCatchPattern":null,"preventionTips":["Register the OpenInterest data type for option subscriptions.","Confirm OI data files exist for the chain dates.","Fail fast with a clear message when the whole chain is zero."],"tags":["quantconnect","lean","regression","options","open-interest","option-chain","data-feed"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}