diff --git a/hts/HTS.py b/hts/HTS.py index a6a66ce..f9ac6e9 100644 --- a/hts/HTS.py +++ b/hts/HTS.py @@ -355,8 +355,8 @@ class HTS: #주문 리스트를 가져온다. orderList = self.requestOrderList() - #if len(orderList) < 1: - # return + if len(orderList) < 1: + return objTrade = win32com.client.Dispatch("CpTrade.CpTdUtil") initCheck = objTrade.TradeInit(0) @@ -975,7 +975,6 @@ class HTS: def buyRealTime(self, stock_code, given_day): PREVIOUS_PRICE = 0 BUY_COUNT = 100 - TOTAL_BUY_AMT = 0 logFp = open(given_day+".log", "w") @@ -990,6 +989,7 @@ class HTS: "low": [], "vol": []} + 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'): @@ -1009,6 +1009,7 @@ class HTS: data, upper, lower = self.analyze(result) # 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다. bs_buy_price, bs_sell_price = self.checkTransaction_Realtime(data, upper, lower) + final_price = data["Close"][len(data["Close"])-1] if bs_buy_price > 0: if PREVIOUS_PRICE > 0: @@ -1052,14 +1053,15 @@ class HTS: else: # 15:19:00 이후라면 모든 매수/매도 주문 취소하고 현재가-5원으로 매도한다. - self.cancelOrderList(); + self.cancelOrderList() # 만약 잔고가 있으면 장부가보다 5원 높게 매도한다. jangoDic = self.requstJango() if jangoDic and len(jangoDic.keys()) > 0: for code in jangoDic: - TOTAL_BUY_AMT = jangoDic[code]['매입금액'] if jangoDic[code]['매도가능'] > 0: + orderNum = self.requestOrder("1", stock_code, jangoDic[code]['매도가능'], final_price-5) + """ if final_price > jangoDic[code]['장부가'] + 5: orderNum = self.requestOrder("1", stock_code, jangoDic[code]['매도가능'], final_price) else: @@ -1076,6 +1078,7 @@ class HTS: else: # 장부가의 마지막 자리수가 7,8,9 라면 (2097, 2098, 2099 -> 2105 에 매도) orderNum = self.requestOrder("1", stock_code, jangoDic[code]['매도가능'], sell_price + 15) + """ break time.sleep(0.9)