This commit is contained in:
dsyoon
2023-01-29 22:18:01 +09:00
parent c6a1698f33
commit 95c950bad0
2 changed files with 45 additions and 25 deletions

View File

@@ -129,14 +129,20 @@ class HTS_etf (HTS):
bs_buy_weight = bsLine['buy_weight'][0]
bs_sell_price = bsLine['sell'][0]
# 미체결 기록을 가져와서 10분 이상 된 매수 주문을 취소 한다.
ORDER_LIST = self.requestOrderList()
orderListToCancel = self.orderChecker.cancel(today, stock['stock_code'], ORDER_LIST)
self.cancelOrderList(orderListToCancel)
if bs_buy_price > 0:
buy_count = int(self.MAX_BUY_PRICE/bs_buy_price)
# 매수를 주문한다.
orderNum = self.requestOrder(OrderType.buy, self.stock_code, buy_count , bs_buy_price)
orderNum = self.requestOrder(OrderType.buy, stock['stock_code'], buy_count , bs_buy_price)
self.orderChecker.buy(today, stock['stock_code'], buy_count, bs_buy_price, orderNum)
# slackbot에 메시지를 보냄
self.slackBot.post_to_slack(stock['stock_code'], stock['stock_name'], "BUY", bsLine['buy'][len(bsLine['buy']) - 1], buy_count)
self.orderChecker.add(today, stock['stock_code'], 1, buy_count, bs_buy_price, orderNum)
# 로그 출력
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock['stock_code'], stock['stock_name'], bs_buy_price, buy_count)
@@ -144,11 +150,11 @@ class HTS_etf (HTS):
if bs_sell_price > 0:
# 매도한다.
orderNum = self.getSellingPrice(THIS_TIME, self.stock_code, bs_sell_price, without_loss=True)
orderNum = self.getSellingPrice(THIS_TIME, stock['stock_code'], bs_sell_price, without_loss=True)
self.orderChecker.sell(today, stock['stock_code'])
# slackbot에 메시지를 보냄
self.slackBot.post_to_slack(stock['stock_code'], stock['stock_name'], "SELL", bsLine['sell'][len(bsLine['sell']) - 1], -1)
self.orderChecker.delete(today, stock['stock_code'])
# 로그 출력
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), str(orderNum), stock['stock_code'], stock['stock_name'], bs_sell_price)
@@ -166,18 +172,19 @@ class HTS_etf (HTS):
# 손해 보지 않는 가격에 매도한다.
####
# 주문 리스트를 가져온다.
orderList = self.requestOrderList()
# 15:10:00 이후라면 모든 미체결 취소한다.
self.cancelOrderList(orderList)
for stock in stocks:
# 주문 리스트를 가져온다.
orderList = self.requestOrderList()
# 15:10:00 이후라면 모든 미체결 취소한다.
self.cancelOrderList(orderList)
# 매도 가격을 가져온다.
result = self.getRealTime(self.stock_code, today, LAST_DATA)
final_price = result["close"][len(result["close"]) - 1]
# 매도 가격을 가져온다.
result = self.getRealTime(stock['stock_code'], today, LAST_DATA)
final_price = result["close"][len(result["close"]) - 1]
self.getSellingPrice(THIS_TIME, self.stock_code, final_price)
self.getSellingPrice(THIS_TIME, stock['stock_code'], final_price)
final_sell_check = True
final_sell_check = True
time.sleep(0.9)
THIS_TIME = datetime.now()