diff --git a/stockpredictor/analysis/Analyzer.py b/stockpredictor/analysis/Analyzer.py index 06a521b..34d5c0b 100644 --- a/stockpredictor/analysis/Analyzer.py +++ b/stockpredictor/analysis/Analyzer.py @@ -457,6 +457,12 @@ class Analyzer: rowid = 1 cursor.execute('SELECT * FROM ' + self.tableName + ' WHERE rowid=?', (rowid,)) result = cursor.fetchone() + + # 최근 10일간 +-종목 개수 체크 + inde_check = [] + for check_index in range(20): + inde_check.append([0,0]) + while result != None: item_code = result[0] item_name = result[1] @@ -516,22 +522,22 @@ class Analyzer: if len(STOCK) > 5: # 볼린저밴드 하단에 부딪혔다면, - if (STOCK[-3]['low'] <= BOLINGERBAND[-3]['lower'] <= STOCK[-3]['high'] or - STOCK[-4]['low'] <= BOLINGERBAND[-4]['lower'] <= STOCK[-4]['high'] or - STOCK[-5]['low'] <= BOLINGERBAND[-5]['lower'] <= STOCK[-5]['high']): + 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[-2]['open'] < STOCK[-2]['close'] or ( - (STOCK[-3]['close'] <= STOCK[-2]['open'] and STOCK[-3]['open'] < STOCK[-2]['close']) or - (STOCK[-3]['open'] <= STOCK[-2]['open'] and STOCK[-3]['close'] < STOCK[-2]['close'])): + 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[-1]['open'] < STOCK[-1]['close']: + if STOCK[last_index]['open'] < STOCK[last_index]['close']: isbuy = 3 # (KOSPI: 2011년 9월 26일) # 오늘 음봉이라면, 오늘 시가는 어제 종가보다 높아야 하고, 오늘 종가는 어제 시가보다 높아야 한다. - if (STOCK[-1]['close'] < STOCK[-1]['open']) and (STOCK[-2]['close'] < STOCK[-1]['open'] and STOCK[-2]['open'] < STOCK[-1]['close']): + 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 = 3 if isbuy >= 3 and state != "": @@ -543,12 +549,24 @@ class Analyzer: 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']: + inde_check[check_index][0] += 1 + else: + inde_check[check_index][1] += 1 + rowid += 1 cursor.execute('SELECT * FROM ' + self.tableName + ' WHERE rowid=?', (rowid,)) result = cursor.fetchone() + print() + for check_index in range(20): + print ("%d일전: (+) %d, (-) %d, (%4.2f)" % (check_index, inde_check[check_index][0], inde_check[check_index][1], inde_check[check_index][0]*100/(inde_check[check_index][0]+inde_check[check_index][1]))) + print() + cursor.close() conn.close() + return def analyze(self):