{"record":{"id":"d8edb4932ad77122","repo":"QuantConnect/Lean","slug":"option-was-not-delisted","errorCode":null,"errorMessage":"Option was not delisted","messagePattern":"Option was not delisted","errorType":"exception","errorClass":"RegressionTestException","httpStatus":null,"severity":"error","filePath":"Algorithm.CSharp/DuplicateOptionAssignmentRegressionAlgorithm.cs","lineNumber":177,"sourceCode":"\n            if (!_optionAssigned)\n            {\n                throw new RegressionTestException(\"Option was not assigned\");\n            }\n\n            if (!_stockAssigned)\n            {\n                throw new RegressionTestException(\"Stock was not assigned\");\n            }\n\n            if (!_optionDelistedWarningReceived)\n            {\n                throw new RegressionTestException(\"Option delisting warning was not received\");\n            }\n\n            if (!_optionDelisted)\n            {\n                throw new RegressionTestException(\"Option was not delisted\");\n            }\n\n            if (!_orderCanceled)\n            {\n                throw new RegressionTestException(\"Order was not canceled\");\n            }\n\n            var openOrders = Transactions.GetOpenOrders();\n            if (openOrders.Count != 0)\n            {\n                throw new RegressionTestException(\"There should be no open orders\");\n            }\n\n            if (!Portfolio.Invested)\n            {\n                throw new RegressionTestException(\"Portfolio should be invested\");\n            }\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.CSharp/DuplicateOptionAssignmentRegressionAlgorithm.cs#L159-L195","documentation":"Asserts _optionDelisted: the option received the final DelistingType.Delisted event. Failure means the option was never fully delisted by algorithm end. This pairs with the warning check (106) to confirm the full two-phase delisting completed.","triggerScenarios":"The final delisting event never fired (only warning fired), or error 102 aborted first. Algorithm ended between the warning date and the final delisting date.","commonSituations":"Date range too short to reach the delisting date; delisting provider changed to stop emitting the final Delisted event; the option was removed from the portfolio by another path.","solutions":["Extend the end date past the option's final delisting date.","Confirm the DelistingType.Delisted path in the delisting provider emits for the option.","Check that error 102 did not fire earlier and prevent the flag from being set."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check the final-delisting phase is reached\nif (!_optionDelistedWarningReceived) Log(\"Warning never received; final delisting cannot complete\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure the date range reaches the final delisting date, not just the warning date.","Confirm the delisting provider emits both Warning and Delisted phases.","Triage earlier delisting-guard failures (102) before this postcondition."],"tags":["quantconnect","lean","regression-test","options","delisting","postcondition"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}