R/tracking_error.R

Defines functions tracking.error

Documented in tracking.error

#' @title Tracking Error
#' @description Calculates the Tracking Error
#' @param R1 Returns of the portfolio
#' @param R2 Returns of the benchmark
#' @details Tracking error is the divergence between the price behavior of a position or a portfolio and the price behavior of a benchmark.
#' @examples
#' tracking.error(funds$ret1, funds$rfr)
#' @return Calculates the Tracking error of the security
#' @import xts
#' @import zoo
#' @rdname tracking.error
#' @export
tracking.error = function(R1, R2){
  te = sd(risk.premium(R1, R2)) * sqrt(252)
  te
}

Try the rportfolio package in your browser

Any scripts or data that you put into this service are public.

rportfolio documentation built on July 1, 2020, 10:35 p.m.