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.