portfolio_fun <- function(data, ...) {
X <- diff(log(data$adjusted))[-1] # compute log returns
Sigma <- cov(X) # compute SCM
# design GMVP
w <- solve(Sigma, rep(1, nrow(Sigma)))
w <- w/sum(abs(w)) # it may not satisfy w>=0
return(w)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.