R/index.R

Defines functions compute_index

Documented in compute_index

#' Compute Index
#'
#' Function to compute an Index given the prices and weights
#'
#' @param prices  component's prices, in currency (€, $, ...) per share
#' @param weights component's weights, in number of shares
#'
#' @return the index value given the prices and weights.
#' @export
#'
#' @examples
#' myIndex <- compute_index(c(1.50, 2.22, 3.88, 10.66),
#'                          c(654, 543, 123, 10))
#'
compute_index <- function(prices, weights){

  index <- prices %*% weights
  invisible(index)

}
bpvgoncalves/DynHedge documentation built on Dec. 19, 2021, 10:52 a.m.