From da2164d599d2e3f5bfb5bfb2af7a65e4d6fb4a97 Mon Sep 17 00:00:00 2001 From: dosangyoon Date: Wed, 2 Feb 2022 15:19:43 +0900 Subject: [PATCH] init --- stockpredictor/analysis/AnalyzerSqlite.py | 83 ++++++++++++----------- 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/stockpredictor/analysis/AnalyzerSqlite.py b/stockpredictor/analysis/AnalyzerSqlite.py index 7f7907b..767ed68 100644 --- a/stockpredictor/analysis/AnalyzerSqlite.py +++ b/stockpredictor/analysis/AnalyzerSqlite.py @@ -382,19 +382,20 @@ class AnalyzerSqlite: shutil.rmtree(outPath) os.mkdir(outPath) - self.makeDir("기준선 위 전환선") - self.makeDir("스토케스틱이 10 미만") - self.makeDir("bolingerband 하단 돌파") - self.makeDir("260일 위치 에너지가 10% 미만") - self.makeDir("260일 가격 반토막 이상") - self.makeDir("240일선 아래") - self.makeDir("240일선 돌파") - self.makeDir("20일선 돌파") - self.makeDir("60일선 돌파") - self.makeDir("거래량 5배 이상") - self.makeDir("정배열") - self.makeDir("GoldenCross") - self.makeDir("모든 라인 돌파") + self.makeDir("0_스토케스틱이 10 미만") + self.makeDir("0_bolingerband 하단") + self.makeDir("0_260일 위치 에너지가 10% 미만") + self.makeDir("0_260일 가격 반토막 이상") + self.makeDir("0_240일선 아래") + self.makeDir("1_기준선 위 전환선") + self.makeDir("1_240일선 돌파") + self.makeDir("1_20일선 돌파") + self.makeDir("1_60일선 돌파") + self.makeDir("1_거래량 5배 이상") + self.makeDir("1_bolingerband 하단 돌파 상승") + self.makeDir("1_정배열") + self.makeDir("1_GoldenCross") + self.makeDir("1_모든 라인 돌파") return @@ -473,7 +474,7 @@ class AnalyzerSqlite: avg200.append(price[6]) avg240.append(price[7]) bolingerband_upper.append(price[8]) - bolingerband_lower.append(price[8]) + bolingerband_lower.append(price[9]) bolingerband_middle.append(price[10]) ichimokucloud_changeLine.append(price[11]) ichimokucloud_baseLine.append(price[12]) @@ -493,10 +494,6 @@ class AnalyzerSqlite: } stochastic_score = stochastic_slow_k[0] - if bolingerband_upper[0] == bolingerband_lower[0]: - bolingerband_score = 0 - else: - bolingerband_score = round(((close[0]-bolingerband_lower[0])/(bolingerband_upper[0]-bolingerband_lower[0])), 2) # 위치 에너지 positionalEnergy1, positionalEnergy2 = self.getPositionalEnergy(close) @@ -505,75 +502,83 @@ class AnalyzerSqlite: # 종목 상태 체크 분석 state = self.analyzeFinalScore(stock) - if len(close) > 50: - if (ichimokucloud_changeLine[0] > ichimokucloud_baseLine[0] and - ichimokucloud_changeLine[1] < ichimokucloud_baseLine[1] and - ichimokucloud_changeLine[2] < ichimokucloud_baseLine[2]): - type = "기준선 위 전환선" - self.writeFile(type, CODE, NAME, stock, state) - # 스토케스틱이 10 미만 if len(close) > 5 and stochastic_score is not None and stochastic_score < 10: - type = "스토케스틱이 10 미만" + type = "0_스토케스틱이 10 미만" self.writeFile(type, CODE, NAME, stock, state) - # bolingerband 하단 돌파 - if len(close) > 5 and bolingerband_score is not None and bolingerband_score < 0: - type = "bolingerband 하단 돌파" + # bolingerband 하단 + if len(close) > 60 and bolingerband_lower[0] is not None and close[0] < bolingerband_lower[0]: + type = "0_bolingerband 하단" self.writeFile(type, CODE, NAME, stock, state) # 260일 위치 에너지가 10% 미만 if len(close) > 5 and positionalEnergy1 is not None and positionalEnergy1 < 0.1: - type = "260일 위치 에너지가 10% 미만" + type = "0_260일 위치 에너지가 10% 미만" self.writeFile(type, CODE, NAME, stock, state) # 260일 가격 반토막 이상 if len(close) > 5 and positionalEnergy2 is not None and positionalEnergy2 < 0.5: - type = "260일 가격 반토막 이상" + type = "0_260일 가격 반토막 이상" self.writeFile(type, CODE, NAME, stock, state) # 종가가 240일선 아래라면 매수한다. if close[0] < avg240[0]: - type = "240일선 아래" + type = "0_240일선 아래" self.writeFile(type, CODE, NAME, stock, state) + # 기준선 위 전환선 + if len(close) > 50: + if ((ichimokucloud_changeLine[0] > ichimokucloud_baseLine[0] and + ichimokucloud_changeLine[1] < ichimokucloud_baseLine[1] and + ichimokucloud_changeLine[2] < ichimokucloud_baseLine[2]) and + volume[0] > volume[1]): + type = "1_기준선 위 전환선" + self.writeFile(type, CODE, NAME, stock, state) + # 종가가 240일선 돌파 if close[0] > avg240[0] and close[1] < avg240[1]: - type = "240일선 돌파" + type = "1_240일선 돌파" self.writeFile(type, CODE, NAME, stock, state) # 20일선 돌파 temp_status = self.common.check_Dolpa_Jiji(stock, '20') if temp_status != "": - type = "20일선 돌파" + type = "1_20일선 돌파" self.writeFile(type, CODE, NAME, stock, state) # 60일선 돌파 temp_status = self.common.check_Dolpa_Jiji(stock, '60') if temp_status != "": - type = "60일선 돌파" + type = "1_60일선 돌파" self.writeFile(type, CODE, NAME, stock, state) # 골든크로스 golden_cross_status = self.common.check_golded_cross(stock) if golden_cross_status != "": - type = "GoldenCross" + type = "1_GoldenCross" self.writeFile(type, CODE, NAME, stock, state) # 거래량 5배 이상 if volume[0] > volume[1]*5: - type = "거래량 5배 이상" + type = "1_거래량 5배 이상" + self.writeFile(type, CODE, NAME, stock, state) + + # bolingerband 하단 돌파 상승 + if (len(close) > 60 and (bolingerband_lower[0] is not None and bolingerband_lower[1] is not None) and + close[0] > bolingerband_lower[0] and close[1] < bolingerband_lower[1]): + type = "1_bolingerband 하단 돌파 상승" self.writeFile(type, CODE, NAME, stock, state) # 정배열 right_arrange = self.common.check_RightArrange(stock) if right_arrange != "": - type = "정배열" + type = "1_정배열" self.writeFile(type, CODE, NAME, stock, state) # 모든 라인 돌파 if len(close) > 50 and close[0] > max(open[0], avg5[0], avg20[0], avg60[0], avg120[0], avg240[0], bolingerband_upper[0], ichimokucloud_changeLine[0], ichimokucloud_baseLine[0]): - type = "모든 라인 돌파" + type = "1_모든 라인 돌파" self.writeFile(type, CODE, NAME, stock, state) return