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["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]):
|
if data["close"][i] > max(data["avg3"][i], data["avg5"][i], data["avg10"][i], data["avg20"][i], data["avg30"][i]):
|
||||||
buy = data["low"][i]
|
buy = data["low"][i]
|
||||||
weight = 3
|
weight = 2
|
||||||
return self.getBuyCheck(data, i, buy, weight)
|
return self.getBuyCheck(data, i, buy, weight)
|
||||||
|
|
||||||
# 만약 30원 이상 장대 양봉이 나온 경우, 다음이나 다다음 중간 값에서 매수를 한다.
|
# 만약 30원 이상 장대 양봉이 나온 경우, 다음이나 다다음 중간 값에서 매수를 한다.
|
||||||
@@ -279,7 +279,7 @@ class BuySellChecker:
|
|||||||
if data['avg3'][i-index1-1] < data['avg10'][i-index1-1]:
|
if data['avg3'][i-index1-1] < data['avg10'][i-index1-1]:
|
||||||
if data["slow_k"][i] < 40:
|
if data["slow_k"][i] < 40:
|
||||||
buy = data["close"][i]
|
buy = data["close"][i]
|
||||||
weight = 3
|
weight = 2
|
||||||
return self.getBuyCheck(data, i, buy, weight)
|
return self.getBuyCheck(data, i, buy, weight)
|
||||||
|
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ class BuySellChecker:
|
|||||||
if diff5 < diff4 < 0:
|
if diff5 < diff4 < 0:
|
||||||
if data["rsi"][i] < 30:
|
if data["rsi"][i] < 30:
|
||||||
buy = (data["open"][i]+data["close"][i])/2
|
buy = (data["open"][i]+data["close"][i])/2
|
||||||
weight = 2
|
weight = 1
|
||||||
return self.getBuyCheck(data, i, buy, weight)
|
return self.getBuyCheck(data, i, buy, weight)
|
||||||
|
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ class BuySellChecker:
|
|||||||
break
|
break
|
||||||
if valid:
|
if valid:
|
||||||
buy = data["close"][i]
|
buy = data["close"][i]
|
||||||
weight = 2
|
weight = 1
|
||||||
return self.getBuyCheck(data, i, buy, weight)
|
return self.getBuyCheck(data, i, buy, weight)
|
||||||
|
|
||||||
return buy, weight
|
return buy, weight
|
||||||
|
|||||||
@@ -79,10 +79,11 @@ class HTS_122630 (HTS):
|
|||||||
timecheckList = pd.read_csv("timecheck.csv").values.tolist()
|
timecheckList = pd.read_csv("timecheck.csv").values.tolist()
|
||||||
timecheck = {today + " " + str(second).zfill(6):False for second, check in timecheckList}
|
timecheck = {today + " " + str(second).zfill(6):False for second, check in timecheckList}
|
||||||
|
|
||||||
print ("START...")
|
print("START...")
|
||||||
THIS_TIME = datetime.now()
|
THIS_TIME = datetime.now()
|
||||||
final_sell_check = False
|
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 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')]:
|
if THIS_TIME.strftime('%Y%m%d %H%M%S') in timecheck and not timecheck[THIS_TIME.strftime('%Y%m%d %H%M%S')]:
|
||||||
@@ -96,16 +97,15 @@ class HTS_122630 (HTS):
|
|||||||
# 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다.
|
# 사야 할 시점/가격과 팔아야 할 시점/가격을 체크한다.
|
||||||
bs_buy_price, bs_weight, bs_sell_price = self.checkTransaction(data)
|
bs_buy_price, bs_weight, bs_sell_price = self.checkTransaction(data)
|
||||||
data_size = len(data["close"])
|
data_size = len(data["close"])
|
||||||
final_price = data["close"][data_size-1]
|
final_price = data["close"][data_size - 1]
|
||||||
|
|
||||||
if bs_buy_price > 0:
|
if bs_buy_price > 0:
|
||||||
# 기본 100 주에 가중치를 추가해서 매수한다.
|
# 기본 100 주에 가중치를 추가해서 매수한다.
|
||||||
#BUY_COUNT = int(self.buy_count * bs_weight)
|
#33BUY_COUNT = int(self.buy_count * bs_weight)
|
||||||
BUY_COUNT = int(self.buy_count * 1)
|
BUY_COUNT = int(self.buy_count * 1)
|
||||||
|
|
||||||
|
|
||||||
# 매수를 주문한다.
|
# 매수를 주문한다.
|
||||||
orderNum = self.requestOrder(OrderType.buy, self.stock_code, BUY_COUNT , bs_buy_price)
|
orderNum = self.requestOrder(OrderType.buy, self.stock_code, BUY_COUNT, bs_buy_price)
|
||||||
|
|
||||||
# 미체결 기록을 가져온다.
|
# 미체결 기록을 가져온다.
|
||||||
ORDER_LIST = self.requestOrderList()
|
ORDER_LIST = self.requestOrderList()
|
||||||
@@ -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))
|
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:
|
||||||
# 미체결 기록을 가져온다.
|
# 미체결 기록을 가져온다.
|
||||||
ORDER_LIST = self.requestOrderList()
|
ORDER_LIST = self.requestOrderList()
|
||||||
@@ -127,7 +126,7 @@ class HTS_122630 (HTS):
|
|||||||
|
|
||||||
# 매도 가격을 가져온다.
|
# 매도 가격을 가져온다.
|
||||||
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, self.stock_code, selling_count, selling_price)
|
orderNum = self.requestOrder(OrderType.sell, self.stock_code, selling_count, selling_price)
|
||||||
@@ -135,20 +134,21 @@ 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("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(
|
||||||
(str(THIS_TIME), final_price, data["open"][data_size - 1], data["high"][data_size - 1],
|
"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" %
|
||||||
data["low"][data_size - 1],
|
(str(THIS_TIME), final_price, data["open"][data_size - 1], data["high"][data_size - 1],
|
||||||
data["avg3"][data_size - 1], data["avg5"][data_size - 1], data["avg10"][data_size - 1],
|
data["low"][data_size - 1],
|
||||||
data["avg20"][data_size - 1], data["avg30"][data_size - 1], data["avg60"][data_size - 1],
|
data["avg3"][data_size - 1], data["avg5"][data_size - 1], data["avg10"][data_size - 1],
|
||||||
data["lower"][data_size - 1], data["upper"][data_size - 1],
|
data["avg20"][data_size - 1], data["avg30"][data_size - 1], data["avg60"][data_size - 1],
|
||||||
data["macd"][data_size - 2], data["macds"][data_size - 2], data["macdo"][data_size - 1],
|
data["lower"][data_size - 1], data["upper"][data_size - 1],
|
||||||
data["fast_k"][data_size - 2], data["slow_k"][data_size - 2], data["slow_d"][data_size - 1],
|
data["macd"][data_size - 2], data["macds"][data_size - 2], data["macdo"][data_size - 1],
|
||||||
data["rsi"][data_size - 1], data["rsis"][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
|
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:
|
if not final_sell_check:
|
||||||
####
|
####
|
||||||
@@ -157,14 +157,14 @@ class HTS_122630 (HTS):
|
|||||||
|
|
||||||
# 주문 리스트를 가져온다.
|
# 주문 리스트를 가져온다.
|
||||||
orderList = self.requestOrderList()
|
orderList = self.requestOrderList()
|
||||||
# 15:18:00 가 되면 모든 미체결 취소한다.
|
# 15:10:00 이후라면 모든 미체결 취소한다.
|
||||||
self.cancelOrderList(orderList)
|
self.cancelOrderList(orderList)
|
||||||
|
|
||||||
# 매도 가격을 가져온다.
|
# 매도 가격을 가져온다.
|
||||||
result = self.getRealTime(self.stock_code, lastday, today)
|
result = self.getRealTime(self.stock_code, lastday, today)
|
||||||
final_price = result["close"][len(result["close"])-1]
|
final_price = result["close"][len(result["close"]) - 1]
|
||||||
selling_count, selling_price = self.getFinalSellingPrice(final_price)
|
selling_count, selling_price = self.getFinalSellingPrice(final_price)
|
||||||
# 분석된 가격으로 매도 요청한다.
|
# 분석되 가격으로 매도 요청한다.
|
||||||
if selling_count != 0 and selling_price != 0:
|
if selling_count != 0 and selling_price != 0:
|
||||||
orderNum = self.requestOrder(OrderType.sell, self.stock_code, selling_count, selling_price)
|
orderNum = self.requestOrder(OrderType.sell, self.stock_code, selling_count, selling_price)
|
||||||
# 로그 출력
|
# 로그 출력
|
||||||
|
|||||||
@@ -187,7 +187,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
# KODEX 인버스 * 2
|
# KODEX 인버스 * 2
|
||||||
stock_code = "252670"
|
stock_code = "252670"
|
||||||
buy_count = 300
|
buy_count = 600
|
||||||
|
|
||||||
hts = HTS_252670(stock_code, buy_count)
|
hts = HTS_252670(stock_code, buy_count)
|
||||||
today_str = today.strftime('%Y%m%d')
|
today_str = today.strftime('%Y%m%d')
|
||||||
|
|||||||
Reference in New Issue
Block a user