Individual Data Lab 2
- Portfolio Construction (portfolio optimization)
Note 1: Review what you have learned in DataCamp assignments (e.g., Introduction to Portfolio Analysis in Python).¶ Note 2: To deep dive into what each function does, use the help function, e.g., run "help(npf.npv)."
1. Craft an all-weather portfolio. Pick your own portfolio of stocks following an investment theme that has stood and will stand the test of time. Extract the data from Yahoo Finance/Refinitiv/any other platforms and explore the statistical distribution of each stock's past 5-year returns.
[*********************100%%**********************] 10 of 10 completed
Stock Name: AAPL
Mean: 0.0011953447742575152
Std. dev / Volatility: 0.0210352256977011
Skewness: -0.05669532989639144
Kurtosis: 4.523925065305724
Stock Name: MSFT
Mean: 0.0011170886067587758
Std. dev / Volatility: 0.019737199708404384
Skewness: 0.019894449281605393
Kurtosis: 6.398696441468854
Stock Name: GOOGL
Mean: 0.0008689011377693623
Std. dev / Volatility: 0.020243704276955043
Skewness: 0.011079078396462229
Kurtosis: 3.4468055344332864
Stock Name: AMZN
Mean: 0.0005473404809143355
Std. dev / Volatility: 0.023126288082679712
Skewness: 0.10459944195167964
Kurtosis: 3.839429938406828
Stock Name: NVDA
Mean: 0.0021045929372477297
Std. dev / Volatility: 0.03404218270152162
Skewness: 0.14045176587413188
Kurtosis: 4.51870062310065
Stock Name: TSLA
Mean: 0.0029205307377940704
Std. dev / Volatility: 0.041589625835712594
Skewness: 0.11119927815139374
Kurtosis: 3.291813379495686
Stock Name: META
Mean: 0.0008706146040383815
Std. dev / Volatility: 0.02784679837270109
Skewness: -0.5181917052521029
Kurtosis: 17.367463393750537
Stock Name: UNH
Mean: 0.0007323608478360226
Std. dev / Volatility: 0.018910245971289295
Skewness: -0.02625573371074217
Kurtosis: 12.186160253282068
Stock Name: WMT
Mean: 0.0005817262317861116
Std. dev / Volatility: 0.013986103902166596
Skewness: 0.1517081062954399
Kurtosis: 13.97443612884718
Stock Name: JPM
Mean: 0.0005124183057082227
Std. dev / Volatility: 0.020308988331634067
Skewness: 0.41239849111542054
Kurtosis: 12.65612942779793
2018-09-11 00:00:00
0.02528301468
0.02482707844
2018-09-12 00:00:00
-0.01241906063
0.001434233286
2018-09-13 00:00:00
0.02415534452
-0.00006532908684
2018-09-14 00:00:00
-0.01135110833
-0.009890105003
2018-09-17 00:00:00
-0.02662626205
-0.03155027437
2. Build an equally-weighted all-weather portfolio of your stock picks. Then, deep dive into the return characteristics of the portfolio (i.e., annualized portfolio return and volatility, portfolio's Sharpe ratio, portfolio's daily return profile - mean, volatility, skewness, kurtosis). Finally, draw the cumulative return of your all-weather portfolio for the past five years.
Portfolio's Annualized Return: 28.860000000000003%
Portfolio's Annualized Volatility/Std. Dev: 4.408
Portfolio's Sharpe Ratio: 5.59 %
Portfolio daily return - Mean : 0.11%
Portfolio daily return - Standard Deviation : 1.7500000000000002%
Portfolio daily return - skewness : -0.3752
Portfolio daily return - Kurtosis : 5.9488
3. Repeat (2) but with the maximum Sharpe portfolio and minimum volatility portfolio.
3.1 With maximum Sharpe portfolio
Expected annual return: 40.6%
Annual volatility: 34.9%
Sharpe Ratio: 1.11
[0.06899 0.04814 0. 0. 0.18588 0.35872 0. 0.00963 0.32865
0. ]
Portfolio's Annualized Return: 23.69%
Portfolio's Annualized Volatility/Std. Dev: 4.3
Portfolio's Sharpe Ratio: 4.53 %
Portfolio daily return - Mean : 0.09%
Portfolio daily return - Standard Deviation : 1.71%
Portfolio daily return - skewness : -0.2973
Portfolio daily return - Kurtosis : 9.2244
3.2 With minimum volatility portfolio.
Expected annual return: 12.7%
Annual volatility: 19.6%
Sharpe Ratio: 0.54
[0. 0. 0.0723 0.05106 0. 0. 0.0009 0.15028 0.58998
0.13548]
Portfolio's Annualized Return: 26.22%
Portfolio's Annualized Volatility/Std. Dev: 4.076
Portfolio's Sharpe Ratio: 5.4 %
Portfolio daily return - Mean : 0.1%
Portfolio daily return - Standard Deviation : 1.6199999999999999%
Portfolio daily return - skewness : -0.4878
Portfolio daily return - Kurtosis : 12.3724
4. [Optional Bonus] With PyPortfolioOpt, how can you further improve your all-weather portfolio construction?
Hint: The Black-Litterman model (https://pyportfolioopt.readthedocs.io/en/latest/BlackLitterman.html) to express subjective views and L2 regularisation to alleviate extreme portfolio allocation (i.e., weights).
/root/venv/lib/python3.9/site-packages/pypfopt/efficient_frontier/efficient_frontier.py:259: UserWarning: max_sharpe transforms the optimization problem so additional objectives may not work as expected.
warnings.warn(
Expected annual return: 9.0%
Annual volatility: 21.4%
Sharpe Ratio: 0.33
Portfolio's Annualized Return: 31.330000000000002%
Portfolio's Annualized Volatility/Std. Dev: 4.21
Portfolio's Sharpe Ratio: 6.4399999999999995 %
Portfolio daily return - Mean : 0.12%
Portfolio daily return - Standard Deviation : 1.67%
Portfolio daily return - skewness : -0.4669
Portfolio daily return - Kurtosis : 8.8655