#' Extract Trading Statistics from a Backtest Parameter Screen
#'
#' @param screen_results list containing backtest parameter screen results
#'
#' @import xts
#' @importFrom magrittr %>% %<>%
#'
#' @return
#' @export
#'
#' @examples pull_trade_stats(strategy_screen_results)
pull_trade_stats <- function(screen_results) {
ret_list <- sapply(unlist(screen_results, recursive = FALSE), `[`, "returns")
w_list <- sapply(unlist(screen_results, recursive = FALSE), `[`, "weights")
parms <- ret_list %>% names() %>%
stringr::str_split("\\.", simplify = TRUE) %>% .[, 1:2] %>%
apply(2, as.numeric)
ret_list %>%
purrr::map2(., w_list,
~ tradr::calc_trade_stats(.x, .y)
) %>%
`names<-`(paste0(parms[, 1], "/", parms[, 2])) %>%
dplyr::bind_rows(.id = "parameter")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.