my first trading algo
This strategy dynamically chooses the top performing stocks (by Sharpe ratio) of each cluster, then uses an L1 regularization term (LASSO) to penalize the portfolio weights and achieve an all-long portfolio, with quarterly rebalancing, or at least, that's the goal here
I added as many comments in the source code as possible to help elucidate, step-by-step, how the code operates. Below are some notes I took after messing with it for a bit:
- More clusters results in lower beta (expected that)
- Shifting market entry point by 17 days from month's start to try and coincide with the release of earnings reports resulted in -300% returns (unexpected, will have to test further to evaluate the best entry point)
- Cluster size of 30 seemed to provide the best risk/return tradeoff
- Kept penalization parameter at 2 for all tests
- This algo would not survive the 2008-2009 financial crisis
Feedback and criticism are heavily encouraged and appreciated!! Particularly how to go about reducing the risk factors associated with this strategy