Hi - in a given bar where a function is scheduled using schedule_function, does the scheduled function execute before or after handle_data for that same bar? I assume before but just thought I'd check.
Hi - in a given bar where a function is scheduled using schedule_function, does the scheduled function execute before or after handle_data for that same bar? I assume before but just thought I'd check.
@Matt C., That's one of those questions where a simple test can confirm (and imprint) one's speculations...
def initialize(context):
symbols("SPY")
schedule_function(HandleEntry)
def handle_data(context, data):
print("handle_data")
def HandleEntry(context, data):
print("HandleEntry")
'''
Daily
2011-01-04 PRINT handle_data
2011-01-04 PRINT HandleEntry
2011-01-05 PRINT handle_data
2011-01-05 PRINT HandleEntry
2011-01-06 PRINT handle_data
2011-01-06 PRINT HandleEntry
'''
'''
Minutely
2011-01-04 PRINT handle_data
2011-01-04 PRINT HandleEntry
2011-01-04 PRINT handle_data
2011-01-04 PRINT handle_data
2011-01-04 PRINT handle_data
'''
Notice that in minutely, HandleEntry is called only once, at day's open.
Now what TIME was that? Who knows? Maybe the log statements should include TIME when they emit on log.info or print...