rand_port: Generates N random portfolios based on an asset universe

Description Usage Arguments Value See Also

Description

This function is slow for 1000 random portfolios. May need to look at Rcpp since bytecode compilation doesn't seem to help, and neither using lapply to get rid of the for loop.

Usage

1
2
rand_port(data, N = 50, K = 1, weights = "equal",
  return_ec = FALSE)

Arguments

data

An xts matrix of periodic returns (NOT prices). These may be daily, weekly, monthly, quarterly or yearly returns.

N

The number of random portfolios to generate

K

The number of asset returns randomly picked (without replacement) at each time period to build each random strategy equity curve.

weights

Specifies how the asset weights will be assigned in each random portfolio. Set to "equal" to specify equal weighting. Set to "uniform" to specify a uniform random distribution for each asset. Set to "average" to calculate the equal weight, daily rebalance equity curve (very fast). By the Central Limit Theorem, all equity curves should be identical. However, statistics are not available when set to "average" (return NAs).

return_ec

Logical. If set to TRUE, all randomly generated equity curves are returned via an object $ec in the returned list. Otherwise, only the average equity curve is returned in $ec, named 'ecavg'.

Value

Returns a list of statistics and matrices related to the random portfolios generated as follows:

$cagr, $mdd, $mar:

Each of these is a numeric vector containing the following statistics for the performance metric: CAGR (the annualized return), the Maximum Drawdown (MDD) and the MAR ratio (CAGR / MDD).

  • mean The average (mean) CAGR over the distribution of portfolios.

  • SD The standard deviation of CAGRs over the distribution of portfolios.

  • skewness The skewness of CAGRs over the distribution of portfolios.

  • kurtosis The kurtosis of CAGRs over the distribution of portfolios.

  • quantiles The next three items are, respectively: First Quartile, Median and Thrid Quartile.

$ec 

An xts matrix containing the average equity curve of all random portfolio, named ecavg, if return_ec = FALSE. If return_ec = TRUE, then all random portfolio equity curves are included, in addition to ecavg.

$cagr_dist, $mdd_dist, $mar_dist: 

Each of these is a named numeric vector containing the value of their statistic for each equity curve. These are useful to visualize the distribution of the statistic.

See Also

quantmod::endpoints()


jeanmarcgp/xtsanalytics documentation built on May 19, 2019, 12:38 a.m.