73 lines
2.6 KiB
Python
73 lines
2.6 KiB
Python
|
|
# from tr.tr_0424 import Tr_0424
|
|
# tr_0424=Tr_0424()
|
|
import os
|
|
#XReal_S3_
|
|
class XReal_KH_:
|
|
def __init__(self):
|
|
super().__init__()
|
|
self.count = 0
|
|
# self.tr_0424=tr_0424
|
|
|
|
def OnReceiveRealData(self, tr_code): # event handler
|
|
"""
|
|
이베스트 서버에서 ReceiveRealData 이벤트 받으면 실행되는 event handler
|
|
"""
|
|
shcode = self.GetFieldData("OutBlock", "shcode")
|
|
price = self.GetFieldData("OutBlock", "price")
|
|
tvol = self.GetFieldData("OutBlock", "tvol")
|
|
tval = self.GetFieldData("OutBlock", "tval")
|
|
|
|
|
|
# print('@@프로그램: ',shcode)
|
|
# print('@@프로그램 price: ',price)
|
|
# print('@@프로그램 순매수 수량: ',tvol)
|
|
# print('@@프로그램 순매수 금액: ',tval)
|
|
|
|
if shcode is not None and price is not None:
|
|
self.process_balance_change(shcode,price)
|
|
|
|
# chetime = self.GetFieldData("OutBlock", "chetime")
|
|
|
|
# #print('chetime: ',chetime)
|
|
# self.continue_draw_balance_table()
|
|
|
|
|
|
|
|
def initialize_continue_draw_balance_table(self,continue_draw_balance_table):
|
|
#print('s3 initialize_continue_draw_balance_table @#@#@#@#@#@#@#')
|
|
self.continue_draw_balance_table=continue_draw_balance_table
|
|
|
|
def initialize_process_balance_change(self,process_balance_change):
|
|
#print('s3 initialize_process_balance_change @#@#@#@#@#@#@#')
|
|
self.process_balance_change=process_balance_change
|
|
|
|
def start(self,stock_code):
|
|
print('프로그램 리얼 스타트: ',stock_code)
|
|
# #print('왜 자꾸 콜하는겨')
|
|
"""
|
|
이베스트 서버에 실시간 data 요청함.
|
|
"""
|
|
|
|
the_path=os.environ.get('ROOT_FILE_PATH')+"\\Res\\KH_.res"
|
|
# print('the_path: ',the_path)
|
|
# the_path=os.environ.get('ROOT_FILE_PATH')+"\\Res\\S3_.res"
|
|
self.ResFileName = the_path # RES 파일 등록
|
|
|
|
# self.ResFileName = "C:\\eBEST\\xingAPI\\Res\\S3_.res" # RES 파일 등록
|
|
|
|
self.SetFieldData("InBlock", "shcode", stock_code)
|
|
self.AdviseRealData() # 실시간데이터 요청
|
|
|
|
def add_item(self, stockcode):
|
|
# 실시간데이터 요청 종목 추가
|
|
self.SetFieldData("InBlock", "shcode", stockcode)
|
|
self.AdviseRealData()
|
|
|
|
def remove_item(self, stockcode):
|
|
# stockcode 종목만 실시간데이터 요청 취소
|
|
self.UnadviseRealDataWithKey(stockcode)
|
|
|
|
def end(self):
|
|
self.UnadviseRealData() # 실시간데이터 요청 모두 취소
|