Hi guys,
I am new to Quantopian and trying to code this moving average crossover strat. When I try to the build the algorithm, I get a build error which does not contain detail.
Build error seems to coming from the line marked in bold.
I will really appreciate if some one could help me out with this error.
Thanks and Regards,
Vipin Anand
from collections import deque
**slowMovingAverage = ta.SMA(30) # Error seems to be at this line**
fastMovingAverage = ta.SMA(10)
cci = ta.CCI(20);
def initialize(context):
context.tna = sid(37515)
context.smaSlowbuffer = deque(maxlen=2)
context.smaFastbuffer = deque(maxlen=2)
context.max_notional = 1000000.1
context.min_notional = -1000000.0
def handle_data(context, data):
price = data[context.tna].price
slowMovingAverage_data = slowMovingAverage(data)
fastMovingAverage_data = fastMovingAverage(data)
slowMovingAverage_data_arr = slowMovingAverage_data[context.tna]
fastMovingAverage_data_arr = fastMovingAverage_data[context.tna]
context.smaSlowbuffer.append(slowMovingAverage_data_arr);
context.smaFastbuffer.append(fastMovingAverage_data_arr);
notional = context.portfolio.positions[context.tna].amount * price
if context.smaFastbuffer[0] >= context.smaSlowbuffer[0] and context.smaFastbuffer[1] < context.smaSlowbuffer[1]:
order(context.tna,+100)
elif context.smaFastbuffer[0] < context.smaSlowbuffer[0] and context.smaSlowbuffer[1] >= context.smaFastbuffer[1]:
order(context.tna,-100)