Hi all,
I'm about to create a new strategy based on fundamental data, my first strategy was based on technical.
At first glance, it seems that fundamental data is accessible only through the universe selection, to filter asset.
Is there any best practice to use fundamental data in actual algorithm logic?
Ex: If this asset's current P/E ratio is over X ... then buy/sell etc..
Thanks
Davide
Adam W
Fundamental data can be accessed by `Security.Fundamentals` if the universe passes through a `FineFundamentalUniverseSelection`.
What I typically do though when using fundamental data is something like:
class MyAlgo(QCAlgorithm): def Initialize(self): self.symbolFundamentals = None self.AddUniverseSelection( FineFundamentalUniverseSelectionModel(self.CoarseFilter, self.FineFilter) ) def CoarseFilter(self, coarse): symbols = # do something return symbols def FineFilter(self, fine): currentFundamentals = {symbol: SymbolData(symbol) for symbol in self.symbols} for x in fine: currentFundamentals[x.Symbol].UpdateFundamentals( {'PERatio':ValuationRatios.PERatio} ) self.symbolFundamentals = currentFundamentals symbols = # do something return symbols def OnData(self, data): # do something with self.symbolFundamentals.fundamentals class SymbolData: def __init__(self, symbol): self.symbol = symbol self.fundamentals = {} def UpdateFundamentals(self, fundamentals={}): self.fundamentals = fundamentals
Adam W
Some typos above - i.e. should be `x.ValuationRatios.PERatio`, save self.symbols in CoarseFilter, etc but you get the point
Frank Giardina
Davide,
I am trying to do the same . I attached what i have so far and now trying to figure out how to make a trade. I get errors for data not available etc. when i try to trade from the added securities section. The code has alot of logging just so i can see the event flow. Once i select the universe i will tackle what additional indicators or conditions i want to test before i buy. For now i just want to get around the data issues. I did alot of work in the Quantiopian platform and in Quantconnect the concepts of rolling windows, warming up just escape me. Hope this helps and
if you are looking for someone to collorabate with let me know
Frank
.
Sunil Mishra
Hello Frank,
I think I see what you're trying to do.
What's worked for me is to keep a running list of symbols in my universe. When `OnSecuritiesChanged` is called, update the universe based on the added and removed securities. And trade on the universe during `EveryDayAfterMarketOpen` or some other appropriate function. Such as OnData. I honestly do not really understand the role of ActiveSecurities, and it doesn't matter to me as I don't use indicators and such. I've been having some performance issues with my algorithm though, so my approach may not be the best :)
Sunil
Frank Giardina
Sunil,
That is exactly what i am going to try, and think you approach is a good one. My understanding is that ActiveSecruites are just the securities left after the changes.RemovedSecurities removes symbols that don't meet your universe selection, at least that is what is happening when i print what is in there. I put the functions in the algo in the order they fire just so i could see what was really happening. Thanks for the comment. Once Iget that working i will repost. My plan is simple identify the best stocks based on revenue and growth and then figure out the right time to buy them
Thanks again
Frank
Davide Carbone
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!