In a previous thread (https://quantopian.com/posts/template-limit-leverage-in-your-algos#51e82f6153ddf0d6a2000066) a fellow Quantopian-user noticed a seeming postdictive error when reviewing his log file. I decided to dig a little deeping on that possible problem and quickly generated the following code:
def initialize(context):
pass
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
# Implement your algorithm logic here.
# data[sid(X)] holds the trade event data for that security.
# data.portfolio holds the current portfolio state.
# Place orders with the order(SID, amount) method.
# TODO: implement your own logic here.
d=get_datetime()
log.info(d)
order(sid(24), 50)
which stores the date in d and then prints it to the log file. I ran this on daily data and here is the output:
2008-01-03handle_data:17INFO2008-01-04 00:00:00+00:00
2008-01-06handle_data:17INFO2008-01-07 00:00:00+00:00
2008-01-07handle_data:17INFO2008-01-08 00:00:00+00:00
2008-01-08handle_data:17INFO2008-01-09 00:00:00+00:00
2008-01-09handle_data:17INFO2008-01-10 00:00:00+00:00
2008-01-10handle_data:17INFO2008-01-11 00:00:00+00:00
So when get_datetime() returns 2008-01-04 , the log file prints the comment leading with 2008-01-03. Is this a bug or intentional?