quantlab.dataset.constituent.CrspSP500ConstituentDataset#

class quantlab.dataset.constituent.CrspSP500ConstituentDataset(dataset_config)[source]#

Bases: IndexConstituentDataset

Daily point-in-time S&P 500 membership panel from CRSP’s membership records.

Intervals come from CrspMembership, which reads CRSP’s S&P 500 list (the dsp500list_v2 table) from the reference directory at config.cache_dir. Coverage starts on 1925-12-31. The symbol axis is the int64 PERMNO, the same id the CRSP price panel uses for its columns, so this mask lines up with that panel without any ticker matching. It is not interchangeable with the ticker axis of SP500ConstituentDataset.

Every interval has an explicit end no later than the last date of the downloaded CRSP data, so the panel ends on that date, never today.

Parameters:
dataset_configFileConstituentDatasetConfig

Output Zarr path, CRSP reference directory (cache_dir) and date range. kwargs["allow_unlinked"] is passed to CrspMembership.

Examples

Needs a CRSP reference directory on disk; no WRDS connection is made:

>>> config = FileConstituentDatasetConfig(
...     zarr_file_path="data/reference/crsp_sp500.zarr",
...     cache_dir="downloads/us_equity/1d/wrds_crsp/_reference",
...     start_date="2015-01-01",
...     end_date="2024-12-31",
... )
>>> panel = CrspSP500ConstituentDataset(config).from_raw_data()
>>> panel.get_xarray_dataset()["symbol"].dtype
dtype('int64')
INDEX = 'crsp_sp500'#

The CrspMembership index this class reads. Both hooks use it, so they cannot disagree.

config_cls#

The config class a saved config.json is rebuilt with.

alias of FileConstituentDatasetConfig