The goal behind this algorithm was to invest in a broad range of stocks, eliminate the ones that aren't doing well, and "double down" on the ones that are. I used 60k as the initial capital because I wanted to try and create a realistic strategy. I also ran this algorithm with a higher starting capital of $1M and buying shares in blocks of 100, which also showed high returns, peaking at 16x, and ending at 10x.
The stop loss price is set as a function of the rate of return, and trails the current price so as to lock in a profit in the event that the price of a particular security starts dropping.
There is a lot that could be done to further improve this algorithm, some of my initial thoughts:
- Refine initial investment criteria to pick fewer losers.
- Set a initial timeframe during which a stock must go up a certain % otherwise it is sold as a "loser"
- Optimize the setting of the stop loss price
- Testing on a wider range of stocks and time frames
Additionally, this algorithm works best (perhaps only?) during bull markets since it only goes long (hence the start date of 2010). You could probably modify to go short as well, particularly if it started to sense the portfolio as whole a starting to see negative returns.