init
This commit is contained in:
@@ -41,8 +41,9 @@ class HTS_etf (HTS):
|
||||
for code in jangoDic:
|
||||
if jangoDic[code]['매도가능'] > 0:
|
||||
if 2 < jangoDic[code]['평가손익']:
|
||||
self.requestOrder(OrderType.sell, code, jangoDic[code]['매도가능'], jangoDic[code]['평가금액'])
|
||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", jangoDic[code]['평가금액'], jangoDic[code]['매도가능'])
|
||||
currentStock = self.currentStock(code[1:])
|
||||
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close'])
|
||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능'])
|
||||
return
|
||||
|
||||
def getSellingPrice(self, log_time, stock_code, final_price, without_loss=False):
|
||||
|
||||
@@ -60,8 +60,9 @@ class HTS_Stocks (HTS):
|
||||
for code in jangoDic:
|
||||
if jangoDic[code]['매도가능'] > 0:
|
||||
if 2 < jangoDic[code]['평가손익']:
|
||||
self.requestOrder(OrderType.sell, code, jangoDic[code]['매도가능'], jangoDic[code]['평가금액'])
|
||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", jangoDic[code]['평가금액'], jangoDic[code]['매도가능'])
|
||||
currentStock = self.currentStock(code[1:])
|
||||
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close'])
|
||||
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능'])
|
||||
return
|
||||
|
||||
def getSellingPrice(self, log_time, stock_code, final_price, without_loss=False):
|
||||
|
||||
32
hts/HTS.py
32
hts/HTS.py
@@ -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) # 종목코드
|
||||
|
||||
Reference in New Issue
Block a user