This commit is contained in:
dsyoon
2023-02-01 14:06:09 +09:00
parent e938024ec5
commit a409e5c07c
3 changed files with 8 additions and 5 deletions

View File

@@ -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)

View File

@@ -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:

View File

@@ -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]
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