{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

30.sim_ccm_stockPortfolio

# 30.sim_ccm_stockPortfolio - #=> 2 <=#=> main functions...

This preview shows pages 1–2. Sign up to view the full content.

########################## #===> ((((( 2 ))))) <===# #===> main functions <===# ########################## #===> obtain a lot of tickers via included data set <===# library(stockPortfolio) #DATA: ticker <- c("C", "KEY", "WFC", "JPM", "SO", "DUK", "D", "HE", "EIX", "LUV", "AMR", "AMGN", "GILD", "CELG", "GENZ", "BIIB", "CAT", "DE", "HIT", "IMO", "MRO", "HES", "YPF", "^GSPC") #===> get data <===# gr1 <- getReturns(ticker, start='1999-12-31', end='2004-12-31') summary(gr1) gr1\$R # returns gr1\$ticker # original ticker gr1\$period # sample spacing gr1\$start # when collection started gr1\$end # when collection ended #===> simple model building <===# ======================================================================== #No model - classical Markowitz model: m1 <- stockModel(gr1, drop=24) # drop index summary(m1) #Find the point of tangency: op1 <- optimalPort(m1) #Type op1 to see the composition of the point of tangency: op1 #Plot the 24 stocks and point G (point of tangency): plot(op1, xlim=c(0,0.3)) #Add the portfolio possibilities curve: portPossCurve(m1, add=TRUE) #Add the tangent (the following will draw the line only up to G: segments(0,0,op1\$risk,op1\$R) #If you want to extend the tangent beyond G: slope <- (op1\$R-0)/op1\$risk segments(0,0,2*op1\$risk, m1\$Rf+slope*2*op1\$risk) #Add a cloud of points for visualization: portCloud(m1) ========================================================================

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}