Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Newb Moving Average/Standard Dev Question

I've been going through the tutorials and looking at all of your wonderful examples here, trying to get my first also on the platform together. The algo I'm using to learn the platform is an existing also that I run live on a commercial platform in c#.

When I try to build the code, I get an error at the AvgRange function. Do I need to make it AvgRange[stock] for this to work correctly? Ditto for the rest of my calcs in the Heavy Calcs function.


def initialize(context):

 context.stock = sid(24), sid(33748)  
 schedule_function( heavy_calcs, date_rules.every_day(), time_rules.market_open(minutes= 1), half_days = True )  
 schedule_function( EOD_Exit, date_rules.every_day(), time_rules.market_close(minutes= 32), half_days = True )  

 set_slippage(slippage.VolumeShareSlippage(volume_limit=0.25, price_impact=0.1))  
 set_commission(commission.PerTrade(cost=6.00))  

Will be called on every trade event for the securities you specify.

def handle_data(context, data):
pass


def heavy_calcs (context, data):

stock = context.stock  
AvgRange = history(30, '1d', 'high')[stock] - history(30, '1d', 'low')[stock].mavg(30)  
SD = (history(30, '1d', 'high')[stock] - history(30, '1d', 'low')[stock] ).stddev(30)  
RSize = 1000  

Gap = history(1, '1d', 'price')[stock] - history(0, '1d', 'open_price')[stock]  

context.hod = HOD(data[stock].high)