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

i have a question about QTradableStocksUS in zipline .

The zipline dosen't has the QTradableStocksUS module, how can i use the QTradableStocksUS in zipline?

where can i find the code of QTradableStocksUS or i need to make it by my own?

any one know it please give me help, thanks

7 responses

Hi Zeng,

I was told in an e-mail from Quantopian support, dated Feb. 23, 2018, that there is no plan to open-source the QTradableStocksUS code.

The specifications are described on the help page:

https://www.quantopian.com/help#built-in-factors

Note that to re-create the code, you'd need off-line access to:

https://www.quantopian.com/data/eventvestor/mergers_and_acquisitions

thank you,Kiehne,I will try it.

Hi Zeng,

QTradableStocksUS is a universe defined by database queries and filtering by attributes. For reference, in the pre-Pipeline days before the first Q500US universe existed, you may look for community postings that share algorithms with codes such as:

def before_trading_start(context, data):

    df = get_fundamentals(  
        query(fundamentals.valuation.market_cap,  
              fundamentals.valuation.shares_outstanding,  
              fundamentals.income_statement.ebit,  
              fundamentals.income_statement.ebit_as_of,  
              fundamentals.valuation.market_cap,  
              fundamentals.valuation.enterprise_value,  
              fundamentals.valuation.enterprise_value_as_of,  
              fundamentals.share_class_reference.symbol,  
              fundamentals.company_reference.standard_name,  
              fundamentals.operation_ratios.total_debt_equity_ratio  
              )  
        .filter(fundamentals.operation_ratios.total_debt_equity_ratio != None)  
        .filter(fundamentals.valuation.market_cap != None)  
        .filter(fundamentals.valuation.shares_outstanding != None)  
        .filter(fundamentals.company_reference.primary_exchange_id != "OTCPK") # no pink sheets  
        .filter(fundamentals.company_reference.primary_exchange_id != "OTCBB") # no pink sheets  
        .filter(fundamentals.asset_classification.morningstar_sector_code != None) # require sector  
        .filter(fundamentals.share_class_reference.security_type == 'ST00000001') # common stock only  
        .filter(~fundamentals.share_class_reference.symbol.contains('_WI')) # drop when-issued  
        .filter(fundamentals.share_class_reference.is_primary_share == True) # remove ancillary classes  
        .filter((fundamentals.valuation.market_cap*1.0 / fundamentals.valuation.shares_outstanding*1.0) > 1.0) # price >$1  
        .filter(fundamentals.share_class_reference.is_depositary_receipt == False) # !ADR/GDR  
        .filter(fundamentals.valuation.market_cap > 30000000) # cap > $30MM  
        .filter(~fundamentals.company_reference.standard_name.contains(' LP')) # exclude LPs  
        .filter(~fundamentals.company_reference.standard_name.contains(' L P'))  
        .filter(~fundamentals.company_reference.standard_name.contains(' L.P'))  
        .filter(fundamentals.balance_sheet.limited_partnership == None) # exclude LPs  
        .order_by(fundamentals.valuation.market_cap.desc())  
        .offset(0)  
        .limit(2500)  
        ).T  

Hope this helps.

QTradableStocksUS() (aka QTU) is also addressed in Help > Built-in Filters.

Requires some fundamentals and I hear they are expensive. It's a set of over 900 of them.
Would be convenient if one of those companies like Morningstar could offer a lite version of just a handful of the basics for filtering.
These are some that I think of as essential:

exchange_id
is_depositary_receipt
is_primary_share
limited_partnership
market_cap
primary_share_class_id
security_type
standard_name
symbol (like _WI not in symbol)
and yesterday's close

This may help, as well:

https://www.quantopian.com/posts/the-tradeable500us-is-almost-here

It is a predecessor to the QTU.

Thanks,Karl,your code is very helpful.
actually,when i try to re-create the code ,i found that quantopian's data come from Morningstar and zipline doesn't have the Morningstar module. So the work on zipline become more complex.
If quantopian can realize real-time singal in paper-trade, this will become more easy.

Note to Q support -

There would seem to be some upcoming use cases for offline access to the QTU, point-in-time:

  1. The new My Data API. For some types of offline analyses, it might be necessary to have the QTU. Of course, if an offline factor is just doing analysis of each stock, independent of the others, it doesn't matter (except, perhaps to limit compute resources). Just run the analysis on every stock there ever was, and filter out ones not in the QTU, upon upload to Quantopian, re-rank, and presto...done! However, I suspect that for certain types of analysis (Pairs trading? ML?), it might be critical to have the QTU offline.
  2. The Quantopian Emerging Managers Program (e.g see https://quantopianemergingmanager.splashthat.com/). It's not yet clear how it will work, but I get the impression that a track record of real-money offline trading is required, as part of the evaluation ("Track Record: Top performing emerging managers will be eligible to receive an independently corroborated track record after 3 consecutive years of proven performance"). One could craft an offline strategy with one's own capital, using the QTU, and then in three years, apply to the program. Without out access to the QTU (or some other approved Quantopian universe), it seems like things could be a bit of a guessing game.