| random.portfolio {PortfolioProbe} | R Documentation |
Returns a list of portfolios that satisfy the constraints imposed, but the utility is ignored.
random.portfolio(number.rand=1, ..., out.trade=FALSE, seed=NULL, control=random.portfolio.control, identity=NULL)
number.rand |
the number of random portfolios desired.
This can be zero (in which case |
... |
arguments of |
out.trade |
logical value stating if it should be the random trades ( The full name ("out.trade") needs to be given – no abbreviations are allowed. |
seed |
either The full name ("seed") needs to be given – no abbreviations are allowed. |
control |
a list like the output of 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. |
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 |
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 |
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 |
identity |
the input value of |
class |
|
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.
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.
Tracing generally does not work under Windows.
This help was last revised 2013 April 19.
trade.optimizer, random.portfolio.control,
random.portfolio.utility, randport.eval,
deport.randportBurSt, summary.randportBurSt,
valuation.randportBurSt, head.randportBurSt,
update.randportBurSt, seed.BurSt.
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"))