View source: R/backtestLeaderboard.R
backtestLeaderboard | R Documentation |
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.
backtestLeaderboard( bt = NA, weights = list(), summary_fun = median, show_benchmark = TRUE )
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
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
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.