Q1 Import stock prices of Netflix, Tesla and Amazon for the last 5 years.

## Loading required package: lubridate
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
## Loading required package: PerformanceAnalytics
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## Registered S3 method overwritten by 'xts':
##   method     from
##   as.zoo.xts zoo
## 
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
## 
##     legend
## Loading required package: quantmod
## Loading required package: TTR
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## Version 0.4-0 included new data defaults. See ?getSymbols.
## Loading required package: tidyverse
## ── Attaching packages ──────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1     ✔ purrr   0.3.2
## ✔ tibble  2.1.3     ✔ dplyr   0.8.3
## ✔ tidyr   0.8.3     ✔ stringr 1.4.0
## ✔ readr   1.3.1     ✔ forcats 0.4.0
## ── Conflicts ─────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ lubridate::as.difftime() masks base::as.difftime()
## ✖ lubridate::date()        masks base::date()
## ✖ dplyr::filter()          masks stats::filter()
## ✖ dplyr::first()           masks xts::first()
## ✖ lubridate::intersect()   masks base::intersect()
## ✖ dplyr::lag()             masks stats::lag()
## ✖ dplyr::last()            masks xts::last()
## ✖ lubridate::setdiff()     masks base::setdiff()
## ✖ lubridate::union()       masks base::union()
## # A tibble: 3,777 x 8
##    symbol date        open  high   low close   volume adjusted
##    <chr>  <date>     <dbl> <dbl> <dbl> <dbl>    <dbl>    <dbl>
##  1 NFLX   2014-12-01  49.3  49.6  48.2  48.8 11964400     48.8
##  2 NFLX   2014-12-02  48.8  50.5  48.7  50.3 14271600     50.3
##  3 NFLX   2014-12-03  50.2  50.7  49.2  50.7 13819400     50.7
##  4 NFLX   2014-12-04  50.4  51.1  49.9  50.1 11853800     50.1
##  5 NFLX   2014-12-05  50.1  50.6  49.7  50.1  9930200     50.1
##  6 NFLX   2014-12-08  49.9  50.0  48.3  48.5 13621300     48.5
##  7 NFLX   2014-12-09  47.8  49.3  47.0  49.1 17976700     49.1
##  8 NFLX   2014-12-10  49.0  49.2  47.7  47.8 12644800     47.8
##  9 NFLX   2014-12-11  48.0  48.7  47.7  47.8 11769100     47.8
## 10 NFLX   2014-12-12  47.4  48.3  47.0  47.8 13521200     47.8
## # … with 3,767 more rows

Q2 Calculate monthly returns.

## # A tibble: 180 x 3
## # Groups:   symbol [3]
##    symbol date              Ra
##    <chr>  <date>         <dbl>
##  1 NFLX   2014-12-31 -0.000585
##  2 NFLX   2015-01-30  0.293   
##  3 NFLX   2015-02-27  0.0749  
##  4 NFLX   2015-03-31 -0.123   
##  5 NFLX   2015-04-30  0.336   
##  6 NFLX   2015-05-29  0.121   
##  7 NFLX   2015-06-30  0.0527  
##  8 NFLX   2015-07-31  0.218   
##  9 NFLX   2015-08-31  0.00630 
## 10 NFLX   2015-09-30 -0.102   
## # … with 170 more rows
## # A tibble: 60 x 2
##    date             Rb
##    <date>        <dbl>
##  1 2014-12-31  0.00184
##  2 2015-01-30 -0.0213 
##  3 2015-02-27  0.0708 
##  4 2015-03-31 -0.0126 
##  5 2015-04-30  0.00827
##  6 2015-05-29  0.0260 
##  7 2015-06-30 -0.0164 
##  8 2015-07-31  0.0284 
##  9 2015-08-31 -0.0686 
## 10 2015-09-30 -0.0327 
## # … with 50 more rows

Q3 Aggregate.

## Ungrouping data frame groups: symbol
## # A tibble: 18,000 x 4
## # Groups:   portfolio [100]
##    portfolio symbol date              Ra
##        <int> <chr>  <date>         <dbl>
##  1         1 NFLX   2014-12-31 -0.000585
##  2         1 NFLX   2015-01-30  0.293   
##  3         1 NFLX   2015-02-27  0.0749  
##  4         1 NFLX   2015-03-31 -0.123   
##  5         1 NFLX   2015-04-30  0.336   
##  6         1 NFLX   2015-05-29  0.121   
##  7         1 NFLX   2015-06-30  0.0527  
##  8         1 NFLX   2015-07-31  0.218   
##  9         1 NFLX   2015-08-31  0.00630 
## 10         1 NFLX   2015-09-30 -0.102   
## # … with 17,990 more rows
## [1] 3
## [1] 0.06385721 0.32707606 0.60906672
##   [1] 0.0638572143 0.3270760642 0.6090667215 0.6674315634 0.0835250188
##   [6] 0.2490434179 0.9486860994 0.0501059340 0.0012079666 0.3082285074
##  [11] 0.3311331158 0.3606383768 0.1122350958 0.6053920568 0.2823728474
##  [16] 0.5903503322 0.2067945255 0.2028551423 0.2308615067 0.0173753274
##  [21] 0.7517631659 0.4117328513 0.0418477936 0.5464193551 0.3082213739
##  [26] 0.2995600218 0.3922186042 0.5221402226 0.1136128758 0.3642469016
##  [31] 0.0857777279 0.6071222641 0.3071000080 0.1944349897 0.0029123276
##  [36] 0.8026526826 0.1962747315 0.0904070712 0.7133181973 0.1588861502
##  [41] 0.1306861357 0.7104277140 0.8440541434 0.1414887353 0.0144571213
##  [46] 0.7966482679 0.0351519424 0.1681997897 0.1807254998 0.6042723870
##  [51] 0.2150021133 0.2389462919 0.5176046358 0.2434490724 0.3562180211
##  [56] 0.3205262697 0.3232557091 0.4174840255 0.1583388411 0.4241771335
##  [61] 0.1504051252 0.3887717656 0.4608231091 0.4359975604 0.2236178115
##  [66] 0.3403846282 0.2422919362 0.5420307070 0.2156773568 0.2298394081
##  [71] 0.4745642522 0.2955963397 0.6258799869 0.0470416916 0.3270783215
##  [76] 0.0375024606 0.5680024794 0.3944950600 0.0067017451 0.4451984253
##  [81] 0.5480998296 0.1778505542 0.0676041283 0.7545453175 0.6894674809
##  [86] 0.1230664686 0.1874660505 0.2058625557 0.2131162025 0.5810212418
##  [91] 0.2013536913 0.3865516332 0.4120946755 0.0952859495 0.0685476365
##  [96] 0.8361664140 0.1381823656 0.7144982803 0.1473193541 0.3775856681
## [101] 0.2000978957 0.4223164362 0.0258709076 0.0040990973 0.9700299951
## [106] 0.2257158658 0.4868523953 0.2874317388 0.4520090686 0.0244057050
## [111] 0.5235852264 0.2803844183 0.6376286114 0.0819869703 0.0697063785
## [116] 0.0290425441 0.9012510774 0.2231925349 0.6202506609 0.1565568042
## [121] 0.0009567274 0.6347501962 0.3642930763 0.4652535468 0.5267369885
## [126] 0.0080094647 0.2455690326 0.5717535003 0.1826774671 0.3309030798
## [131] 0.3034736423 0.3656232778 0.2554464112 0.0708831192 0.6736704696
## [136] 0.1052531952 0.7828613615 0.1118854433 0.7046088497 0.0596986255
## [141] 0.2356925248 0.3761585231 0.1659869477 0.4578545291 0.3481856456
## [146] 0.3822073762 0.2696069782 0.5244447065 0.2792275760 0.1963277175
## [151] 0.6065907234 0.2213197036 0.1720895730 0.3427638044 0.5191903980
## [156] 0.1380457976 0.1276013840 0.4892495682 0.3831490478 0.1110758134
## [161] 0.2420915307 0.6468326559 0.0106872793 0.4357936298 0.5535190909
## [166] 0.1927190754 0.4503961648 0.3568847599 0.5162877000 0.4488447069
## [171] 0.0348675931 0.0060355372 0.2789414194 0.7150230433 0.2701046988
## [176] 0.4184351300 0.3114601711 0.2568394218 0.5781026899 0.1650578883
## [181] 0.1619223342 0.4994306306 0.3386470352 0.3610243672 0.0146180678
## [186] 0.6243575651 0.2348479216 0.0849322565 0.6802198219 0.5817097924
## [191] 0.1324886060 0.2858016016 0.1098506262 0.7657505460 0.1243988278
## [196] 0.6334049297 0.1678676454 0.1987274250 0.0912114033 0.7903820183
## [201] 0.1184065784 0.1932190827 0.1458225858 0.6609583315 0.4054246263
## [206] 0.2570355292 0.3375398444 0.3087824071 0.1639304662 0.5272871268
## [211] 0.6402869809 0.0111529650 0.3485600541 0.6183618691 0.0447616260
## [216] 0.3368765048 0.4133743953 0.2577889026 0.3288367020 0.5067144651
## [221] 0.0076246934 0.4856608415 0.7231894799 0.1317818118 0.1450287083
## [226] 0.5244801973 0.2174437300 0.2580760727 0.4000706738 0.3209665995
## [231] 0.2789627267 0.3616019287 0.6374677932 0.0009302781 0.3023019873
## [236] 0.1927107023 0.5049873104 0.1554450225 0.0488181734 0.7957368041
## [241] 0.0097467289 0.1565462507 0.8337070204 0.0703802700 0.8226276855
## [246] 0.1069920445 0.5283486014 0.1723249501 0.2993264485 0.2353959384
## [251] 0.4908058548 0.2737982068 0.9296928791 0.0003363329 0.0699707880
## [256] 0.6333949310 0.2909886991 0.0756163700 0.0715088164 0.2376923505
## [261] 0.6907988330 0.1826897927 0.3067737606 0.5105364467 0.0269268886
## [266] 0.8082488808 0.1648242306 0.1397872302 0.1511347455 0.7090780244
## [271] 0.4692959369 0.4335684299 0.0971356332 0.1340574222 0.7232535251
## [276] 0.1426890527 0.8350737332 0.0936780574 0.0712482093 0.0399914719
## [281] 0.8819474026 0.0780611255 0.1437206552 0.2424383720 0.6138409728
## [286] 0.1119870632 0.4740645280 0.4139484088 0.4601041367 0.2248874852
## [291] 0.3150083781 0.1636324150 0.2519571851 0.5844103999 0.3345076842
## [296] 0.4942367005 0.1712556153 0.7141235650 0.0222984271 0.2635780079
## Ungrouping data frame groups: symbol
## # A tibble: 300 x 3
## # Groups:   portfolio [100]
##    portfolio symbol weights
##        <int> <chr>    <dbl>
##  1         1 NFLX   0.0639 
##  2         1 TSLA   0.327  
##  3         1 AMZN   0.609  
##  4         2 NFLX   0.667  
##  5         2 TSLA   0.0835 
##  6         2 AMZN   0.249  
##  7         3 NFLX   0.949  
##  8         3 TSLA   0.0501 
##  9         3 AMZN   0.00121
## 10         4 NFLX   0.308  
## # … with 290 more rows
## # A tibble: 6,000 x 3
## # Groups:   portfolio [100]
##    portfolio date            Ra
##        <int> <date>       <dbl>
##  1         1 2014-12-31 -0.0423
##  2         1 2015-01-30  0.0780
##  3         1 2015-02-27  0.0520
##  4         1 2015-03-31 -0.0428
##  5         1 2015-04-30  0.165 
##  6         1 2015-05-29  0.0508
##  7         1 2015-06-30  0.0313
##  8         1 2015-07-31  0.163 
##  9         1 2015-08-31 -0.0436
## 10         1 2015-09-30 -0.0125
## # … with 5,990 more rows

Q4 Calculate performance metrics, CAPM measures.

## # A tibble: 6,000 x 4
## # Groups:   portfolio [100]
##    portfolio date            Ra       Rb
##        <int> <date>       <dbl>    <dbl>
##  1         1 2014-12-31 -0.0423  0.00184
##  2         1 2015-01-30  0.0780 -0.0213 
##  3         1 2015-02-27  0.0520  0.0708 
##  4         1 2015-03-31 -0.0428 -0.0126 
##  5         1 2015-04-30  0.165   0.00827
##  6         1 2015-05-29  0.0508  0.0260 
##  7         1 2015-06-30  0.0313 -0.0164 
##  8         1 2015-07-31  0.163   0.0284 
##  9         1 2015-08-31 -0.0436 -0.0686 
## 10         1 2015-09-30 -0.0125 -0.0327 
## # … with 5,990 more rows
##                      [,1]   [,2]   [,3]   [,4]   [,5]   [,6]   [,7]   [,8]
## portfolio          1.0000 2.0000 3.0000 4.0000 5.0000 6.0000 7.0000 8.0000
## ActivePremium      0.2062 0.2922 0.3111 0.2191 0.1287 0.2628 0.2858 0.2891
## Alpha              0.0129 0.0191 0.0218 0.0140 0.0094 0.0173 0.0172 0.0178
## AnnualizedAlpha    0.1666 0.2543 0.2949 0.1812 0.1185 0.2288 0.2276 0.2357
## Beta               1.2742 1.4214 1.4435 1.3104 1.1293 1.3839 1.4062 1.4133
## Beta-              1.6334 1.6272 1.6176 1.5592 1.3751 1.5781 1.7440 1.6897
## Beta+              1.1036 1.4827 1.5359 1.2069 0.7553 1.3922 1.4616 1.4705
## Correlation        0.7287 0.5734 0.4958 0.6662 0.6498 0.5810 0.6947 0.6546
## Correlationp-value 0.0000 0.0000 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000
## InformationRatio   1.1593 0.9729 0.8368 1.0088 0.6696 0.9182 1.3054 1.1856
## R-squared          0.5310 0.3288 0.2458 0.4438 0.4222 0.3376 0.4826 0.4286
## TrackingError      0.1779 0.3004 0.3718 0.2172 0.1922 0.2862 0.2189 0.2438
## TreynorRatio       0.2630 0.2963 0.3048 0.2655 0.2281 0.2830 0.2949 0.2957
##                      [,9]   [,10]   [,11]   [,12]   [,13]   [,14]   [,15]
## portfolio          9.0000 10.0000 11.0000 12.0000 13.0000 14.0000 15.0000
## ActivePremium      0.2269  0.2794  0.1262  0.2871  0.2688  0.2582  0.2885
## Alpha              0.0143  0.0177  0.0092  0.0173  0.0163  0.0157  0.0201
## AnnualizedAlpha    0.1864  0.2347  0.1166  0.2281  0.2137  0.2051  0.2701
## Beta               1.3224  1.4032  1.1204  1.4076  1.3812  1.3644  1.4188
## Beta-              1.5790  1.6351  1.3806  1.7603  1.7206  1.7122  1.5846
## Beta+              1.2361  1.4394  0.7269  1.4681  1.3930  1.3476  1.4790
## Correlation        0.6709  0.6170  0.6550  0.6985  0.7055  0.7136  0.5098
## Correlationp-value 0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio   1.0466  1.0515  0.6714  1.3226  1.2899  1.2844  0.8196
## R-squared          0.4501  0.3806  0.4290  0.4879  0.4977  0.5092  0.2599
## TrackingError      0.2167  0.2657  0.1880  0.2170  0.2084  0.2010  0.3520
## TreynorRatio       0.2690  0.2909  0.2277  0.2955  0.2879  0.2837  0.2942
##                      [,16]   [,17]   [,18]   [,19]   [,20]   [,21]   [,22]
## portfolio          16.0000 17.0000 18.0000 19.0000 20.0000 21.0000 22.0000
## ActivePremium       0.3075  0.1341  0.1647  0.2244  0.2649  0.1952  0.2513
## Alpha               0.0205  0.0098  0.0113  0.0144  0.0166  0.0124  0.0160
## AnnualizedAlpha     0.2759  0.1239  0.1438  0.1872  0.2182  0.1598  0.2099
## Beta                1.4397  1.1494  1.2141  1.3212  1.3815  1.2604  1.3637
## Beta-               1.6341  1.3586  1.4338  1.5550  1.6329  1.5629  1.5950
## Beta+               1.5263  0.8203  0.9759  1.2354  1.3858  1.0732  1.3408
## Correlation         0.5406  0.6281  0.6447  0.6495  0.6477  0.7096  0.6343
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    0.9297  0.6467  0.7814  0.9807  1.0956  1.0541  1.0200
## R-squared           0.2922  0.3945  0.4156  0.4218  0.4195  0.5035  0.4023
## TrackingError       0.3307  0.2073  0.2108  0.2288  0.2418  0.1851  0.2464
## TreynorRatio        0.3031  0.2287  0.2418  0.2673  0.2850  0.2571  0.2788
##                      [,23]   [,24]   [,25]   [,26]   [,27]   [,28]   [,29]
## portfolio          23.0000 24.0000 25.0000 26.0000 27.0000 28.0000 29.0000
## ActivePremium       0.1577  0.1765  0.2977  0.1354  0.1706  0.2728  0.2852
## Alpha               0.0110  0.0117  0.0191  0.0096  0.0112  0.0165  0.0189
## AnnualizedAlpha     0.1400  0.1504  0.2547  0.1214  0.1431  0.2166  0.2518
## Beta                1.2017  1.2342  1.4271  1.1335  1.2027  1.3868  1.4134
## Beta-               1.4100  1.4738  1.6493  1.4411  1.5685  1.7364  1.6064
## Beta+               0.9495  1.0196  1.4982  0.7445  0.9117  1.4095  1.4633
## Correlation         0.6333  0.6635  0.5904  0.6809  0.7178  0.7064  0.5610
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    0.7347  0.8635  1.0290  0.7624  0.9949  1.3060  0.9262
## R-squared           0.4011  0.4402  0.3485  0.4636  0.5153  0.4990  0.3147
## TrackingError       0.2147  0.2044  0.2893  0.1776  0.1715  0.2089  0.3079
## TreynorRatio        0.2384  0.2474  0.2989  0.2331  0.2490  0.2896  0.2929
##                      [,30]   [,31]   [,32]   [,33]   [,34]   [,35]   [,36]
## portfolio          30.0000 31.0000 32.0000 33.0000 34.0000 35.0000 36.0000
## ActivePremium       0.2419  0.1988  0.2687  0.0929  0.2537  0.2790  0.1727
## Alpha               0.0149  0.0127  0.0162  0.0081  0.0159  0.0168  0.0116
## AnnualizedAlpha     0.1936  0.1634  0.2129  0.1016  0.2082  0.2218  0.1479
## Beta                1.3408  1.2704  1.3792  1.0557  1.3648  1.3947  1.2271
## Beta-               1.6559  1.5495  1.7611  1.2163  1.6197  1.8115  1.4644
## Beta+               1.2822  1.1022  1.3923  0.6076  1.3433  1.4414  1.0028
## Correlation         0.7077  0.6950  0.7131  0.5676  0.6575  0.7033  0.6611
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    1.2095  1.0230  1.3175  0.4185  1.0909  1.3162  0.8454
## R-squared           0.5009  0.4831  0.5085  0.3221  0.4323  0.4947  0.4371
## TrackingError       0.2000  0.1943  0.2039  0.2219  0.2326  0.2120  0.2043
## TreynorRatio        0.2765  0.2579  0.2882  0.2100  0.2803  0.2924  0.2458
##                      [,37]   [,38]   [,39]   [,40]   [,41]   [,42]   [,43]
## portfolio          37.0000 38.0000 39.0000 40.0000 41.0000 42.0000 43.0000
## ActivePremium       0.2944  0.1305  0.2758  0.1320  0.1104  0.1767  0.1489
## Alpha               0.0182  0.0101  0.0166  0.0099  0.0086  0.0131  0.0106
## AnnualizedAlpha     0.2416  0.1284  0.2188  0.1250  0.1078  0.1686  0.1353
## Beta                1.4207  1.1556  1.3900  1.1509  1.0728  1.2547  1.1859
## Beta-               1.6893  1.2994  1.7866  1.3305  1.3720  1.3864  1.3795
## Beta+               1.4887  0.8660  1.4250  0.8368  0.5880  1.1100  0.9164
## Correlation         0.6437  0.5677  0.7085  0.6023  0.6448  0.5409  0.6184
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    1.1678  0.5356  1.3244  0.5946  0.5984  0.6201  0.6771
## R-squared           0.4143  0.3223  0.5020  0.3628  0.4157  0.2926  0.3824
## TrackingError       0.2521  0.2437  0.2083  0.2220  0.1845  0.2849  0.2199
## TreynorRatio        0.2979  0.2245  0.2912  0.2266  0.2230  0.2435  0.2342
##                      [,44]   [,45]   [,46]   [,47]   [,48]   [,49]   [,50]
## portfolio          44.0000 45.0000 46.0000 47.0000 48.0000 49.0000 50.0000
## ActivePremium       0.2271  0.2758  0.0636  0.2986  0.2612  0.2085  0.2432
## Alpha               0.0144  0.0167  0.0071  0.0196  0.0163  0.0136  0.0161
## AnnualizedAlpha     0.1876  0.2203  0.0883  0.2617  0.2135  0.1765  0.2110
## Beta                1.3240  1.3925  0.9799  1.4292  1.3752  1.2964  1.3559
## Beta-               1.5713  1.7135  1.0927  1.6333  1.6379  1.5163  1.5486
## Beta+               1.2410  1.4215  0.4375  1.5016  1.3701  1.1768  1.3253
## Correlation         0.6620  0.6936  0.5112  0.5648  0.6606  0.6399  0.5917
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    1.0227  1.2709  0.2667  0.9674  1.1222  0.9082  0.8924
## R-squared           0.4383  0.4811  0.2613  0.3190  0.4364  0.4094  0.3501
## TrackingError       0.2221  0.2170  0.2386  0.3087  0.2327  0.2295  0.2725
## TreynorRatio        0.2689  0.2906  0.1964  0.2991  0.2836  0.2602  0.2744
##                      [,51]   [,52]   [,53]   [,54]   [,55]   [,56]   [,57]
## portfolio          51.0000 52.0000 53.0000 54.0000 55.0000 56.0000 57.0000
## ActivePremium       0.2604  0.1710  0.1657  0.2300  0.1735  0.1809  0.2010
## Alpha               0.0173  0.0120  0.0110  0.0141  0.0113  0.0118  0.0143
## AnnualizedAlpha     0.2288  0.1541  0.1404  0.1836  0.1449  0.1517  0.1863
## Beta                1.3813  1.2351  1.2046  1.3177  1.2089  1.2387  1.2956
## Beta-               1.5684  1.4106  1.4897  1.6687  1.5746  1.5035  1.4415
## Beta+               1.3867  1.0426  0.9340  1.2209  0.9282  1.0248  1.1981
## Correlation         0.5726  0.5984  0.6938  0.7247  0.7196  0.6843  0.5489
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    0.8928  0.7069  0.9031  1.2290  1.0112  0.9313  0.6956
## R-squared           0.3279  0.3581  0.4814  0.5252  0.5179  0.4682  0.3013
## TrackingError       0.2917  0.2419  0.1835  0.1872  0.1716  0.1943  0.2890
## TreynorRatio        0.2818  0.2428  0.2445  0.2724  0.2501  0.2501  0.2546
##                      [,58]   [,59]   [,60]   [,61]   [,62]   [,63]   [,64]
## portfolio          58.0000 59.0000 60.0000 61.0000 62.0000 63.0000 64.0000
## ActivePremium       0.2152  0.1944  0.1477  0.1650  0.2923  0.2719  0.2783
## Alpha               0.0134  0.0127  0.0106  0.0110  0.0178  0.0165  0.0180
## AnnualizedAlpha     0.1734  0.1633  0.1354  0.1408  0.2362  0.2167  0.2381
## Beta                1.2872  1.2682  1.1850  1.2067  1.4167  1.3864  1.4031
## Beta-               1.6840  1.5081  1.3705  1.4705  1.7130  1.7124  1.6164
## Beta+               1.1366  1.1035  0.9176  0.9447  1.4829  1.4056  1.4382
## Correlation         0.7280  0.6631  0.6104  0.6804  0.6678  0.6984  0.5951
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    1.1926  0.9216  0.6586  0.8656  1.2357  1.2748  0.9918
## R-squared           0.5299  0.4397  0.3726  0.4630  0.4459  0.4877  0.3541
## TrackingError       0.1804  0.2109  0.2243  0.1906  0.2365  0.2133  0.2806
## TreynorRatio        0.2673  0.2549  0.2334  0.2435  0.2973  0.2890  0.2902
##                      [,65]   [,66]   [,67]   [,68]   [,69]   [,70]   [,71]
## portfolio          65.0000 66.0000 67.0000 68.0000 69.0000 70.0000 71.0000
## ActivePremium       0.0709  0.2732  0.0593  0.2566  0.2421  0.2583  0.3053
## Alpha               0.0073  0.0180  0.0069  0.0156  0.0154  0.0159  0.0195
## AnnualizedAlpha     0.0912  0.2391  0.0861  0.2043  0.2018  0.2086  0.2611
## Beta                0.9988  1.3980  0.9658  1.3628  1.3495  1.3689  1.4361
## Beta-               1.1278  1.5919  1.0778  1.6947  1.5825  1.6546  1.6629
## Beta+               0.4776  1.4262  0.4003  1.3420  1.3056  1.3552  1.5213
## Correlation         0.5278  0.5726  0.5051  0.7090  0.6409  0.6815  0.5892
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    0.3046  0.9244  0.2480  1.2626  1.0110  1.1767  1.0452
## R-squared           0.2785  0.3278  0.2551  0.5027  0.4108  0.4644  0.3472
## TrackingError       0.2328  0.2956  0.2391  0.2032  0.2395  0.2195  0.2921
## TreynorRatio        0.2000  0.2876  0.1948  0.2828  0.2749  0.2828  0.3023
##                      [,72]   [,73]   [,74]   [,75]   [,76]   [,77]   [,78]
## portfolio          72.0000 73.0000 74.0000 75.0000 76.0000 77.0000 78.0000
## ActivePremium       0.2978  0.2424  0.3002  0.2850  0.2572  0.2267  0.1365
## Alpha               0.0191  0.0155  0.0187  0.0191  0.0167  0.0147  0.0109
## AnnualizedAlpha     0.2542  0.2024  0.2488  0.2548  0.2199  0.1913  0.1387
## Beta                1.4272  1.3502  1.4285  1.4137  1.3746  1.3269  1.1765
## Beta-               1.6514  1.5805  1.6862  1.5987  1.5825  1.5456  1.2889
## Beta+               1.4986  1.3075  1.5072  1.4641  1.3688  1.2515  0.9357
## Correlation         0.5929  0.6378  0.6286  0.5488  0.6029  0.6320  0.5323
## Correlationp-value  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    1.0358  1.0035  1.1397  0.8975  0.9562  0.9431  0.5014
## R-squared           0.3515  0.4068  0.3952  0.3012  0.3635  0.3995  0.2833
## TrackingError       0.2875  0.2415  0.2634  0.3175  0.2690  0.2403  0.2722
## TreynorRatio        0.2989  0.2749  0.3003  0.2927  0.2808  0.2679  0.2255
##                      [,79]   [,80]   [,81]   [,82]   [,83]   [,84]   [,85]
## portfolio          79.0000 80.0000 81.0000 82.0000 83.0000 84.0000 85.0000
## ActivePremium       0.2515  0.2757  0.2448  0.0437  0.2672  0.1722  0.3197
## Alpha               0.0156  0.0166  0.0150  0.0065  0.0172  0.0116  0.0219
## AnnualizedAlpha     0.2034  0.2187  0.1952  0.0803  0.2268  0.1481  0.2974
## Beta                1.3590  1.3907  1.3390  0.9198  1.3879  1.2272  1.4526
## Beta-               1.6412  1.7514  1.7486  1.0012  1.6052  1.4585  1.6383
## Beta+               1.3290  1.4221  1.2812  0.2953  1.4009  1.0045  1.5567
## Correlation         0.6823  0.7072  0.7203  0.4698  0.6082  0.6559  0.5083
## Correlationp-value  0.0000  0.0000  0.0000  0.0002  0.0000  0.0000  0.0000
## InformationRatio    1.1582  1.3183  1.2677  0.1743  0.9960  0.8314  0.8822
## R-squared           0.4655  0.5001  0.5188  0.2207  0.3699  0.4302  0.2583
## TrackingError       0.2172  0.2092  0.1931  0.2506  0.2683  0.2072  0.3624
## TreynorRatio        0.2799  0.2909  0.2791  0.1876  0.2854  0.2453  0.3088
##                      [,86]   [,87]   [,88]   [,89]   [,90]   [,91]   [,92]
## portfolio          86.0000 87.0000 88.0000 89.0000 90.0000 91.0000 92.0000
## ActivePremium       0.2461  0.2290  0.2182  0.0457  0.2527  0.2022  0.0893
## Alpha               0.0169  0.0141  0.0136  0.0064  0.0154  0.0140  0.0080
## AnnualizedAlpha     0.2230  0.1828  0.1761  0.0800  0.2007  0.1822  0.0999
## Beta                1.3637  1.3142  1.3016  0.9145  1.3553  1.2946  1.0469
## Beta-               1.5279  1.6844  1.6081  1.0426  1.7079  1.4585  1.2024
## Beta+               1.3497  1.2113  1.1796  0.2512  1.3231  1.1881  0.5875
## Correlation         0.5483  0.7277  0.7100  0.4855  0.7173  0.5737  0.5613
## Correlationp-value  0.0000  0.0000  0.0000  0.0001  0.0000  0.0000  0.0000
## InformationRatio    0.8047  1.2370  1.1362  0.1913  1.2796  0.7460  0.3993
## R-squared           0.3006  0.5295  0.5041  0.2357  0.5145  0.3291  0.3151
## TrackingError       0.3058  0.1851  0.1920  0.2388  0.1975  0.2711  0.2236
## TreynorRatio        0.2750  0.2723  0.2666  0.1909  0.2815  0.2557  0.2084
##                      [,93]   [,94]   [,95]   [,96]   [,97]   [,98]   [,99]
## portfolio          93.0000 94.0000 95.0000 96.0000 97.0000 98.0000 99.0000
## ActivePremium       0.2977  0.0135  0.2317  0.1691  0.2523  0.2305  0.1776
## Alpha               0.0204  0.0058  0.0143  0.0111  0.0162  0.0142  0.0122
## AnnualizedAlpha     0.2741  0.0724  0.1851  0.1422  0.2120  0.1845  0.1571
## Beta                1.4291  0.8245  1.3219  1.2095  1.3658  1.3209  1.2454
## Beta-               1.6060  0.8175  1.6582  1.5078  1.5897  1.6466  1.4338
## Beta+               1.5015  0.0867  1.2322  0.9434  1.3465  1.2294  1.0624
## Correlation         0.5208  0.3909  0.7202  0.7019  0.6253  0.7165  0.6118
## Correlationp-value  0.0000  0.0020  0.0000  0.0000  0.0000  0.0000  0.0000
## InformationRatio    0.8631  0.0477  1.2181  0.9377  0.9992  1.2010  0.7528
## R-squared           0.2712  0.1528  0.5187  0.4927  0.3910  0.5134  0.3743
## TrackingError       0.3449  0.2823  0.1902  0.1803  0.2525  0.1919  0.2359
## TreynorRatio        0.2985  0.1726  0.2728  0.2463  0.2790  0.2721  0.2460
##                      [,100]
## portfolio          100.0000
## ActivePremium        0.3064
## Alpha                0.0200
## AnnualizedAlpha      0.2677
## Beta                 1.4380
## Beta-                1.6484
## Beta+                1.5236
## Correlation          0.5663
## Correlationp-value   0.0000
## InformationRatio     0.9893
## R-squared            0.3207
## TrackingError        0.3097
## TreynorRatio         0.3027

Q5 Find the portfolio that is least affected by adverse market movements.

## # A tibble: 100 x 13
## # Groups:   portfolio [100]
##    portfolio ActivePremium  Alpha AnnualizedAlpha  Beta `Beta-` `Beta+`
##        <int>         <dbl>  <dbl>           <dbl> <dbl>   <dbl>   <dbl>
##  1        85         0.320 0.0219           0.297  1.45    1.64    1.56
##  2         3         0.311 0.0218           0.295  1.44    1.62    1.54
##  3        16         0.308 0.0205           0.276  1.44    1.63    1.53
##  4        93         0.298 0.0204           0.274  1.43    1.61    1.50
##  5        15         0.288 0.0201           0.270  1.42    1.58    1.48
##  6       100         0.306 0.02             0.268  1.44    1.65    1.52
##  7        47         0.299 0.0196           0.262  1.43    1.63    1.50
##  8        71         0.305 0.0195           0.261  1.44    1.66    1.52
##  9         2         0.292 0.0191           0.254  1.42    1.63    1.48
## 10        25         0.298 0.0191           0.255  1.43    1.65    1.50
## # … with 90 more rows, and 6 more variables: Correlation <dbl>,
## #   `Correlationp-value` <dbl>, InformationRatio <dbl>, `R-squared` <dbl>,
## #   TrackingError <dbl>, TreynorRatio <dbl>

Portfolio 85 is least affected, it has the highest Alpha.

Q6 What are the weights of the stocks in the portfolio that is least affected by adverse market movements?

The weights of the stocks for the least affected portfolio(85) are NFLX 0.9296928791, TSLA 0.0003363329, AMZN 0.0699707880

Q7 Calculate the Sharpe ratios with an annualized risk-free rate of 2% and a confidence interval of 0.99. Which portfolio would yield the greatest return per risk when VaR is used as the measure of risk?

##                             [,1]         [,2]         [,3]        
## symbol                      "NFLX"       "TSLA"       "AMZN"      
## ESSharpe(Rf=0.2%,p=99%)     "0.1958779"  "0.0405976"  "0.1457544" 
## StdDevSharpe(Rf=0.2%,p=99%) "0.29753614" "0.09310117" "0.36692880"
## VaRSharpe(Rf=0.2%,p=99%)    "0.19587789" "0.04779468" "0.18695785"

Netflix, due to the much higher Sharpe Ratio. ## Q8 Hide the messages, but display the code and its results on the webpage. Hint: Use message, echo and results in the chunk options. Refer to the RMarkdown Reference Guide.

Q9 Display the title and your name correctly at the top of the webpage.

Q10 Use the correct slug.