I add securities via `ScheduledUniverseSelectionModel` that fetch outsize data by interval.
And I want do some filter like realtime like `Volume/SharesOutstanding` in PortfolioConstructionModel stage.
How can i get `CompanyProfile.SharesOutstanding` field ?
In backtest mode Security.Fundamentals was None
Varad Kabade
Hi Cool nemo,
When using ScheduledUniverseSelectionModel the algorithm does not receive the Fine Fundamental data, so self.Securities[symbol].Fundamentals is a None type object. To resolve this, we need to use Coarse+Fine Universe Selection instead.
Best,
Varad Kabade
Cool nemo
@Varad kabade,thank u for u reply
Is that sure we can't get Fundamentals outside `Coarse+Fine Universe Selection` ?
Varad Kabade
Hi Cool nemo,
Yes, We can only get Fundamental data when we use fine Universe selection. Refer to the following thread for more information about using Fundamental data outside fine Universe selection,
Best,
Varad Kabade
Big mak
Cool nemo,
If you need to access fundamentals outside of the Fine Filter, you may want to save the fine fundamental object for the stocks you are interested in. Once you save it, you can access it later. Here's an example where you can access new fundamental data in a custom function (MainFunction) using self.stocks (which is a list of FineFundamental objects).
Varad Kabade
Hi Big mak,
Thank you for your response. An alternative way is to use the Fundamentals property of the security object. With this, we don't have to store all the fundamentals objects explicitly. Refer to the attached code snippet.
Â
Best,
Varad Kabade
Big mak
Thanks Varad. Any idea how to do that for all stocks in the securities list, and preferably in one line? Kind of like the way I had it in my attached code.
Louis Szeto
Hi Big mak
Since the return of Varad's code snippet is a float, you may set up a panda Series/dataframe to store the data, but they cannot be appended by a single line as pandas data structures' limitation. There is no additional benefit on putting them all into a single either. Please refer to the attached backtest as an example.
Best,
Louis Szeto
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.
Big mak
Is there any advantage to doing it the way you and Varad are suggesting with self.Securities? I just tested it; it's twice as slow and arguably less readable with the for loop vs list comprehension. Is there something I'm missing?
Louis Szeto
Hi Big mak
Both ways shall work fine, but using a new list will induce extra memory usage. The speed of a list iteration and a for-loop should be similar.
Best
Louis Szeto
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.
Big mak
Thanks Louis, that answers my question.Â
A list like this is quite small in memory, so unless the original poster or any future viewer is extremely strapped on memory, the 2x speed improvement from accessing a finefundamental object vs Self.Securities is likely a good tradeoff. I would imagine that this speed difference comes from accessing a finefundamental object vs using self.Securities.
Cool nemo
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!