I have the following pieces of code in rebalance and initialize
def rebalance(context, data):
prices_1m = data.history(sid(8554), "price", 100, "1m")
prices_1d = data.history(sid(8554), "price", 250, "1d")
def initialize(context):
schedule_function(func=rebalance,
date_rule=date_rules.every_day(),
time_rule=time_rules.market_close(hours=0,minutes=15),
half_days=True)
schedule_function(func=rebalance,
date_rule=date_rules.every_day(),
time_rule=time_rules.market_open(hours=0,minutes=15),
half_days=True)
When I step into the debugger and stop after fetching both the "1m" and "1d" prices for SPY in my rebalance if I check the values of prices_1d[-1] and prices_1m[-1] in watch expression they are always the same (checked about 15 times I reached that breakpoint). I was expecting them to be different because my rebalance is being called 15 minutes after market open and 15 minutes before market close.
prices_1d[-2] and prices_1m[-2] are different and all indexes -3 and less are also different.
Any idea why my rebalance is not getting the prices_1d and prices_1m same for -1 index?