PortStat <- function(data,port.budget,port.names,data.length){
library(corpcor)
data <- apply(data,2,PriceToReturn)
if(dim(data)[1] > data.length){
data <- data[(dim(data)[1] - data.length +1):dim(data)[1],]
}
port <- port.budget/sum(port.budget)
cov.mat <- cov.shrink(data,verbose=FALSE)
mu <- apply(data,2,mean)
sd.port <- c(sqrt(t(port) %*% cov.mat[port.names,port.names] %*% port))*sqrt(220)
mu.port <- c(mu[port.names] %*% port)*220
out <- c(sd.port,mu.port)
return(out)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.