diff --git a/HTS_122630.py b/HTS_122630.py index e23b069..26033e8 100644 --- a/HTS_122630.py +++ b/HTS_122630.py @@ -60,15 +60,14 @@ class HTS_122630 (HTS): if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'): # 3시 까지만 매수를 시도한다. - """ if THIS_TIME.strftime('%S') in ("09", "19", "29", "39", "49", "59"): - # 데이터를 가지고 온다. - result = self.getRealTime(self.stock_code, today, LAST_DATA) - final_price = result["close"][len(result["close"])-1] + if THIS_TIME.strftime('%S') in ("06", "16", "26", "36", "46", "56"): + # 데이터를 가지고 온다. + result = self.getRealTime(self.stock_code, today, LAST_DATA) + final_price = result["close"][len(result["close"]) - 1] - # 10초마다 체크하여 체결된 내역이 있으면 60원 높게 매도를 주문한다. - self.getDefaultSell(THIS_TIME, self.stock_code, final_price) - """ + # 10초마다 체크하여 체결된 내역이 있으면 50원 높게 매도를 주문한다. + self.getSellingPrice(THIS_TIME, self.stock_code, final_price) if THIS_TIME.strftime('%S') == "05": # 매분 5초마다 실행한다. @@ -79,6 +78,17 @@ class HTS_122630 (HTS): # 규칙 기반의 분석을 통해서 볼린저밴드 상/하단을 계산한다. data = self.buySellChecker.analyze(result) + # 만약 미체결 내역이 있는데, 지표가 꺽여 내려온다면, 매수 주문을 취소 시킨다. + last_index = len(data['close']) - 1 + if data['slow_k'][last_index - 1] >= 80 and data['slow_k'][last_index - 1] > data['slow_k'][ + last_index]: + # 미체결 기록을 가져온다. + ORDER_LIST = self.requestOrderList() + orderListToCancel = self.orderChecker.remove(self.stock_code, OrderType.sell, ORDER_LIST) + self.cancelOrderList(orderListToCancel) + print("CANCEL", THIS_TIME.strftime('%Y%m%d %H%M%S'), len(orderListToCancel), len(ORDER_LIST)) + + # 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다. bsLine, data = self.buySellChecker.checkTransaction(data, self.stock_code, isRealTime=True) bs_buy_price = bsLine['buy'][0] diff --git a/HTS_252670.py b/HTS_252670.py index cf4174b..9370747 100644 --- a/HTS_252670.py +++ b/HTS_252670.py @@ -81,6 +81,16 @@ class HTS_252670 (HTS): # 규칙 기반의 분석을 통해서 볼린저밴드 상/하단을 계산한다. data = self.buySellChecker.analyze(result) + # 만약 미체결 내역이 있는데, 지표가 꺽여 내려온다면, 매수 주문을 취소 시킨다. + last_index = len(data['close']) - 1 + if data['slow_k'][last_index-1]>=80 and data['slow_k'][last_index-1] > data['slow_k'][last_index]: + # 미체결 기록을 가져온다. + ORDER_LIST = self.requestOrderList() + orderListToCancel = self.orderChecker.remove(self.stock_code, OrderType.sell, ORDER_LIST) + self.cancelOrderList(orderListToCancel) + print("CANCEL", THIS_TIME.strftime('%Y%m%d %H%M%S'), len(orderListToCancel), len(ORDER_LIST)) + + # 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다. bsLine, data = self.buySellChecker.checkTransaction(data, self.stock_code, isRealTime=True) bs_buy_price = bsLine['buy'][0] diff --git a/hts/HTS.py b/hts/HTS.py index 7a3f704..88d15bc 100644 --- a/hts/HTS.py +++ b/hts/HTS.py @@ -338,7 +338,7 @@ class HTS: return orderList # 미체결 취소하기 - def cancelOrderList(self, orderList): + def cancelOrderList(self, orderList=None): if len(orderList) < 1: return