auxPort

The package auxPort provides various functions necessary fo cleaning stock data, optimizing portfolios, and evaluating their performance.

Installation

You can install this version of the package from Github with:

install.packages("devtools")
library(devtools)
install_github("antshi/auxPort")

Examples

These are basic examples to show you how to use the some of the functionality.

Example 1: Data Cleaning

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)

Example 2: Portfolio Optimization

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)


antshi/auxPort documentation built on Oct. 27, 2020, 1:16 p.m.