QuantConnect/Lean · error · RegressionTestException

Expected at least one option contract for

Error message

Expected at least one option contract for {}

What it means

FutureOptionWithFutureFilterRegressionAlgorithm.validate_option_chains inspects each future contract that has an option chain in the slice and asserts the chain is non-empty. An empty option chain (len(chain) == 0) for a contract that should have options raises RegressionTestException — it signals the option data is missing or the filter excluded everything.

Solutions

  1. Verify the test data set includes option chains for every future contract the filter selects.
  2. Tighten set_filter so it only returns futures that actually have listed options.
  3. If running locally, confirm the future-option data files are present and correctly keyed.
Defensive patterns

Strategy: validation

Validate before calling

def validate_option_chains(self, slice):
    for future_contract in (fc for fc_chain in slice.future_chains.values() for fc in fc_chain):
        chain = slice.option_chains.get(future_contract.symbol)
        if chain is None:
            continue  # contract has no option chain — allowed
        if len(chain) == 0:
            self.Debug(f'Skipping empty option chain for {chain.symbol}')  # tolerate instead of raising

Type guard

def chain_has_contracts(chain) -> bool:
    return chain is not None and len(chain) > 0

Prevention

When it happens

Trigger: A future_contract.symbol exists in slice.option_chains, but the corresponding OptionChain has zero contracts, so len(chain) == 0 trips the check.

Common situations: Option data for that future is missing from the data set, the future filter (set_filter 0–368 days) selected a contract with no listed options, or a data-provider/regional change dropped option chain entries.

Related errors


AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13). Data as JSON: /api/errors/8f18c339fff9a8c4. Report an issue: GitHub.

Appendix: source

Thrown at Algorithm.Python/FutureOptionWithFutureFilterRegressionAlgorithm.py:35

### <summary>
### Regression algorithm that validates that when using a Future with filter
### the option chains are correctly populated and are unique
### </summary>
class FutureOptionWithFutureFilterRegressionAlgorithm(FutureOptionContinuousFutureRegressionAlgorithm):
    def set_filter(self):
        """Set future filter for specific contracts"""
        self.future.set_filter(0, 368)
    
    def validate_option_chains(self, slice: Slice):
        future_contracts_with_option_chains = 0
        for future_chain in slice.future_chains.values():
            for future_contract in future_chain:
                # Not all future contracts have option chains, so we need to check if the contract is in the option chain
                if future_contract.symbol in slice.option_chains:
                    chain = slice.option_chains[future_contract.symbol]
                    if len(chain) == 0:
                        raise RegressionTestException("Expected at least one option contract for {}".format(chain.symbol))
                    future_contracts_with_option_chains += 1
        
        if future_contracts_with_option_chains < 1:
            raise RegressionTestException("Expected at least two future contracts with option chains, but found {}".format(future_contracts_with_option_chains))

View on GitHub (pinned to d2c3659f87)