hi, all,
I'm trying to add a list to context object as context.SAR to store the last number from ta_sar. when I run the code, I kept getting "run time error, key error 'SAR' ".
I just can't figure it out, can some one shed a light on it?
many thanks!
def SAR_handling(context, data):
global c
H = data.history(context.stock,'high', 20, '1d').dropna()
L = data.history(context.stock,'low', 20, '1d').dropna()
ta_sar = talib.SAR(H, L, acceleration=0.02, maximum=0.2)
context.SAR[c]=ta_sar[-1]
c=c+1