Chapter 2 Exercise Day 2

2.1 Exercise 1

In “fm_intro1.r,” we use the following as start date and end date.

# In line 35 & 36
date_start <- "2011-01-01"
date_end <- "2020-08-31"

Now, in the assignment, you should change the end date to June 30, 2021, as required. All the other code should remain the same.

2.2 Exercise 2

In “fm_intro1.r” and “fm_intro2.r,” we investigate different stocks. Now in the assignment, you should change them to the stocks that you are insterested. All the others should be the same.

# In line 51 to 58
getSymbols("BAC",src='yahoo', from=date_start, to=date_end)
getSymbols("GE",src='yahoo', from=date_start, to=date_end)
getSymbols("AAPL",src='yahoo', from=date_start, to=date_end)
getSymbols("GOOG",src='yahoo', from=date_start, to=date_end)
getSymbols("AMZN",src='yahoo', from=date_start, to=date_end)
getSymbols("XOM",src='yahoo', from=date_start, to=date_end)
getSymbols("DB",src='yahoo', from=date_start, to=date_end)
getSymbols("XLF",src='yahoo', from=date_start, to=date_end)
# Change the stock, in line 46 to 49
plot(GE[,"GE.Adjusted"])
plot(AMZN[,"AMZN.Adjusted"])
plot(SP500[,6])
plot(VIX[,6])

Note that the in the above chunk, all the codes are commented. This is because I do not want to To find your stocks, you can go to http://finance.yahoo.com.

2.3 Exercise 3

In “fm_intro3.r,” we investigate SP500; in the assignment, change it to your stock. All the others should be the same.

# In line 30
Y00.name0 = "SP500"

Note that since in exercise 1, you have already choose your stocks and store them in the file “casestudy_1_0.RData.” Hence, in exercise 2 and 3, you only need to read the RData file first, and no need to add more stocks in exercise 2 and 3. If you have any questions regarding the second assignment, please feel free to contact the TA.