quantlab.dataset.crsp.membership#

Point-in-time index membership from the CRSP reference tables, keyed by PERMNO.

CRSP (the Center for Research in Security Prices) is a US stock database sold through WRDS (Wharton Research Data Services). A PERMNO is CRSP’s permanent integer id for one security. Compustat is S&P’s fundamentals database, which identifies a security by (gvkey, iid) (company key and issue id). Point-in-time membership records who was in an index on each past day, which is what a backtest needs to avoid survivorship bias (testing only on companies that are still around today). A spell is one row of a membership table: one security’s membership over one date range.

CrspMembership answers “which securities were in this index on these dates” from parquet files on disk, with no WRDS connection. It serves the two index histories this vendor offers:

  • crsp_sp500: CRSP’s own S&P 500 membership from crsp_a_indexes.dsp500list_v2, one spell per (permno, mbrstartdt, mbrenddt), with coverage from 1925-12-31.

  • comp_nasdaq100: Compustat’s Nasdaq-100 constituent history from comp.idxcst_his (gvkeyx = '000208'), whose (gvkey, iid) pairs are mapped to PERMNOs through the CRSP/Compustat Merged (CCM) link table crsp_a_ccm.ccmxpf_lnkhist.

Memberships are returned as intervals keyed by PERMNO, because a PERMNO stays the same through a ticker change and a ticker does not. Intervals include both ends and every end is explicit: an open membership is cut at CrspReference.product_end (the last date of the downloaded CRSP data) rather than left null, so a membership panel built from them cannot extend past the CRSP price data.

This module imports only polars, loguru, the standard library and quantlab.dataset.crsp.reference, so it works on a machine with no database driver.

Classes

CrspMembership

Point-in-time index membership from one CRSP reference directory.