QuantConnect/Lean · error · ValueError
Unexpected multi symbol dividend count: {len(multi_symbol_re
Error message
Unexpected multi symbol dividend count: {len(multi_symbol_request)} What it means
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.
Source
Thrown at Algorithm.Python/HistoryAuxiliaryDataRegressionAlgorithm.py:33
### <summary>
### Regression algorithm asserting the behavior of auxiliary data history requests
### </summary>
class HistoryAuxiliaryDataRegressionAlgorithm(QCAlgorithm):
def initialize(self):
'''Initialise the data and resolution required, as well as the cash and start-end dates for your algorithm. All algorithms must initialized.'''
self.set_start_date(2021, 1, 1)
self.set_end_date(2021, 1, 5)
aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
# multi symbol request
spy = Symbol.create("SPY", SecurityType.EQUITY, Market.USA)
multi_symbol_request = self.history(Dividend, [ aapl, spy ], 360, Resolution.DAILY)
if len(multi_symbol_request) != 12:
raise ValueError(f"Unexpected multi symbol dividend count: {len(multi_symbol_request)}")
# continuous future mapping requests
sp500 = Symbol.create(Futures.Indices.SP_500_E_MINI, SecurityType.FUTURE, Market.CME)
continuous_future_open_interest_mapping = self.history(SymbolChangedEvent, sp500, datetime(2007, 1, 1), datetime(2012, 1, 1), data_mapping_mode = DataMappingMode.OPEN_INTEREST)
if len(continuous_future_open_interest_mapping) != 9:
raise ValueError(f"Unexpected continuous future mapping event count: {len(continuous_future_open_interest_mapping)}")
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)
if len(continuous_future_last_trading_day_mapping) != 9:
raise ValueError(f"Unexpected continuous future mapping event count: {len(continuous_future_last_trading_day_mapping)}")
dividend = self.history(Dividend, aapl, 360)
self.debug(str(dividend))
if len(dividend) != 6:
raise ValueError(f"Unexpected dividend count: {len(dividend)}")
for distribution in dividend.distribution:
if distribution == 0:
raise ValueError(f"Unexpected distribution: {distribution}")
View on GitHub (pinned to d2c3659f87)
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.
Example fix
# before: counts drifted after a factor-file refresh if len(multi_symbol_request) != 12: # after: rebaselined to verified dividend row count if len(multi_symbol_request) != 12: # 7 AAPL + 5 SPY, verified against factor files
Defensive patterns
Strategy: validation
Validate before calling
# validate multi-symbol auxiliary counts deterministically
rows = self.history(Dividend, [aapl, spy], 360, Resolution.DAILY)
if len(rows) != 12:
self.debug(f"multi-symbol dividend rows: {len(rows)}; per-symbol:\n{rows.groupby(level=0).size()}") Prevention
- 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.
When it happens
Trigger: len(self.history(Dividend, [aapl, spy], 360, Resolution.DAILY)) != 12 during initialize.
Common situations: 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.
Related errors
- Unexpected dividend count: {len(dividend)}
- Unexpected distribution: {distribution}
- Unexpected continuous future mapping event count: {len(conti
- Unexpected continuous future mapping event count: {len(conti
- Unexpected split count: {len(split)}
AI-assisted analysis of QuantConnect/Lean@d2c3659f87 (2026-08-13).
Data as JSON: /api/errors/b787e74f85733851.
Report an issue: GitHub.