scenario.optimizer {pprobeSup}R Documentation

Scenario optimization of a portfolio

Description

Uses random portfolios, a utility function (written in R) and an array of scenarios to optimize a portfolio.

Usage

scenario.optimizer(scenarios, utility, prices = NULL, 
	existing = NULL, regulate = NULL, extraArgs = NULL, 
	maximize = TRUE, verbose = TRUE, start.sol = NULL, 
	checkPositive = TRUE, ...)

Arguments

scenarios

either a matrix or a three-dimensional array – most likely filled with asset prices.

If a matrix, then the rows correspond to assets and need to be named with the asset identifiers. The columns represent different scenarios.

If a 3-D array, then the rows are times, the columns are assets and the third diminesion is scenarios.

utility

a function that takes a random portfolio object as its first argument, it must have an argument called 'scenarios', and it may have additional arguments as well. It needs to return a single number for each random portfolio.

prices

named numeric vector of prices to be used in the generation of the random portfolios.

If not given, then the first scenario (at the first time if there are multiple times) is used.

existing

named numeric vector giving the existing portfolio. The numbers are the number of units (shares, contracts, etc.) for the assets.

regulate

named numeric vector giving controls for the optimization process. See the Details section for specifics.

extraArgs

a list with named components giving additional arguments to the utility function.

maximize

logical value: do you want to maximize or minimize the utility function?

verbose

logical value: if TRUE, then the progress of the optimization is printed at each iteration.

start.sol

named numeric vector (or a portfolio object containing a trade component) giving a suggestion for a starting trade.

checkPositive

logical value: should scenarios be checked to all positive values and no missing values?

...

the constraints to be given to random.portfolio from Portfolio Probe. This minimally includes a specification of the amount of money in the portfolio.

Value

a list with components:

new.portfolio

named numeric vector giving the number of units for each asset in the optimized portfolio.

trade

named numeric vector giving the number of units for each asset in the trade from the existing portfolio to new.portfolio.

existing

named numeric vector giving the number of units for each asset in the existing portfolio – the same as the input existing.

utility.value

the value of the utility for the optimized portfolio.

optim

a vector giving some details of the optimization process.

violated

either NULL or a vector of strings giving the constraints that are violated by the solution.

This is only given when the regulate value returnstart is TRUE.

timestamp

two character strings giving the time and date of the start and finish of the optimization.

call

an image of the call that created the object.

Side effects

The S language random seed is changed or created.

Dependency

This depends explicitly on the random.portfolio function from Portfolio Probe. Utilities are likely to depend on the valuation method for random portfolio objects.

Details

OVERVIEW OF OPTIMIZATION PROCESS

There is an initial set of random portfolios that satisfy the problem constraints. The utility is evaluated on each of the random portfolios, and the portfolio with the best utility is selected as the candidate for the optimized portfolio.

Then some number of iterations is done. At each iteration some number of random portfolios is generated that are within some radius of best solution as well as satisfying the other constraints of the problem. If a better solution is found among the new random portfolios, then that becomes the new candidate solution. If none of the random portfolios have a better utility, then the radius is reduced.

The optimization terminates if either the radius becomes too small, or the limit on iterations is exhausted.

REGULATE VALUES

There are a number of values that can be given in the regulate argument:

DISCLAIMER

The only sense in which the values in regulate are optimal is that minimum effort was put into deciding their values.

RETURN STARTING SOLUTION

To get the utility and other information for a particular trade, then the regulate value of returnstart must be TRUE and start.sol must be given.

WRITING YOUR OWN UTILITY

The utility functions that are provided are intended merely as examples. You can easily write your own utility function to satisfy your needs.

The function must take a first argument that is expected to be a random portfolio object. It must also have an argument named scenarios. It can have any additional arguments that you desire.

The other key requirement is that the function needs to return a numeric vector that is as long as the number of random portfolios given it.

Most likely a call to valuation (from Portfolio Probe) will be made using the random portfolios and the scenarios.

Several of the utility functions show how to get either the mean utility or a quantile of the utility. pputil.valueWt shows how to give different weights to different scenarios. pputil.multomega shows how to get a single utility by doing a weighted sum of utilities at different times. It is perfectly feasible to have both weighting schemes in a single utility function.

Restrictions

Distance constraints are not allowed to be imposed (for the real problem). It would be possible to lift this restriction by adding some ugly code.

Testing status

In test suite, mildly tested.

Revision

This help file was last revised 2013 May 02.

See Also

pp.historyScenarios, pp.normalScenarios, pp.priceScenarios

pputil.fourmoments, pputil.meanvar, pputil.omega, pputil.value.

Examples

# get the utility of a particular portfolio
omegaTest  <- scenario.optimizer(scenWith2timepoints, 
	utility=pputil.omega, extraArgs=list(target=0.04), 
	max.weight=.07, gross=1e7, long.only=TRUE, 
	existing=NULL, port.size=c(20,30),
	start.sol=myPortfolio, regulate=c(returnstart=TRUE))

# see also the examples in the pputil.* help files

[Package pprobeSup version 1.00 Index]