Using the ROI solvers with PortfolioAnalytics
Using the ROI solvers with PortfolioAnalytics
Ross Bennett May 17, 2018
Abstract
The purpose of this vignette is to demonstrate a sample of the optimzation problems that can be solved in PortfolioAnalytics with the ROI solvers. See demo(demo_ROI) for a more complete set of examples.
Contents
1 Getting Started
2
1.1 Load Packages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Maximizing Mean Return
3
2.1 Portfolio Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Backtesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 Minimizing Portfolio Variance
10
3.1 Global Minimum Variance Portfolio . . . . . . . . . . . . . . . . . . . . . . 10
3.1.1 Portfolio Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.1.2 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.1.3 Backtesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 Constrained Minimum Variance Portfolio . . . . . . . . . . . . . . . . . . . 11
3.2.1 Portfolio Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2.2 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.3 Backtesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
1
4 Maximizing Quadratic Utility
12
4.1 Portfolio Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.2 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
4.3 Backtesting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5 Minimizing Expected Tail Loss
14
1 Getting Started
1.1 Load Packages
Load the necessary packages.
> suppressMessages(library(PortfolioAnalytics)) > suppressMessages(library(foreach)) > suppressMessages(library(iterators)) > suppressMessages(library(ROI)) > suppressMessages(library(ROI.plugin.quadprog)) > suppressMessages(library(ROI.plugin.glpk))
1.2 Data
The edhec data set from the PerformanceAnalytics package will be used as example data.
> data(edhec) > # Use the first 4 columns in edhec for a returns object > returns colnames(returns) print(head(returns, 5))
CA CTAG
DS
EM
1997-01-31 0.0119 0.0393 0.0178 0.0791
1997-02-28 0.0123 0.0298 0.0122 0.0525
1997-03-31 0.0078 -0.0021 -0.0012 -0.0120
1997-04-30 0.0086 -0.0170 0.0030 0.0119
1997-05-31 0.0156 -0.0015 0.0233 0.0315
> # Get a character vector of the fund names > funds # Create portfolio object
> portf_maxret # Add constraints to the portfolio object
> portf_maxret portf_maxret # Add objective to the portfolio object
> portf_maxret print(portf_maxret)
************************************************** PortfolioAnalytics Portfolio Specification **************************************************
Call: portfolio.spec(assets = funds)
Number of assets: 4 Asset Names [1] "CA" "CTAG" "DS"
"EM"
Constraints
3
Enabled constraint types - full_investment - box
Objectives: Enabled objective names
- mean
> summary(portf_maxret)
$assets CA CTAG DS EM
0.25 0.25 0.25 0.25
$enabled_constraints $enabled_constraints[[1]] An object containing 6 nonlinear constraints.
$enabled_constraints[[2]] An object containing 5 nonlinear constraints.
$disabled_constraints list()
$enabled_objectives $enabled_objectives[[1]] $name [1] "mean"
$target NULL
$arguments list()
$enabled [1] TRUE
$multiplier [1] -1
4
$call add.objective(portfolio = portf_maxret, type = "return", name = "mean")
attr(,"class") [1] "return_objective" "objective"
$disabled_objectives list()
attr(,"class") [1] "summary.portfolio"
2.2 Optimization
The next step is to run the optimization. Note that optimize_method="ROI" is specified in the call to optimize.portfolio to select the solver used for the optimization.
> # Run the optimization
> opt_maxret print(opt_maxret)
*********************************** PortfolioAnalytics Optimization ***********************************
Call: optimize.portfolio(R = returns, portfolio = portf_maxret, optimize_method = "ROI",
trace = TRUE)
Optimal Weights: CA CTAG DS EM
0.02 0.05 0.43 0.50
Objective Measure:
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- roi calculator for partnerships to address the social
- hr analytics the key to calculating roi
- pharmacists improving care and reducing costs for your
- many solvers one interface roi the r optimization
- engineering economics 4 1
- return on investment and community health improvement an
- taking the mystery out of roi calculations
- return on investment tool for assessing safety interventions
- using the roi solvers with portfolioanalytics
- some examples of npv and irr university of wisconsin
Related searches
- word using the letters
- words using the letters verify
- words using the following letters
- words using the letters money
- find words using the letters
- words using the letters ussequi
- not using the word i
- 6 letter words using the letters
- 7 letters words using the following letters
- form a word using the following letters
- six letter words using the letters
- four letter words using the letters found