Skip to content

louisprp/Finance-Research-Notebooks

Repository files navigation

Finance Research Notebooks

A small collection of Python notebooks focused on portfolio construction and empirical asset pricing.

Notebooks

1) Black-Litterman model (US 5 industry portfolios)

Implements the Black-Litterman framework for the five US industry portfolios from Kenneth French's Data Library over January 1990 to December 2023. It:

  • Pulls monthly value-weighted industry returns and industry metadata (number of firms and average firm size)
  • Builds equilibrium (market-cap proxy) weights from number of firms times average firm size
  • Computes the covariance matrix of excess returns and implied equilibrium excess returns
  • Incorporates investor views using P, Q, and Omega, then computes posterior expected returns and optimal weights
  • Runs multiple scenarios, including an absolute view (Consumer at 60 bps monthly excess return), a relative view (High Tech outperforming Healthcare by 50 bps), combined views, and sensitivity checks to view magnitude and confidence

2) Size and value strategies

Forms monthly rebalanced, equally weighted portfolios based on market cap (CAP) and book-to-market (BM). It:

  • Constructs small, large, and small-minus-large portfolios from CAP sorts
  • Constructs growth, value, and value-minus-growth portfolios from BM sorts
  • Evaluates average returns and estimates CAPM and Fama-French 3-factor regressions
  • Checks robustness across different tail cutoffs (10%, 20%, 30%) and across sub-periods (1990-2006 and 2007-2023)

3) Earnings momentum strategies

Implements a post-earnings-announcement drift style strategy. It:

  • Computes standardized earnings surprises (SUE) using (EPS - consensus) scaled by the firm-specific standard deviation of surprises over 2016-2019
  • Each earnings announcement month from April 2020 through January 2022, forms equally weighted portfolios of the top 30 and bottom 30 stocks by SUE
  • Holds portfolios for three months, rebalances each announcement month, and builds monthly return series through April 2022
  • Evaluates average returns and runs CAPM and Fama-French 3-factor regressions for Good, Bad, and Good-minus-Bad (momentum)

Data notes (not included)

This repository does not include the raw input data due to licensing restrictions.

Public data

Kenneth French Data Library

Used in the Black-Litterman notebook and to source factors for regressions:

  • 5 Industry Portfolios: monthly value-weighted industry returns, number of firms, and average firm size
  • Fama-French factor data: monthly Mkt-RF, SMB, HML, and RF

You can download these files directly from Kenneth French's Data Library, or load them programmatically using pandas_datareader with the famafrench reader.

Licensed data

Data2 contents (inputs for size and value strategies)

A dataset of monthly stock returns and firm characteristics for US listed equities (NYSE, AMEX, NASDAQ) over January 1990 to December 2023, including:

  • Monthly returns
  • Market capitalization (CAP, in $000) measured at month-end
  • Book-to-market ratios (BM) measured at month-end
  • Pre-sorted next-month returns by CAP and by BM (stocks sorted on characteristics at month t, returns measured in month t+1)

How to obtain:

  • Use WRDS CRSP for returns, prices, and shares outstanding (to compute market equity / market cap)
  • Use WRDS Compustat for accounting variables to compute book equity and BM (using standard Fama-French style book equity construction)

Data3 contents (inputs for earnings momentum strategies)

A dataset combining returns with earnings and analyst expectations, including:

  • Monthly stock returns for a cross-section of US stocks
  • Quarterly EPS actuals for fiscal quarter ends (December, March, June, September), aligned to typical announcement months (January, April, July, October)
  • Analyst consensus forecasts for the same quarterly EPS

How to obtain:

  • Use WRDS CRSP for monthly returns
  • Use WRDS IBES for analyst forecasts and EPS actuals (and link IBES identifiers to CRSP securities using an appropriate mapping table)

Reproduction notes

  • Returns are handled at monthly frequency throughout.
  • Excess returns are formed by subtracting the risk-free rate (RF) from portfolio returns when running CAPM and Fama-French regressions.
  • Portfolio construction in the size, value, and earnings momentum notebooks uses equally weighted portfolios and explicit rebalancing rules described in each notebook.

About

Finance and markets notebooks in Python covering portfolio construction and empirical asset pricing

Resources

License

Stars

Watchers

Forks

Contributors