Description Usage Arguments Value Author(s) Examples
View source: R/backtestLeaderboard.R
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.
1 2 
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 
List with the following elements:

Matrix with the individual scores for the portfolios (as chosen in 

Matrix with all the performance measures for the portfolios. 

Error messages generated by each portfolio on each dataset. Useful for debugging and give feedback to the portfolio managers of the different portfolios. 
Daniel P. Palomar and Rui Zhou
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

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.