backtestLeaderboard {portfolioBacktest} | R Documentation |
Leaderboard of portfolios from the backtest results
Description
Leaderboard of portfolios according to the backtesting results
and a ranking based on the combination of several performance criteria.
Since the different performance measures hava different ranges and distributions,
each is first transformed according to its empirical distribution function (along
the empirical distribution of the portfolios being ranked) to obtain percentile
scores. After that transformation, each of the measures has an empirical uniform
distribution in the interval [0, 100]
and can be weighted to obtain the final ranking.
Usage
backtestLeaderboard(
bt = NA,
weights = list(),
summary_fun = median,
show_benchmark = TRUE
)
Arguments
bt |
Backtest results as produced by the function |
weights |
List of weights for the different performance measures as obtained
in |
summary_fun |
Summary function to be employed (e.g., |
show_benchmark |
Logical value indicating whether to include benchmarks in the summary (default is |
Value
List with the following elements:
leaderboard_scores |
Matrix with the individual scores for the portfolios (as chosen in |
leaderboard_performance |
Matrix with all the performance measures for the portfolios. |
error_summary |
Error messages generated by each portfolio on each dataset. Useful for debugging and give feedback to the portfolio managers of the different portfolios. |
Author(s)
Daniel P. Palomar and Rui Zhou
Examples
library(portfolioBacktest)
data(dataset10) # load dataset
# define your own portfolio function
quintile_portfolio <- function(data, ...) {
X <- diff(log(data$adjusted))[-1]
N <- ncol(X)
ranking <- sort(colMeans(X), decreasing = TRUE, index.return = TRUE)$ix
w <- rep(0, N)
w[ranking[1:round(N/5)]] <- 1/round(N/5)
return(w)
}
# do backtest
bt <- portfolioBacktest(quintile_portfolio, dataset10,
benchmark = c("1/N", "index"))
# see all performance measures available for the ranking
backtestSummary(bt)$performance
# show leaderboard
leaderboard <- backtestLeaderboard(bt, weights = list("Sharpe ratio" = 6,
"max drawdown" = 1,
"ROT (bps)" = 1,
"cpu time" = 1,
"failure rate" = 1))
leaderboard$leaderboard_scores