Hi,
I'm doing something stupid, obviously, but can't see it so appreciate a little help.
I'm trying to add a dictionary item to the variable that stores the history output using the following code:
y = get_datetime().year
m = get_datetime().month
d = get_datetime().day
h = get_datetime().hour
mi = get_datetime().minute
s = get_datetime().second
ms = get_datetime().microsecond
date = datetime.datetime(y,m,d, h, mi, s, ms)
daily_prices = history(bar_count=252, frequency='1d', field='price')
if ( isTodayMonday ): # Just a logical check which is working
dct = { str(date) : currentClose }
daily_prices.update(dct)
but I'm getting this runtime error:
KeyError: u'no item named 2014-01-03 00:00:00'
There was a runtime error on line 138.
Where line 138 is daily_prices.update(dct)
What am I doing wrong? How do I add an element to the daily_prices variable?
Thanks in advance for your help.
Andrew