Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Newbie Question How to set trading universe to SP500 (at least the symbols, no fundamentals needed) and will it be dynamic when you backtest ?

Newbie Question How to set trading universe to SP500 (at least the symbols, no fundamentals) and will it be dynamic when you backtest ?

1 response

Try Q500US:

from quantopian.algorithm import attach_pipeline, pipeline_output  
from quantopian.pipeline import Pipeline, factors, filters

def initialize(context):  
    attach_pipeline(Pipeline(screen = filters.Q500US()), 'Q500US')

def before_trading_start(context, data):  
    context.stocks = pipeline_output('Q500US')  
    print len(context.stocks)  

It will dynamically updating symbols.