Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
Computational Finance – HW 2
Complete the following problems in your home work groups. All calculations must be done in MATLAB.
When the question tells you to report or output an answer, your code must print it using the disp or
printf functions. When the question tells you to plot something, your code must produce a MATLAB
figure. When the question asks you to describe something or compare, you need to answer it in your own
words. Type your answer as a comment in your code file. See the Sample Homework on OneDrive as a
template. I recommend starting each script file with commands to close all figures, clear the workspace,
and clear the command window: close all; clc; clear;
1. A momentum strategy is a strategy that bets on the idea that stocks that have gone up over a recent
period (“winners”) will continue to go up (i.e., they will maintain their momentum) and stocks that
have had recent lower returns (“losers”) will continue to lose. In this question, you will construct two
different momentum portfolios and evaluate their performance coming out of the recession during the
2007-08 Financial Crisis. First, you must sort stocks based on momentum during the estimation period.
Based on this sort, you then decide which stocks you will go long (take a positive position in) and which
stocks you will short (take a negative position in). To assess the performance of the strategy, you
calculate the returns on this portfolio during the test period. It is crucial that the test period come after
the estimation period i.e., that the portfolio is constructed based on information known at the time of
construction.1
You will find 3 data files attached to this homework:
- returns.xlsx has monthly stock returns for many companies
- marketcaps.xlsx has total market capitalizations (stock price x shares outstanding) for these
companies. You can assume that the columns in this file are in the exact same order as in the returns
file and that the dates match up.
- F-F_Research_Factors.TXT has Fama-French factor data
You will also find a code file: estimate_capm() is a function that Professor Vadim Elenev wrote to
help you estimate CAPM betas and alphas. Put it in the folder where you write your code and use it like
you would any MATLAB function. Refer to its documentation for help.
a. Set the estimation period to Jan 2009 – Dec 2009 and estimate momentum of each stock, where
the momentum is:
= (1 + 1) × (1 + 2) × … × (1 + −1) × (1 + )
1 Think about the alternative. If you can use today’s information to construct a portfolio in the past, you would just pick the
stocks that you know will do well. Investing becomes much easier if you have a time machine!
Stuart Urban Computational Finance 2021 Fall II
Where is the stock’s return in month t and T is the number of months in your estimation period
(in this case, T=12).
b. Identify which stocks are in the lowest quintile and which stocks are in the highest quintile by
momentum. That is, find stocks whose MOMs are lower than the 20th percentile MOM, and those
that are higher than the 80th percentile MOM.2 Plot a histogram3 of all MOMs and add vertical lines
to the plot to indicate these percentiles.
We will now construct a portfolio where we will go long (take positive positions in) the highest-MOM
stocks and we will go short (take negative positions in) the lowest-MOM stocks.
The idea behind long-short portfolios is as follows. The portfolio manager goes long stocks that she
believes will perform well and short similar stocks that she believes will perform less well (not
necessarily poorly). The less-well performing stocks act as a hedge. For example, if the overall market
goes down, the long leg of the portfolio will go down, but the short leg will go up. As a result, she
expects to generate a high return with limited market exposure.
c. Construct an equal-weighted portfolio that goes long the highest-quintile MOMs and short the
lowest-quintile MOMs (based on quintiles measured during the estimation period), and calculate
the returns on this portfolio over the test period of Jan 2010 – Dec 2010.
Hint: if there are 2 long stocks A and B and 2 short stocks C and D, the return on your portfolio at
time t should be , = , − ,, where , = 0.5 , + 0.5 , is the equal-weighted return on
the “long leg” and , = 0.5 , + 0.5 , is the equal-weighted return on the “short leg.” If each
leg had 3 stocks instead, the weights would be 1/3 = 0.333… instead of 0.5, and so on.
d. Report the monthly mean and volatility of this portfolio (during the test period) in percent.
Additionally, report the monthly mean and volatility for the return on the market portfolio during
the same period (remember that the Fama-French data you have contains the market excess
returns, but you can construct the total market returns using the risk-free rate). How did your
momentum portfolio do relative to the market portfolio?
When constructing long-short portfolios, we should make sure that these returns are not just
compensation for beta. Recall CAPM – you can always generate a high expected return by investing in a
high-beta stock. But then you’re just taking on extra market risk. So, let’s check to see if the
momentum portfolio you constructed is a high-beta portfolio or if it indeed has high alpha – positive
performance unrelated to its market exposure.
e. Estimate the CAPM beta and alpha. Report beta as-is and alpha in percent. Has this portfolio
delivered good performance? How about risk-adjusted good performance? Why or why not?
It is well-known that smaller stocks (by market capitalization) tend to generate larger returns than
bigger stocks. Consequently, it may be that we can take more advantage of momentum among smaller
stocks and improve our portfolio’s performance. We can create a “momentum/size sort” portfolio that
includes both factors by taking a long position in stocks that are in the highest momentum quintile and
2 Use the prctile() function
3 Use the histogram() function
Stuart Urban Computational Finance 2021 Fall II
the lowest size (by market capitalization) quintile, while taking a short position in stocks that are in the
lowest momentum quintile and the highest size quintile.
f. Repeat steps (c) through (e) but this time using a momentum/size sort portfolio by using your
momentum quintiles from before and the stock sizes (i.e., market caps) in the last month of your
estimation period to determine the size quintiles. How do your results change? Are your main
conclusions altered?