Task
Write a function that can be used as the utility
argument in scenario.optimizer
.
Preparation
You need R.
Doing it
There are requirements on the arguments and on the output.
Arguments
The first argument should expect a random portfolio object. It is traditionally called rp
.
The second argument should be called scenarios
.
There can be as many additional arguments as you like, with or without default values.
Output
The output needs to be a numeric vector that is as long as the input random portfolio object. (And obviously each value in the output should be for the corresponding random portfolio.)
Body
All of the utility functions in pprobeSup
use the valuation
function from Portfolio Probe, and hence the scenarios
argument must be a matrix or a three-dimensional array of prices. But there is no reason that valuation
has to be used and hence no reason that scenarios
must look anything like an array of prices.
Explanation
scenario.optimizer
presents the utility function a set of portfolios. It then uses the result to select the portfolio in the set with the best utility.
Further details
pputil.multomega
is an example of combining utilities from multiple times. pputil.valueWt
is an example of allowing scenarios to have different importances.
See also
Navigation
- Back to “Scenario optimization”
- Back to “Optimize trades”
- Back to the top level of “Portfolio Probe Cookbook”