Lean
Lean copied to clipboard
Universe History with Scheduled Settings Creates Duplicate Index
Expected Behavior
Universe history doesn't create a duplicate index
Actual Behavior
Universe history doesn't create a duplicate index because it fills forward data to a date with data.
Potential Solution
N/A
Reproducing the Problem
class UniverseHistoricalDataAlgorithm(QCAlgorithm):
def initialize(self) -> None:
self.set_start_date(2024, 11, 18)
self.set_end_date(2024, 12, 31)
month_start = self.date_rules.month_start("SPY")
self.universe_settings.schedule.on(month_start)
self._universe = self.add_universe(BrainStockRankingUniverse)
self.schedule.on(month_start, self.time_rules.at(9, 31), self.trade)
def trade(self) -> None:
history = self.history(self._universe, 5)
if history.index.has_duplicates:
self.quit(str(history))
We see in the logs:
Checklist
- [x] I have completely filled out this template
- [x] I have confirmed that this issue exists on the current
masterbranch - [x] I have confirmed that this is not a duplicate issue by searching issues
- [x] I have provided detailed steps to reproduce the issue