quantlab.dataset.constituent.CrspSP500ConstituentDataset#
- class quantlab.dataset.constituent.CrspSP500ConstituentDataset(dataset_config)[source]#
Bases:
IndexConstituentDatasetDaily 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 (thedsp500list_v2table) from the reference directory atconfig.cache_dir. Coverage starts on 1925-12-31. Thesymbolaxis 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 ofSP500ConstituentDataset.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 toCrspMembership.
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
CrspMembershipindex this class reads. Both hooks use it, so they cannot disagree.
- config_cls#
The config class a saved
config.jsonis rebuilt with.alias of
FileConstituentDatasetConfig