1 | opt.outputMeanVol(opt, returns, digits = NULL, names = NULL)
|
opt |
|
returns |
|
digits |
|
names |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (opt, returns, digits = NULL, names = NULL)
{
wts = opt$weights
sigmasq = as.numeric(t(wts) %*% var(returns) %*% wts)
sigma = sqrt(sigmasq)
mu.ret = apply(returns, 2, mean)
mu = as.numeric(t(wts) %*% mu.ret)
if (is.null(digits)) {
names(sigma) = "sigma"
names(mu) = "mu"
output = c(wts, mu, sigma)
}
else {
if (is.null(names)) {
output = list(wts = wts, mean = mu, vol = sigma)
output = lapply(output, round, digits)
}
else {
output = list(wts, mu, sigma)
names(output) = names
output = lapply(output, round, digits)
}
}
output
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.