View source: R/runMultipleBacktests.R
| runMultipleBacktests | R Documentation |
Runs n_simulations independent portfolio backtests, each time drawing
a random subset of stocks from stock_list. For every simulation a full
backtest is executed via runPortfolioBacktest(), and an individual plot
can optionally be saved. After all simulations finish, the function
averages the cumulative return series across simulations and can save a
summary plot of those averaged returns.
runMultipleBacktests(
n_simulations,
portfolio_size,
seed = NULL,
return_portfolio,
stock_list,
buildPortfolios = buildPortfolios,
market_return = NULL,
rebalance_on = NULL,
rolling_window = NULL,
optimize_method = "CVXR",
moment_list = NULL,
save_plot = TRUE,
plot_path = "./",
plot_name = "backtest",
plot_main = NULL,
plotType = "both",
save_avg_plot = TRUE,
avg_plot_path = "./",
avg_plot_name = "avg_backtest",
avg_plot_main = NULL,
avgPlotType = "both",
colorSet = NULL,
ltySet = NULL,
lwdSet = NULL
)
n_simulations |
Integer. Number of independent backtest simulations to run. |
portfolio_size |
Integer. Number of stocks to randomly sample from
|
seed |
Integer. Random seed passed to |
return_portfolio |
An |
stock_list |
Character vector. Universe of stock tickers from which
|
buildPortfolios |
A function that accepts a character vector of
selected stock tickers and returns a named list of
|
market_return |
An |
rebalance_on |
Character string passed to |
rolling_window |
Positive integer. Length of the rolling estimation window in periods. |
optimize_method |
Character string specifying the solver. Default |
moment_list |
If different moment functions are passed into multiple GMV
portfolios, please define each moment function via this parameter. For the
portfolio that do not require moment function, please pass NULL. Example:
|
save_plot |
Logical. Whether to save the plot to a PNG file. Default |
plot_path |
Character string. Full file path for the each simulation output.
Required when |
plot_name |
Plot name for each simulation output. Default |
plot_main |
Plot title for each simulation PNG output. |
plotType |
"cumRet", "drawdown", or the default is "both" |
save_avg_plot |
Logical. Whether to save the the average cumulative
returns plot to a PNG file. Default |
avg_plot_path |
Character string. Full file path for the average simulation output.
Required when |
avg_plot_name |
Plot name for average simulation output. Default |
avg_plot_main |
Plot title for the average simulation PNG output. |
avgPlotType |
"cumRet", "drawdown", or the default is "both" |
colorSet |
Optional character vector of colors passed to |
ltySet |
Optional integer vector of line types passed to |
lwdSet |
Optional integer vector of line width passed to |
A named list with four elements:
resultsA list of length n_simulations. Each element
contains the returns component returned by
runPortfolioBacktest() for that simulation.
selected_stocks_allA list of length n_simulations.
Each element is a character vector of the tickers chosen for that
simulation.
avg_algorithm_returnsAn xts object containing the
element-wise average of all simulations' algorithm return series.
avg_cumulative_returnAn xts object containing the
element-wise average of all simulations' cumulative return series.
args(runMultipleBacktests)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.