35.multigroup_stockPortfolio

35.multigroup_stockPortfolio - #Put them together data<...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
########################################## #===> ((((( Multi group model ))))) <===# ########################################## #===> obtain a lot of tickers via included data set <===# library(stockPortfolio) #Stock and index tickers: 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") #Industries: ind <- c("Money Center Banks", "Money Center Banks", "Money Center Banks", "Money Center Banks", "Electrical Utilities", "Electrical Utilities", "Electrical Utilities", "Electrical Utilities", "Electrical Utilities", "Major Airlines", "Major Airlines", "Biotechnology", "Biotechnology", "Biotechnology", "Biotechnology", "Biotechnology", "Machinery", "Machinery", "Machinery", "Fuel Refining", "Fuel Refining", "Fuel Refining", "Fuel Refining", "Index")
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: #Put them together: data <- as.data.frame(cbind(ticker, ind)) ticker <- data$ticker ind <- data$ind #===> 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 #Multi group model (short sales, Rf=0): mc <- stockModel(gr1, model='MGM', drop=24, industry=ind) #===> identify the optimal portfolio for multi group model<===# opmc <- optimalPort(mc) #Plot the optimal portfolio and the stocks: plot(opmc) #Add the portfolio possibilities curve: portPossCurve(mc, add=TRUE, riskRange=5) #Draw the tangent line: slope <- (opmc$R-0)/opmc$risk segments(0,0,2*opmc$risk, mc$Rf+slope*2*opmc$risk)...
View Full Document

Ask a homework question - tutors are online