Perform a scenario optimization that maximizes the omega ratio.
- a three-dimensional array containing scenarios
- Portfolio Probe
pprobeSup package needs to be loaded into your R session:
pprobeSup is not installed on your machine, then you can get it with:
or alternatively with:
install.packages("pprobeSup", repos="http://www.portfolioprobe.com/R", type="source")
You also need to have the Portfolio Probe package loaded into your R session:
If you don’t have Portfolio Probe, see “Demo or Buy”.
Doing the example
You need to have the
pprobeData package loaded into your R session:
This package may be installed from the same repository as
We use a scenario object created in “generate historical scenarios”.
We need to specify the constraints for the portfolio in addition to the utility and the scenarios. The omega ratio also requires a target return which in this case we take to be 3%:
omegaOpt <- scenario.optimizer(monScen, utility=pputil.omega, extraArgs=list(target=0.03), gross.value=1e6, long.only=TRUE, max.weight=.08, port.size=c(20,30))
The constraints for this problem are that the gross value of the portfolio is (close to) $1 million, the portfolio is long-only, no asset may have a weight greater than 8% and there are between 20 and 30 names in the portfolio.
The result is an object that holds the best portfolio found, the trade to get there, and some other information.
There is a demand for the current prices in order to constrain the current portfolio value. In this case the default prices are used, which is the first row of the first scenario.
extraArgs argument to
scenario.optimizer is used to give additional arguments to the utility function.
There’s not much else to explain. Feed in the scenarios, utility and constraints. Out comes an approximately optimal portfolio for that problem.
the number of iterations
You can specify the maximum number of iterations that can be used — the number of bites is the function’s analogy:
omegaOpt2 <- scenario.optimizer(monScen, utility=pputil.omega, extraArgs=list(target=0.03), gross.value=1e6, long.only=TRUE, max.weight=.08, port.size=c(20,30), regulate=c(nbites=100))
We can get utilities at multiple future time points. But to do an optimization, we need to combine those into a single number. In this problem we have returns over two different time periods and then we do a weighted sum of them for each portfolio:
multomegaOpt <- scenario.optimizer(dqScen[c(1,21,41),,], utility=pputil.multomega, extraArgs=list(target=0.03, weights=c(.8, .2)), gross.value=1e6, long.only=TRUE, max.weight=.08, port.size=c(20,30), regulate=c(nbite=100))
The length of the
weights argument to the utility (given via
extraArgs) needs to be one less than the number of time points in the scenarios. Here we have 3 time points for the prices which means 2 returns.
A possibility that isn’t done is to allow cumulative returns. The returns in this problem are from day 1 to day 21, and then from day 21 to day 41. Cumulative returns would be from day 1 to day 21 and then from day 1 to day 41.
You can provide a variance matrix in order to impose variance constraints, tracking error constraints or risk fraction constraints.
- First four moments utility
- Maximize value
- Write your own utility function
- the Portfolio Probe User’s Manual