This commit is contained in:
dsyoon
2022-12-31 12:40:06 +09:00
parent 245202157b
commit 9c2523b192

View File

@@ -285,7 +285,7 @@ class AnalyzerSqlite:
return return
def writeFile(self, type, CODE, NAME, top, stock, state, final_status_count=-1): def writeFile(self, dir_code, dir_name, CODE, NAME, top, stock, state, final_status_count):
# 3년 이내 한번이라도 영업이익이 났는지 체크를 함 # 3년 이내 한번이라도 영업이익이 났는지 체크를 함
fnguide = None fnguide = None
if CODE in self.fnguide: if CODE in self.fnguide:
@@ -302,11 +302,14 @@ class AnalyzerSqlite:
title = "%s (%s), %d, %s 차트 (<a href=\"https://alphasquare.co.kr/home/stock/financial-information?code=%s\">URL1</a>, <a href=\"https://www.tradingview.com/chart/jJ8zOXz0/?symbol=KRX:%s\">URL2</a>)" % (NAME, CODE, stock['close'][0], type, CODE, CODE) title = "%s (%s), %d, %s 차트 (<a href=\"https://alphasquare.co.kr/home/stock/financial-information?code=%s\">URL1</a>, <a href=\"https://www.tradingview.com/chart/jJ8zOXz0/?symbol=KRX:%s\">URL2</a>)" % (NAME, CODE, stock['close'][0], type, CODE, CODE)
fig['layout'].update(title=title) fig['layout'].update(title=title)
fileName = self.outPath + "/" + str(type) fileName = self.outPath + "/" + dir_code+"_"+dir_name
if final_status_count == -1:
fileName = "%s/%s_%s_%s_%s.html" % (fileName, top, NAME.replace(" ", ""), CODE, state) if dir_code == "0":
else:
fileName = "%s/%s_%s_%s_%s_%s.html" % (fileName, str(final_status_count), top, NAME.replace(" ", ""), CODE, state) fileName = "%s/%s_%s_%s_%s_%s.html" % (fileName, str(final_status_count), top, NAME.replace(" ", ""), CODE, state)
elif dir_code == "25": # 낙폭과대
fileName = "%s/%s_%s_%s_%s.html" % (fileName, state, NAME.replace(" ", ""), CODE, top)
else:
fileName = "%s/%s_%s_%s_%s.html" % (fileName, top, NAME.replace(" ", ""), CODE, state)
po.write_html(fig, file=fileName, auto_open=False) po.write_html(fig, file=fileName, auto_open=False)
return return
@@ -466,37 +469,37 @@ class AnalyzerSqlite:
if (stock_monthly['avg6'][1] is not None and stock_monthly['avg36'][1] is not None and if (stock_monthly['avg6'][1] is not None and stock_monthly['avg36'][1] is not None and
stock_monthly['avg6'][0] is not None and stock_monthly['avg36'][0] is not None): stock_monthly['avg6'][0] is not None and stock_monthly['avg36'][0] is not None):
if stock_monthly['avg6'][1] <= stock_monthly['avg36'][1] and stock_monthly['avg6'][0] > stock_monthly['avg36'][0]: if stock_monthly['avg6'][1] <= stock_monthly['avg36'][1] and stock_monthly['avg6'][0] > stock_monthly['avg36'][0]:
type = "monthly_6월선_36월선_상향돌파" dir_code = "1"
final_status += " " + type dir_name = "monthly_6월선_36월선_상향돌파"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_monthly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_monthly, status)
# 종가가 20주선을 상향 돌파함 # 종가가 20주선을 상향 돌파함
if len(stock_monthly['close']) > 2: if len(stock_monthly['close']) > 2:
if stock_monthly['close'][1] is not None and stock_monthly['avg12'][1] is not None and stock_monthly['close'][0] is not None and stock_monthly['avg12'][0] is not None: if stock_monthly['close'][1] is not None and stock_monthly['avg12'][1] is not None and stock_monthly['close'][0] is not None and stock_monthly['avg12'][0] is not None:
if stock_monthly['close'][1] <= stock_monthly['avg12'][1] and stock_monthly['close'][0] > stock_monthly['avg12'][0]: if stock_monthly['close'][1] <= stock_monthly['avg12'][1] and stock_monthly['close'][0] > stock_monthly['avg12'][0]:
type = "monthly_종가_12월선_상향돌파" dir_code = "2"
final_status += " " + type dir_name = "monthly_종가_12월선_상향돌파"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_monthly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_monthly, status)
# MACD가 0 이하인 경우 # MACD가 0 이하인 경우
if len(stock_monthly['close']) > 1: if len(stock_monthly['close']) > 1:
if stock_monthly['macd'][0] is not None: if stock_monthly['macd'][0] is not None:
if stock_monthly['macd'][0] <= -300: if stock_monthly['macd'][0] <= -300:
type = "monthly_macd_-300이하" dir_code = "3"
final_status += " " + type dir_name = "monthly_macd_-300이하"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_monthly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_monthly, status)
# RSI가 20 이하인 경우 # RSI가 20 이하인 경우
if len(stock_monthly['close']) > 1: if len(stock_monthly['close']) > 1:
if stock_monthly['rsi'][0] is not None: if stock_monthly['rsi'][0] is not None:
if stock_monthly['rsi'][0] <= 20: if stock_monthly['rsi'][0] <= 20:
type = "monthly_rsi_20이하" dir_code = "4"
final_status += " " + type dir_name = "monthly_rsi_20이하"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_monthly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_monthly, status)
if len(stock_monthly['volume']) > 5: if len(stock_monthly['volume']) > 5:
# BB 하단에 부딪힘 # BB 하단에 부딪힘
@@ -504,10 +507,10 @@ class AnalyzerSqlite:
if stock_monthly['bolingerband_lower'][c_index+1] is None: if stock_monthly['bolingerband_lower'][c_index+1] is None:
break break
if stock_monthly['close'][c_index] <= (stock_monthly['bolingerband_lower'][c_index+1]): if stock_monthly['close'][c_index] <= (stock_monthly['bolingerband_lower'][c_index+1]):
type = "monthly_BB하단_내려옴" dir_code = "5"
final_status += " " + type dir_name = "monthly_BB하단_내려옴"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_monthly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_monthly, status)
break break
@@ -526,28 +529,28 @@ class AnalyzerSqlite:
if (stock_weekly['avg4'][1] is not None and stock_weekly['avg48'][1] is not None and if (stock_weekly['avg4'][1] is not None and stock_weekly['avg48'][1] is not None and
stock_weekly['avg4'][0] is not None and stock_weekly['avg48'][0] is not None): stock_weekly['avg4'][0] is not None and stock_weekly['avg48'][0] is not None):
if stock_weekly['avg4'][1] <= stock_weekly['avg48'][1] and stock_weekly['avg4'][0] > stock_weekly['avg48'][0]: if stock_weekly['avg4'][1] <= stock_weekly['avg48'][1] and stock_weekly['avg4'][0] > stock_weekly['avg48'][0]:
type = "weekly_4주선_48주선_상향돌파" dir_code = "11"
final_status += " " + type dir_name = "weekly_4주선_48주선_상향돌파"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_weekly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_weekly, status)
# 종가가 20주선을 상향 돌파함 # 종가가 20주선을 상향 돌파함
if len(stock_weekly['close']) > 2: if len(stock_weekly['close']) > 2:
if stock_weekly['close'][1] is not None and stock_weekly['avg12'][1] is not None and stock_weekly['close'][0] is not None and stock_weekly['avg12'][0] is not None: if stock_weekly['close'][1] is not None and stock_weekly['avg12'][1] is not None and stock_weekly['close'][0] is not None and stock_weekly['avg12'][0] is not None:
if stock_weekly['close'][1] <= stock_weekly['avg12'][1] and stock_weekly['close'][0] > stock_weekly['avg12'][0]: if stock_weekly['close'][1] <= stock_weekly['avg12'][1] and stock_weekly['close'][0] > stock_weekly['avg12'][0]:
type = "weekly_종가_12주선_상향돌파" dir_code = "12"
final_status += " " + type dir_name = "weekly_종가_12주선_상향돌파"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_weekly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_weekly, status)
# RSI가 15 이하인 경우 # RSI가 15 이하인 경우
if len(stock_monthly['close']) > 1: if len(stock_monthly['close']) > 1:
if stock_weekly['rsi'][0] is not None: if stock_weekly['rsi'][0] is not None:
if stock_weekly['rsi'][0] <= 15: if stock_weekly['rsi'][0] <= 15:
type = "weekly_rsi_15이하" dir_code = "13"
final_status += " " + type dir_name = "weekly_rsi_15이하"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_weekly, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_weekly, status)
@@ -558,38 +561,38 @@ class AnalyzerSqlite:
# RSI가 10 이하인 경우 # RSI가 10 이하인 경우
if stock_daily['macd'][0] is not None: if stock_daily['macd'][0] is not None:
if stock_daily['macd'][0] <= -500: if stock_daily['macd'][0] <= -500:
type = "daily_macd_-500이하" dir_code = "21"
final_status += " " + type dir_name = "daily_macd_-500이하"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_daily, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_daily, status)
# 2년 중 최대 거래량인 경우 # 2년 중 최대 거래량인 경우
c_index = 520 c_index = 520
if len(stock_daily['volume']) < c_index: if len(stock_daily['volume']) < c_index:
c_index = len(stock_daily['volume']) c_index = len(stock_daily['volume'])
if max(stock_daily['volume'][1:c_index]) < stock_daily['volume'][0]: if max(stock_daily['volume'][1:c_index]) < stock_daily['volume'][0]:
type = "daily_이전에_없던_거래량" dir_code = "22"
final_status += " " + type dir_name = "daily_이전에_없던_거래량"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_daily, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_daily, status)
# daily_이격도 # daily_이격도
if (98<stock_daily['disparity_avg5'][0]<102 and 98<stock_daily['disparity_avg10'][0]<102 and if (98<stock_daily['disparity_avg5'][0]<102 and 98<stock_daily['disparity_avg10'][0]<102 and
98<stock_daily['disparity_avg20'][0]<102 and 98<stock_daily['disparity_avg60'][0]<102 and 98<stock_daily['disparity_avg20'][0]<102 and 98<stock_daily['disparity_avg60'][0]<102 and
98<stock_daily['disparity_avg120'][0]<102): 98<stock_daily['disparity_avg120'][0]<102):
type = "daily_이격도" dir_code = "23"
final_status += " " + type dir_name = "daily_이격도"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_daily, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_daily, status)
# daily_weekly_monthly_rsi_10_20_30이하 # daily_weekly_monthly_rsi_10_20_30이하
if len(stock_monthly['close']) > 1: if len(stock_monthly['close']) > 1:
if stock_monthly['rsi'][0] is not None and stock_weekly['rsi'][0] is not None and stock_daily['rsi'][0] is not None: if stock_monthly['rsi'][0] is not None and stock_weekly['rsi'][0] is not None and stock_daily['rsi'][0] is not None:
if stock_monthly['rsi'][0] <= 30 and stock_weekly['rsi'][0] <= 20 and stock_daily['rsi'][0] <= 10: if stock_monthly['rsi'][0] <= 30 and stock_weekly['rsi'][0] <= 20 and stock_daily['rsi'][0] <= 10:
type = "daily_weekly_monthly_rsi_10_20_30이하" dir_code = "24"
final_status += " " + type dir_name = "daily_weekly_monthly_rsi_10_20_30이하"
final_status_count += 1 final_status_count += 1
self.writeFile(type, CODE, NAME, top, stock_daily, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_daily, status)
# daily_낙폭과대 (50% 이상 하락) # daily_낙폭과대 (50% 이상 하락)
c_index = 52*5 c_index = 52*5
@@ -601,15 +604,16 @@ class AnalyzerSqlite:
location = (max(stock_daily['close'][1:c_index]) - stock_daily['close'][0]) / max(stock_daily['close'][1:c_index]) location = (max(stock_daily['close'][1:c_index]) - stock_daily['close'][0]) / max(stock_daily['close'][1:c_index])
if location > 0.5: if location > 0.5:
type = "daily_낙폭과대" dir_code = "25"
final_status += " " + type dir_name = "daily_낙폭과대"
final_status_count += 1 final_status_count += 1
status = "{:.2f}".format(location) + "_" + status status = "{:.2f}".format(location) + "_" + status
self.writeFile(type, CODE, NAME, top, stock_daily, status) self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_daily, status)
if final_status_count >= 5: if final_status_count >= 5:
type = "final" dir_code = "0"
self.writeFile(type, CODE, NAME, top, stock_daily, final_status, final_status_count) dir_name = "final"
self.writeFile(dir_code, dir_name, CODE, NAME, top, stock_daily, final_status, final_status_count)
return return
def get_moving_average(self, stock): def get_moving_average(self, stock):