Skip to content

Get the current and historical constituents of popular stock indices.

License

Notifications You must be signed in to change notification settings

jcoffi/index-constituents

 
 

Repository files navigation

index-constituents

update-monthly

Get the current and historical constituents of popular stock indices. All symbols are consistent with those in Yahoo Finance.

Supported indices

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

Usage

Direct download

To get the current index constituents, use the links above. You probably have noticed the URLs have some pattern:

wget https://raw.githubusercontent.com/jcoffi/index-constituents/refs/heads/main/docs/constituents-$CODE.$FORMAT

Use in your program

Using Python as an example:

import pandas as pd

url = "https://raw.githubusercontent.com/jcoffi/index-constituents/refs/heads/main/docs/constituents-csi300.csv"
df = pd.read_csv(url)

Build yourself

Check requirements.txt. Run:

./get-constituents.py

Historical data

To get the historical index constituents, use the following URL:

https://github.com/jcoffi/index-constituents/blob/main/docs/$YYYY/$MM/constituents-$CODE.$FORMAT

By 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.

Data source

Author

  • Forked from original author: yfiua

About

Get the current and historical constituents of popular stock indices.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 97.3%
  • Shell 2.7%