Hi,
as described in Greenblatt's the little book that beats the market, I want to:
I want to buy the top 2 securities based on fundamental data (P/E, ROE) each month.
The tricky part is to keep a security one year.
Jan 2000: Buy 2 stocks based on fine criteria (ROE e.g.)
Feb 2000: Buy 2 stocks based on fine criteria (ROE e.g.)
….
Jan 2001: sell stocks bough Jan 2000, buy 2 stocks based on fine criteria (ROE e.g.)
Right now the universe does not have a defined length. Ideally, I would always add 2 securities that are not already present.
I want to do this in the universe selection, because later the universe should be tilted towards long, and then I want to do technical analysis to do some risk managing / trend following.
Do you have any suggestions?
Fred Painchaud
Hi Jens,
Let me rephrase to see if we are on the same page:
Jan 2000: Buy 2 stocks not already owned based on fine criteria (ROE e.g.)
Feb 2000: Buy 2 stocks not already owned based on fine criteria (ROE e.g.)
….
Jan 2001: sell stocks bough Jan 2000, buy 2 stocks not already owned (and could these be one of or both ones you just sold?) based on fine criteria (ROE e.g.)
So, is that what you want to do?
If so, you would need to make sure the selected stocks are not already in your active stocks:
self.symbols = [i.Symbol for i in sortedPERatio[:self._NumStocksInPortfolio] if i not in self.ActiveSecurities]
For my last question, if you do not want to maybe pick a stock you just sold, you would need to sell them after the selection or you would need to put them in a struct so you can remember which they were and add a condition so they are not selected back:
self.symbols = [i.Symbol for i in sortedPERatio[:self._NumStocksInPortfolio] if i not in self.ActiveSecurities and i not in self._lastTwoStockSold]
Something along those lines you know…
Fred
Jens.
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!