limit QTU to specfic industry sector and market cap?

Looking for guidance on how to limit QTradableStocksUS() (QTU) to a specific industry sector and market cap? Also is there a way to compute the market cap weights of the industry sectors (e.g. point-in-time, Industrials represents what percentage by market cap of the sectors in the QTU))?

9 responses

Here's one way:

from quantopian.pipeline.classifiers.morningstar import Sector

factor = factor.zscore(groupby=Sector())

That's going to be very useful! Thanks @Joakim

Hi Grant,

Is that what you're looking for?

3
Notebook previews are currently unavailable.

Thanks all -

Getting there. Here's what I came up with so far, which I think should get me 0-50 percentile market cap of the financial sector (103) within the QTU, right?

def factor_pipeline():
market_cap = factset.Fundamentals.mkt_val.latest
factors = make_factors()
pipeline_columns = {}
for k,f in enumerate(factors):
pipe = Pipeline(columns = pipeline_columns,
screen = universe)
return pipe


Wondering if it would also work just to use the market cap values of the sector ETFs (see https://www.quantopian.com/papers/risk)?

Here's an update. This seems to work pretty well:

def factor_pipeline():
factors = make_factors()
sectors = [101,102,103,104,205,206,207,308,309,310,311]
market_cap = factset.Fundamentals.mkt_val.latest
pipeline_columns = {}
for k,f in enumerate(factors):
for s in sectors:

pipe = Pipeline(columns = pipeline_columns,
return pipe


There's a nice, detailed factor construction recipe here, by the way:

Step-by-step guide to Vanguard’s factor construction