try except deletion

This commit is contained in:
dsyoon
2021-10-25 13:01:33 +09:00
parent d0290034a0
commit b6ec663d63

View File

@@ -569,11 +569,7 @@ class HTS_252670:
if THIS_TIME.strftime('%Y%m%d %H%M%S') in timecheck and not timecheck[THIS_TIME.strftime('%Y%m%d %H%M%S')]: if THIS_TIME.strftime('%Y%m%d %H%M%S') in timecheck and not timecheck[THIS_TIME.strftime('%Y%m%d %H%M%S')]:
# 데이터를 가지고 온다. # 데이터를 가지고 온다.
try: self.getRealTime(stock_code, GIVEN_DAY, result)
self.getRealTime(stock_code, GIVEN_DAY, result)
except:
time.sleep(0.9)
continue
# 분석을 통해서 볼린저밴드 상/하단을 계산한다. # 분석을 통해서 볼린저밴드 상/하단을 계산한다.
data = self.buySellChecker.analyze(result) data = self.buySellChecker.analyze(result)
@@ -588,46 +584,34 @@ class HTS_252670:
BUY_COUNT = int(BASE_COUNT * 1) BUY_COUNT = int(BASE_COUNT * 1)
# 매수를 주문한다. # 매수를 주문한다.
try: orderNum = self.requestOrder(OrderType.buy, stock_code, BUY_COUNT , bs_buy_price)
orderNum = self.requestOrder(OrderType.buy, stock_code, BUY_COUNT , bs_buy_price)
except:
time.sleep(0.9)
continue
# 미체결 기록을 가져온다. # 미체결 기록을 가져온다.
try: ORDER_LIST = self.requestOrderList()
ORDER_LIST = self.requestOrderList() # 매수 주문을 기록한다.
# 매수 주문을 기록한다. orderListToCancel = orderChecker.add(stock_code, OrderType.buy, orderNum, BUY_COUNT, bs_buy_price, ORDER_LIST)
orderListToCancel = orderChecker.add(stock_code, OrderType.buy, orderNum, BUY_COUNT, bs_buy_price, ORDER_LIST) # 두 시간 이전 미체결을 모두 취소한다.
# 두 시간 이전 미체결을 모두 취소한다. self.cancelOrderList(orderListToCancel)
self.cancelOrderList(orderListToCancel)
except:
time.sleep(0.9)
continue
# 로그 출력 # 로그 출력
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), BUY_COUNT, bs_buy_price, len(orderListToCancel), len(ORDER_LIST)) print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), BUY_COUNT, bs_buy_price, len(orderListToCancel), len(ORDER_LIST))
if bs_sell_price > 0: if bs_sell_price > 0:
try: # 미체결 기록을 가져온다.
# 미체결 기록을 가져온다. ORDER_LIST = self.requestOrderList()
ORDER_LIST = self.requestOrderList() # 매도 주문을 기록을 가져온다.
# 매도 주문을 기록을 가져온다. orderListToCancel = orderChecker.remove(stock_code, OrderType.sell, ORDER_LIST)
orderListToCancel = orderChecker.remove(stock_code, OrderType.sell, ORDER_LIST) # 매도 미체결을 모두 취소한다.
# 매도 미체결을 모두 취소한다. self.cancelOrderList(orderListToCancel)
self.cancelOrderList(orderListToCancel)
# 매도 가격을 가져온다. # 매도 가격을 가져온다.
selling_count, selling_price = self.getSellingPrice(final_price) selling_count, selling_price = self.getSellingPrice(final_price)
# 분석되 가격으로 매도 요청한다. # 분석되 가격으로 매도 요청한다.
if selling_count != 0 and selling_price != 0: if selling_count != 0 and selling_price != 0:
# 매도를 요청한다. # 매도를 요청한다.
orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, selling_price) orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, selling_price)
# 로그 출력 # 로그 출력
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), selling_count, selling_price, len(orderListToCancel), len(ORDER_LIST)) print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), selling_count, selling_price, len(orderListToCancel), len(ORDER_LIST))
except:
time.sleep(0.9)
continue
# 로그 출력 # 로그 출력
print("TIMECHECK", THIS_TIME, final_price, data["low"][data_size-1], data["slow_k"][data_size-1], data["slow_d"][data_size-1]) print("TIMECHECK", THIS_TIME, final_price, data["low"][data_size-1], data["slow_k"][data_size-1], data["slow_d"][data_size-1])
@@ -637,24 +621,21 @@ class HTS_252670:
#### ####
# 손해 보지 않는 가격에 매도한다. # 손해 보지 않는 가격에 매도한다.
#### ####
try:
# 주문 리스트를 가져온다.
orderList = self.requestOrderList()
# 15:10:00 이후라면 모든 미체결 취소한다.
self.cancelOrderList(orderList)
# 매도 가격을 가져온다. # 주문 리스트를 가져온다.
selling_count, selling_price = self.getSellingPrice(final_price) orderList = self.requestOrderList()
# 분석되 가격으로 매도 요청한다. # 15:10:00 이후라면 모든 미체결 취소한다.
if selling_count != 0 and selling_price != 0: self.cancelOrderList(orderList)
orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, selling_price)
# 로그 출력
print("SELL", THIS_TIME, selling_count, selling_price)
break # 매도 가격을 가져온다.
except: selling_count, selling_price = self.getSellingPrice(final_price)
time.sleep(0.9) # 분석되 가격으로 매도 요청한다.
continue if selling_count != 0 and selling_price != 0:
orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, selling_price)
# 로그 출력
print("SELL", THIS_TIME, selling_count, selling_price)
break
time.sleep(0.9) time.sleep(0.9)
THIS_TIME = datetime.now() THIS_TIME = datetime.now()