더북(TheBook)

이제 main.py 파일에서 함수를 호출하여 삼성전자(005930)의 일봉 정보를 출력해 보겠습니다.

main.py

from api.Kiwoom import *
import sys

app = QApplication(sys.argv)
kiwoom = Kiwoom()

df = kiwoom.get_price_data("005930")
print(df)

app.exec_()

main.py 파일을 실행하면 다음과 같이 가격 정보를 받아 와 DataFrame으로 만든 값이 출력됩니다.

connected
8*********
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
[Kiwoom] _on_receive_tr_data is called 0001 / opt10081_req / opt10081
           open   high    low  close    volume
19850104    130    130    129    129    111765
19850105    129    129    128    128    108497
19850107    129    130    128    129    771895
19850108    129    129    127    127    845098
19850109    126    126    122    123    324837
...         ...    ...    ...    ...       ...
20210628  81700  82000  81600  81900  11578529
20210629  81900  82100  80800  81000  15744317
20210630  81100  81400  80700  80700  13288643
20210701  80500  80600  80000  80100  13382882
20210702  80000  80400  79900  80000   8753097
[9641 rows x 5 columns]
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.