PC Lab 2 — Applying the CAPM
A small hedge fund hires you to measure the systematic risk of its stocks — estimate betas and alphas, build a high-beta portfolio, and then test whether the CAPM actually survives the data.
The setting
Your Meridian internship paid off: a small, unsophisticated hedge fund has poached you. The economics here are different — a hedge fund lives off its returns, not its size, so passive investing is not an option.
The fund manager has a job for you:
“I need to know what I’m actually exposed to. Take our eight stocks and tell me their systematic risk — the betas. And while you’re at it: everyone quotes the CAPM at me in meetings. Check whether it actually works before I bet money on it.”
Your goals: estimate each stock’s beta and alpha, build a portfolio with the risk profile the boss wants, and then run the experiment most textbooks skip — testing the CAPM against the data. (Spoiler from the lecture: the empirical beta–return line is much flatter than theory predicts. Now you get to see it yourself.)
Background
Everything you need is in this week’s lecture: CAPM and APT — the Security Market Line, what beta means, and why the model may fail in practice (leverage constraints, betting-against-beta). Same dataset as Lab 1, so you already know the data.
The data
The same 8 stocks + S&P 500 you used in PC Lab 1: daily prices from 2012, columns Date, AAPL, BA, T, MGM, AMZN, IBM, TSLA, GOOG, sp500. (The assignment slides refer to PCLab_Data.xlsx — use the CSV above, it is the same data.)
Your assignment
Part 1 — Eyeball the risk (Task 1)
- Scatter-plot each stock’s daily returns against the market’s daily returns.
- Comment: is there an apparent correlation? How strong? For which stock is it strongest?
Part 2 — Estimate alpha and beta (Task 2)
- Run the CAPM as an OLS regression of each stock’s returns on market returns over the whole period (assume the risk-free rate is 0). Are the estimates significant?
- Plot beta and alpha for the 8 stocks. Which stock has the highest (lowest) beta? And alpha? Comment.
- Use observed vs. predicted returns to compute the error terms ε and plot their histogram per stock. Comment.
- The boss wants high risk for high return: select the 4 riskiest assets, form an equally weighted portfolio of them, and estimate its return from your estimated parameters.
Part 3 — Does the CAPM survive the data? (Task 3)
- For each year, estimate each stock’s beta over the previous year (252 business days).
- Compare each stock’s realized average annualized return in year y to the CAPM-predicted one (beta from year y−1, market return from year y).
- Scatter realized returns against beta — or invent a better plot.
- Try betas estimated over longer or shorter windows.
- Comment in light of the lecture, with as much economic interpretation as possible. This part is graded on thinking, not on code volume.
Part 4 — Get your own data (optional)
- Web-scrape the S&P 500 ticker list from Wikipedia (
bs4), feed the tickers toyfinance, and download the data yourself. - Describe what you get: why are there more variables than in the course dataset?
Deliverables
- One Jupyter notebook per group, by email to the instructor (clement.mazetsonilhac@unibocconi.it) and the TA (andrea.andolfatto@phd.unibocconi.it).
- Email title — and notebook name:
PCLab#2 - Group X - Name1 Name2 Name3. Tell us how long it took and how hard it felt (1–10). - Deadline: Friday, midnight (end of Week 3).
Grading
- Submitting before the deadline;
- Code quality — comments, readability, use of functions;
- Notebook structure — well organized, explain what and why;
- Completing the tasks — and innovating beyond them.
Model solution
A complete model solution — code, output, charts, and commentary — will be published on this page after the submission deadline.