Get the current and historical constituents of popular stock indices. All symbols are consistent with those in Yahoo Finance.
| Code | Name | Start | Download |
|---|---|---|---|
| csi300 | CSI 300 (沪深300) | 2023/07 | json / csv |
| csi500 | CSI 500 (中证500) | 2024/01 | json / csv |
| csi1000 | CSI 1000 (中证1000) | 2024/01 | json / csv |
| sse | SSE (上证综指) | 2023/07 | json / csv |
| szse | SZSE (深证成指) | 2023/07 | json / csv |
| nasdaq100 | NASDAQ 100 | 2023/07 | json / csv |
| sp500 | S&P 500 | 2023/07 | json / csv |
| dowjones | Dow Jones | 2023/07 | json / csv |
| dax | DAX | 2023/07 | json / csv |
| hsi | HSI (恒生指数) | 2023/07 | json / csv |
| ftse100 | FTSE 100 | 2023/07 | json / csv |
| ibex35 | IBEX 35 | 2024/03 | json / csv |
| ftsemib | FTSE MIB | 2024/03 | json / csv |
| nifty50 | NIFTY 50 | 2024/03 | json / csv |
| asx200 | S&P/ASX 200 | 2024/03 | json / csv |
To get the current index constituents, use the links above. You probably have noticed the URLs have some pattern:
wget https://yfiua.github.io/index-constituents/constituents-$CODE.$FORMATUsing Python as an example:
import pandas as pd
url = "https://yfiua.github.io/index-constituents/constituents-csi300.csv"
df = pd.read_csv(url)Check requirements.txt. Run:
./get-constituents.pyA new script get-constituents-historical.py is included for "time-traveling" and backfilling data that was not previously archived in this repository. It uses the MediaWiki Revision API (for Wikipedia) and the Wayback Machine (for external sites).
Example: Backfill NIFTY 50 data starting from 2008:
python get-constituents-historical.py --indices nifty50To get the historical index constituents, use the following URL:
https://yfiua.github.io/index-constituents/$YYYY/$MM/constituents-$CODE.$FORMATBy default we automatically update the data monthly (usually on the first day). Historical data of a particular index is only available from the month we start to include it.
- 中证指数
- 深交所
- Slickcharts
- Bloomberg
- 乌龟量化 - deprecated