I've created a list of stocks to trade (either buy or sell). I'm trying to get the number of "Buys" based on the IF statement. When I run the algo, I get a KeyError: 'BABVA_list' on the last line. Does anyone know how to get around this?
return context.tradable_dfs
return context.tradable_sids
context.BABVA = [ ]
for z in range(len(context.tradable_dfs)):
if(context.tradable_dfs[z]['5-Day MA'].values[-1] < context.tradable_dfs[z]['10-Day MA'].values[-1]):
context.BABVA.append(context.tradable_sids[z])
else:
pass
return context.BABVA
context.BABVA_list = context.BABVA
return context.BABVA_list
def print_to_console(context, data):
print len(context.BABVA_list)