Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Algorithm Help

Hi All,

Quite new to this so not sure if this is an appropriate request but could someone help code the following.

Using USEquityPricing.close to create a mean daily variance over a one month time frame. Following that I would make criteria base don't he value but I think I can figure that out by myself.

Thanks.

2 responses
from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline import Pipeline  
from quantopian.pipeline.data.builtin import USEquityPricing  
from quantopian.pipeline.factors import SimpleMovingAverage

def initialize(context):  
    pipe = Pipeline()  
    pipe = attach_pipeline(pipe, name='my_pipeline')  
    sma_Close_30 = SimpleMovingAverage(inputs=[USEquityPricing.close], window_length=30)  
    pipe.add(sma_Close_30, 'sma_Close_30')



def before_trading_start(context, data):

    results = pipeline_output('my_pipeline')  
    print results.head(10)  

Thanks Buk,

I think this will provide a 30 moving average of the closing price.

Was trying to calculate the daily variance in stock price. Then average those values over 30 days. Is there also a way to limit the search to a certain index?