This commit is contained in:
dsyoon
2023-02-27 10:12:48 +09:00
parent 817fbe2c58
commit 9b3db7a695
2 changed files with 20 additions and 12 deletions

View File

@@ -50,6 +50,7 @@ class HTS_etf (HTS):
return return
def sellStocks(self, stock_code=None, bs_sell_price=None): def sellStocks(self, stock_code=None, bs_sell_price=None):
check = False
jangoDic = self.requstJango() jangoDic = self.requstJango()
if jangoDic and len(jangoDic.keys()) > 0: if jangoDic and len(jangoDic.keys()) > 0:
for code in jangoDic: for code in jangoDic:
@@ -59,6 +60,7 @@ class HTS_etf (HTS):
if 2 < jangoDic[code]['평가손익']: if 2 < jangoDic[code]['평가손익']:
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price) self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price)
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능']) self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능'])
check = True
else: else:
continue continue
else: else:
@@ -68,7 +70,8 @@ class HTS_etf (HTS):
currentStock = self.currentStock(code[1:]) currentStock = self.currentStock(code[1:])
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close']) self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close'])
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능']) self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능'])
return check = True
return check
def getSellingPrice(self, log_time, stock_code, final_price, without_loss=False): def getSellingPrice(self, log_time, stock_code, final_price, without_loss=False):
@@ -243,8 +246,9 @@ class HTS_etf (HTS):
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock['stock_code'], stock['stock_name'], bs_buy_price, buy_count) print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock['stock_code'], stock['stock_name'], bs_buy_price, buy_count)
if bs_sell_price > 1000: if bs_sell_price > 1000:
self.sellStocks(stock['stock_code'], bs_sell_price) check = self.sellStocks(stock['stock_code'], bs_sell_price)
if check:
# slackbot에 메시지를 보냄 # slackbot에 메시지를 보냄
self.slackBot.post_to_slack(stock['stock_code'], stock['stock_name'], "SELL", bs_sell_price, 'ALL') self.slackBot.post_to_slack(stock['stock_code'], stock['stock_name'], "SELL", bs_sell_price, 'ALL')

View File

@@ -55,6 +55,7 @@ class HTS_Stocks (HTS):
return return
def sellStocks(self, stock_code=None, bs_sell_price=None): def sellStocks(self, stock_code=None, bs_sell_price=None):
check = False
jangoDic = self.requstJango() jangoDic = self.requstJango()
if jangoDic and len(jangoDic.keys()) > 0: if jangoDic and len(jangoDic.keys()) > 0:
for code in jangoDic: for code in jangoDic:
@@ -64,6 +65,7 @@ class HTS_Stocks (HTS):
if 2 < jangoDic[code]['평가손익']: if 2 < jangoDic[code]['평가손익']:
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price) self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], bs_sell_price)
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능']) self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", bs_sell_price, jangoDic[code]['매도가능'])
check = True
else: else:
continue continue
else: else:
@@ -73,7 +75,8 @@ class HTS_Stocks (HTS):
currentStock = self.currentStock(code[1:]) currentStock = self.currentStock(code[1:])
self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close']) self.requestOrder(OrderType.sell, code[1:], jangoDic[code]['매도가능'], currentStock['close'])
self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능']) self.slackBot.post_to_slack(code, jangoDic[code]['종목명'], "SELL", currentStock['close'], jangoDic[code]['매도가능'])
return check = True
return check
def getSellingPrice(self, log_time, stock_code, final_price, without_loss=False): def getSellingPrice(self, log_time, stock_code, final_price, without_loss=False):
# final_price와 diff를 받으면, 해당 가격으로 그냥 매도한다는 의미 # final_price와 diff를 받으면, 해당 가격으로 그냥 매도한다는 의미
@@ -244,8 +247,9 @@ class HTS_Stocks (HTS):
# 다음 조건이면 매도한다. # 다음 조건이면 매도한다.
if len(data) > 10 and max(bsLine['sell'][len(bsLine['sell']) - 1:]) > 1000: if len(data) > 10 and max(bsLine['sell'][len(bsLine['sell']) - 1:]) > 1000:
bs_sell_price = bsLine['sell'][len(bsLine['sell']) - 1] bs_sell_price = bsLine['sell'][len(bsLine['sell']) - 1]
self.sellStocks(stock_code, bs_sell_price) check = self.sellStocks(stock_code, bs_sell_price)
if check:
# slackbot에 메시지를 보냄 # slackbot에 메시지를 보냄
self.slackBot.post_to_slack(stock_code, stock_name, "SELL", bsLine['sell'][len(bsLine['sell']) - 1], 'ALL') self.slackBot.post_to_slack(stock_code, stock_name, "SELL", bsLine['sell'][len(bsLine['sell']) - 1], 'ALL')