{"record":{"id":"8d5ee9c768ec809f","repo":"QuantConnect/Lean","slug":"expected-subscriptions-for-the-added-index-option","errorCode":null,"errorMessage":"Expected subscriptions for the added index option contract","messagePattern":"Expected subscriptions for the added index option contract","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/DuplicatedIndexOptionSubscriptionRegressionAlgorithm.cs","lineNumber":57,"sourceCode":"\n            if (SubscriptionManager.Subscriptions.Single().Symbol != spx)\n            {\n                throw new RegressionTestException($\"Expected a single subscription to exist ({spx})\");\n            }\n\n            var spxOption = QuantConnect.Symbol.CreateOption(\n                spx,\n                Market.USA,\n                OptionStyle.European,\n                OptionRight.Call,\n                3200m,\n                new DateTime(2021, 1, 15));\n\n            AddIndexOptionContract(spxOption, Resolution.Minute);\n\n            if (SubscriptionManager.Subscriptions.Count() < 2)\n            {\n                throw new RegressionTestException(\"Expected subscriptions for the added index option contract\");\n            }\n\n            if (SubscriptionManager.Subscriptions.Count(x => x.Symbol == spx) != 1)\n            {\n                throw new RegressionTestException(\"Expected a single subscription for the underlying index security\");\n            }\n\n            // Quit early, we already tested what we wanted\n            Quit();\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 virtual 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.","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/DuplicatedIndexOptionSubscriptionRegressionAlgorithm.cs#L39-L75","documentation":"After AddIndexOptionContract(spxOption, Resolution.Minute), this asserts at least two subscriptions exist: the underlying index plus the option contract. A count < 2 means the option contract subscription was not created, so AddIndexOptionContract failed to register its data feed.","triggerScenarios":"AddIndexOptionContract did not add the option's subscription, or it deduplicated against the underlying and removed itself. Subscription registration path for index options broken.","commonSituations":"Refactor of AddOption/AddIndexOptionContract not registering the contract's subscription; the option symbol resolution colliding with the index; fillForward/resolution handling change.","solutions":["List SubscriptionManager.Subscriptions after AddIndexOptionContract to confirm whether the option subscription exists.","Trace AddIndexOptionContract into the SubscriptionManager to see where the option config is added.","Verify the option symbol is valid and resolves to a contract in available data."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var symbols = SubscriptionManager.Subscriptions.Select(s => s.Symbol).ToList();\nif (symbols.Count < 2 || !symbols.Contains(spxOption))\n{\n    Log($\"Index option contract subscription missing. Subs: {string.Join(\", \", symbols)}\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify AddIndexOptionContract returns/registers the contract subscription.","Confirm the option symbol resolves to available data.","Log all subscription symbols after adding the contract."],"tags":["quantconnect","lean","regression-test","subscriptions","index-options","invariant"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}