LoginSignup
9
21

More than 1 year has passed since last update.

Pythonで株価の東証の銘柄コード一覧を取得して、東証1部、2部、TOPIXに整理

Posted at

東証の銘柄コードの取得と市場ごとの整理

JPXに一覧のexcelがあるため、これをダウンロード

pandasで読み出して市場や指標ごとに取り出します.

株関連の前提

大丈夫かと思いますが、大事なポイントを書き下しておきます.

  • 4桁の銘柄コードになります. 何番代かで業界が異なります.
  • このExcelに東証1部、2部、TOPIXで選ばれるもの、当たり前ですが日経平均225のものも全て含まれます. (しかし日経平均225に含まれるものは別途取得必要)
  • TOPIX100はCore 30とLarge 70、TOPIX500はそれにMid 400、TOPIX 1000はそれにSmall 1、TOPIXはSmall 2を加えたものとなります

環境

Google Colaboratoryにて確認.

コード

import pandas as pd

##東証から上場企業の一覧を取得
!wget 'https://www.jpx.co.jp/markets/statistics-equities/misc/tvdivq0000001vg2-att/data_j.xls'

codelist = pd.read_excel("./data_j.xls")

## 各市場を整理
firstSectionCodeList = codelist.loc[codelist["市場・商品区分"] == "市場第一部(内国株)"]
secondSectionCodeList = codelist.loc[codelist["市場・商品区分"] == "市場第二部(内国株)"]
mothersCodeList = codelist.loc[codelist["市場・商品区分"] == "マザーズ(内国株)"]
jasdaqStandardCodeList = codelist.loc[codelist["市場・商品区分"] == "JASDAQ(スタンダード・内国株)"]
jasdaqGrowthCodeList = codelist.loc[codelist["市場・商品区分"] == "JASDAQ(グロース・内国株)"]

## TOPIXを整理
topix100CodeList = codelist.loc[codelist["規模区分"].isin([ "TOPIX Core30" ,  "TOPIX Large70" ])]
topix500CodeList = codelist.loc[codelist["規模区分"].isin([ "TOPIX Core30" ,  "TOPIX Large70"  ,  "TOPIX Mid400" ])]
topix1000CodeList = codelist.loc[codelist["規模区分"].isin([ "TOPIX Core30" ,  "TOPIX Large70"  ,  "TOPIX Mid400", "TOPIX Small 1"])]
topixCodeList = codelist.loc[codelist["規模区分"].isin([ "TOPIX Core30" ,  "TOPIX Large70"  ,  "TOPIX Mid400", "TOPIX Small 1", "TOPIX Small 2"])]

実際に値を確認すると以下のようになる


firstSectionCodeList[["コード", "銘柄名"]]

fs.png

9
21
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
21