{"record":{"id":"ced2ef9093e9e5eb","repo":"QuantConnect/Lean","slug":"unexpected-split-count-len-split","errorCode":null,"errorMessage":"Unexpected split count: {len(split)}","messagePattern":"Unexpected split count: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/HistoryAuxiliaryDataRegressionAlgorithm.py","lineNumber":55,"sourceCode":"        continuous_future_open_interest_mapping = self.history(SymbolChangedEvent, sp500, datetime(2007, 1, 1), datetime(2012, 1, 1), data_mapping_mode = DataMappingMode.OPEN_INTEREST)\n        if len(continuous_future_open_interest_mapping) != 9:\n                raise ValueError(f\"Unexpected continuous future mapping event count: {len(continuous_future_open_interest_mapping)}\")\n        continuous_future_last_trading_day_mapping = self.history(SymbolChangedEvent, sp500, datetime(2007, 1, 1), datetime(2012, 1, 1), data_mapping_mode = DataMappingMode.LAST_TRADING_DAY)\n        if len(continuous_future_last_trading_day_mapping) != 9:\n                raise ValueError(f\"Unexpected continuous future mapping event count: {len(continuous_future_last_trading_day_mapping)}\")\n\n        dividend = self.history(Dividend, aapl, 360)\n        self.debug(str(dividend))\n        if len(dividend) != 6:\n            raise ValueError(f\"Unexpected dividend count: {len(dividend)}\")\n        for distribution in dividend.distribution:\n            if distribution == 0:\n                raise ValueError(f\"Unexpected distribution: {distribution}\")\n\n        split = self.history(Split, aapl, 360)\n        self.debug(str(split))\n        if len(split) != 2:\n            raise ValueError(f\"Unexpected split count: {len(split)}\")\n        for splitfactor in split.splitfactor:\n            if splitfactor == 0:\n                raise ValueError(f\"Unexpected splitfactor: {splitfactor}\")\n\n        symbol = Symbol.create(\"BTCUSD\", SecurityType.CRYPTO_FUTURE, Market.BINANCE)\n        margin_interest = self.history(MarginInterestRate, symbol, 24 * 3, Resolution.HOUR)\n        self.debug(str(margin_interest))\n        if len(margin_interest) != 8:\n            raise ValueError(f\"Unexpected margin interest count: {len(margin_interest)}\")\n        for interestrate in margin_interest.interestrate:\n            if interestrate == 0:\n                raise ValueError(f\"Unexpected interestrate: {interestrate}\")\n\n        # last trading date on 2007-05-18\n        delisted_symbol = Symbol.create(\"AAA.1\", SecurityType.EQUITY, Market.USA)\n        delistings = self.history(Delisting, delisted_symbol, datetime(2007, 5, 15), datetime(2007, 5, 21))\n        self.debug(str(delistings))\n        if len(delistings) != 2:","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/HistoryAuxiliaryDataRegressionAlgorithm.py#L37-L73","documentation":"Asserts a Split history request for AAPL over 360 bars returns exactly 2 split rows. Divergence means AAPL split data or the split history request changed.","triggerScenarios":"len(self.history(Split, aapl, 360)) != 2.","commonSituations":"AAPL factor-files split rows changed (e.g. the 2020 4-for-1 split added/removed); split history request handling changed; regression date window shifted.","solutions":["Reconcile AAPL split rows in equity/usa/factorfiles across the 360-day window to 2.","Inspect the split auxiliary-data history path for filtering/sorting changes.","Confirm the regression start date is unchanged.","Rebaseline 2 if data was legitimately corrected."],"exampleFix":"# before\nif len(split) != 2:\n# after\nif len(split) != 2:  # verified AAPL splits in window","handlingStrategy":"validation","validationCode":"splits = self.history(Split, aapl, 360)\nif len(splits) != 2:\n    self.debug(f\"AAPL splits: {len(splits)}\\n{splits}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the regression start date so the lookback is stable.","Reconcile split counts against the factor file after any data refresh.","Log rows on mismatch."],"tags":["quantconnect","lean","regression","history","auxiliary-data","splits"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}