3.2) For financial data you will need the “quantmod” package. From that package you can…
- User
3.2) For financial data you will need the “quantmod” package. From that package you can use the getSymbols function to download stock data. Example: You can get the stock price of Microsoft (ticker:MSFT) getSymbols(“MSFT” , src = "yahoo", from = start_date, auto.assign = TRUE) EC 233 HOMEWORK OZAN HATIPOGLU BOGAZICI UNIVERSITY ECONOMICS 3 Where the start date is in yyyy-mm-dd format. Please learn all the options including beginning and end dates and frequencies (daily, weekly, etc. and the price available) that are available for getSymbols function. For future reference you can use getSymbols also to download macro data from the Federal Reserve system by defining the source as (src = “FRED”) You can also make a list of stocks by defining it first as a vector and populating it afterwards.stocks<- vector() stocks <- c(“MSFT, GOOG”) And get multiple stock data as: getSymbols(stocks , src = "yahoo", from = start_date, auto.assign = TRUE) Now, download weekly prices of two stocks of your choice between 2005-05-05 and 2023- 10-01 and draw their price data, you can use the closing price. Next, find the max, min, range, average and calculate the standard deviation for the price of each stock. Calculate also the coefficient of variation. Which stock is riskier? Calculate the weekly return, defined as percentage or logarithmic change or from a week earlier, for each stock and draw them together in the same graph. Now calculate a rolling window (8 weeks) of standard deviations of each stock, i.e first observation for this series is the standard deviation which is calculated using the first eight weeks, the second one is calculated using the next 8 weeks starting at the second week (hence the name rolling window). Is there a change? Comment. Now draw the returns and the rolling window of standard deviations in the same graph separately for each stock. Find the correlation coefficient between returns and standard deviations. Comment.
- Assistant