Portfolio construction

Investors are interested in reducing risk and maximizing return of their investment and creating a portfolio does this job provided we have constructed it by keeping in mind the investor risk-return profile. I will guide you through creating an efficient frontier that can help you to measure risk with respect to your return expectation. For that, I will start extracting data for four securities. The first line of code creates a new environment to store data; the next few lines are for symbols list, data starting date, and extracting data using getSymbols():

>stockData<- new.env() 
> symbols <- c("MSFT","FB","GOOG","AAPL")
>start_date<- as.Date("2014-01-01")
>getSymbols(symbols, src="yahoo", env=stockData, from=start_date) ...

Get Learning Quantitative Finance with R now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.