I would like to filter down my investment universe to only include equities with a market cap over $100 million, or free-float market cap would be even better. I looked through the fundamental data library but I cannot find market cap anywhere. One would expect something like this to be readily available from Morningstar or any other financial data provider. Am I overlooking something here, or is there maybe another way I can filter on free-float market cap?
Jason Mark
I had the same question. I calculated Market Cap in the following manner:
https://www.quantconnect.com/forum/discussion/6473/calculating-market-capitalization-in-finefundamentalfunction/p1
In your case, I think that you could do something like this in the FineSelectionFunction
def FineSelectionFunction(self, fine): # Filter by Market Capitalization marketCap = {} for i in fine: marketCap[i] = (i.EarningReports.BasicAverageShares.ThreeMonths * i.EarningReports.BasicEPS.TwelveMonths * i.ValuationRatios.PERatio) return [x.Symbol for x in fine if marketCap[x] > 1000000]
Shile Wen
For anyone reading this now, checkout Bootcamp "Sector Weighted Portfolio Construction: Selecting Universe by Sector" for how to filter by market cap
from QuantConnect.Data.UniverseSelection import *
from Selection.FundamentalUniverseSelectionModel import FundamentalUniverseSelectionModel
class SectorBalancedPortfolioConstruction(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2016, 12, 28)
self.SetEndDate(2017, 3, 1)
self.SetCash(100000)
#1. Set an instance of MyUniverseSelectionModel using self.SetUniverseSelection
self.SetUniverseSelection(MyUniverseSelectionModel())
class MyUniverseSelectionModel(FundamentalUniverseSelectionModel):
def __init__(self):
super().__init__(True, None, None)
def SelectCoarse(self, algorithm, coarse):
return [c.Symbol for c in coarse]
def SelectFine(self, algorithm, fine):
#2. Save the top 3 securities sorted by MarketCap for the Technology sector to the variable self.technology
filteredByMktCap = [x for x in fine if 1e8 < x.MarketCap < 1e9]
return [x.Symbol for x in filteredByMktCap]
Jakob kaae
HI Shile Wen. How do you access market cap in the research notebook? :)
Mak K
Hi Jakob,
How do you access market cap in the research notebook? :)
This is how you access market cap in the research notebook :)
This is the documentation for fundamentals in the research notebook
This is documentation on the GetFundamental function
https://lean-api-docs.netlify.app/classQuantConnect_1_1Research_1_1QuantBook.html#:~:text=%E2%97%86%C2%A0-,GetFundamental()%20%5B,-1/5%5D
Let me know if you need anything else!
Jakob kaae
Thank you very much! This solves it. (I presume it is the same way with other standard fundamental values (shares outstanding, float etc). I actually read through the documentation before asking and I could not find market cap in there. Is there a list where I can see the precise fundamental values such as market cap? (It might also be me that was not able to find it in the documentation´s list, but I went through it all and was not able to locate it) . I used this list to try to find market cap:
(I even considered to make a calculation as I see that some of the other fundamental values uses sharesoutstanding and hense I could derive market cap.)
Thanks again for solving my problem ;)
Mak K
Hi Jakob,
If you click on “CoarseFundamental” and “FineFundamental” it will show you a list of what can be used with it.
Also here is a list of other fundamentals https://www.quantconnect.com/docs/data-library/fundamentals
Casper
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!