init
This commit is contained in:
@@ -12,6 +12,8 @@ import sqlite3
|
||||
from datetime import datetime
|
||||
|
||||
from matplotlib import rc
|
||||
import math
|
||||
|
||||
rc('font', family='AppleGothic')
|
||||
plt.rcParams['axes.unicode_minus'] = False
|
||||
|
||||
@@ -71,26 +73,14 @@ class Analyzer:
|
||||
while result != None:
|
||||
data = json.loads(result[2])
|
||||
self.fnguide[result[0]] = True
|
||||
if (year1 in data):
|
||||
if (data[year1]['영업이익'] > 0 and data[year1]['당기순이익'] > 0):
|
||||
self.fnguide[result[0]] = True
|
||||
if (year2 in data):
|
||||
if (data[year2]['영업이익'] > 0 and data[year2]['당기순이익'] > 0):
|
||||
self.fnguide[result[0]] = True
|
||||
if (year3 in data):
|
||||
if (data[year3]['영업이익'] > 0 and data[year3]['당기순이익'] > 0):
|
||||
self.fnguide[result[0]] = True
|
||||
else:
|
||||
self.fnguide[result[0]] = False
|
||||
else:
|
||||
if (data[year1]['영업이익'] > data[year2]['영업이익']):
|
||||
self.fnguide[result[0]] = True
|
||||
else:
|
||||
self.fnguide[result[0]] = False
|
||||
else:
|
||||
|
||||
if (year1 in data and year2 in data and year3 in data):
|
||||
if (data[year1]['영업이익'] < 0 and data[year2]['영업이익'] < 0 and data[year3]['영업이익'] < 0):
|
||||
# 3년 연속 영업이익이 적자이면 매수하지 않는다.
|
||||
self.fnguide[result[0]] = False
|
||||
if (data[year1]['영업이익'] < -100):
|
||||
# 전년 영억적자가 100억 이상이면 매수하지 않는다.
|
||||
self.fnguide[result[0]] = False
|
||||
else:
|
||||
self.fnguide[result[0]] = False
|
||||
|
||||
rowid += 1
|
||||
cursor.execute('SELECT * FROM fnguide WHERE rowid=?', (rowid,))
|
||||
@@ -314,6 +304,8 @@ class Analyzer:
|
||||
1) 상향이고 30을 돌파하면 매수,
|
||||
2) rsi가 상향이고 40을 돌파하면 매수,
|
||||
3) rsi가 상향이고 70을 돌파하면 단기매수,
|
||||
|
||||
시장 보다 강한 종목이란 (https://biz.sbs.co.kr/article/10000976754)
|
||||
"""
|
||||
|
||||
i = last_index
|
||||
@@ -343,14 +335,30 @@ class Analyzer:
|
||||
if stochastic_score > 0:
|
||||
return True, buy_price, stochastic_score
|
||||
"""
|
||||
if STOCHASTIC[i]['slow_k'] < 10 and self.common.checkLongYangBongAfterUmBong(STOCK, i):
|
||||
return 'STOCHASTIC_YANGBONG', buy_price
|
||||
if STOCHASTIC[i]['slow_k'] < 10:
|
||||
return 'STOCHASTIC', buy_price
|
||||
if self.common.checkLongYangBongAfterUmBong(STOCK, i):
|
||||
return 'YANGBONG', buy_price
|
||||
|
||||
return "", buy_price
|
||||
status = ""
|
||||
if STOCK[i]['volume'] > 100000 and STOCK[i]['close'] > 1000:
|
||||
# 거래량이 10만 이상이고, 종가가 1천원 이상인지 체크 (https://happpy-rich.tistory.com/94)
|
||||
|
||||
if self.common.check_on_120_daysLine(STOCK, i):
|
||||
# 특히 종목이 120일선을 뚫은 후 60일선이 상승세인지를 확인한다. (https://biz.sbs.co.kr/article/10000976754)
|
||||
if STOCHASTIC[i]['slow_k'] < 70:
|
||||
status += '120_'
|
||||
if self.common.check_on_60_daysLine(STOCK, i):
|
||||
if STOCHASTIC[i]['slow_k'] < 70:
|
||||
status += '60_'
|
||||
if self.common.check_on_20_daysLine(STOCK, i):
|
||||
if STOCHASTIC[i]['slow_k'] < 70:
|
||||
status += '20_'
|
||||
|
||||
if STOCHASTIC[i]['slow_k'] < 10:
|
||||
# 스토캐스틱이 10 이하였다면,
|
||||
status += 'STOCHASTIC_'
|
||||
if self.common.checkLongYangBongAfterUmBong(STOCK, i):
|
||||
# 어제 음봉 이후 장대양봉이었다면,
|
||||
status += 'YANGBONG_'
|
||||
|
||||
return status, buy_price
|
||||
|
||||
def analyzeToFile(self, outFileName):
|
||||
conn = sqlite3.connect(self.inFileName)
|
||||
@@ -403,14 +411,28 @@ class Analyzer:
|
||||
while result != None:
|
||||
item_code = result[0]
|
||||
item_name = result[1]
|
||||
"""
|
||||
if (item_code in self.fnguide and not self.fnguide[item_code]):
|
||||
|
||||
# 부실 기업은 매수하지 않고 그냥 넘긴다.
|
||||
# kospi 지수와 kosdak 지수도 그냥 넘긴다.
|
||||
if ((item_code in self.fnguide and not self.fnguide[item_code]) or (item_code == "KOSPI" or item_code == "KOSDAK")):
|
||||
rowid += 1
|
||||
# 다음 종목을 가져옴
|
||||
cursor.execute('SELECT * FROM ' + self.tableName + ' WHERE rowid=?', (rowid,))
|
||||
result = cursor.fetchone()
|
||||
continue
|
||||
"""
|
||||
stock = {"CODE": result[0], "NAME": result[1], "PRICE": json.loads(result[2]), "MACD": json.loads(result[3]), "STOCHASTIC": json.loads(result[4]), "ICHIMOKU": json.loads(result[5]), "RSI": json.loads(result[6])}
|
||||
|
||||
result_3 = result[3]
|
||||
result_4 = result[4]
|
||||
result_5 = result[5]
|
||||
result_6 = result[6]
|
||||
if result[3] != result[3]: result_3 = result[3].replace("NaN", "0")
|
||||
if result[4] != result[4]: result_4 = result[4].replace("NaN", "0")
|
||||
if result[5] != result[5]: result_5 = result[5].replace("NaN", "0")
|
||||
if result[6] != result[6]: result_6 = result[6].replace("NaN", "0")
|
||||
|
||||
if rowid == 2435:
|
||||
print (1)
|
||||
stock = {"CODE": result[0], "NAME": result[1], "PRICE": json.loads(result[2]), "MACD": json.loads(result_3), "STOCHASTIC": json.loads(result_4), "ICHIMOKU": json.loads(result_5), "RSI": json.loads(result_6)}
|
||||
|
||||
last_index = self.get_last_index(stock)
|
||||
STOCK = stock['PRICE']
|
||||
@@ -432,7 +454,7 @@ class Analyzer:
|
||||
fileName = "%s/%s__%.3f__%.3f__%s.html" % (outPath, state, stochastic_score, rsi_score, item_name.replace(" ", ""))
|
||||
po.write_html(fig, file=fileName, auto_open=False)
|
||||
else:
|
||||
if RSI[last_index]['rsi_buy'] == 1 and STOCK[last_index]['volume'] > 10000:
|
||||
if RSI[last_index]['rsi_buy'] == 1 and STOCK[last_index]['volume'] > 100000:
|
||||
fig = self.draw(stock)
|
||||
title = "%s (%s) buy_price (%d), stochastic(%.3f), rsi(%.3f), macd(%.3f), ichimoku(%d)) 차트"%(item_name, item_code, buy_price, stochastic_score, rsi_score, macd_score, ichimoku_score)
|
||||
fig['layout'].update(title=title)
|
||||
|
||||
Reference in New Issue
Block a user