This commit is contained in:
dsyoon
2024-01-25 10:19:20 +09:00
parent c3b89e30a8
commit ef1c9dcfa7

View File

@@ -573,48 +573,45 @@ class Common:
return False return False
def check_optimal_buy_timeing(self, param, stock): def check_optimal_buy_timeing(self, param, stock):
check = False
rise_rate = param['bull'][0] / (param['bull'][0]+param['bear'][0]+param['bull'][0])
if ( if (
(stock['macd'][-2] < stock['macd'][-1] and stock['rsi'][-1]) < 80 or (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'][-2] < stock['rsi'][-1] and np.min(stock['rsi'][-3:]) < 35) or
(stock['rsi'][-1:] < 33) or (stock['rsi'][-1:] < 33) or
0.9 <= param['bull'][0] / param['bull'][0] 0.7 <= rise_rate
): ):
# avg360 상승 # avg300 상승
if stock['avg300'][i - 1] < stock['avg300'][i]: if stock['avg300'][i - 1] < stock['avg300'][i]:
# avg3 < trend # avg5 < trend
if stock['avg3'][i] < stock['trend'][i]: if stock['avg5'][i] < stock['trend'][i]:
# avg3 이전 3개 봉 위 # avg5 이전 3개 봉 위
if np.max(stock['avg3'][i - 3:i]) < stock['avg3'][i]: if np.max(stock['avg5'][i - 3:i]) < stock['avg5'][i]:
buy_type = "trend" buy_type = "trend"
buy_weight = 1 # 8
check = True check = True
# 상승 추세일 때 # 상승 추세일 때
if (stock['macd'][-2] < stock['macd'][-1] and stock['macds'][-1] < stock['macd'][ if (stock['macd'][-2] < stock['macd'][-1] and stock['macds'][-1] < stock['macd'][-1] or
-1] or
stock['rsi'][-2] < stock['rsi'][-1]): stock['rsi'][-2] < stock['rsi'][-1]):
# rsi가 50을 상향 돌파할 때 # rsi가 50을 상향 돌파할 때
if 0.9 <= ticker['rise_rate'] and np.max(stock['rsi'][i - 5:i]) < 50 and 50 < stock['rsi'][i]: if 0.9 <= rise_rate and np.max(stock['rsi'][i - 5:i]) < 50 and 50 < stock['rsi'][i]:
buy_type = "rsi" buy_type = "rsi"
buy_weight = 0.5 # 1
check = True check = True
# golden & 거래량 # golden & 거래량
if stock['avg120'][i] < stock['avg30'][i] < stock['avg15'][i] < stock['avg10'][i] < stock['avg3'][i]: if stock['avg120'][i] < stock['avg60'][i] < stock['avg20'][i] < stock['avg5'][i]:
buy_type = "golden" buy_type = "golden"
buy_weight = 0.5 # 6
check = True check = True
# rsi가 30보다 작은 후에 상승일 때 # rsi가 30보다 작은 후에 상승일 때
if np.min(stock['rsi'][i - 5:i]) < 30: if np.min(stock['rsi'][i - 5:i]) < 30:
if stock['rsi'][i - 1] < stock['rsi'][i]: if stock['rsi'][i - 1] < stock['rsi'][i]:
buy_type = "rsi" buy_type = "rsi"
buy_weight = 0.8 # 4
check = True check = True
return False return check
# 낙폭 과대 체크 # 낙폭 과대 체크