This commit is contained in:
dsyoon
2021-09-11 00:09:16 +09:00
parent f598aeaff4
commit 42670252fa

View File

@@ -455,10 +455,10 @@ class Analyzer:
conn = sqlite3.connect(self.inFileName)
cursor = conn.cursor()
rowid = 1
cursor.execute('SELECT * FROM ' + self.tableName + ' WHERE rowid=?', (rowid,))
cursor.execute('SELECT CODE, NAME, PRICE, STOCHASTIC, BOLINGERBAND FROM ' + self.tableName + ' WHERE rowid=?', (rowid,))
result = cursor.fetchone()
# 최근 10일간 +-종목 개수 체크
# 최근 20일간 +-종목 개수 체크
inde_check = []
for check_index in range(20):
inde_check.append([0,0])
@@ -468,9 +468,13 @@ class Analyzer:
item_name = result[1]
print("#html", rowid, item_name)
if rowid == 1821 or item_name == "롯리츠":
print(1)
# 부실 기업은 매수하지 않고 그냥 넘긴다.
# kospi 지수와 kosdak 지수도 그냥 넘긴다.
if ((item_code in self.fnguide and not self.fnguide[item_code]) or (item_code == "KOSPI" or item_code == "KOSDAK") or result[3] == ''):
#if ((item_code in self.fnguide and not self.fnguide[item_code]) or (item_code == "KOSPI" or item_code == "KOSDAK") or result[3] == ''):
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 CODE, NAME, PRICE, STOCHASTIC, BOLINGERBAND FROM ' + self.tableName + ' WHERE rowid=?', (rowid,))
@@ -506,48 +510,47 @@ class Analyzer:
# 위치 에너지
positionalEnergy = self.getPositionalEnergy(STOCK, last_index)
if stochastic_score < 30 or bolingerband_score < 0.3:
if STOCK[last_index]['volume'] > 100000 and STOCK[last_index]['close'] > 1000:
# 종목 상태 체크 분석
state, buy_price = self.analyzeFinalScore(last_index, STOCK, STOCHASTIC)
if STOCK[last_index]['volume'] > 100000 and STOCK[last_index]['close'] > 1000:
# 종목 상태 체크 분석
state, buy_price = self.analyzeFinalScore(last_index, STOCK, STOCHASTIC)
isbuy = 0
# 종가가 240일선 아래에 있으면 매수한다.
if isbuy > 0 and STOCK[last_index]['close'] < STOCK[last_index]['avg240']:
isbuy = 1
isbuy = 0
# 종가가 240일선 아래에 있으면 매수한다.
if isbuy > 0 and STOCK[last_index]['close'] < STOCK[last_index]['avg240']:
isbuy = 1
# 위치에너지 < 0.4 and 볼린저밴드 < 0.3 이어야 한다.
if positionalEnergy < 0.2 or bolingerband_score < 0.2:
isbuy = 2
# 위치에너지 < 0.4 and 볼린저밴드 < 0.3 이어야 한다.
if positionalEnergy < 0.2 or bolingerband_score < 0.2:
isbuy = 2
if len(STOCK) > 5:
# 볼린저밴드 하단에 부딪혔다면,
if (STOCK[last_index-2]['low'] <= BOLINGERBAND[last_index-2]['lower'] <= STOCK[last_index-2]['high'] or
STOCK[last_index-3]['low'] <= BOLINGERBAND[last_index-3]['lower'] <= STOCK[last_index-3]['high'] or
STOCK[last_index-4]['low'] <= BOLINGERBAND[last_index-4]['lower'] <= STOCK[last_index-4]['high']):
# 어제 양봉이거나
# 음봉이라면 그저깨 종가보다 어제 시가가 높거나 같고 그저깨 시가보다 어제 종가가 높다.
# 음봉이라면 그저깨 시가보다 어제 시가가 높거나 같고 그저깨 종가보다 어제 종가가 높다.
if STOCK[last_index-1]['open'] < STOCK[last_index-1]['close'] or (
(STOCK[last_index-2]['close'] <= STOCK[last_index-1]['open'] and STOCK[last_index-2]['open'] < STOCK[last_index-1]['close']) or
(STOCK[last_index-2]['open'] <= STOCK[last_index-1]['open'] and STOCK[last_index-2]['close'] < STOCK[last_index-1]['close'])):
# (KOSPI: 2011년 8월 11일)
# 오늘 양봉이어야 한다.
if STOCK[last_index]['open'] < STOCK[last_index]['close']:
isbuy = 9
# (KOSPI: 2011년 9월 26일)
# 오늘 음봉이라면, 오늘 시가는 어제 종가보다 높아야 하고, 오늘 종가는 어제 시가보다 높아야 한다.
if (STOCK[last_index]['close'] < STOCK[last_index]['open']) and (STOCK[last_index-1]['close'] < STOCK[last_index]['open'] and STOCK[last_index-1]['open'] < STOCK[last_index]['close']):
isbuy = 9
if len(STOCK) > 5:
# 볼린저밴드 하단에 부딪혔다면,
if (STOCK[last_index-2]['low'] <= BOLINGERBAND[last_index-2]['lower'] <= STOCK[last_index-2]['high'] or
STOCK[last_index-3]['low'] <= BOLINGERBAND[last_index-3]['lower'] <= STOCK[last_index-3]['high'] or
STOCK[last_index-4]['low'] <= BOLINGERBAND[last_index-4]['lower'] <= STOCK[last_index-4]['high']):
# 어제 양봉이거나
# 음봉이라면 그저깨 종가보다 어제 시가가 높거나 같고 그저깨 시가보다 어제 종가가 높다.
# 음봉이라면 그저깨 시가보다 어제 시가가 높거나 같고 그저깨 종가보다 어제 종가가 높다.
if STOCK[last_index-1]['open'] < STOCK[last_index-1]['close'] or (
(STOCK[last_index-2]['close'] <= STOCK[last_index-1]['open'] and STOCK[last_index-2]['open'] < STOCK[last_index-1]['close']) or
(STOCK[last_index-2]['open'] <= STOCK[last_index-1]['open'] and STOCK[last_index-2]['close'] < STOCK[last_index-1]['close'])):
# (KOSPI: 2011년 8월 11일)
# 오늘 양봉이어야 한다.
if STOCK[last_index]['open'] < STOCK[last_index]['close']:
isbuy = 9
# (KOSPI: 2011년 9월 26일)
# 오늘 음봉이라면, 오늘 시가는 어제 종가보다 높아야 하고, 오늘 종가는 어제 시가보다 높아야 한다.
if (STOCK[last_index]['close'] < STOCK[last_index]['open']) and (STOCK[last_index-1]['close'] < STOCK[last_index]['open'] and STOCK[last_index-1]['open'] < STOCK[last_index]['close']):
isbuy = 9
if isbuy >= 3 and state != "":
isbuy = 4
if isbuy >= 3 and state != "":
isbuy = 4
fig = self.draw(stock)
title = "%s (%s), %s, buy_price (%d), stochastic(%.2f), bolingerband(%.2f), positionalEnergy(%.2f) 차트" % (item_name, item_code, state, buy_price, stochastic_score, bolingerband_score, positionalEnergy)
fig['layout'].update(title=title)
fig = self.draw(stock)
title = "%s (%s), %s, buy_price (%d), stochastic(%.2f), bolingerband(%.2f), positionalEnergy(%.2f) 차트" % (item_name, item_code, state, buy_price, stochastic_score, bolingerband_score, positionalEnergy)
fig['layout'].update(title=title)
self.writeFile(fig, state, isbuy, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code)
self.writeFile(fig, state, isbuy, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code)
for check_index in range(20):
if len(STOCK) > check_index and STOCK[last_index-check_index]['open'] < STOCK[last_index-check_index]['close']:
@@ -556,7 +559,7 @@ class Analyzer:
inde_check[check_index][1] += 1
rowid += 1
cursor.execute('SELECT * FROM ' + self.tableName + ' WHERE rowid=?', (rowid,))
cursor.execute('SELECT CODE, NAME, PRICE, STOCHASTIC, BOLINGERBAND FROM ' + self.tableName + ' WHERE rowid=?', (rowid,))
result = cursor.fetchone()
print()