vignettes/portfolio_files/0001.R

library(CVXR)

# GMVP
portfolio_fun <- function(data, ...) {
  X <- as.matrix(diff(log(data$adjusted))[-1])
  Sigma <- cov(X)
  w <- Variable(nrow(Sigma))
  prob <- Problem(Minimize(quad_form(w, Sigma)), 
                  constraints = list(w >= 0, sum(w) == 1))
  result <- solve(prob)
  return(as.vector(result$getValue(w)))
}

Try the portfolioBacktest package in your browser

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

portfolioBacktest documentation built on April 22, 2022, 9:05 a.m.