Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Change universe to all stocks on the NYSE and NASDAQ

Hello,

I would like to scan and create a small list of stocks like this algorithm has done (https://www.quantopian.com/posts/can-someone-check-my-logic-trying-to-calculate-top-gainers-and-losers-by-percentage-each-day-1). The only difference is that I would like to scan all stocks that are traded on the NYSE and NASDAQ, not just QTradableStocksUS. What can I put in the place of 'QTradableStocksUS' in this algorithm to instead have it scan all stocks that are traded on the NYSE and NASDAQ? I thought substituting in 'US_EQUITIES' would do the trick. But that doesn't do the trick and I'm not understanding why.

Thank you!
Sean

3 responses

You can use Morningstar Fundamentals to get the exchange where the securities are listed and the security type to filter for stocks only. Then you simply create a filter out of them.
I noticed that before some date in 2015 there are no securities listed on NYSE, I have no idea why...

Alternatively you can use FactSet EquityMetadata

from quantopian.pipeline.data.factset import EquityMetadata  

and replace the filters in the pipeline function like this:

    exchange = EquityMetadata.listing_exchange.latest  
    exch_filter = exchange.element_of(['NAS', 'NYS'])  
    asset_type = EquityMetadata.security_type.latest  
    stock_filter = asset_type.eq('SHARE')

Then you'll have also stocks listed on NYSE before 2015. However, FactSet data has a 1-year holdout period, so your latest end date for any backtest is one year before the current date.

Thank you so much Tentor! That seems to have done the trick! I really appreciate your help and the time you put into this for me

Sean