Hello everyone,

thanks to all of your help I got my first simple algorithm working. Now I'm thinking of modifying it, so I can trade more than one stock. But I don't know how to create rolling windows for multiple stocks. I thought I'd use a list and iterate through it, but then I think I'd overwrite the same rolling window again and again. So how is this correctly done? This is the part of my code I'm unsure about:

self.AddEquity("SPY", Resolution.Second)

consolidator_daily = TradeBarConsolidator(timedelta(1))
consolidator_daily.DataConsolidated += self.OnDailyData
self.SubscriptionManager.AddConsolidator("SPY", consolidator_daily)

consolidator_minute = TradeBarConsolidator(60)
consolidator_minute.DataConsolidated += self.OnMinuteData
self.SubscriptionManager.AddConsolidator("SPY", consolidator_minute)

self.daily_rw = RollingWindow[TradeBar](2)
self.minute_rw = RollingWindow[TradeBar](2)
self.window = RollingWindow[TradeBar](2)

self.Schedule.On(self.DateRules.EveryDay(),
self.TimeRules.AfterMarketOpen('SPY', 1),
Action(self.one_minute_after_open_market))

self.Schedule.On(self.DateRules.EveryDay(),
self.TimeRules.BeforeMarketClose('SPY', 1),
Action(self.before_close_market))

# Add daily bar to daily rolling window
def OnDailyData(self, sender, bar):
self.daily_rw.Add(bar)

def OnMinuteData(self, sender, bar):
self.minute_rw.Add(bar)

Thank you very much for your help.

Kind regards,

Christian Lauer