init
This commit is contained in:
@@ -156,7 +156,7 @@ class HTS_etf(HTS):
|
|||||||
|
|
||||||
if buy_count > 0:
|
if buy_count > 0:
|
||||||
# 매수를 주문한다.
|
# 매수를 주문한다.
|
||||||
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, bs_buy_price, self.slackBot)
|
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, bs_buy_price)
|
||||||
self.orderChecker.buy(today, "A" + stock_code, buy_count, bs_buy_price, orderNum)
|
self.orderChecker.buy(today, "A" + stock_code, buy_count, bs_buy_price, orderNum)
|
||||||
|
|
||||||
# 로그 출력
|
# 로그 출력
|
||||||
|
|||||||
17
hts/HTS.py
17
hts/HTS.py
@@ -8,6 +8,7 @@ import time
|
|||||||
import sqlite3
|
import sqlite3
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from hts.OrderItem import OrderItem
|
from hts.OrderItem import OrderItem
|
||||||
|
from stock.util.SlackBot import SlackBot
|
||||||
|
|
||||||
class HTS:
|
class HTS:
|
||||||
|
|
||||||
@@ -20,7 +21,7 @@ class HTS:
|
|||||||
|
|
||||||
def __init__(self, RESOURCE_PATH):
|
def __init__(self, RESOURCE_PATH):
|
||||||
self.RESOURCE_PATH = RESOURCE_PATH
|
self.RESOURCE_PATH = RESOURCE_PATH
|
||||||
#self.connect()
|
self.slackBot = SlackBot()
|
||||||
self.connect2DB(os.path.join( RESOURCE_PATH, "hts.db"))
|
self.connect2DB(os.path.join( RESOURCE_PATH, "hts.db"))
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -156,21 +157,21 @@ class HTS:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
# 주식 현금 매수주문
|
# 주식 현금 매수주문
|
||||||
def requestOrder(self, type, stock_code, count, price, slackBot=None):
|
def requestOrder(self, type, stock_code, count, price):
|
||||||
# type = 2: buy, type=1: sell
|
# type = 2: buy, type=1: sell
|
||||||
# 주문 초기화
|
# 주문 초기화
|
||||||
# 연결 여부 체크
|
# 연결 여부 체크
|
||||||
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
|
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
|
||||||
bConnect = objCpCybos.IsConnect
|
bConnect = objCpCybos.IsConnect
|
||||||
if (bConnect == 0):
|
if (bConnect == 0):
|
||||||
slackBot.sendMsg("PLUS가 정상적으로 연결되지 않음. ")
|
self.slackBot.sendMsg("PLUS가 정상적으로 연결되지 않음. ")
|
||||||
print("PLUS가 정상적으로 연결되지 않음. ")
|
print("PLUS가 정상적으로 연결되지 않음. ")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
objTrade = win32com.client.Dispatch("CpTrade.CpTdUtil")
|
objTrade = win32com.client.Dispatch("CpTrade.CpTdUtil")
|
||||||
initCheck = objTrade.TradeInit(0)
|
initCheck = objTrade.TradeInit(0)
|
||||||
if (initCheck != 0):
|
if (initCheck != 0):
|
||||||
slackBot.sendMsg("주문 초기화 실패")
|
self.slackBot.sendMsg("주문 초기화 실패")
|
||||||
print("주문 초기화 실패")
|
print("주문 초기화 실패")
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
@@ -202,18 +203,16 @@ class HTS:
|
|||||||
rqRet = objStockOrder.GetDibMsg1()
|
rqRet = objStockOrder.GetDibMsg1()
|
||||||
print("통신상태", rqStatus, rqRet)
|
print("통신상태", rqStatus, rqRet)
|
||||||
if rqStatus != 0:
|
if rqStatus != 0:
|
||||||
slackBot.sendMsg("통신상태: "+ str(rqStatus)+' ('+str(rqRet)+')')
|
self.slackBot.sendMsg("통신상태: "+ str(rqStatus)+" ("+str(rqRet)+")")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
orderNum = objStockOrder.GetHeaderValue(0)
|
orderNum = objStockOrder.GetHeaderValue(0)
|
||||||
|
|
||||||
if (type == "1"):
|
if (type == "1"):
|
||||||
if slackBot is not None:
|
self.slackBot.post_to_slack(stock_code, stock_code, "SELL", price, count)
|
||||||
slackBot.post_to_slack(stock_code, stock_code, "SELL", price, count)
|
|
||||||
print ("(SELL", count, price, ")")
|
print ("(SELL", count, price, ")")
|
||||||
else:
|
else:
|
||||||
if slackBot is not None:
|
self.slackBot.post_to_slack(stock_code, stock_code, "BUY", price, count)
|
||||||
slackBot.post_to_slack(stock_code, stock_code, "BUY", price, count)
|
|
||||||
print ("(BUY", count, price, ")")
|
print ("(BUY", count, price, ")")
|
||||||
return orderNum
|
return orderNum
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user