I have some trouble with the event scheduling system. Im trying to fire 3 events in a specific order but it doenst work.

( I have inserted a "test"-variable to show the problem)

self.test = 0 self.Schedule.On(self.DateRules.EveryDay("AAPL"), self.TimeRules.At(9, 25), self.BeforeOpen) self.Schedule.On(self.DateRules.EveryDay("AAPL"), self.TimeRules.BeforeMarketClose("AAPL", 5), self.BeforeClose) self.Schedule.On(self.DateRules.EveryDay("AAPL"), self.TimeRules.At(16, 5), self.AfterClose)def BeforeOpen(self): self.Debug(str(self.Time) + " before open // Test value: {} (expected to be 0)".format(self.test)) self.test = 1 def BeforeClose(self): self.Debug(str(self.Time) + " before close // Test value: {} (expected to be 1)".format(self.test)) self.test = 2 def AfterClose(self): self.Debug(str(self.Time) + " after close // Test value: {} (expected to be 2)".format(self.test)) # expected to be 2 self.test = 0 # reset the variable after market close


The result is:


As u can see the dates and the value of the test-variable get mixed up. Is there a way to fix this?