16.15. Assignment 4#
16.16. Write your name and simon email#
Please write names below
[Name, student ID, email]:
[Name, student ID, email]:
[Name, student ID, email]:
In this assignment we will explore different portfolio allocation rules. We apply these approaches to “alpha” type strategies or to combine different systemtic factors. We will use there the 5 factor model as a laboratory to think about these allocation rules.
The five factor model includes 5 excess return portfolios
Market minus risk-free rate
Small minus big (go long small caps, short large caps)
High minus Low (go long High Book-to-market stonks and short low Book to market stonks–also called value minus growth)
Robust minus Weak ( go long high profitability firms short low profitability firms)
Conservative minus aggressive Investment ( go long low investment firms short high investment firms)
16.17. Exercises#
Exercise 1
Let’s start by importing our data.
We will import monthly data on the five factor model.
You should go to Ken French website and figure out the name of the data set.
An alternative way is to use
from pandas_datareader.famafrench import get_available_datasets
(you need to !pip install pandas-datareader first!)
And call get_available_datasets to see the name of the different data set available (hint: try datasets = get_available_datasets()
to get different data set names)
TIP: When you complete and run the code below, the data set should have 7 columns: Date, factors and the risk-free rate.
Also note that there is a lot of stuff on a given file, i.e., ds
below will contain multiple datasets associated with this dataset you choose. (Hint: check the data type of ds
).
You have to choose the right one–the one that contains monthly return data!
Note that the data is percent, so a 5% return shows us as 5 and not 0.05. While we will not cumulate returns here, it is important to keep this in mind.
Finally make sure the index is in the datetime format
Here is the code to get you started!
What would you replace _
with in web.DataReader(_, 'famafrench')
? Recall what we had in datasets
.
import ___ as pd
import pandas_datareader.data as web
ds = web.DataReader(_, 'famafrench')
df=ds[_]
df.____ = pd.to_datetime(df.____.to_timestamp())
Exercise 2
Let’s start by computing the mean-variance efficient portfolio across these five factors.
I would like you start by using the full sample to estimate the weights and the leverage up the weights so this portfolio has the same in sample volatility as the market portfolio.
Report weights and the Sharpe ratio of the MVE portfolio.
Hint: take a look at your Assignment 3.
Exercise 4
Now lets do the same thing for four additional portfolio allocation rules
Use an Equal weight approach to invest across these factors.
Risk Parity 1: Assume expected returns of each factor are of the form \(E[R^i_t]=c*\sigma(R^i_t)\) so they are exactly proportional to their standard deviation. Meaning that instead of estimating expected excess returns you simply use the vector of standard deviations \(c[\sigma(R^1_t),\sigma(R^2_t),\sigma(R^3_t),..]\). Apply the MVE formula given the estimated covariance matrix and these “estimates” for expected returns
Risk Parity 2: Also Assume that all factors have zero correlation with each other
Minimum-Variance investing: Assume expected excess return are the same across assets, for example \(E[R^i_t]=1\)
Exercise 5
We now should have 5 strategies (MVE plus the 4 above). Compute the full sample Sharpe Ratio of all five trading strategies. Also compute the one of the market portfolio as a comparison.
Discuss what we can learn and not learn from such exercise. What are the issues with interpreting the differences in the full sample performance?
# your code here
Your discussion here.
Exercise 6
Lets pursue a rolling approach to evaluate these strategies.
I would like you to split the sample down the middle–how to find the middle of the sample?
And then proceed by estimating in the first half, then looking at the performance in the following month.
Then adding this month to the estimation sample, and so on.
I provide code below that constructs this for the standard MVE strategy.
I advise you to
import numpy as np
Rp=pd.DataFrame([],index=[],columns=[],dtype=float) # Create an empty dataframe
Re=__ # Dataframe that holds monthly returns for factors
start_date=__ # Compute the start date of performance evaluation
for date in Re[start_date:].index:
# I am using DateOffset function to tell python to stop one month before
# so the estimation sample will be all months up to one month before the return that I
# I will be trading
# this guarantees the strategy is VALID with respect to information
ERe=Re[:date- pd.DateOffset(months=1)].mean()
CovRe=Re[:date- pd.DateOffset(months=1)].cov()
Target_vol=___ # target volatiility so that it matches market portfolio volatility as in Exercise 3
X=np.linalg.inv(CovRe) @ ERe* (Targetvol/(ERe @ np.linalg.inv(CovRe) @ ERe)**0.5) # Can you see why we are doing this?
#store the strategy returns of the relevant month
Rp.at[date,'MVE']=X @ Re.loc[date]
The above is the code for MVE strategy. You should write similar codes for the rest of the four strategies in Exercise 4.
Exercise 7
Compute their Sharpe Ratios, volatilities, and expected returns
Is there a conclusion? What statistical test can you to see if the differences in expected returns is statistically significant?
Would that be enough to know that one of them is better strategy? What source of difference of expected returns might not be so interesting for an investor
Your discussion here.