Created
May 26, 2021 18:42
-
-
Save chulman444/cdf2723dbb881e2c1a1e24326ff27c2c to your computer and use it in GitHub Desktop.
대신 cybos Request 예제 (DsCbo1.StockWeek Request)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client, signal | |
from PyQt5.QtWidgets import * | |
from PyQt5.QAxContainer import * | |
from PyQt5.QtCore import * | |
from src.qtpy_base import QtPy | |
class CpEvent: | |
def set_params(self, inst): | |
self.inst = inst | |
def OnReceived(self): | |
print("Received") | |
count = self.inst.GetHeaderValue(1) # 데이터 개수 | |
print(f"OnReceived {count}") | |
class Cybos: | |
def __init__(self): | |
super().__init__() | |
def start(self): | |
objStockWeek = win32com.client.Dispatch("DsCbo1.StockWeek") | |
handler = win32com.client.WithEvents(objStockWeek, CpEvent) | |
handler.set_params(objStockWeek) | |
objStockWeek.SetInputValue(0, 'A005930') | |
objStockWeek.Request() | |
class QtPy(): | |
def __init__(self): | |
self.app = QApplication([]) | |
def run(self): | |
Cybos().start() | |
def start(self): | |
self.run() | |
self.app.exec_() | |
if __name__ == "__main__": | |
QtPy().start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"[파이썬] 데이터 요청 방법 2가지 BlockRequest 와 Request 방식 비교 예제" (링크)에서는 QtPy 없이 EventLoop을 넣고 "[파이썬] ETF NAV , ETN IIV 실시간 수신 예제" (링크)에서는
PyQt5
를 사용하는 모습. PyQt에 내부적으로 EventLoop를 처리하는것 같다.나름
threading.Timer(3, lambda: print("done").start()
혹은for x in range(10): time.sleep(1)
사용하며 작동되기를 기도했지만 택도 없었다.