From 47e924149da9975cc872f26ab119053549fb3081 Mon Sep 17 00:00:00 2001 From: dosangyoon Date: Mon, 11 Oct 2021 16:23:31 +0900 Subject: [PATCH] init --- hts/HTS.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/hts/HTS.py b/hts/HTS.py index f9ac6e9..c4a0b59 100644 --- a/hts/HTS.py +++ b/hts/HTS.py @@ -992,11 +992,10 @@ class HTS: TOTAL_BUY_AMT = 0 final_price = 0 print ("START...") - #while datetime.strptime(given_day + " 070000", '%Y%m%d %H%M%S') < datetime.now() < datetime.strptime(given_day + " 15200", '%Y%m%d %H%M%S'): - while datetime.strptime(given_day + " 070000", '%Y%m%d %H%M%S') < datetime.now() < datetime.strptime(given_day + " 18000", '%Y%m%d %H%M%S'): + while datetime.strptime(given_day + " 070000", '%Y%m%d %H%M%S') < datetime.now() < datetime.strptime(given_day + " 15200", '%Y%m%d %H%M%S'): second = datetime.now().strftime('%Y%m%d %H%M%S') - if datetime.now() < datetime.strptime(given_day + " 151900", '%Y%m%d %H%M%S'): + if datetime.strptime(given_day + " 085900", '%Y%m%d %H%M%S') < datetime.now() < datetime.strptime(given_day + " 151500", '%Y%m%d %H%M%S'): if second in timecheck and not timecheck[second]: print("TIMECHECK", second) logFp.write("%s,%s,\n" %("TIMECHECK", second)) @@ -1051,8 +1050,8 @@ class HTS: logFp.write("%s,%s,\n" % ("NONE", second)) logFp.flush() - else: - # 15:19:00 이후라면 모든 매수/매도 주문 취소하고 현재가-5원으로 매도한다. + if datetime.strptime(given_day + " 151501", '%Y%m%d %H%M%S') < datetime.now(): + # 15:15:00 이후라면 모든 매수/매도 주문 취소하고 현재가-5원으로 매도한다. self.cancelOrderList() # 만약 잔고가 있으면 장부가보다 5원 높게 매도한다. @@ -1060,7 +1059,13 @@ class HTS: if jangoDic and len(jangoDic.keys()) > 0: for code in jangoDic: if jangoDic[code]['매도가능'] > 0: - orderNum = self.requestOrder("1", stock_code, jangoDic[code]['매도가능'], final_price-5) + # 데이터를 가지고 온다. + self.getRealTime(stock_code, given_day, result) + # 분석을 통해서 볼린저밴드 상/하단을 계산한다. + data, _, _ = self.analyze(result) + final_price = data["Close"][len(data["Close"]) - 1] - 5 + orderNum = self.requestOrder("1", stock_code, jangoDic[code]['매도가능'], final_price) + time.sleep(5) """ if final_price > jangoDic[code]['장부가'] + 5: orderNum = self.requestOrder("1", stock_code, jangoDic[code]['매도가능'], final_price) @@ -1079,7 +1084,8 @@ class HTS: # 장부가의 마지막 자리수가 7,8,9 라면 (2097, 2098, 2099 -> 2105 에 매도) orderNum = self.requestOrder("1", stock_code, jangoDic[code]['매도가능'], sell_price + 15) """ - break + else: + break time.sleep(0.9)