## 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)
Run the code above in your browser using DataLab