This commit is contained in:
dsyoon
2023-02-25 00:02:03 +09:00
parent 8dc4928ad8
commit ae0d0ce315

View File

@@ -180,53 +180,54 @@ class HTS_Stocks (HTS):
print("%5d: %8s, %-50s" % (idx, stock_code, stock_name))
slow_k_week, p_slow_k_week, slow_k_month, p_slow_k_month = self.getSlowK(stock_code)
if (slow_k_week < 0 or 40 < slow_k_week or slow_k_month < 0 or 40 < slow_k_month) or (slow_k_week < p_slow_k_week or slow_k_month < p_slow_k_month):
continue
if 0 < slow_k_week < 50 and 0 < slow_k_month < 50:
if ((20 < slow_k_week and p_slow_k_week < slow_k_week) or (20 < slow_k_month and p_slow_k_month < slow_k_month)):
continue
stock = self.stockStatus.fetchLastData(self.cursor_stock, stock_code, n)
try:
self.getRealTime_DailyCheck(today, stock_code, stock)
data = self.stockStatus.analyze(stock, self.analyzed_day)
except:
print ("#ERROR:", stock_code, stock_name)
continue
stock = self.stockStatus.fetchLastData(self.cursor_stock, stock_code, n)
try:
self.getRealTime_DailyCheck(today, stock_code, stock)
data = self.stockStatus.analyze(stock, self.analyzed_day)
except:
print ("#ERROR:", stock_code, stock_name)
continue
# 분석일 데이터만 활용한다 (이전 데이터는 제거)
data.drop(data.index[:len(data) - self.analyzed_day], inplace=True)
# 분석일 데이터만 활용한다 (이전 데이터는 제거)
data.drop(data.index[:len(data) - self.analyzed_day], inplace=True)
bsLine, data = self.buySellChecker.checkTransactionWithEnvelope(data, stock_code, self.analyzed_day, isRealTime=False)
bsLine, data = self.buySellChecker.checkTransactionWithEnvelope(data, stock_code, self.analyzed_day, isRealTime=False)
# 미체결 기록을 가져와서 10분 이상 된 매수 주문을 취소 한다.
ORDER_LIST = self.requestOrderList()
orderListToCancel = self.orderChecker.cancel(today, "A" + stock_code, ORDER_LIST, mins=10)
if len(orderListToCancel) > 0:
self.cancelOrderList(orderListToCancel)
# 미체결 기록을 가져와서 10분 이상 된 매수 주문을 취소 한다.
ORDER_LIST = self.requestOrderList()
orderListToCancel = self.orderChecker.cancel(today, "A" + stock_code, ORDER_LIST, mins=10)
if len(orderListToCancel) > 0:
self.cancelOrderList(orderListToCancel)
# 다음 조건이면 매수한다.
if len(data) > 10 and max(bsLine['buy'][len(bsLine['buy']) - 1:]) > 1000:
# 다음 조건이면 매수한다.
if len(data) > 10 and max(bsLine['buy'][len(bsLine['buy']) - 1:]) > 1000:
if not self.orderChecker.exist(today, "A" + stock_code, hours=9):
if not self.orderChecker.exist(today, "A" + stock_code, hours=9):
last_index = len(bsLine['buy'])-1
if 0 < bsLine['buy'][last_index] < 200000:
last_index = len(bsLine['buy'])-1
if 0 < bsLine['buy'][last_index] < 200000:
bs_buy_price = bsLine['buy'][last_index]
bs_buy_weight = bsLine['buy_weight'][last_index]
MAX_BUY_PRIFE = self.getMaxPrice(stock_code, valid_company)
buy_count = int(math.ceil(MAX_BUY_PRIFE / bs_buy_price))
if MAX_BUY_PRIFE <= bs_buy_price < 2 * MAX_BUY_PRIFE:
buy_count = int(2 * MAX_BUY_PRIFE / bs_buy_price)
bs_buy_price = bsLine['buy'][last_index]
bs_buy_weight = bsLine['buy_weight'][last_index]
MAX_BUY_PRIFE = self.getMaxPrice(stock_code, valid_company)
buy_count = int(math.ceil(MAX_BUY_PRIFE / bs_buy_price))
if MAX_BUY_PRIFE <= bs_buy_price < 2 * MAX_BUY_PRIFE:
buy_count = int(2 * MAX_BUY_PRIFE / bs_buy_price)
if buy_count > 0:
# 매수를 주문한다.
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, bs_buy_price)
self.orderChecker.buy(today, "A" + stock_code, buy_count, bs_buy_price, orderNum)
if buy_count > 0:
# 매수를 주문한다.
orderNum = self.requestOrder(OrderType.buy, stock_code, buy_count, bs_buy_price)
self.orderChecker.buy(today, "A" + stock_code, buy_count, bs_buy_price, orderNum)
# slackbot에 메시지를 보냄
self.slackBot.post_to_slack(stock_code, stock_name, "BUY", bsLine['buy'][len(bsLine['buy']) - 1], buy_count)
# slackbot에 메시지를 보냄
self.slackBot.post_to_slack(stock_code, stock_name, "BUY", bsLine['buy'][len(bsLine['buy']) - 1], buy_count)
# 로그 출력
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock_code, stock_name, bs_buy_price, buy_count)
# 로그 출력
print("BUY", THIS_TIME.strftime('%Y%m%d %H%M%S'), orderNum, stock_code, stock_name, bs_buy_price, buy_count)
# 다음 조건이면 매도한다.
if len(data) > 10 and max(bsLine['sell'][len(bsLine['sell']) - 1:]) > 1000: