init
This commit is contained in:
@@ -547,7 +547,7 @@ class HTS_122630:
|
||||
|
||||
def buyRealTime(self, stock_code, GIVEN_DAY):
|
||||
orderChecker = OrderChecker(stock_code)
|
||||
BASE_COUNT = 100
|
||||
BASE_COUNT = 150
|
||||
|
||||
timecheckList = pd.read_csv("timecheck.csv").values.tolist()
|
||||
timecheck = {GIVEN_DAY + " " + str(second).zfill(6): False for second, check in timecheckList}
|
||||
@@ -563,10 +563,13 @@ class HTS_122630:
|
||||
final_price = 0
|
||||
print("START...")
|
||||
THIS_TIME = datetime.now()
|
||||
while datetime.strptime(GIVEN_DAY + " 070000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(GIVEN_DAY + " 15200", '%Y%m%d %H%M%S'):
|
||||
while datetime.strptime(GIVEN_DAY + " 070000", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(
|
||||
GIVEN_DAY + " 15200", '%Y%m%d %H%M%S'):
|
||||
|
||||
if datetime.strptime(GIVEN_DAY + " 090100", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(GIVEN_DAY + " 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 datetime.strptime(GIVEN_DAY + " 090100", '%Y%m%d %H%M%S') < THIS_TIME < datetime.strptime(
|
||||
GIVEN_DAY + " 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')]:
|
||||
|
||||
# 데이터를 가지고 온다.
|
||||
self.getRealTime(stock_code, GIVEN_DAY, result)
|
||||
@@ -580,7 +583,8 @@ class HTS_122630:
|
||||
|
||||
if bs_buy_price > 0:
|
||||
# 기본 100 주에 가중치를 추가해서 매수한다.
|
||||
BUY_COUNT = int(BASE_COUNT * bs_weight)
|
||||
# BUY_COUNT = int(BASE_COUNT * bs_weight)
|
||||
BUY_COUNT = int(BASE_COUNT * 1)
|
||||
|
||||
# 매수를 주문한다.
|
||||
orderNum = self.requestOrder(OrderType.buy, stock_code, BUY_COUNT, bs_buy_price)
|
||||
@@ -588,7 +592,8 @@ class HTS_122630:
|
||||
# 미체결 기록을 가져온다.
|
||||
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)
|
||||
# 로그 출력
|
||||
@@ -613,31 +618,25 @@ class HTS_122630:
|
||||
print("SELL", THIS_TIME, selling_count, selling_price)
|
||||
|
||||
# 로그 출력
|
||||
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])
|
||||
timecheck[THIS_TIME] = True
|
||||
|
||||
if datetime.strptime(GIVEN_DAY + " 151500", '%Y%m%d %H%M%S') < THIS_TIME:
|
||||
if datetime.strptime(GIVEN_DAY + " 151530", '%Y%m%d %H%M%S') < THIS_TIME:
|
||||
####
|
||||
# 종가에 그냥 매도한다.
|
||||
# 손해 보지 않는 가격에 매도한다.
|
||||
####
|
||||
|
||||
# 주문 리스트를 가져온다.
|
||||
orderList = self.requestOrderList()
|
||||
# 15:15:00 이후라면 모든 미체결 취소한다.
|
||||
# 15:10:00 이후라면 모든 미체결 취소한다.
|
||||
self.cancelOrderList(orderList)
|
||||
|
||||
# 데이터를 가지고 온다.
|
||||
self.getRealTime(stock_code, GIVEN_DAY, result)
|
||||
|
||||
# 분석을 통해서 볼린저밴드 상/하단을 계산한다.
|
||||
data = self.buySellChecker.analyze(result)
|
||||
data_size = len(data["Close"])
|
||||
final_price = data["Close"][data_size - 1]
|
||||
|
||||
# 매도 가격을 가져온다.
|
||||
selling_count, selling_price = self.getSellingPrice(final_price)
|
||||
# 분석되 가격으로 매도 요청한다.
|
||||
if selling_count != 0 and selling_price != 0:
|
||||
orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, final_price)
|
||||
orderNum = self.requestOrder(OrderType.sell, stock_code, selling_count, selling_price)
|
||||
# 로그 출력
|
||||
print("SELL", THIS_TIME, selling_count, selling_price)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user