optimize.portfolio.rebalancing: Portfolio Optimization with Rebalancing Periods

Description Usage Arguments Details Value Author(s) See Also Examples

Description

Portfolio optimization with support for rebalancing periods for out-of-sample testing (i.e. backtesting)

Usage

1
2
3
4
5
6
7
8
9
optimize.portfolio.rebalancing_v1(R, constraints,
  optimize_method = c("DEoptim", "random", "ROI"), search_size = 20000,
  trace = FALSE, ..., rp = NULL, rebalance_on = NULL,
  training_period = NULL, rolling_window = NULL)

optimize.portfolio.rebalancing(R, portfolio = NULL, constraints = NULL,
  objectives = NULL, optimize_method = c("DEoptim", "random", "ROI"),
  search_size = 20000, trace = FALSE, ..., rp = NULL,
  rebalance_on = NULL, training_period = NULL, rolling_window = NULL)

Arguments

R

an xts, vector, matrix, data frame, timeSeries or zoo object of asset returns

constraints

default NULL, a list of constraint objects

optimize_method

one of "DEoptim", "random", "pso", "GenSA", or "ROI"

search_size

integer, how many portfolios to test, default 20,000

trace

TRUE/FALSE if TRUE will attempt to return additional information on the path or portfolios searched

...

any other passthru parameters to optimize.portfolio

rp

a set of random portfolios passed into the function to prevent recalculation

rebalance_on

character string of period to rebalance on. See endpoints for valid names.

training_period

an integer of the number of periods to use as a training data in the front of the returns data

rolling_window

an integer of the width (i.e. number of periods) of the rolling window, the default of NULL will run the optimization using the data from inception.

portfolio

an object of type "portfolio" specifying the constraints and objectives for the optimization

objectives

default NULL, a list of objective objects

Details

Run portfolio optimization with periodic rebalancing at specified time periods. Running the portfolio optimization with periodic rebalancing can help refine the constraints and objectives by evaluating the out of sample performance of the portfolio based on historical data.

If both training_period and rolling_window are NULL, then training_period is set to a default value of 36.

If training_period is NULL and a rolling_window is specified, then training_period is set to the value of rolling_window.

The user should be aware of the following behavior when both training_period and rolling_window are specified and have different values

This function is a essentially a wrapper around optimize.portfolio and thus the discussion in the Details section of the optimize.portfolio help file is valid here as well.

This function is massively parallel and requires the 'foreach' package. It is suggested to register a parallel backend.

Value

a list containing the following elements

Author(s)

Kris Boudt, Peter Carl, Brian G. Peterson

See Also

portfolio.spec optimize.portfolio

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
## Not run: 
data(edhec)
R <- edhec[,1:4]
funds <- colnames(R)

portf <- portfolio.spec(funds)
portf <- add.constraint(portf, type="full_investment")
portf <- add.constraint(portf, type="long_only")
portf <- add.objective(portf, type="risk", name="StdDev")

# Quarterly rebalancing with 5 year training period
bt.opt1 <- optimize.portfolio.rebalancing(R, portf,
optimize_method="ROI",
rebalance_on="quarters",
training_period=60)

# Monthly rebalancing with 5 year training period and 4 year rolling window
bt.opt2 <- optimize.portfolio.rebalancing(R, portf,
optimize_method="ROI",
rebalance_on="months",
training_period=60,
rolling_window=48)

## End(Not run)

Example output

Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: xts
Loading required package: foreach
Loading required package: PerformanceAnalytics

Attaching package: 'PerformanceAnalytics'

The following object is masked from 'package:graphics':

    legend

Warning message:
executing %dopar% sequentially: no parallel backend registered 

PortfolioAnalytics documentation built on May 1, 2019, 10:56 p.m.