backtestLeaderboard: Leaderboard of portfolios from the backtest results

Description Usage Arguments Value Author(s) Examples

View source: R/backtestLeaderboard.R

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

1
2
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", "cpu_time", and "failure ratio"), 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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
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("uniform", "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 Aug. 23, 2019, 5:05 p.m.