Metadata-Version: 2.4
Name: index-constitution
Version: 0.6.1
Summary: Point-in-time and current constituents for major stock indices (CSI 300, CSI 500, S&P 500, NASDAQ-100), packaged as pandas DataFrames.
Project-URL: Homepage, https://github.com/unliftedq/index-constitution
Project-URL: Repository, https://github.com/unliftedq/index-constitution
Author: index-constitution contributors
License: MIT License
        
        Copyright (c) 2026 index-constitution contributors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in
        all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
        THE SOFTWARE.
License-File: LICENSE
Keywords: backtesting,constituents,csi300,csi500,finance,index,nasdaq100,sp500,stocks
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Financial and Insurance Industry
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Office/Business :: Financial :: Investment
Requires-Python: >=3.9
Requires-Dist: pandas>=1.5
Description-Content-Type: text/markdown

# Index Constitution

[中文](README.zh.md)

## 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](https://en.wikipedia.org/wiki/List_of_S%26P_500_companies) |
| NASDAQ-100 | 100 largest non-financial companies listed on the Nasdaq Stock Market | [Wikipedia: NASDAQ-100](https://en.wikipedia.org/wiki/Nasdaq-100) |
| Dow Jones Industrial Average | 30 large U.S. blue-chip companies in the Dow Jones Industrial Average | [Wikipedia: Dow Jones Industrial Average](https://en.wikipedia.org/wiki/Dow_Jones_Industrial_Average) and [Wikipedia: Historical components of the Dow Jones Industrial Average](https://en.wikipedia.org/wiki/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:

```bash
pip install index-constitution
```

Usage:

```python
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
ic.symbol_status("sp500", "ABMD")   # whether a historical symbol is still directly usable
```

### Ticker and name changes

`history/*.csv` and `latest/*.csv` use the current canonical ticker and namefor each company across the full membership span. For example, S&P 500 historylists 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.

This canonicalization is strongest for pure ticker/name changes. When an event row includes `new_symbol`, it means this dataset treats the new ticker as the usable successor for historical lookup. For example, `FB -> META` means you can use `META` to access the full history for that company in this dataset.

`delisting` means the old ticker was retired and is no longer directly usable. In that case `new_symbol` and `new_name` are left empty because this dataset does not treat any other ticker as its direct successor. For example, `ABMD` remains valid historical S&P 500 membership data, but the symbol itself stopped trading after Johnson & Johnson acquired Abiomed.

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")` or `ic.symbol_status()` to tell whether an old symbol maps to a usable successor ticker or is simply delisted.

## 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
