Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Build error with no details

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) 
2 responses

Hey Vipin,

Try this code instead. I have not polished the order execution logic, but you should be able to. Take a look at the backtest to see where crossovers occur.

from collections import deque  
import talib

def initialize(context):  
    context.my_sid = sid(37515)  

    context.max_notional = 1000000.1  
    context.min_notional = -1000000.0

def handle_data(context, data):  
    price_history = history(bar_count=100, frequency='1d', field='price')  
    my_sid_series = price_history[context.my_sid]  
    fastMovingAverage_data = talib.SMA(my_sid_series, timeperiod=10)  
    slowMovingAverage_data = talib.SMA(my_sid_series, timeperiod=30)

    record(fastMA = fastMovingAverage_data[-1], slowMA = slowMovingAverage_data[-1])    

    #if fastMovingAverage_data[-1] >= slowMovingAverage_data[-1] and fastMovingAverage_data[-2] < slowMovingAverage_data[-2]:  
    #     order(context.my_sid,+1)  
    #elif fastMovingAverage_data[-1] < slowMovingAverage_data[-1] and slowMovingAverage_data[-2] >= fastMovingAverage_data[-2]:  
    #     order(context.my_sid,-1)  

Cheers,
Ryan

Hi Ryan,
Sorry for the late reply as my laptop was broken for couple of days so could not get back to you. I will clone your algorithm for more clues.

Thank you so much for helping me out!

Vipin