I was scheduling an event around market open and noticed that some data points were not being updated as expected.  Specifically, at market open some data from a prior day's EOD event was not updated, and even at one minute after the open an indicator with daily resolution was not updated. 

Ultimately I determined the events fire in this order:  Market Open + 0 minutes fires first, followed by the EOD event from the prior day, Then events 1 and 2 minutes after market open.  An RSI event with daily resolution (and others with daily resolution) was not updated until Market Open + 2 minutes.  This means that any trading right at market open using an indicator with daily resolution would be using day-old data.

Pertinent lines from my code:

self.sym = 'SPY' self.AddEquity(self.sym, Resolution.Minute) self.myRSI = self.RSI(self.sym, 14, MovingAverageType.Wilders, Resolution.Daily) self.Schedule.On(self.DateRules.EveryDay(self.sym), \ self.TimeRules.AfterMarketOpen(self.sym, 0),\ Action(self.MktOpen0)) self.Schedule.On(self.DateRules.EveryDay(self.sym), \ self.TimeRules.AfterMarketOpen(self.sym, 1),\ Action(self.MktOpen1)) self.Schedule.On(self.DateRules.EveryDay(self.sym), \ self.TimeRules.AfterMarketOpen(self.sym, 2),\ Action(self.MktOpen2)) def OnEndOfDay(self): self.prPrice = self.Securities[self.sym].Price # record prior close for tomorrow prc = self.Securities[self.sym].Price self.Log("EOD: "+ str(self.Time)+" : Price="+str(prc)+", PrevClose="+str(self.prPrice)+", RSI="+str(self.myRSI)) # the three MktOpen functions just log a line like the one in the EOD routine.

The following is from the log file for 4/1/2019:

2019-04-01 09:31:00 Open+0: 2019-04-01 09:30:00 : Price=282.62, PrevClose=280.78, RSI=48.12869 2019-04-01 09:31:00 EOD: 2019-03-29 23:58:00 : Price=282.62, PrevClose=282.62, RSI=48.12869 2019-04-01 09:31:00 Open+1: 2019-04-01 09:31:00 : Price=284.77, PrevClose=282.62, RSI=48.12869 2019-04-01 09:32:00 Open+2: 2019-04-01 09:32:00 : Price=284.68, PrevClose=282.62, RSI=53.71998

Note the order the events fire and that RSI is not updated until Open + 2 minutes. 

I recognize the first opportunity to trade is at 9:31, but I would have expected the EOD event to fire first and for indicators with a daily resolution to be updated prior to Market Open events.  This may be a bug, or it may be as designed,  Regardless it could cause issues with trading right at the open.

Thanks for the system, it is pretty amazing ( even when sometimes puzzling ).

Author