Looking for example code of how to use Morningstar stock_type? There's some discussion of it here, but no code.
Looking for example code of how to use Morningstar stock_type? There's some discussion of it here, but no code.
@Grant Glad you highlighted this! The Morningstar stock_type field is definitely underused. It's a great way to group and filter as companies with similar types may tend to behave similarly. What makes this field more interesting than morningstar_sector_code is that it isn't as correlated with the 'sector' exposure factor. Anyway, attached is a notebook which uses stock_type to group the results of Alphalens.
Hope that helps.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.
Thanks Dan -
So how would I do a stock filter/mask/screen thingy in pipeline?
For example, would this work:
stock_type = Fundamentals.stock_type.latest
stock_type_picks = (stock_type.eq('Distressed') | stock_type.eq('Cyclicals'))
This would get me Distressed and Cyclicals, for example, correct?
Yes, that should work (sort of... use the stock_type integer codes rather than the names). So, like this
# Let's first get the stock_type classifier
stock_type = Fundamentals.stock_type.latest
# Make some factor to analyze later. Here it's what I call classic momentum
momentum = Returns(window_length=152).log1p() - Returns(window_length=10).log1p()
# Filter for Distressed and Cyclicals
stock_type_picks = (stock_type.eq(3) | stock_type.eq(4))
my_pipe = Pipeline(
columns={'stock_type': stock_type,
'momentum': momentum,
'sector': Fundamentals.morningstar_sector_code.latest,
'score': score,
},
screen= QTradableStocksUS() & stock_type_picks
)
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.
Thanks Dan -
In my effort to develop algos for the recent $10K Third-Party Challenge: Design a Factor for a Large US Corporate Pension, I've become interested in ways to identify companies that are kinda sketchy from a financial viability standpoint. I've used financial_health_grade and the Factset zscoreso far, and figured that one or more of the stock_type classifications might be useful, too (e.g. Distressed).