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

@@ -472,11 +472,26 @@ class AnalyzerSqlite:
cursor.close()
conn.close()
# 상승 종목 개수
param = {'bull': [], 'bear': [], 'even': []}
for i in range(60):
param['bull'].append(0)
param['bear'].append(0)
param['even'].append(0)
for idx, item in enumerate(items):
CODE = item[0]
stock_daily = self.getStockData(stockAnalysisTableName, CODE)
for c in range(len(stock_daily['open'])):
if c >= 60:
break
if stock_daily['open'][c] < stock_daily['close'][c]:
param['bull'][c] += 1
elif stock_daily['close'][c] < stock_daily['open'][c]:
param['bear'][c] += 1
else:
param['even'][c] += 1
self.writeSummary(param)
for idx, item in enumerate(items):
CODE = item[0]
@@ -526,22 +541,11 @@ class AnalyzerSqlite:
log = "이전없던거래량_" + log
self.writeFile(dir_name, CODE, NAME, top, stock_daily, log)
check = self.common.check_optimal_buy_timeing(stock_daily)
check = self.common.check_optimal_buy_timeing(param, stock_daily)
if check:
dir_name = "daily_최적_타이밍_찾기"
log = dir_name + "_"
self.writeFile(dir_name, CODE, NAME, top, stock_daily, log)
for c in range(len(stock_daily['open'])):
if c >= 60:
break
if stock_daily['open'][c] < stock_daily['close'][c]:
param['bull'][c] += 1
elif stock_daily['close'][c] < stock_daily['open'][c]:
param['bear'][c] += 1
else:
param['even'][c] += 1
self.writeSummary(param)
return
def get_moving_average(self, stock):

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