1. Running optimizations
PortfolioAnalytics supports single period optimization
2. Single period optimization
with the optimize-dot-portfolio function as well as optimization with periodic rebalancing, commonly referred to as backtesting, with the optimize-dot-portfolio-dot-rebalancing function. Optimization with periodic rebalancing just means that you rerun the optimization at specified periods, for example annually. This means that at the end of each year, the optimization is run and the portfolio is rebalanced to the optimal weights.
3. Single period optimization
This slide shows the arguments for optimize-dot-portfolio and optimize-dot-portfolio-dot-rebalancing and we highlight some of them here. To run the optimization, you need to pass in a time series of returns of the assets for the R argument, the portfolio specification with the assets, constraints, and objectives for the portfolio argument, the optimization method for the optimize_method argument, and the name of the function for estimating moments for the momentFUN argument. Chapter 3 will cover methods for estimating the moments. Notice the similarity between these two functions. You only have to pass in a few additional arguments for the rebalancing periodicity and backtest parameters to control the data that is used for each optimization in the backtest period.
4. Optimization methods
The PortfolioAnalytics package supports both global solvers as well as linear and quadratic programming solvers. The optimization method you choose should be based on the type of problem you are solving. For example, a problem that can be formulated as a quadratic programming problem should be solved using a quadratic programming solver whereas a non-convex problem should be solved using a global solver such as DEoptim.
5. Example: optimization
The example in this slide demonstrates running both a single period optimization and an optimization with periodic rebalancing. The data used for this example is the first 6 columns of the edhec dataset. You can see from the portfolio specification that the optimization problem defined is to minimize portfolio standard deviation subject to full investment and long only constraints. To run the single period optimization, you call optimize-dot-portfolio and pass the returns, portfolio, and specify "ROI" as the optimization method. The optimization with periodic rebalancing is run by calling optimize-dot-portfolio-dot-rebalancing. Just as in the single period optimization case, you specify the returns, portfolio, and optimization method. The additional arguments are for the rebalancing paramters. You specify annual rebalancing frequency with rebalance_on equals "years" and use a lookback of 60 periods for the data used for each optimization with training_period and rolling_window. The training_period argument specifies the number of observations to use for the initial optimization and rolling_window controls the number of observations used for each optimization. You will learn how to extract and visualize the results of these optimizations later in this course.
6. Let's practice!
Now let's move on to exercises.