This commit is contained in:
dsyoon
2023-02-09 11:59:56 +09:00
parent 6cdb43571b
commit c952e8b153
3 changed files with 23 additions and 19 deletions

View File

@@ -135,19 +135,7 @@ class HTS:
exDiff = self.objStockMst.GetHeaderValue(56) # 예상체결가 전일대비
exVol = self.objStockMst.GetHeaderValue(57) # 예상체결수량
print("코드", code)
print("이름", name)
print("시간", time)
print("종가", cprice)
print("대비", diff)
print("시가", open)
print("고가", high)
print("저가", low)
print("매도호가", offer)
print("매수호가", bid)
print("거래량", vol)
print("거래대금", vol_value)
"""
if (exFlag == ord('0')):
print("장 구분값: 동시호가와 장중 이외의 시간")
elif (exFlag == ord('1')):
@@ -159,13 +147,24 @@ class HTS:
print("예상체결가", exPrice)
print("예상체결가 대비", exDiff)
print("예상체결수량", exVol)
"""
result = {'code': code, 'name': name, 'time': time, 'close': cprice, 'diff': diff, 'open': open, 'high': high,
'low': low, 'offer': offer, 'bid': bid, 'vol': vol, 'vol_value': vol_value,
'exFlag': exFlag, 'exPrice': exPrice, 'exDiff': exDiff, 'exVol': exVol}
return
return result
# 주식 현금 매수주문
def requestOrder(self, type, stock_code, count, price):
# type = 2: buy, type=1: sell
# 주문 초기화
# 연결 여부 체크
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
bConnect = objCpCybos.IsConnect
if (bConnect == 0):
print("PLUS가 정상적으로 연결되지 않음. ")
exit()
objTrade = win32com.client.Dispatch("CpTrade.CpTdUtil")
initCheck = objTrade.TradeInit(0)
if (initCheck != 0):
@@ -178,7 +177,10 @@ class HTS:
# acc = "782446178"
# accFlag[0] = "01"
objStockOrder = win32com.client.Dispatch("CpTrade.CpTd0311")
objStockOrder.SetInputValue(0, type.value) # 1: 매도, 2: 매수
if type.value == "1":
objStockOrder.SetInputValue(0, "1") # 1: 매도, 2: 매수
else:
objStockOrder.SetInputValue(0, "2") # 1: 매도, 2: 매수
objStockOrder.SetInputValue(1, acc) # 계좌번호
objStockOrder.SetInputValue(2, accFlag[0]) # 상품구분 - 주식 상품 중 첫번째
objStockOrder.SetInputValue(3, "A"+stock_code) # 종목코드