R/cal_yield.R

Defines functions cal_yield

Documented in cal_yield

#' calculate the yield
#'
#' calculate the yield from net value
#'
#' @param x vector of net value
#' @param fisrt, the first day yield
#'
#' @examples
#' data(m_index_acount)
#' cal_yield(m_index_acount$acount)
#'
#' @export
#'
cal_yield <- function(x, first = 0)
{
  return(c(first, (x[-1] / x[-length(x)]) - 1))
}
cloud-brain/backtest documentation built on Feb. 6, 2020, 11:17 p.m.