## # A tibble: 15,116 x 8
## # Groups: symbol [2]
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 MSFT 1989-11-10 0.583 0.590 0.582 0.587 59168000 0.379
## 2 MSFT 1989-11-13 0.587 0.613 0.582 0.612 178905600 0.395
## 3 MSFT 1989-11-14 0.616 0.620 0.597 0.601 95241600 0.388
## 4 MSFT 1989-11-15 0.602 0.620 0.599 0.615 94492800 0.397
## 5 MSFT 1989-11-16 0.618 0.620 0.599 0.608 68054400 0.392
## 6 MSFT 1989-11-17 0.609 0.613 0.602 0.603 31651200 0.389
## 7 MSFT 1989-11-20 0.602 0.602 0.587 0.601 56937600 0.388
## 8 MSFT 1989-11-21 0.601 0.615 0.601 0.612 67116800 0.395
## 9 MSFT 1989-11-22 0.613 0.615 0.608 0.613 38230400 0.396
## 10 MSFT 1989-11-24 0.617 0.618 0.608 0.609 17971200 0.393
## # … with 15,106 more rows
## # A tibble: 62 x 3
## # Groups: symbol [2]
## symbol date yearly.returns
## <chr> <date> <dbl>
## 1 MSFT 1989-12-29 0.0296
## 2 MSFT 1990-12-31 0.730
## 3 MSFT 1991-12-31 1.22
## 4 MSFT 1992-12-31 0.151
## 5 MSFT 1993-12-31 -0.0556
## 6 MSFT 1994-12-30 0.516
## 7 MSFT 1995-12-29 0.436
## 8 MSFT 1996-12-31 0.883
## 9 MSFT 1997-12-31 0.564
## 10 MSFT 1998-12-31 1.15
## # … with 52 more rows
## # A tibble: 2 x 2
## symbol returns_avg
## <chr> <dbl>
## 1 MSFT 0.283
## 2 WMT 0.159
Out of the 3 stocks Microsoft has the highest yearly return, 0.284 ## Q4 Calculate standard deviation of the yearly returns. Which of the three stocks is the riskiest in terms of standard deviation?
## # A tibble: 2 x 2
## # Groups: symbol [2]
## symbol sd.1
## <chr> <dbl>
## 1 MSFT 0.410
## 2 WMT 0.326
Out of the 3 stocks with the standard deviation, Microsoft is the riskiest. Microsoft sd is 0.408 compared to NASDAQ which is 0.277 and Walmart, 0.326.
## # A tibble: 2 x 2
## # Groups: symbol [2]
## symbol skewness.1
## <chr> <dbl>
## 1 MSFT 0.230
## 2 WMT 1.37
## # A tibble: 2 x 2
## # Groups: symbol [2]
## symbol kurtosis.1
## <chr> <dbl>
## 1 MSFT 0.220
## 2 WMT 1.36
During standard deviation the first thing you have to take into account is the downside risk. Each one of the stocks skewness is postive as well as a positive kurtosis which should result in postive returns. Out of the 3, Walmart skewness and kurtosis is the highest which could mean the highest returns
Hint: This is not to be confused with HistoricalVaR you calculated in class. Look for the right code, using tq_performance_fun_options().
## [,1] [,2]
## symbol "MSFT" "WMT"
## DownsideDeviation(0%) "0.1448" "0.0835"
## DownsideDeviation(MAR=0.833333333333333%) "0.1475" "0.0872"
## DownsideDeviation(Rf=0%) "0.1448" "0.0835"
## GainDeviation "0.3295" "0.3131"
## HistoricalES(95%) "-0.5362" "-0.2471"
## HistoricalVaR(95%) "-0.3317" "-0.2215"
## LossDeviation "0.2388" "0.0890"
## MaximumDrawdown "0.6285" "0.3284"
## ModifiedES(95%) "-0.5008" "-0.4960"
## ModifiedVaR(95%) "-0.3513" "-0.2239"
## SemiDeviation "0.2726" "0.1714"
Hint: Make your argument based on the three calculated Sharpe Ratios.
Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.