{"record":{"id":"b787e74f85733851","repo":"QuantConnect/Lean","slug":"unexpected-multi-symbol-dividend-count-len-multi","errorCode":null,"errorMessage":"Unexpected multi symbol dividend count: {len(multi_symbol_request)}","messagePattern":"Unexpected multi symbol dividend count: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Algorithm.Python/HistoryAuxiliaryDataRegressionAlgorithm.py","lineNumber":33,"sourceCode":"\n### <summary>\n### Regression algorithm asserting the behavior of auxiliary data history requests\n### </summary>\nclass HistoryAuxiliaryDataRegressionAlgorithm(QCAlgorithm):\n\n    def initialize(self):\n        '''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''\n\n        self.set_start_date(2021, 1, 1)\n        self.set_end_date(2021, 1, 5)\n\n        aapl = self.add_equity(\"AAPL\", Resolution.DAILY).symbol\n\n        # multi symbol request\n        spy = Symbol.create(\"SPY\", SecurityType.EQUITY, Market.USA)\n        multi_symbol_request = self.history(Dividend, [ aapl, spy ], 360, Resolution.DAILY)\n        if len(multi_symbol_request) != 12:\n                raise ValueError(f\"Unexpected multi symbol dividend count: {len(multi_symbol_request)}\")\n\n        # continuous future mapping requests\n        sp500 = Symbol.create(Futures.Indices.SP_500_E_MINI, SecurityType.FUTURE, Market.CME)\n        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","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/QuantConnect/Lean/blob/d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892/Algorithm.Python/HistoryAuxiliaryDataRegressionAlgorithm.py#L15-L51","documentation":"Validates a multi-symbol auxiliary-data history request in HistoryAuxiliaryDataRegressionAlgorithm. It requests Dividend history for [AAPL, SPY] over 360 daily bars and asserts exactly 12 dividend rows across both symbols. A different count means dividend data coverage, the multi-symbol history request, or auxiliary-data retrieval changed.","triggerScenarios":"len(self.history(Dividend, [aapl, spy], 360, Resolution.DAILY)) != 12 during initialize.","commonSituations":"Dividend data files added/removed/changed for AAPL or SPY in the 360-day lookback; multi-symbol auxiliary history request no longer unions results correctly; the regression date window shifted.","solutions":["Verify the regression start date (2021-01-01) is unchanged so the 360-day lookback window is identical.","Inspect equity/usa/factorfiles for AAPL and SPY dividend rows in the window; reconcile against the expected 12.","Check the auxiliary-data history provider path for multi-symbol aggregation changes.","If data is legitimately corrected, recount and update the 12 constant."],"exampleFix":"# before: counts drifted after a factor-file refresh\nif len(multi_symbol_request) != 12:\n# after: rebaselined to verified dividend row count\nif len(multi_symbol_request) != 12:  # 7 AAPL + 5 SPY, verified against factor files","handlingStrategy":"validation","validationCode":"# validate multi-symbol auxiliary counts deterministically\nrows = self.history(Dividend, [aapl, spy], 360, Resolution.DAILY)\nif len(rows) != 12:\n    self.debug(f\"multi-symbol dividend rows: {len(rows)}; per-symbol:\\n{rows.groupby(level=0).size()}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lock the regression date window; the lookback count depends on it.","Group multi-symbol results by symbol on mismatch to localize which symbol drifted.","Rebaseline counts only after verifying factor files."],"tags":["quantconnect","lean","regression","history","auxiliary-data","dividends","multi-symbol"],"backgroundTag":null,"analyzedSha":"d2c3659f877bfc2b5d9dc0fc89a9c7566f45e892","analyzedAt":"2026-08-13T13:52:21.013Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}