backtestSelector: Selector of portfolio backtest results

View source: R/backtestSummary.R

backtestSelectorR Documentation

Selector of portfolio backtest results

Description

Select the results from a portfolio backtest.

Usage

backtestSelector(
  bt,
  portfolio_index = NULL,
  portfolio_name = NULL,
  measures = NULL
)

Arguments

bt

Backtest results as produced by the function portfolioBacktest.

portfolio_index

Index number of a portfolio, e.g., 1 means to select the performance of the first portfolio recorded in bt.

portfolio_name

String name of a portfolio, e.g., "GMVP" means to select the performance of portfolio with name "GMVP" in bt. Only considered when portfolio_index is not passed.

measures

String vector to select performane measures (default is all) from "Sharpe ratio", "max drawdown", "annual return", "annual volatility", "Sterling ratio", "Omega ratio", and "ROT bps".

Value

List with the following elements:

performance

Performance measures selected by argument measures.

error

Error status (TRUE or FALSE) of portfolio over each dataset (TRUE is when the portfolio function generates an error or the maximum CPU time is exceeded).

error_message

Error messages generated by portfolio function over each dataset. Useful for debugging purposes.

cpu time

CPU usage by portfolio function over each dataset.

portfolio

Portfolio weights generated by portfolio function over each dataset.

return

Portfolio returns over each dataset.

wealth

Portfolio wealth (aka cumulative returns or cumulative P&L) over each dataset.

Author(s)

Rui Zhou and Daniel P. Palomar

Examples


library(portfolioBacktest)
data("dataset10")  # load dataset

# define your own portfolio function
EWP_portfolio <- function(dataset, ...) {
  N <- ncol(dataset$adjusted)
  return(rep(1/N, N))
}

# do backtest
bt <- portfolioBacktest(list("EWP" = EWP_portfolio), dataset10)

# extract your interested portfolio result
bt_sel <- backtestSelector(bt, portfolio_name = "EWP")
names(bt_sel)



dppalomar/portfolioBacktest documentation built on April 27, 2022, 3:27 a.m.