quantlab.dataset.constituent.SP500ConstituentDataset#

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

Bases: IndexConstituentDataset

Daily point-in-time S&P 500 membership panel from a public change log.

Membership intervals come from SP500MembershipFetcher, which starts from the current constituent list and replays Wikipedia’s log of index changes backwards. Coverage starts on 1976-07-01, the earliest entry in that log, so the panel never starts earlier. The symbol axis holds tickers. The source URLs and the coverage date are defined on the fetcher.

Parameters:
dataset_configFileConstituentDatasetConfig

Output Zarr path, cache directory, date range and as_of date.

Examples

Building the panel fetches the change log over the network (or reads the snapshot cached under cache_dir):

>>> config = FileConstituentDatasetConfig(
...     zarr_file_path="data/reference/sp500_constituent.zarr",
...     cache_dir="data/reference/_cache",
...     start_date="2015-01-01",
...     end_date="2024-12-31",
...     as_of="2024-12-31",
... )
>>> SP500ConstituentDataset(config).from_raw_data().save()
>>> panel = SP500ConstituentDataset(config).panel("2015-01-01", "2024-12-31")
config_cls#

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

alias of FileConstituentDatasetConfig