## # A tibble: 22,677 x 8
## # Groups: symbol [3]
## symbol date open high low close volume adjusted
## <chr> <date> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 ^IXIC 1990-04-24 422. 422. 419. 419. 126790000 419.
## 2 ^IXIC 1990-04-25 420 421. 419. 421. 121710000 421.
## 3 ^IXIC 1990-04-26 422. 422 419. 421. 115930000 421.
## 4 ^IXIC 1990-04-27 421. 421. 418. 418 116010000 418
## 5 ^IXIC 1990-04-30 418. 420. 417 420. 105790000 420.
## 6 ^IXIC 1990-05-01 422 422. 421. 422. 124130000 422.
## 7 ^IXIC 1990-05-02 423. 424. 422. 424. 143260000 424.
## 8 ^IXIC 1990-05-03 425 427. 424. 425. 160850000 425.
## 9 ^IXIC 1990-05-04 427. 429. 426. 429. 136810000 429.
## 10 ^IXIC 1990-05-07 429. 432. 429. 431. 122690000 431.
## # … with 22,667 more rows
## # A tibble: 93 x 3
## # Groups: symbol [3]
## symbol date yearly.returns
## <chr> <date> <dbl>
## 1 ^IXIC 1990-12-31 -0.108
## 2 ^IXIC 1991-12-31 0.569
## 3 ^IXIC 1992-12-31 0.155
## 4 ^IXIC 1993-12-31 0.147
## 5 ^IXIC 1994-12-30 -0.0320
## 6 ^IXIC 1995-12-29 0.399
## 7 ^IXIC 1996-12-31 0.227
## 8 ^IXIC 1997-12-31 0.216
## 9 ^IXIC 1998-12-31 0.396
## 10 ^IXIC 1999-12-31 0.856
## # … with 83 more rows
## # A tibble: 3 x 2
## symbol returns_avg
## <chr> <dbl>
## 1 ^IXIC 0.137
## 2 MSFT 0.275
## 3 WMT 0.160
## # A tibble: 3 x 2
## # Groups: symbol [3]
## symbol sd.1
## <chr> <dbl>
## 1 ^IXIC 0.278
## 2 MSFT 0.403
## 3 WMT 0.328
Microsoft is the riskiest stock in terms of standard deviation.
Hint: when the return distribution is not normal, the standard deviation is not an appropriate measure of risk. One can use skewness and kurtosis to detect non-normal returns. Take returns_yearly and pipe it to tidyquant::tq_performance. Use the performance_fun argument to compute skewness. Do the same for kurtosis.
## # A tibble: 3 x 2
## # Groups: symbol [3]
## symbol skewness.1
## <chr> <dbl>
## 1 ^IXIC 0.179
## 2 MSFT 0.272
## 3 WMT 1.42
## # A tibble: 3 x 2
## # Groups: symbol [3]
## symbol kurtosis.1
## <chr> <dbl>
## 1 ^IXIC 0.304
## 2 MSFT 0.424
## 3 WMT 1.52
Standard deviation is not an appropriate measure of risk for stocks, since distribution is not normal. When we look at skewness Walmart has a tendency to show strong positive returns more often than Microsoft or the Nasdaq composite. However, this comes with a higher kurtosis, meaning Walmart has a tendency to show greater extremes in returns both positive and negative.
## [,1] [,2] [,3]
## symbol "^IXIC" "MSFT" "WMT"
## DownsideDeviation(0%) "0.1244" "0.1448" "0.0829"
## DownsideDeviation(MAR=0.833333333333333%) "0.1279" "0.1475" "0.0866"
## DownsideDeviation(Rf=0%) "0.1244" "0.1448" "0.0829"
## GainDeviation "0.2050" "0.3227" "0.3157"
## HistoricalES(95%) "-0.3991" "-0.5362" "-0.2471"
## HistoricalVaR(95%) "-0.3541" "-0.3317" "-0.2197"
## LossDeviation "0.1599" "0.2388" "0.0885"
## MaximumDrawdown "0.6718" "0.6285" "0.3206"
## ModifiedES(95%) "-0.4068" "-0.4907" "-0.5226"
## ModifiedVaR(95%) "-0.2974" "-0.3419" "-0.2183"
## SemiDeviation "0.1891" "0.2663" "0.1707"
The stock with the greatest downside risk is Microsoft. With a historical ES of -.5263, this indicates that 5% of the worst returns for Microsoft yielded -53.62% return. Using the Historical VaR, with 95% confidence we can determine that the worst expected return is -33.17%, slightly less than NASDAQ’s Historical VaR. However, NASDAQ’s historical ES is much lower than Microsoft’s. The Semi-Deviation for Microsoft is also higher than NASDAQ’s, indicating that the standard deviation ofreturns below the mean return is .2663.
## [,1] [,2] [,3]
## symbol "^IXIC" "MSFT" "WMT"
## ESSharpe(Rf=0%,p=95%) "0.3358210" "0.5601502" "0.3054329"
## StdDevSharpe(Rf=0%,p=95%) "0.4915047" "0.6829151" "0.4871825"
## VaRSharpe(Rf=0%,p=95%) "0.4593460" "0.8039521" "0.7310281"
Using the 95% confidence interval, Microsoft appears to be the best choice for stock, as it has the highest Sharpe Ratio in both ES and VaR form. However, this comes with a higher standard deviation in Sharpe Ratio.
## [,1] [,2] [,3]
## symbol "^IXIC" "MSFT" "WMT"
## ESSharpe(Rf=0%,p=99%) "0.2397804" "0.3925834" "0.1596074"
## StdDevSharpe(Rf=0%,p=99%) "0.4915047" "0.6829151" "0.4871825"
## VaRSharpe(Rf=0%,p=99%) "0.2847852" "0.4616862" "1.2950882"
At the 99% confidence interval, we can deduce that Walmart is the best choice of stock. It has the lowest standard deviation of Sharpe Ratio and the highest Sharpe Ratio, indicating that it is the lowest risk stock.