Financial Econometrics CW Tutorial
Outline
1 Assignment Outcomes and Milestones
2 Brief Summary of Replication Paper
3 Data and methodology
4 FAQ and hints
Assignment Outcomes and Milestones
learn how to construct portfolios and strategies, and calculate their expected returns
improve your programming skills (running regressions, producing plots, computing descriptive statistics, cleaning data)
exercise fin. econometrics that you are learning Timeline:
Feb 6, 2023 – Point 1. Portfolio construction (30 %) Feedback
Mar 6, 2023 – Point 1 (potentially updated) +
Point 2. Trading strategies analysis (45%) and Point 3. Factor regressions (25%)
Note that the 5-page limit is for all 3 points.
Financial Econometrics CW Tutorial January 2023 3 / 15
Paper Summary
1/N Strategy
Simple trading rule:
‘fraction 1/N of wealth is allocated to each of the N assets available for investment at each rebalancing date’.
Horserace of 14 mean-variance optimal portfolios against 1/N benchmark.
For considered assets, during the considered time period none of the 14 outperforms consistently the simple 1/N rule.
Based on simluation analysis, one needs 3000 months of formation period for mean-variance portfolio to outperform the 1/N rule (yep, that’s 250 years).
Financial Econometrics CW Tutorial January 2023 4 / 15
Your coursework vs Paper
Your CW
Strategies Formation period Trading period Rebalancing Assets
Paper
1/N + 14 more strategies 60M, 120M
1M
Monthly
Stock indices & portfolios
(dozens)
1/N only
6M, 12M, 48M
1M, 3M, 6M
Monthly
Stocks (thousands)
You will also see in the paper bunch of robustness checks and simulation analysis. For the purposes of the coursework, you can safely ignore those parts as well as the 14 mean-variance strategies.
Financial Econometrics CW Tutorial January 2023 5 / 15
So, what exactly you need to do (or Methodology)
First, load the data:
1 Daily stocks data for January 2, 1990 – December 31, 2014 Column 1: stocks’ permno – 16147 ’tickers’
Column 2: dates – 6301 dates
Column 3: SICs – 1354 industry codes (you won’t need these) Column 4: prices – well… prices
Column 5: market capitalisations
2 Some more data (you will need these for Points 2-3 only)
F-F5 factors – simple returns expressed as % (so divide them by 100)
Now, we can construct the portfolios
Financial Econometrics CW Tutorial January 2023 6 / 15
Methodology cnt’d
You will consider:
1 2 3
formation periods of J = 6, 12, 48 months, and trading periods of K = 1, 3, 6 months;
thus, 9 ‘J-K’ strategies in total.
Financial Econometrics CW Tutorial January 2023 7 / 15
Methodology cnt’d: Portfolios Construction
In the beginning of each month t repeat the following steps:
1. define the stock universe (filter out stocks with missing data over
the past J months);
2. long each stock in the universe; hold these positions for K months.
At this point you already have everything for Point 1 of the assignment: report the average number of stocks and average market capitalisation for each of the 9 strategies.
Financial Econometrics CW Tutorial January 2023 8 / 15
Methodology cnt’d: Strategy Return Computation
Method 1 (without volatility targeting):
1 XN t
rt = N ri,t
t i=1
simple average of all Nt stocks’ returns in month t;
Nt is the number of stocks in the stock universe in month t. Method 2 (with volatility targeting, VT):
rVT =r target t tˆt
target is annualised volatility of market returns over Jan 1990-Dec 2014 from FF-5 datafile (up to you whether to use daily or monthly data for this calculation);
ˆt is volatility of daily strategy returns in previous J months (analogically to formula (5) in Barosso et al).
Financial Econometrics CW Tutorial January 2023 9 / 15
Methodology cnt’d
Point 2:
– calculate and analyse the requested statistics of 9 strategies with and
without volatility targeting (hence 18 return series in total now).
Point 3:
– analyse the exposure of all strategies returns to the F-F5 factors as well
as the alpha (18 regressions in total).
Financial Econometrics CW Tutorial January 2023 10 / 15
FAQ
1. Do I have to use R? – No, please use any software of your choice. To convert data file into csv please run the following lines of code:
library (data . table )
load(”assignment data18.RData”) fwrite(data, ”assignment data18.csv”)
Writing to csv takes 10-20 seconds (Don’t use R’s native ’write.csv’ function – it takes hours)
2. Do I need to submit the code? – No, don’t submit your code. Instead, include a methodology section which outlines all of your steps (portfolio construction, missing value treatment, etc.). This will enable me to verify your results.
Financial Econometrics CW Tutorial January 2023 11 / 15
FAQ
3. What exactly should I submit in Point 1? – You should include (1) an output table and (2) a methodology section which outlines all of your steps and assumptions (portfolio construction, missing value treatment, etc.) detailed enough for the reader to replicate your results. This will enable me to verify your results.
4. Could you give us an example of the output table in Point 1? – This should be a table (2×9) reporting number of stocks and average market equity for each portfolio. Here is what that table could look like.
Numbers are made up. Your table should be fully populated and have no ‘…’ in it.
Financial Econometrics CW Tutorial January 2023 12 / 15
FAQ
5. What function would you suggest for …?
1 … selecting first/last value (say, last market cap or price within a
month)? – first()/last()
to be used inside group by()
2 … counting the stocks? – length() of unique permnos or n() or sum()
of indicator function
3 … computing smth over multiple periods? – lead()/lag()t
first make sure the data are sorted in correct order, e.g. using arrange()
Financial Econometrics CW Tutorial January 2023 13 / 15
More hints
6. Treatment of zero and NaN prices
One does NOT just remove the individual rows that have zero or NaN prices. This will distort your portfolio allocations – even if you remove the rows with zero or NaN price, you are still keeping the rest of the prices for that month for that stock; as a result you might include the stock that was delisted into your stock universe and later into your portfolio.
7. Overlapping trading periods
– for trading periods of 3 and 6 months, each month you will have up to K = 3, 6 overlapping portfolios initiated 1 month apart;
– in each month average out the returns on portfolios initiated this month and in previous K-1 months;
– for trading period of 1 month there is no overlapping. 8. Stock return calculation
Use group by(permno) when calculating the stock returns to ensure that you do not use the last price of the previous stock by mistake.
Financial Econometrics CW Tutorial January 2023 14 / 15
Good Luck! Start /,eı es eı ’pi:/
Financial Econometrics CW Tutorial January 2023 15 / 15