{"record":{"id":"6b661ee39c3fd151","repo":"QuantConnect/Lean","slug":"unexpected-splitfactor-splitfactor","errorCode":null,"errorMessage":"Unexpected splitfactor: {splitfactor}","messagePattern":"Unexpected splitfactor: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/HistoryAuxiliaryDataRegressionAlgorithm.py","lineNumber":58,"sourceCode":"        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:\n            raise ValueError(f\"Unexpected delistings count: {len(delistings)}\")\n        if delistings.iloc[0].type != DelistingType.WARNING:\n            raise ValueError(f\"Unexpected delisting: {delistings.iloc[0]}\")","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/HistoryAuxiliaryDataRegressionAlgorithm.py#L40-L76","documentation":"Per-row sanity check on the AAPL split history: every split factor must be non-zero. A zero split factor indicates malformed split data or a deserialization bug that zeroed the factor.","triggerScenarios":"Iterating split.splitfactor, a value equals 0.0.","commonSituations":"A factor file row has a zero/blank split factor parsed as 0; a split refactor changed how SplitFactor is populated; data corruption.","solutions":["Inspect AAPL factor file rows in the window for zero or malformed split factor values.","Trace Split.SplitFactor population in the split reader/factor provider.","Correct the bad data row and re-run."],"exampleFix":"# before: malformed factor row {time;1.0;0;0.0}\n# after: corrected split factor\n{20200831;0.25;0.25;0.0}","handlingStrategy":"validation","validationCode":"splits = self.history(Split, aapl, 360)\nbad = [s for s in splits.splitfactor if s == 0]\nif bad:\n    self.debug(f\"zero split factors: {len(bad)}\")","typeGuard":"def has_nonzero_split_factors(split_history) -> bool:\n    return all(s != 0 for s in split_history.splitfactor)","tryCatchPattern":null,"preventionTips":["Validate per-row factor values, not just counts.","Inspect factor files for blank/zero split-factor rows.","Reject zero split factors at parse time in custom data readers."],"tags":["quantconnect","lean","regression","history","auxiliary-data","splits","data-quality"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}