init
This commit is contained in:
@@ -161,9 +161,6 @@ class HTS_etf(HTS):
|
|||||||
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, bs_buy_price)
|
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)
|
||||||
|
|
||||||
# slackbot에 메시지를 보냄
|
|
||||||
self.slackBot.post_to_slack(stock_code, stock_code, "BUY", bsLine['buy'][len(bsLine['buy']) - 1], buy_count)
|
|
||||||
|
|
||||||
# 로그 출력
|
# 로그 출력
|
||||||
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock_code, bs_buy_price, buy_count)
|
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock_code, bs_buy_price, buy_count)
|
||||||
|
|
||||||
@@ -171,8 +168,6 @@ class HTS_etf(HTS):
|
|||||||
check = self.sellStocks(stock_code, bs_sell_price)
|
check = self.sellStocks(stock_code, bs_sell_price)
|
||||||
|
|
||||||
if check:
|
if check:
|
||||||
# slackbot에 메시지를 보냄
|
|
||||||
self.slackBot.post_to_slack(stock_code, stock_code, "SELL", bs_sell_price, 'ALL')
|
|
||||||
|
|
||||||
# 로그 출력
|
# 로그 출력
|
||||||
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), stock_code, stock_code, bs_sell_price)
|
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), stock_code, stock_code, bs_sell_price)
|
||||||
|
|||||||
@@ -159,12 +159,9 @@ class HTS_etf(HTS):
|
|||||||
|
|
||||||
if buy_count > 0:
|
if buy_count > 0:
|
||||||
# 매수를 주문한다.
|
# 매수를 주문한다.
|
||||||
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, bs_buy_price)
|
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, bs_buy_price, self.slackBot)
|
||||||
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)
|
||||||
|
|
||||||
# slackbot에 메시지를 보냄
|
|
||||||
self.slackBot.post_to_slack(stock_code, stock_code, "BUY", bsLine['buy'][len(bsLine['buy']) - 1], buy_count)
|
|
||||||
|
|
||||||
# 로그 출력
|
# 로그 출력
|
||||||
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock_code, bs_buy_price, buy_count)
|
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock_code, bs_buy_price, buy_count)
|
||||||
|
|
||||||
@@ -172,8 +169,6 @@ class HTS_etf(HTS):
|
|||||||
check = self.sellStocks(stock_code, bs_sell_price)
|
check = self.sellStocks(stock_code, bs_sell_price)
|
||||||
|
|
||||||
if check:
|
if check:
|
||||||
# slackbot에 메시지를 보냄
|
|
||||||
self.slackBot.post_to_slack(stock_code, stock_code, "SELL", bs_sell_price, 'ALL')
|
|
||||||
|
|
||||||
# 로그 출력
|
# 로그 출력
|
||||||
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), stock_code, stock_code, bs_sell_price)
|
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), stock_code, stock_code, bs_sell_price)
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class HTS:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
# 주식 현금 매수주문
|
# 주식 현금 매수주문
|
||||||
def requestOrder(self, type, stock_code, count, price):
|
def requestOrder(self, type, stock_code, count, price, slackBot=None):
|
||||||
# type = 2: buy, type=1: sell
|
# type = 2: buy, type=1: sell
|
||||||
# 주문 초기화
|
# 주문 초기화
|
||||||
# 연결 여부 체크
|
# 연결 여부 체크
|
||||||
@@ -200,13 +200,18 @@ class HTS:
|
|||||||
rqRet = objStockOrder.GetDibMsg1()
|
rqRet = objStockOrder.GetDibMsg1()
|
||||||
print("통신상태", rqStatus, rqRet)
|
print("통신상태", rqStatus, rqRet)
|
||||||
if rqStatus != 0:
|
if rqStatus != 0:
|
||||||
|
slackBot.post_msg_to_slack("통신상태: "+ 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:
|
||||||
|
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:
|
||||||
|
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