QuantConnect/Lean · error · ValueError
Regression test failed: current open interest was not correc
Error message
Regression test failed: current open interest was not correctly loaded and is not equal to 70
What it means
Per-date open-interest value check for 2014-06-06: both contract.open_interest and security.open_interest must equal 70. Same contract as 174, different date. Divergence means the open-interest value for the second day is wrong.
Source
Thrown at Algorithm.Python/OptionOpenInterestRegressionAlgorithm.py:55
if not self.portfolio.invested:
for chain in slice.option_chains:
for contract in chain.value:
if float(contract.symbol.id.strike_price) == 72.5 and \
contract.symbol.id.option_right == OptionRight.CALL and \
contract.symbol.id.date == datetime(2016, 1, 15):
history = self.history(OpenInterest, contract.symbol, timedelta(1))["openinterest"]
if len(history.index) == 0 or 0 in history.values:
raise ValueError("Regression test failed: open interest history request is empty")
security = self.securities[contract.symbol]
open_interest_cache = security.cache.get_data(OpenInterest)
if open_interest_cache == None:
raise ValueError("Regression test failed: current open interest isn't in the security cache")
if slice.time.date() == datetime(2014, 6, 5).date() and (contract.open_interest != 50 or security.open_interest != 50):
raise ValueError("Regression test failed: current open interest was not correctly loaded and is not equal to 50")
if slice.time.date() == datetime(2014, 6, 6).date() and (contract.open_interest != 70 or security.open_interest != 70):
raise ValueError("Regression test failed: current open interest was not correctly loaded and is not equal to 70")
if slice.time.date() == datetime(2014, 6, 6).date():
self.market_order(contract.symbol, 1)
self.market_on_close_order(contract.symbol, -1)
if all(contract.open_interest == 0 for contract in chain.value):
raise ValueError("Regression test failed: open interest is zero for all contracts")
def on_order_event(self, order_event):
self.log(str(order_event))
View on GitHub (pinned to d2c3659f87)
Solutions
- Inspect the option open-interest data file for 2014-06-06; it must resolve to 70.
- Check fill-forward does not replay the prior day's open interest when a new value exists.
- Ensure the cache updates per time step so security.open_interest reflects 70 on 2014-06-06.
Example fix
// before: open interest fill-forwarded from prior day (50)
// after: cache refreshed with the new 70 value for 2014-06-06
security.Cache.AddData(new OpenInterest { EndTime = slice.Time, Value = 70 }); Defensive patterns
Strategy: validation
Validate before calling
expected = 70 if slice.time.date() == datetime(2014,6,6).date() else None
if expected is not None and (contract.open_interest != expected or security.open_interest != expected):
self.debug(f"OI mismatch on {slice.time.date()}: contract={contract.open_interest} security={security.open_interest} expected={expected}") Prevention
- Ensure fill-forward does not replay prior-day open interest when a new value exists.
- Refresh the security cache per time step.
- Log both chain and cache values to localize divergence.
When it happens
Trigger: slice.time.date() == 2014-06-06 and (contract.open_interest != 70 or security.open_interest != 70).
Common situations: The option open-interest data file for 2014-06-06 changed; fill-forward carried over the 2014-06-05 value (50) instead of updating to 70; cache not refreshed between days.
Related errors
- Regression test failed: current open interest isn't in the s
- Regression test failed: current open interest was not correc
- Regression test failed: open interest is zero for all contra
- Expected greeks to be accessed
- Expected greeks not to be calculated for {contract.symbol.va
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/6d2e5110395ae718.
Report an issue: GitHub.