I trade with minute resolution data but need to execute paricular code at the end of the day.  My intention is to execute this code on the last slice of the day.

After trying OnEndOfDay I shifted to a scheduled event with the following code.  This code should work with regular market days and shortened days.  The problem is that scheduled events don't fire during warm-up.  Does anyone know of a way to detect the last bar of the day even during warm-up?  Thanks for any help.

def Initialize(self):

self.EODevent = False

# Schedule EOD events
self.Schedule.On(self.DateRules.EveryDay('SPY'), \
self.TimeRules.BeforeMarketClose('SPY', 0), \

def EODevents(self):
self.EODevent = True;

def OnData(self,slice):
if self.EODevent:
.. execute code here ...
self.EODevent = False