This commit is contained in:
dosang.yoon
2022-08-29 13:03:22 +09:00
parent b17561f9d5
commit 7e733dc453
3 changed files with 28 additions and 8 deletions

View File

@@ -60,15 +60,14 @@ class HTS_122630 (HTS):
if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'): if datetime.strptime(today + " 090000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151500", '%Y%m%d %H%M%S'):
# 3시 까지만 매수를 시도한다. # 3시 까지만 매수를 시도한다.
"""
if THIS_TIME.strftime('%S') in ("09", "19", "29", "39", "49", "59"): if THIS_TIME.strftime('%S') in ("09", "19", "29", "39", "49", "59"):
# 데이터를 가지고 온다. if THIS_TIME.strftime('%S') in ("06", "16", "26", "36", "46", "56"):
result = self.getRealTime(self.stock_code, today, LAST_DATA) # 데이터를 가지고 온다.
final_price = result["close"][len(result["close"])-1] result = self.getRealTime(self.stock_code, today, LAST_DATA)
final_price = result["close"][len(result["close"]) - 1]
# 10초마다 체크하여 체결된 내역이 있으면 60원 높게 매도를 주문한다. # 10초마다 체크하여 체결된 내역이 있으면 50원 높게 매도를 주문한다.
self.getDefaultSell(THIS_TIME, self.stock_code, final_price) self.getSellingPrice(THIS_TIME, self.stock_code, final_price)
"""
if THIS_TIME.strftime('%S') == "05": if THIS_TIME.strftime('%S') == "05":
# 매분 5초마다 실행한다. # 매분 5초마다 실행한다.
@@ -79,6 +78,17 @@ class HTS_122630 (HTS):
# 규칙 기반의 분석을 통해서 볼린저밴드 상/하단을 계산한다. # 규칙 기반의 분석을 통해서 볼린저밴드 상/하단을 계산한다.
data = self.buySellChecker.analyze(result) data = self.buySellChecker.analyze(result)
# 만약 미체결 내역이 있는데, 지표가 꺽여 내려온다면, 매수 주문을 취소 시킨다.
last_index = len(data['close']) - 1
if data['slow_k'][last_index - 1] >= 80 and data['slow_k'][last_index - 1] > data['slow_k'][
last_index]:
# 미체결 기록을 가져온다.
ORDER_LIST = self.requestOrderList()
orderListToCancel = self.orderChecker.remove(self.stock_code, OrderType.sell, ORDER_LIST)
self.cancelOrderList(orderListToCancel)
print("CANCEL", THIS_TIME.strftime('%Y%m%d %H%M%S'), len(orderListToCancel), len(ORDER_LIST))
# 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다. # 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다.
bsLine, data = self.buySellChecker.checkTransaction(data, self.stock_code, isRealTime=True) bsLine, data = self.buySellChecker.checkTransaction(data, self.stock_code, isRealTime=True)
bs_buy_price = bsLine['buy'][0] bs_buy_price = bsLine['buy'][0]

View File

@@ -81,6 +81,16 @@ class HTS_252670 (HTS):
# 규칙 기반의 분석을 통해서 볼린저밴드 상/하단을 계산한다. # 규칙 기반의 분석을 통해서 볼린저밴드 상/하단을 계산한다.
data = self.buySellChecker.analyze(result) data = self.buySellChecker.analyze(result)
# 만약 미체결 내역이 있는데, 지표가 꺽여 내려온다면, 매수 주문을 취소 시킨다.
last_index = len(data['close']) - 1
if data['slow_k'][last_index-1]>=80 and data['slow_k'][last_index-1] > data['slow_k'][last_index]:
# 미체결 기록을 가져온다.
ORDER_LIST = self.requestOrderList()
orderListToCancel = self.orderChecker.remove(self.stock_code, OrderType.sell, ORDER_LIST)
self.cancelOrderList(orderListToCancel)
print("CANCEL", THIS_TIME.strftime('%Y%m%d %H%M%S'), len(orderListToCancel), len(ORDER_LIST))
# 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다. # 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다.
bsLine, data = self.buySellChecker.checkTransaction(data, self.stock_code, isRealTime=True) bsLine, data = self.buySellChecker.checkTransaction(data, self.stock_code, isRealTime=True)
bs_buy_price = bsLine['buy'][0] bs_buy_price = bsLine['buy'][0]

View File

@@ -338,7 +338,7 @@ class HTS:
return orderList return orderList
# 미체결 취소하기 # 미체결 취소하기
def cancelOrderList(self, orderList): def cancelOrderList(self, orderList=None):
if len(orderList) < 1: if len(orderList) < 1:
return return