Hi community,

I have some issues with accessing pre-market prices using a rolling window. 

If I print pre-market prices using a rolling window, all pre-market prices are equal to the opening price. Why is that the case? In the example code below I aim to have scheduled event pre-market that should print the pre-market price and a on open event that should print the price at the open. Perhaps there is something wrong in my code.

Thanks in advance!

class TachyonQuantumProcessor(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 6, 1) # Set Start Date self.SetEndDate(2019,6,5) self.SetCash(100000) # Set Strategy Cash self.AAPL = self.AddEquity("AAPL", Resolution.Hour, Market.USA, True, 1, True) self.lookback = 3 self.AAPLWindow = RollingWindow[TradeBar](self.lookback) self.Schedule.On(self.DateRules.EveryDay("AAPL"), self.TimeRules.AfterMarketOpen("AAPL",-120), self.EveryDayBuy) self.Schedule.On(self.DateRules.EveryDay("AAPL"), self.TimeRules.AfterMarketOpen("AAPL",1), self.EveryDaySell) def EveryDayBuy(self): if not self.AAPLWindow.IsReady: return self.Debug("Buy") self.Debug(self.Time) self.Debug(self.AAPLWindow[0]) def EveryDaySell(self): if not self.AAPLWindow.IsReady: return self.Debug("Sell") self.Debug(self.Time) self.Debug(self.AAPLWindow[0]) def OnData(self, data): '''OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. Arguments: data: Slice object keyed by symbol containing the stock data ''' if data.ContainsKey("AAPL"): self.AAPLWindow.Add(data["AAPL"]) if not self.AAPLWindow.IsReady: return

 

 

Author