The strategy I use here explained in the last article. But I made some small adjustments for the test. The long-term moving average period I choose here is 200days moving average of each stock and their difference and the short-term period I choose is 5days. You can find this through the code I upload in the end.
As for the backtesting time frame is from 01/04/2015 to 12/04/2015. The picture of the final backtesting output:
The benchmark here is S&P500. Our portfolio’s total returns with last 11 months is 24.3% based on the simulation and the S&P500 returns are 4.2% within last 11 months. Obviously, this portfolio performs better than the benchmark in the simulation. As you can see the β = 0.07 which means the portfolio was influenced by the market in very small amount. But there are still a lot of deficiencies needed to be fixed such as the drawdown is very high and the volatility is till high which are all the indicators showing the output from the algorithm is not very stable over time and the model may contain some errors resulting in the future loss of the portfolio. I will keep learning and trying to construct more stable and better performed portfolios in the future.
Also, here is part of transaction details:
I also backtest this strategy for a long-term time frame from 01/04/2011 to 12/04/2015. The risk metrics and the output graph are as below:
Also, please feel free to comment on inefficiencies about anything I explained here since I am a beginner and I believe the more mistakes I fix the faster I can make progress.
The code I was using is here: