Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
FINM8006 Advanced Investment: Assignment
Instruction
This assignment can be done in python or R. However, python is recommended and preferred.
Your tutor can give better help or feedback in python. If your answer is written in jupyter
notebook, you can write both text and codes in the ipynb notebook and submit just the
notebook. Otherwise, you need to submit your code file in addition to your report. Please
make sure your codes are executable. This is a group assignment, each group only needs to
submit one submission. The assignment has two parts, one on industry portfolio and one on
Chinese stock market. It accounts for 20% of your overall grade. The due date is 5pm, April
28, 2023. Be sure to include your group number on your report. Below are a list of python
library you may consider importing.
import numpy as np
from numpy.linalg import inv
from pandas import Series, DataFrame
from pandas.tseries.offsets import MonthEnd
import pandas as pd
import statsmodels.api as sm
import statsmodels.formula.api as smf
from statsmodels.iolib.summary2 import summary_col
import pandas_datareader.data as web
from datetime import datetime
import matplotlib.pyplot as plt
%matplotlib inline
plt.rc('figure', figsize=(8, 5))
import warnings
warnings.filterwarnings('ignore')
Mean Variance with Industry Portfolio
In lecture, we solve mean-variance optimal portfolio with risk-free asset by solving
1
min
1
2
′Σ s.t. ′(̄ − ) = −
(what is and here?)
The solution for optimal portfolio is
= Σ−1(̄ − )
= − (̄ − )′Σ−1(̄ − )
and the optimized portfolio variance:
̂2 = ′Σ =
( − )2
(̄ − )′Σ−1(̄ − )
Shrinkage with implied expected returns
Suppose risk aversion is such that investment in risky assets is 60% of the total portfolio.
Suppose also the required rate of return is the average portfolio return of 60-40 portfolio in
the last three years. Suppose also the variance-covariance matrix estimate Σ is accurate. You
will investigate the returns of two mean-variance approach:
• estimate ̄ from last 36 months of data, use mean-variance with required return to
get the optimal , use current period risk free rate as , then calculate the realized
returns.
• estimate ̄ as a shrinkage estimation of
̃ = 0.5̄ + 0.5
, where ̄ is estimated as above, and is the implied asset expected returns from the
end of last period risky asset weights and portfolio variance with the parameters given.
Then get the optimal and calculate the realized returns
The data we use can be found on Fama-French Data Library, ‘10 Industry Portfolios’ has
industry portfolio returns and market caps of 10 industries, ‘Fama/French 5 Factors (2x3)’
has factor returns you need.
(1) Starting from January 2015 to December 2022, calculate and plot the cumulative returns
of total portfolio using the two approach.
(2) At which time period shrink MV significantly overperform historical MV? Can you ex-
plain why?
2
Liquidity in Chinese market
Stock market in China is often said to be driven by individual traders. data ‘china_monthly_2010.csv’
contains monthly stock information for stocks on Chinese market from 2010 to 2021. Variables
are as follows:
• stkcd: stock code
• date: date of monthly end date
• mretwd: stock return
• msmvosd: market value of tradable shares
• amihud: a measure of stock iliquidity, the higher the value the lower a stock’s liquidity
• mktret: market return
• rf: risk free rate
CAPM
Starting from 2013, estimate stock beta using data in the last 3 years (require at least 24
month of data to be in the sample, otherwise drop the data). For each month, sort stocks into
deciles (portfolios of 10), calcualte the value weighted average of portfolio beta and portfolio
returns. Then take the time series average of beta and return for each decile.
(1) Plot the average excess return against beta. What’s the feature of your graph? Is it
consistent with CAPM?
Size and Liquidity Factors
Stocks that are smaller in size and more illiquid earn higher expected returns. You will create
a size and a liquidity factor using last period market value as a proxy for size and using last
period amihud measure as a proxy for illiquidity. From 2013, sort stocks in each month into
quitiles according to size and illiquidity, then form a hedge portfolio for size and liquidity,
respectively, by substracting portfolio returns of portfolios expected to be lower from portfolio
returns of portfolios expected to be higher. Stocks within portfolio are equally weighted.
(2) Create the size and liquidity factors and plot their cumulative returns on the same graph.
• What’s the feature of your graph before and after 2017?
• Is there anything you can think of that can explain the difference before and after 2017?
3
CAPM within size and liquidity sorts
You will repeat your beta sorted plotting procedure above on data from year 2018. Except,
this time, you will sort stocks into size quintile or liquidity quintile first, then within each size
quintile or liquidity quintile you sort stocks into beta quintiles then form portfolios.
(3) Produce two graphs, one for average excess return-beta plots for each size quintile, one
for average excess return-beta plots for each liquidity quintile. Which of the size and
liquidity quitles are more consistent with the CAPM model?