Download Stock Data

## Downloading 20 stocks...
##   |                                                                              |====                                                                  |   5%  |                                                                              |=======                                                               |  10%  |                                                                              |==========                                                            |  15%  |                                                                              |==============                                                        |  20%  |                                                                              |==================                                                    |  25%  |                                                                              |=====================                                                 |  30%  |                                                                              |========================                                              |  35%  |                                                                              |============================                                          |  40%  |                                                                              |================================                                      |  45%  |                                                                              |===================================                                   |  50%  |                                                                              |======================================                                |  55%  |                                                                              |==========================================                            |  60%  |                                                                              |==============================================                        |  65%  |                                                                              |=================================================                     |  70%  |                                                                              |====================================================                  |  75%  |                                                                              |========================================================              |  80%  |                                                                              |============================================================          |  85%  |                                                                              |===============================================================       |  90%  |                                                                              |==================================================================    |  95%  |                                                                              |======================================================================| 100%
## 
## Successes: 20     fails: 0
## Saving stock data to local file C:/Users/Admin/OneDrive - 亞洲大學[Asia University]/4th year/2nd Sem/2b. Topics in Financial Institution and Management/stockdata_from_2019-01-01_to_2025-03-20_(0f9cf120d38e5ba793ee9b2a12c3efc1).RData for future use.

Optimization

In this section we assign our riskParity & max_sharpe_ratio portfolio functions. The functions will get passed into out optimization to find the weights at each period.

## Backtesting 2 portfolios over 1 datasets (periodicity = monthly data)...
## Backtesting benchmarks...

Table of Stats

Get rebalanced dates along with the table of stats for each portfolio.

## 
## Rebalanced:
##  [1] "Jun 2019" "Jul 2019" "Aug 2019" "Sep 2019" "Oct 2019" "Nov 2019"
##  [7] "Dec 2019" "Jan 2020" "Feb 2020" "Mar 2020" "Apr 2020" "May 2020"
## [13] "Jun 2020" "Jul 2020" "Aug 2020" "Sep 2020" "Oct 2020" "Nov 2020"
## [19] "Dec 2020" "Jan 2021" "Feb 2021" "Mar 2021" "Apr 2021" "May 2021"
## [25] "Jun 2021" "Jul 2021" "Aug 2021" "Sep 2021" "Oct 2021" "Nov 2021"
## [31] "Dec 2021" "Jan 2022" "Feb 2022" "Mar 2022" "Apr 2022" "May 2022"
## [37] "Jun 2022" "Jul 2022" "Aug 2022" "Sep 2022" "Oct 2022" "Nov 2022"
## [43] "Dec 2022" "Jan 2023" "Feb 2023" "Mar 2023" "Apr 2023" "May 2023"
## [49] "Jun 2023" "Jul 2023" "Aug 2023" "Sep 2023" "Oct 2023" "Nov 2023"
## [55] "Dec 2023" "Jan 2024" "Feb 2024" "Mar 2024" "Apr 2024" "May 2024"
## [61] "Jun 2024" "Jul 2024" "Aug 2024" "Sep 2024" "Oct 2024" "Nov 2024"
## [67] "Dec 2024" "Jan 2025"
##                    risk parity portfolio tangency portfolio       1/N
## Sharpe ratio                      4.8375             5.3316    6.4539
## max drawdown                      0.2098             0.2226    0.2057
## annual return                     4.1739             4.9992    5.3952
## annual volatility                 0.8628             0.9377    0.8360
## Sortino ratio                     8.4315            10.2150   12.3165
## downside deviation                0.4950             0.4894    0.4380
## Sterling ratio                   19.8972            22.4600   26.2285
## Omega ratio                       2.1090             2.3280    2.6267
## VaR (0.95)                        0.0786             0.0868    0.0736
## CVaR (0.95)                       0.1016             0.0960    0.0812
## rebalancing period                1.0147             1.0147    1.0147
## turnover                          0.3367             0.5033    0.0524
## ROT (bps)                       488.6738           384.2061 4052.4865
## cpu time                          0.0039             0.0070    0.0009
## failure rate                      0.0000             0.0000    0.0000

Returns + Drawdown Charts

Plot the returns for all the portfolios.

Weight Alloc through time

Plots the weigjt changes at each interval.