random.portfolio {PortfolioProbe} | R Documentation

## Generate Random Portfolios

### Description

Returns a list of portfolios that satisfy the constraints imposed, but the utility is ignored.

### Usage

    random.portfolio(number.rand=1, ..., out.trade=FALSE,
    	seed=NULL, control=random.portfolio.control, identity=NULL)

### Arguments

`number.rand` | the number of random portfolios desired. This can be zero (in which case `NULL` is returned), but can not be negative.
`...` | arguments of `trade.optimizer` need to be given that specify the constraints. Arguments concerning utility are ignored.
`out.trade` | logical value stating if it should be the random trades (`TRUE`), or the resulting random portfolios (`FALSE`) that are to be returned. The full name ("out.trade") needs to be given – no abbreviations are allowed.
`seed` | either `NULL`, a single integer or a random seed to use for the computations. If `NULL` or an integer, then a random seed is created by calling `seed.BurSt`. The full name ("seed") needs to be given – no abbreviations are allowed.
`control` | a list like the output of `random.portfolio.control` or a function that produces such a list. The full name ("control") needs to be given – no abbreviations are allowed.
`identity` | an arbitrary object, most likely a string or an integer. This is merely added unchanged to the output. It is useful when generation of portfolios is repeatedly done in parallel. The whole name ("identity") must be used – no abbreviations allowed.

### Value

a list of the random portfolios or trades. This has attributes:

`call` | an image of the call that created the object.
`timestamp` | two character strings giving the time and date of creation (the start time and the end time of the call).
`seed` | the random seed for the generator internal to the C code.
`version` | a vector stating the versions of C and S code used. This attribute is suppressed when the object is printed.
`checkinput` | list with components `prices`, `variance`, `expected.return` and `existing` that contains a few values of each input. This is used in `randport.eval` and `update` to make sure that the data for these inputs are what you expect they are. This attribute is suppressed when the object is printed.
`trade.portfolio` | a length 2 logical vector stating if the values represent the trade or the portfolio. When there is no existing portfolio, both are `TRUE`.
`funevals` | the number of portfolios that were examined during the search. This attribute is suppressed when the object is printed.
`iterhistory` | only present if the `save.iterhistory` control argument is `TRUE`, and is seldom of any interest. If present, it is a numeric vector giving the value of the objective at each iteration of the algorithm for the last random portfolio that is generated. The value of the objective is a measure of how much a given portfolio violates the constraints.
`identity` | the input value of `identity`. This is suppressed when the object is printed.
`class` | `"randportBurSt"`. There are several methods for this class.

### Side Effects

the S language random seed is created or changed (unless the `seed` argument is given explicitly and is not `NULL`).

An error occurs if no portfolios were found that satisfy the constraints, unless `throw.error` (a control variable) is set to `FALSE`. This generally only happens if the constraints are inconsistent, or at least very restrictive. In the latter case, you can adjust control arguments to search more thoroughly.

### Details

It is possible that fewer portfolios are generated than requested. This happens if too many attempts fail. There is a warning for this unless the `do.warn` item `randport.fail` is set to `FALSE`.

If you want a bound on the utility, then you can use `random.portfolio.utility`. However, this is substantially slower than using `random.portfolio`.

There are `randportBurSt` methods for several generic functions.

When tracing is done, a message gives: the number of optimizations, the number of satisfactory portfolios found, and the number of failures.

### Bugs

Tracing generally does not work under Windows.

### Revision

This help was last revised 2013 April 19.

### See Also

`trade.optimizer`, `random.portfolio.control`, `random.portfolio.utility`, `randport.eval`, `deport.randportBurSt`, `summary.randportBurSt`, `valuation.randportBurSt`, `head.randportBurSt`, `update.randportBurSt`, `seed.BurSt`.

### Examples

    randport1 <- random.portfolio(100, prices, varian, long.only=TRUE,
    	bench.constr=c(spx=.04^2/252), lin.constraints=cntrysect.conmat,
    	lin.bounds=cntrysect.bounds, gross.value=1e6)

    randtrade1 <- random.portfolio(100, prices, varian, long.only=TRUE,
    	bench.constr=c(spx=.04^2/252), lin.constraints=cntrysect.conmat,
    	lin.bounds=cntrysect.bounds, gross.value=1e6, out.trade=TRUE)

    # now use it
    randalpha1 <- numeric(length(randtrade1))
    for(i in 1:length(randtrade1)) {
    	randalpha1[i] <- trade.optimizer(prices, varian, long.only=TRUE,
    	  bench.constr=c(spx=.04^2/252), lin.constraints=cntrysect.conmat,
    	  lin.bounds=cntrysect.bounds, gross.value=1e6, funeval=0,
    	  start=randtrade1[[i]])$alpha.values
    }

    # same thing again
    randalpha1 <- unlist(randport.eval(randtrade1, keep="alpha.values"))
    # and again
    randalpha1 <- unlist(randport.eval(randport1, keep="alpha.values"))

[Package PortfolioProbe version 1.06 Index]