Hello,
I am newbie to Quantopian. I am just writting a very simple code to try with. The code looks like below.
def initialize(context) :
context.dat = { }
def handle_data(context,data) :
full = data[symbol('SPY')]
date = str(full.datetime)[:10]
context.dat[date] = [full.open_price,full.high,full.low,full.close_price]
log.info(context.dat)
#log.info(context.dat['2015-06-04'])
I am just trying to get the data every minute and append it to a dictionary which is indexed by time so that I can use the data to compute my indicators. I ran it for 3 days with daily data settings. End of the backtest the dictionary looks like this
{'2015-06-08': [209.64, 209.83, 208.39, 208.47], '2015-06-04': [211.07, 211.78, 209.75, 210.22], '2015-06-05': [209.95, 210.58, 208.98, 209.79]}
The problem now is that I am not able to access the dictionaries. If i say
context.dat['2015-06-04']
It's giving me
key error 2015-06-04
why is it giving the key error even if there is a key? I just created same kind of dictionary in my own computer's python command prompt and I am able to access the dictionary using keys But its not woking as expected in quantopian. I am unable to figure out the problem here. Please assist me to solve this.
Thanks for any help.