nate — Jun 25, 2014, 4:16 PM
library("stockPortfolio")
# APPLE, GOOGLE, FACEBOOK, FORD
stockNames = c("APP", "GOOGL", "FB", "FORD")
data = getReturns(stockNames, start="2012-05-02", end="2014-06-02")
plot(data) # time series of stock returns
summary(data) # summary of stock returns
4 stocks, observed once per month between 2012-06-01 and 2014-06-02
APP GOOGL FB FORD
Mean Return 0.012 0.029 0.043 -0.012
pairs(data) # matrix scatterplot of stock returns
model1 <- stockModel(data) # Default Model
summary(model1)
Model: none
25 observations, each one month apart
Dates: 2012-06-01 to 2014-06-02
Short selling is permitted
plot(model1)
model2 <- stockModel(data, model='CCM') # CCM
summary(model2)
Model: CCM
25 observations, each one month apart
Dates: 2012-06-01 to 2014-06-02
Short selling is permitted
plot(model2)
model1OP = optimalPort(model1) # Optimal Portfolio
summary(model1OP)
Model: no model specified.
Expected return: 0.03531
Risk estimate: 0.06238
plot(model1OP, xlim=c(0,0.4), ylim=0.06*c(-1,1.5))
portPossCurve(model1, 10, add=TRUE)
points(0, 0, pch=20, col=2)