I am from the former quantopian/zipline world and just started exploring quantconnect and got confused by how coarse and fine selection are used in add_universe. It seems to be done by two fucntions each returns a list of symbols. Both functions accept an argument whose type is list of Fundamentals. How are they cordinated and connected to screen for stocks stepwisely?
Mia Alissi
In QuantConnect, the
add_universe
method is used to dynamically select stocks for your algorithm using a two-step process: coarse and fine selection. Here's how they work together:Coarse Selection: This is the initial filtering step. You define a coarse selection function that takes a list of
CoarseFundamental
objects and returns a list ofSymbol
objects. The coarse selection is typically used to filter stocks based on basic criteria such as dollar volume and whether the stock has fundamental data. This step is lightweight and helps reduce the number of stocks for further analysis.Example of a coarse selection function:
Fine Selection: After the coarse selection, the fine selection function further narrows down the list using detailed fundamental data. This function takes a list of
FineFundamental
objects and returns a list ofSymbol
objects. Fine selection allows you to filter stocks based on more specific criteria such as earnings, P/E ratio, or other fundamental metrics.Example of a fine selection function:
Coordination: In the
initialize
method of your algorithm, you useadd_universe
to coordinate these two functions. The method first applies the coarse selection function to filter the initial list of stocks and then applies the fine selection function to the output of the coarse selection.Example of using
add_universe
:This setup allows your algorithm to dynamically select stocks based on your defined criteria, focusing on strategy development rather than static stock selection.
Sources: Initialization - QuantConnect.com, Legacy Fundamental Universes - QuantConnect.com, Key Concepts - QuantConnect.com, Legacy Fundamental Universes - QuantConnect.com, Stock Selection Strategy Based On Fundamental Factors
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Fimmu smu
Ok. I understand that universe selection takes two steps: coarse and fine selections. The coarse selection returns list of symbol objects but I do not see where they are passed to the fine selection function as a starting point for further narrowing down the list.
Can you explain this “After the coarse selection, the fine selection function further narrows down the list using detailed fundamental data. This function takes a list of FineFundamental objects and returns a list of Symbol objects.”?
Fimmu smu
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 QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect 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. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!