backtestLeaderboard: Leaderboard of portfolios from the backtest results

View source: R/backtestLeaderboard.R

backtestLeaderboardR 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 portfolioBacktest.

weights

List of weights for the different performance measures as obtained in backtestSummary()$performance (i.e., "Sharpe ratio", "max drawdown", "annual return", "annual volatility", "Sterling ratio", "Omega ratio", "ROT bps", as well as "cpu time" and "failure rate". For example: weights = list("Sharpe ratio" = 8, "max drawdown" = 4).

summary_fun

Summary function to be employed (e.g., median or mean).

show_benchmark

Logical value indicating whether to include benchmarks in the summary (default is TRUE).

Value

List with the following elements:

leaderboard_scores

Matrix with the individual scores for the portfolios (as chosen in weights) and the final score.

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



portfolioBacktest documentation built on April 22, 2022, 9:05 a.m.