init
This commit is contained in:
14
hts/HTS.py
14
hts/HTS.py
@@ -8,7 +8,7 @@ import time
|
||||
import sqlite3
|
||||
from datetime import datetime, timedelta
|
||||
from hts.OrderItem import OrderItem
|
||||
from stock.util.SlackBot import SlackBot
|
||||
from stock.util.TelegramBot import TelegramBot
|
||||
|
||||
class HTS:
|
||||
|
||||
@@ -21,7 +21,7 @@ class HTS:
|
||||
|
||||
def __init__(self, RESOURCE_PATH):
|
||||
self.RESOURCE_PATH = RESOURCE_PATH
|
||||
self.slackBot = SlackBot()
|
||||
self.bot = TelegramBot()
|
||||
self.connect2DB(os.path.join( RESOURCE_PATH, "hts.db"))
|
||||
return
|
||||
|
||||
@@ -164,14 +164,14 @@ class HTS:
|
||||
objCpCybos = win32com.client.Dispatch("CpUtil.CpCybos")
|
||||
bConnect = objCpCybos.IsConnect
|
||||
if (bConnect == 0):
|
||||
self.slackBot.sendMsg("PLUS가 정상적으로 연결되지 않음. ")
|
||||
self.bot.sendMsg("PLUS가 정상적으로 연결되지 않음. ")
|
||||
print("PLUS가 정상적으로 연결되지 않음. ")
|
||||
exit()
|
||||
|
||||
objTrade = win32com.client.Dispatch("CpTrade.CpTdUtil")
|
||||
initCheck = objTrade.TradeInit(0)
|
||||
if (initCheck != 0):
|
||||
self.slackBot.sendMsg("주문 초기화 실패")
|
||||
self.bot.sendMsg("주문 초기화 실패")
|
||||
print("주문 초기화 실패")
|
||||
exit()
|
||||
|
||||
@@ -203,16 +203,16 @@ class HTS:
|
||||
rqRet = objStockOrder.GetDibMsg1()
|
||||
print("통신상태", rqStatus, rqRet)
|
||||
if rqStatus != 0:
|
||||
self.slackBot.sendMsg("통신상태: "+ str(rqStatus)+" ("+str(rqRet)+")")
|
||||
self.bot.sendMsg("통신상태: "+ str(rqStatus)+" ("+str(rqRet)+")")
|
||||
return None
|
||||
|
||||
orderNum = objStockOrder.GetHeaderValue(0)
|
||||
|
||||
if (type == "1"):
|
||||
self.slackBot.post_to_slack(stock_code, stock_code, "SELL", price, count)
|
||||
self.bot.post(stock_code, stock_code, "SELL", price, count)
|
||||
print ("(SELL", count, price, ")")
|
||||
else:
|
||||
self.slackBot.post_to_slack(stock_code, stock_code, "BUY", price, count)
|
||||
self.bot.post_to_slack(stock_code, stock_code, "BUY", price, count)
|
||||
print ("(BUY", count, price, ")")
|
||||
return orderNum
|
||||
|
||||
|
||||
Reference in New Issue
Block a user