■ get_market_fundamental_by_ticker 함수를 사용해 특정일에 전체 종목의 BPS/PER/PBR/EPS/DIV/DPS 리스트를 구하는 방법을 보여준다.
• DIV(배당수익률) : (주가배당금 / 주가) * 100
• BPS(주당순자산가치 = 청산가치) : (순자산) / (총발행주식수)
• PER(주가수익비율) : (주가) / (주당순이익)
• EPS(주당순이익) : (당기순이익) / (총발행주식수)
• PBR(주가순자산비율) : (주가) / (BPS) = PER * EPS / BPS
▶ main.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
from pykrx import stock baseDate = "20240620" market = "KOSPI" # ALL, KOSPI, KOSDAQ, KONEX dataFrame = stock.get_market_fundamental_by_ticker(date = baseDate, market = market) print(dataFrame.head()) """ BPS PER PBR EPS DIV DPS 티커 095570 9326 12.32 0.48 367 5.97 270 006840 44339 5.56 0.33 2635 1.37 200 027410 17286 4.38 0.21 813 3.37 120 282330 62197 9.69 1.77 11337 3.73 4100 138930 31746 4.29 0.26 1905 6.24 510 """ |
▶ requirements.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
certifi==2024.6.2 charset-normalizer==3.3.2 contourpy==1.2.1 cycler==0.12.1 DateTime==5.5 Deprecated==1.2.14 fonttools==4.53.0 idna==3.7 kiwisolver==1.4.5 matplotlib==3.9.0 multipledispatch==1.0.0 numpy==2.0.0 packaging==24.1 pandas==2.2.2 pillow==10.3.0 pykrx==1.0.45 pyparsing==3.1.2 python-dateutil==2.9.0.post0 pytz==2024.1 requests==2.32.3 six==1.16.0 tzdata==2024.1 urllib3==2.2.2 wrapt==1.16.0 xlrd==2.0.1 zope.interface==6.4.post2 |
※ pip install pykrx 명령을 실행했다.