Hi Everyone,
This is my first algorithm/post, so let me know what you think!
Basically how the algorithm works is it uses the CAPM model to predict what the asset's return should be (in this case, stock in Bank of America).
If today's returns did not quite meet the expectation of the CAPM model, hold a portfolio of only the stock. If the asset returns more than what the CAPM model predicted, then switch to holding a portfolio of only the safer market ETF. Lastly, if the CAPM is predicting negative returns, hedge your bets and hold half stock and half ETF.
The assumption is that the returns on the asset are likely to gravitate toward what the CAPM is predicting. So if it's coming up short, then there's still room to move upward, and vice-versa.
This definitely could use some work, but on the handful of stocks I ran backtests on, it seems to do a decent job.
Any and all tips would be appreciated!