Skip to main content

Point-in-time and current constituents for major stock indices (CSI 300, CSI 500, S&P 500, NASDAQ-100), packaged as pandas DataFrames.

Project description

Index Constitution

中文

Purpose

This repository was created to make it easier to train quantitative models on major stock indices. Reliable historical index composition data (constituent additions and removals over time) is notoriously hard to obtain — vendors often charge for it, official sources are scattered across PDFs and announcements, and free APIs rarely expose point-in-time membership. Without this data, backtests suffer from survivorship bias and lookahead bias.

This repo collects and normalizes that information into plain CSV files so it can be consumed directly by research and modeling pipelines.

Datasets

Index Description Source
CSI 300 Top 300 A-share stocks listed on the Shanghai and Shenzhen exchanges Official announcements from China Securities Index Co. (csindex.com.cn)
CSI 500 500 mid-cap A-share stocks listed on the Shanghai and Shenzhen exchanges Official announcements from China Securities Index Co. (csindex.com.cn)
S&P 500 500 leading large-cap U.S. companies listed on U.S. exchanges Wikipedia: List of S&P 500 companies
NASDAQ-100 100 largest non-financial companies listed on the Nasdaq Stock Market Wikipedia: NASDAQ-100
Dow Jones Industrial Average 30 large U.S. blue-chip companies in the Dow Jones Industrial Average Wikipedia: Dow Jones Industrial Average and Wikipedia: Historical components of the Dow Jones Industrial Average

Python package

This repo also ships a small Python library that embeds the CSVs and exposes them as pandas DataFrames.

Install:

pip install index-constitution

Usage:

import index_constitution as ic

ic.list_indices()                    # ['csi300', 'csi500', 'sp500', 'nasdaq100', 'dow30']

ic.latest("sp500")                   # current S&P 500 members
ic.latest("dow30")                   # current Dow 30 members
ic.history("csi300")                 # full CSI 300 history with opt-in/opt-out
ic.constituents_at("sp500", "2015-06-30")   # point-in-time membership
ic.is_member("sp500", "AAPL", "2020-01-02") # True
ic.events("sp500")                   # ticker/name change audit trail

Ticker and name changes

history/*.csv and latest/*.csv use the current canonical ticker and name for each company across the full membership span. For example, S&P 500 history lists Meta Platforms only as META, even for the period when it traded as FB. The event/us.csv and event/cn.csv files are the audit trail for those changes.

Events are not scoped to a single index — a corporate ticker or name change applies to every index that includes the company. ic.events("sp500") filters the table to events whose old or new symbol ever appeared in S&P 500 history.

is_member() and constituents_at() are strict — they do not resolve old tickers automatically. Use ic.events("sp500") to map renamed symbols.

Use Cases

  • Check the current constituents of an index
  • Reconstruct point-in-time index membership for backtesting
  • Avoid survivorship bias when training quantitative models
  • Keep a consistent structure for adding more indices later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

index_constitution-0.5.0.tar.gz (72.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

index_constitution-0.5.0-py3-none-any.whl (90.2 kB view details)

Uploaded Python 3

File details

Details for the file index_constitution-0.5.0.tar.gz.

File metadata

  • Download URL: index_constitution-0.5.0.tar.gz
  • Upload date:
  • Size: 72.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for index_constitution-0.5.0.tar.gz
Algorithm Hash digest
SHA256 dcecc6fe9c633a942b8728451c40ce417f97438eeccd14b59a0b7689e627fb0e
MD5 e6cb2d02e422bb26ae37ea3646688e4b
BLAKE2b-256 ffe5ec316a6f3a6ce7e036f1782cd616c6318cc47ca378fd01eeec9ba1b2a044

See more details on using hashes here.

File details

Details for the file index_constitution-0.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for index_constitution-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b7c3f8d08499b6d9b3313833b9d855e0e78f48e1dfd836cb2b32115c4af5017
MD5 44998a1c7f138ff0538ea9dc760face0
BLAKE2b-256 74ffdd052705a7fb38e92bd2a9a75a523037b9b150ca3d42a226998bc4837fb9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page