키움증권 openAPI 20번 - 종목코드의 전일가를 반환한다

2023. 1. 18. 23:28시스템트레이딩

728x90
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import sys
from PyQt5.QtWidgets import *
from PyQt5.QAxContainer import *
from PyQt5.QtCore import *
 
class Kiwoom(QAxWidget):
    def __init__(self):
        super().__init__()
        self._create_kiwoom_instance()
        self._set_signal_slots()
 
    def _create_kiwoom_instance(self):
        self.setControl("KHOPENAPI.KHOpenAPICtrl.1")
 
    def _set_signal_slots(self):
        self.OnEventConnect.connect(self._event_connect)
 
    def comm_connect(self):
        self.dynamicCall("CommConnect()")
        self.login_event_loop = QEventLoop()
        self.login_event_loop.exec_()
 
    def _event_connect(self, err_code):
        if err_code == 0:
            print("connected")
        else:
            print("disconnected")
 
        self.login_event_loop.exit()
 
    def get_master_listed_stock_date(self, code):
        code_list = self.dynamicCall("GetMasterListedStockDate(QString)", code)
        return code_list
 
 
if __name__ == "__main__":
    app = QApplication(sys.argv)
    kiwoom = Kiwoom()
    kiwoom.comm_connect()
 
    res = kiwoom.get_master_listed_stock_date('005930')
    print("res : ", res)
cs


결과

어제의 종가가 61,000원 이었네. 아직 멀었다. --

728x90