The package auxPort provides various functions necessary fo cleaning stock data, optimizing portfolios, and evaluating their performance.
You can install this version of the package from Github with:
install.packages("devtools") library(devtools) install_github("antshi/auxPort")
These are basic examples to show you how to use the some of the functionality.
library(auxPort) dates <- as.Date(sp500[,1], format="%d.%m.%Y", stringsAsFactors=FALSE) find_weekends(dates)
prices <- as.matrix(sp500[,-1]) find_nas(prices, all=FALSE) find_nas(prices, all=TRUE)
returns <- sp500_rets[,-1] Sigma <- cov(returns) image(Sigma) naive <- port_estim_naive(Sigma) gmv <- port_estim_gmv(Sigma) gmv_lasso <- port_estim_solver(Sigma, lambda1=0.0001) matplot(cbind(naive, gmv, gmv_lasso), type="l", col=c("black", "green", "darkgreen"), lty=1, lwd=1, ylab="Weights") legend("topleft", legend=c("Naive", "GMV", "GMV-lasso"), col=c("black", "green", "darkgreen"), lty=1, lwd=1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.