I tried to print out the first available price for each day.
# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
from pytz import timezone
def initialize(context):
context.prev_day = {"day":0}
# Will be called on every trade event for the securities you specify.
def handle_data(context, data):
exchange_time = get_datetime().astimezone(timezone('US/Eastern'))
if exchange_time.day != context.prev_day["day"]:
log.info(exchange_time)
context.prev_day["day"] = exchange_time.day
order(sid(19656), 100)
the log shows this:
2007-01-03handle_data:12INFO2007-01-03 09:34:00-05:00
2007-01-04handle_data:12INFO2007-01-04 09:33:00-05:00
2007-01-05handle_data:12INFO2007-01-05 09:31:00-05:00
My question is how to understand the minute range given here 09:31:00-05:00
. Also, why is that not every date starts at 9:30 or 9:31? Thanks