QuantConnect/Lean · error · RegressionTestException

We expected some FOP trading to happen

Error message

We expected some FOP trading to happen

What it means

The _traded flag is set true only when a future-option contract is found in slice.OptionChains and a MarketOrder is placed. OnEndOfAlgorithm asserts _traded is true — if no FOP contract ever appeared in the option chain during the whole backtest window (2020-01-03 to 2020-03-23), the regression fails.

Source

Thrown at Algorithm.CSharp/DelistingFutureOptionRegressionAlgorithm.cs:87

            {
                return;
            }

            foreach (var chain in slice.OptionChains.Values)
            {
                foreach (var contractsValue in chain.Contracts.Values)
                {
                    MarketOrder(contractsValue.Symbol, 1);
                    _traded = true;
                }
            }
        }

        public override void OnEndOfAlgorithm()
        {
            if (!_traded)
            {
                throw new RegressionTestException("We expected some FOP trading to happen");
            }
            if (Portfolio.Invested)
            {
                throw new RegressionTestException("We shouldn't be invested anymore");
            }
        }

        /// <summary>
        /// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.
        /// </summary>
        public bool CanRunLocally { get; } = true;

        /// <summary>
        /// This is used by the regression test system to indicate which languages this algorithm is written in.
        /// </summary>
        public List<Language> Languages { get; } = new() { Language.CSharp };

        /// <summary>

View on GitHub (pinned to d2c3659f87)

Solutions

  1. Confirm ES (SP500EMini) future-option data exists for Jan–Mar 2020 in the data folder.
  2. Widen the filter (e.g., Strikes(-5, 5)) temporarily to verify contracts appear at all.
  3. Log slice.OptionChains count each bar to see whether chains are empty or whether OnData returns early due to Portfolio.Invested.
  4. Verify AddFutureOption(future.Symbol, ...) is called after AddFuture and that UniverseSettings.Resolution is set.
Defensive patterns

Strategy: validation

Validate before calling

// In OnData, log chain availability before trading
foreach (var chain in slice.OptionChains.Values)
{
    if (chain.Contracts.Count == 0)
    {
        Debug($"No contracts in chain for {chain.Symbol} at {Time}");
        continue;
    }
    foreach (var c in chain.Contracts.Values)
    {
        MarketOrder(c.Symbol, 1);
        _traded = true;
    }
}

Prevention

When it happens

Trigger: The future-option chain filter (Strikes(-2, 2)) returns zero contracts for every day, or AddFutureOption was not wired correctly, or the underlying future data is missing so no option chain is generated.

Common situations: Missing ES future-option data in the local data store, a filter that is too narrow for the available strikes, or a Lean version change in future-option chain population. Also happens if Portfolio.Invested short-circuits OnData before any chain is ever inspected.

Related errors


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