diff --git a/HTS_etf.py b/HTS_etf.py index cb94323..f78ca03 100644 --- a/HTS_etf.py +++ b/HTS_etf.py @@ -132,7 +132,7 @@ class HTS_etf (HTS): if bs_buy_price > 0: - if not self.orderChecker.exist(today, "A" + stock['stock_code'], mins=10): + if not self.orderChecker.exist(today, "A" + stock['stock_code'], mins=30): buy_count = int(self.MAX_BUY_PRICE/bs_buy_price) diff --git a/HTS_stocks.py b/HTS_stocks.py index 1bc0a24..20e12e3 100644 --- a/HTS_stocks.py +++ b/HTS_stocks.py @@ -137,14 +137,14 @@ class HTS_Stocks (HTS): # 미체결 기록을 가져와서 10분 이상 된 매수 주문을 취소 한다. ORDER_LIST = self.requestOrderList() - orderListToCancel = self.orderChecker.cancel(today, "A" + stock_code, ORDER_LIST, mins=60) + orderListToCancel = self.orderChecker.cancel(today, "A" + stock_code, ORDER_LIST, mins=10) if len(orderListToCancel) > 0: self.cancelOrderList(orderListToCancel) # 다음 조건이면 매수한다. if len(data) > 10 and max(bsLine['buy'][len(bsLine['buy']) - 1:]) > 1000: - if not self.orderChecker.exist(today, "A" + stock_code, mins=10): + if not self.orderChecker.exist(today, "A" + stock_code, hours=2): last_index = len(bsLine['buy'])-1 if bsLine['buy'][last_index] > 0: diff --git a/hts/OrderChecker.py b/hts/OrderChecker.py index ef6f7e9..500faff 100644 --- a/hts/OrderChecker.py +++ b/hts/OrderChecker.py @@ -29,11 +29,14 @@ class OrderChecker: order_df['datetime'] = pd.to_datetime(order_df['datetime']) return order_df - def exist(self, ymd, stock_code, mins=30): + def exist(self, ymd, stock_code, mins=None, hours=None): order_df = self.read(ymd) if order_df is not None and len(order_df)>0: tmp = order_df.loc[order_df["stock_code"] == stock_code] - now = datetime.now() - timedelta(minutes=mins) + if mins is not None: + now = datetime.now() - timedelta(minutes=mins) + else: + now = datetime.now() - timedelta(hours=hours) tmp = tmp.loc[now < tmp["datetime"]] if tmp is not None and len(tmp) > 0: return True