This commit is contained in:
dsyoon
2024-01-24 23:57:35 +09:00
parent 00b7020496
commit 12ee951d07
2 changed files with 58 additions and 18 deletions

View File

@@ -572,13 +572,49 @@ class Common:
return False
def check_optimal_buy_timeing(self, stock):
def check_optimal_buy_timeing(self, param, stock):
if stock['avg120'][0] < stock['avg60'][0] < stock['avg20'][0] < stock['avg5'][0]:
if stock['avg20'][1] < stock['avg20'][0] and stock['avg5'][1] < stock['avg5'][0]:
if stock['avg240'][0] < stock['avg20'][0] < stock['avg5'][0]:
if stock['rsi'][0] < 70:
return True
if (
(stock['macd'][-2] < stock['macd'][-1] and stock['rsi'][-1]) < 80 or
(stock['rsi'][-2] < stock['rsi'][-1] and np.min(stock['rsi'][-3:]) < 35) or
(stock['rsi'][-1:] < 33) or
0.9 <= ticker['rise_rate']
):
# trend 상승
if stock['trend'][i - 1] < stock['trend'][i]:
# avg360 상승
if stock['avg360'][i - 1] < stock['avg360'][i]:
# avg3 < trend
if stock['avg3'][i] < stock['trend'][i]:
# avg3 이전 3개 봉 위
if np.max(stock['avg3'][i - 3:i]) < stock['avg3'][i]:
buy_type = "trend"
buy_weight = 1 # 8
check = True
# 상승 추세일 때
if (stock['macd'][-2] < stock['macd'][-1] and stock['macds'][-1] < stock['macd'][
-1] or
stock['rsi'][-2] < stock['rsi'][-1]):
# rsi가 50을 상향 돌파할 때
if 0.9 <= ticker['rise_rate'] and np.max(stock['rsi'][i - 5:i]) < 50 and 50 < stock['rsi'][i]:
buy_type = "rsi"
buy_weight = 0.5 # 1
check = True
# golden & 거래량
if stock['avg120'][i] < stock['avg30'][i] < stock['avg15'][i] < stock['avg10'][i] < stock['avg3'][i]:
buy_type = "golden"
buy_weight = 0.5 # 6
check = True
# rsi가 30보다 작은 후에 상승일 때
if np.min(stock['rsi'][i - 5:i]) < 30:
if stock['rsi'][i - 1] < stock['rsi'][i]:
buy_type = "rsi"
buy_weight = 0.8 # 4
check = True
return False