init
This commit is contained in:
@@ -181,7 +181,7 @@ class BuySellChecker:
|
||||
if data["open"][i] == data["low"][i] and data["close"][i] == data["high"][i]:
|
||||
if data["close"][i] > max(data["avg3"][i], data["avg5"][i], data["avg10"][i], data["avg20"][i], data["avg30"][i]):
|
||||
buy = data["low"][i]
|
||||
weight = 3
|
||||
weight = 2
|
||||
return self.getBuyCheck(data, i, buy, weight)
|
||||
|
||||
# 만약 30원 이상 장대 양봉이 나온 경우, 다음이나 다다음 중간 값에서 매수를 한다.
|
||||
@@ -279,7 +279,7 @@ class BuySellChecker:
|
||||
if data['avg3'][i-index1-1] < data['avg10'][i-index1-1]:
|
||||
if data["slow_k"][i] < 40:
|
||||
buy = data["close"][i]
|
||||
weight = 3
|
||||
weight = 2
|
||||
return self.getBuyCheck(data, i, buy, weight)
|
||||
|
||||
|
||||
@@ -312,7 +312,7 @@ class BuySellChecker:
|
||||
if diff5 < diff4 < 0:
|
||||
if data["rsi"][i] < 30:
|
||||
buy = (data["open"][i]+data["close"][i])/2
|
||||
weight = 2
|
||||
weight = 1
|
||||
return self.getBuyCheck(data, i, buy, weight)
|
||||
|
||||
|
||||
@@ -357,7 +357,7 @@ class BuySellChecker:
|
||||
break
|
||||
if valid:
|
||||
buy = data["close"][i]
|
||||
weight = 2
|
||||
weight = 1
|
||||
return self.getBuyCheck(data, i, buy, weight)
|
||||
|
||||
return buy, weight
|
||||
|
||||
@@ -82,7 +82,8 @@ class HTS_122630 (HTS):
|
||||
print("START...")
|
||||
THIS_TIME = datetime.now()
|
||||
final_sell_check = False
|
||||
while datetime.strptime(today + " 070000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100", '%Y%m%d %H%M%S'):
|
||||
while datetime.strptime(today + " 070000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 153100",
|
||||
'%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'):
|
||||
if THIS_TIME.strftime('%Y%m%d %H%M%S') in timecheck and not timecheck[THIS_TIME.strftime('%Y%m%d %H%M%S')]:
|
||||
@@ -100,10 +101,9 @@ class HTS_122630 (HTS):
|
||||
|
||||
if bs_buy_price > 0:
|
||||
# 기본 100 주에 가중치를 추가해서 매수한다.
|
||||
#BUY_COUNT = int(self.buy_count * bs_weight)
|
||||
#33BUY_COUNT = int(self.buy_count * bs_weight)
|
||||
BUY_COUNT = int(self.buy_count * 1)
|
||||
|
||||
|
||||
# 매수를 주문한다.
|
||||
orderNum = self.requestOrder(OrderType.buy, self.stock_code, BUY_COUNT, bs_buy_price)
|
||||
|
||||
@@ -116,7 +116,6 @@ class HTS_122630 (HTS):
|
||||
# 로그 출력
|
||||
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:
|
||||
# 미체결 기록을 가져온다.
|
||||
ORDER_LIST = self.requestOrderList()
|
||||
@@ -127,7 +126,7 @@ class HTS_122630 (HTS):
|
||||
|
||||
# 매도 가격을 가져온다.
|
||||
selling_count, selling_price = self.getSellingPrice(final_price)
|
||||
# 분석된 가격으로 매도 요청한다.
|
||||
# 분석되 가격으로 매도 요청한다.
|
||||
if selling_count != 0 and selling_price != 0:
|
||||
# 매도를 요청한다.
|
||||
orderNum = self.requestOrder(OrderType.sell, self.stock_code, selling_count, selling_price)
|
||||
@@ -135,9 +134,9 @@ class HTS_122630 (HTS):
|
||||
# 로그 출력
|
||||
print("SELL", THIS_TIME.strftime('%Y%m%d %H%M%S'), selling_count, selling_price, len(orderListToCancel), len(ORDER_LIST))
|
||||
|
||||
|
||||
# 로그 출력
|
||||
print("TIMECHECK: %s, price: %d, open: %d, high: %d, low: %d, avg3: %.2f, avg5: %.2f, avg10: %.2f, avg20: %.2f, avg30: %.2f, avg60: %.2f,\n lower: %.2f, upper: %.2f, macd: %.2f, macds: %.2f, macdo: %.2f,\n rsi: %.2f, rsis: %.2f, fast_k: %.2f, slow_k: %.2f, slow_d: %.2f" %
|
||||
print(
|
||||
"TIMECHECK: %s, price: %d, open: %d, high: %d, low: %d, avg3: %.2f, avg5: %.2f, avg10: %.2f, avg20: %.2f, avg30: %.2f, avg60: %.2f,\n lower: %.2f, upper: %.2f, macd: %.2f, macds: %.2f, macdo: %.2f,\n rsi: %.2f, rsis: %.2f, fast_k: %.2f, slow_k: %.2f, slow_d: %.2f" %
|
||||
(str(THIS_TIME), final_price, data["open"][data_size - 1], data["high"][data_size - 1],
|
||||
data["low"][data_size - 1],
|
||||
data["avg3"][data_size - 1], data["avg5"][data_size - 1], data["avg10"][data_size - 1],
|
||||
@@ -146,9 +145,10 @@ class HTS_122630 (HTS):
|
||||
data["macd"][data_size - 2], data["macds"][data_size - 2], data["macdo"][data_size - 1],
|
||||
data["fast_k"][data_size - 2], data["slow_k"][data_size - 2], data["slow_d"][data_size - 1],
|
||||
data["rsi"][data_size - 1], data["rsis"][data_size - 1]))
|
||||
|
||||
timecheck[THIS_TIME] = True
|
||||
|
||||
elif datetime.strptime(today + " 151800", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 152000", '%Y%m%d %H%M%S'):
|
||||
elif datetime.strptime(today + " 151530", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(today + " 151600", '%Y%m%d %H%M%S'):
|
||||
|
||||
if not final_sell_check:
|
||||
####
|
||||
@@ -157,14 +157,14 @@ class HTS_122630 (HTS):
|
||||
|
||||
# 주문 리스트를 가져온다.
|
||||
orderList = self.requestOrderList()
|
||||
# 15:18:00 가 되면 모든 미체결 취소한다.
|
||||
# 15:10:00 이후라면 모든 미체결 취소한다.
|
||||
self.cancelOrderList(orderList)
|
||||
|
||||
# 매도 가격을 가져온다.
|
||||
result = self.getRealTime(self.stock_code, lastday, today)
|
||||
final_price = result["close"][len(result["close"]) - 1]
|
||||
selling_count, selling_price = self.getFinalSellingPrice(final_price)
|
||||
# 분석된 가격으로 매도 요청한다.
|
||||
# 분석되 가격으로 매도 요청한다.
|
||||
if selling_count != 0 and selling_price != 0:
|
||||
orderNum = self.requestOrder(OrderType.sell, self.stock_code, selling_count, selling_price)
|
||||
# 로그 출력
|
||||
|
||||
@@ -187,7 +187,7 @@ if __name__ == "__main__":
|
||||
|
||||
# KODEX 인버스 * 2
|
||||
stock_code = "252670"
|
||||
buy_count = 300
|
||||
buy_count = 600
|
||||
|
||||
hts = HTS_252670(stock_code, buy_count)
|
||||
today_str = today.strftime('%Y%m%d')
|
||||
|
||||
Reference in New Issue
Block a user