Download Stock Data

## Loading stock data from local file /cloud/project/stockdata_from_2019-01-01_to_2023-05-31_(0f9cf120d38e5ba793ee9b2a12c3efc1).RData

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"
##                    risk parity portfolio tangency portfolio       1/N
## Sharpe ratio                      5.1805             4.9795    5.8403
## max drawdown                      0.2098             0.2226    0.2057
## annual return                     5.0913             5.1154    5.4966
## annual volatility                 0.9828             1.0273    0.9411
## Sortino ratio                     8.9534             9.2194   10.9557
## downside deviation                0.5686             0.5548    0.5017
## Sterling ratio                   24.2706            22.9820   26.7218
## Omega ratio                       2.1958             2.1866    2.3825
## VaR (0.95)                        0.0846             0.0918    0.0782
## CVaR (0.95)                       0.1087             0.0984    0.0827
## rebalancing period                1.0217             1.0217    1.0217
## turnover                          0.2899             0.5199    0.0530
## ROT (bps)                       688.6811           376.1231 4072.5260
## cpu time                          0.0058             0.0314    0.0034
## 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.

R Markdown

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.

When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:

summary(cars)
##      speed           dist       
##  Min.   : 4.0   Min.   :  2.00  
##  1st Qu.:12.0   1st Qu.: 26.00  
##  Median :15.0   Median : 36.00  
##  Mean   :15.4   Mean   : 42.98  
##  3rd Qu.:19.0   3rd Qu.: 56.00  
##  Max.   :25.0   Max.   :120.00

Including Plots

You can also embed plots, for example:

Note that the echo = FALSE parameter was added to the code chunk to prevent printing of the R code that generated the plot.