The whole project is conducted under R, and the library "tidyquant" is heavily utilized.
For a quick starting guide, please refer to the vignette written by Matt Dancho
https://cran.r-project.org/web/packages/tidyquant/vignettes/TQ00-introduction-to-tidyquant.html
This backtest serves as a regular risk monitoring procedure.
As a high-level overview, below are the main steps for the backtest procedure:
- Current weight of the portfolio is retrieved
- The period for backtesting is set (Default = 3 years)
- Daily stock returns over the past 3 years are obtained from yahoo finance
- Monthly portfolio returns are calculated from the daily stock returns by the function tq_portfolio()
- Some ETFs/indices that serve as benchmarks are chosen and their data is obtained again through yahoo finance
- Various performance metrics (e.g. Historical ES, Annualized Sharpe ratio, beta) are calculated by the function tq_performance()
- The time series and density plots of the monthly portfolio return are generated by the function ggplot()
- The evolution of wealth level is also investigated for both the portfolio and the benchmark indices
- Detailed checks are implemented to ensure the above metrics/plots match my personal risk appetite
This project also serves as a building block for the complete portfolio analysis that will be finalized at a later stage.
Possible future projects include:
- Forecasting future returns using GARCH type models
- Rebalancing the portfolio automatically using certain kinds of indicators
- Conducting portfolio optimization using the dynamic programming approach
- Conducting portfolio optimization using LSTM or other kinds of RNN structures