Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Need Help in using List of Stocks as Input

I am working on an algo in which I need to use a list of stock symbols as input . I have searched on Q but didn't found any significant answer .
Example list :- ['AAPL','GOOGL','TSLA']

import numpy as np  
from quantopian.pipeline.filters import StaticAssets  
def initialize(context):  
    c = context  
    c.upb          = 0  
    c.lwb          = 0  
    c.avg          = 0  
    c.std          = 0  
    c.prc          = 0  
    close_point    = 25  # minutes before close to stop trading and close all.  
    set_slippage(slippage.FixedSlippage(spread=0.00))  
    set_commission(commission.PerTrade(cost=0.00))  
    context.stocks = StaticAssets(symbols(['AAPL', 'IBM']))  

how to add the list to context.stocks . Please help

1 response

Actually I have a large dictionary of stocks where longs and shorts are two list of stocks . Stocks list is dynamic so I can't manually type stocks .
Is there any way I can use a list as input .
like:-
context.stocks = (symbols(*['AAPL', 'IBM'])) # even unpacking didn't works here .