{"record":{"id":"6b3545ac451ccac1","repo":"QuantConnect/Lean","slug":"we-expected-some-fop-trading-to-happen","errorCode":null,"errorMessage":"We expected some FOP trading to happen","messagePattern":"We expected some FOP trading to happen","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/DelistingFutureOptionRegressionAlgorithm.cs","lineNumber":87,"sourceCode":"            {\n                return;\n            }\n\n            foreach (var chain in slice.OptionChains.Values)\n            {\n                foreach (var contractsValue in chain.Contracts.Values)\n                {\n                    MarketOrder(contractsValue.Symbol, 1);\n                    _traded = true;\n                }\n            }\n        }\n\n        public override void OnEndOfAlgorithm()\n        {\n            if (!_traded)\n            {\n                throw new RegressionTestException(\"We expected some FOP trading to happen\");\n            }\n            if (Portfolio.Invested)\n            {\n                throw new RegressionTestException(\"We shouldn't be invested anymore\");\n            }\n        }\n\n        /// <summary>\n        /// This is used by the regression test system to indicate if the open source Lean repository has the required data to run this algorithm.\n        /// </summary>\n        public bool CanRunLocally { get; } = true;\n\n        /// <summary>\n        /// This is used by the regression test system to indicate which languages this algorithm is written in.\n        /// </summary>\n        public List<Language> Languages { get; } = new() { Language.CSharp };\n\n        /// <summary>","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/DelistingFutureOptionRegressionAlgorithm.cs#L69-L105","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm ES (SP500EMini) future-option data exists for Jan–Mar 2020 in the data folder.","Widen the filter (e.g., Strikes(-5, 5)) temporarily to verify contracts appear at all.","Log slice.OptionChains count each bar to see whether chains are empty or whether OnData returns early due to Portfolio.Invested.","Verify AddFutureOption(future.Symbol, ...) is called after AddFuture and that UniverseSettings.Resolution is set."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// In OnData, log chain availability before trading\nforeach (var chain in slice.OptionChains.Values)\n{\n    if (chain.Contracts.Count == 0)\n    {\n        Debug($\"No contracts in chain for {chain.Symbol} at {Time}\");\n        continue;\n    }\n    foreach (var c in chain.Contracts.Values)\n    {\n        MarketOrder(c.Symbol, 1);\n        _traded = true;\n    }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm future-option data exists for the full backtest window before relying on chains.","Log empty chains to catch missing data or over-narrow filters.","Widen the strike filter during development to verify the chain populates at all."],"tags":["quantconnect","future-options","option-chain","filter","regression-test"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}