init
This commit is contained in:
@@ -399,31 +399,26 @@ class Analyzer:
|
|||||||
|
|
||||||
return energy
|
return energy
|
||||||
|
|
||||||
def writeFile(self, fig, state, isbuy, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code):
|
def writeFile(self, fig, state, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code):
|
||||||
|
|
||||||
if state != "":
|
if state != "":
|
||||||
fileName = self.status_path
|
fileName = self.status_path
|
||||||
fileName = "%s/%d__%s__p(%.2f)__b(%.2f)__s(%.2f)__%d__%s_%s.html" % (fileName, isbuy, state, positionalEnergy, bolingerband_score, stochastic_score, buy_price, item_name.replace(" ", ""), item_code)
|
fileName = "%s/%s__p(%.2f)__b(%.2f)__s(%.2f)__%d__%s_%s.html" % (fileName, state, positionalEnergy, bolingerband_score, stochastic_score, buy_price, item_name.replace(" ", ""), item_code)
|
||||||
po.write_html(fig, file=fileName, auto_open=False)
|
po.write_html(fig, file=fileName, auto_open=False)
|
||||||
|
|
||||||
if bolingerband_score < 0.15:
|
if bolingerband_score < 0.15:
|
||||||
fileName = self.bolingerband_path
|
fileName = self.bolingerband_path
|
||||||
fileName = "%s/%d__b(%.2f)__p(%.2f)__s(%.2f)__%s__%d__%s_%s.html" % (fileName, isbuy, bolingerband_score, positionalEnergy, stochastic_score, state, buy_price, item_name.replace(" ", ""), item_code)
|
fileName = "%s/b(%.2f)__p(%.2f)__s(%.2f)__%s__%d__%s_%s.html" % (fileName, bolingerband_score, positionalEnergy, stochastic_score, state, buy_price, item_name.replace(" ", ""), item_code)
|
||||||
po.write_html(fig, file=fileName, auto_open=False)
|
po.write_html(fig, file=fileName, auto_open=False)
|
||||||
|
|
||||||
if stochastic_score < 15:
|
if stochastic_score < 15:
|
||||||
fileName = self.stochastic_path
|
fileName = self.stochastic_path
|
||||||
fileName = "%s/%d__s(%.2f)__b(%.2f)__p(%.2f)__%s__%d__%s_%s.html" % (fileName, isbuy, stochastic_score, bolingerband_score, positionalEnergy, state, buy_price, item_name.replace(" ", ""), item_code)
|
fileName = "%s/s(%.2f)__b(%.2f)__p(%.2f)__%s__%d__%s_%s.html" % (fileName, stochastic_score, bolingerband_score, positionalEnergy, state, buy_price, item_name.replace(" ", ""), item_code)
|
||||||
po.write_html(fig, file=fileName, auto_open=False)
|
po.write_html(fig, file=fileName, auto_open=False)
|
||||||
|
|
||||||
if positionalEnergy < 0.5:
|
if positionalEnergy < 0.5:
|
||||||
fileName = self.positionalEnergy_path
|
fileName = self.positionalEnergy_path
|
||||||
fileName = "%s/%d__p(%.2f)__b(%.2f)__s(%.2f)__%s__%d__%s_%s.html" % (fileName, isbuy, positionalEnergy, bolingerband_score, stochastic_score, state, buy_price, item_name.replace(" ", ""), item_code)
|
fileName = "%s/p(%.2f)__b(%.2f)__s(%.2f)__%s__%d__%s_%s.html" % (fileName, positionalEnergy, bolingerband_score, stochastic_score, state, buy_price, item_name.replace(" ", ""), item_code)
|
||||||
po.write_html(fig, file=fileName, auto_open=False)
|
|
||||||
|
|
||||||
if isbuy > 0:
|
|
||||||
fileName = self.outPath
|
|
||||||
fileName = "%s/%d__p(%.2f)__b(%.2f)__s(%.2f)__%s__%d__%s_%s.html" % (fileName, isbuy, positionalEnergy, bolingerband_score, stochastic_score, state, buy_price, item_name.replace(" ", ""), item_code)
|
|
||||||
po.write_html(fig, file=fileName, auto_open=False)
|
po.write_html(fig, file=fileName, auto_open=False)
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -520,55 +515,48 @@ class Analyzer:
|
|||||||
# 종목 상태 체크 분석
|
# 종목 상태 체크 분석
|
||||||
state, buy_price = self.analyzeFinalScore(last_index, STOCK, STOCHASTIC)
|
state, buy_price = self.analyzeFinalScore(last_index, STOCK, STOCHASTIC)
|
||||||
|
|
||||||
isbuy = 0
|
# 스토케스틱이 20이하이어야 하며, 볼린저밴드 0.3 보다 작으며, 위치에너지도 0.3보다 낮다면,
|
||||||
|
if stochastic_score < 20 and bolingerband_score < 0.3 and positionalEnergy < 0.3 and len(STOCK) > 5:
|
||||||
|
state = '1_' + state
|
||||||
|
|
||||||
# 스토케스틱이 20이하이어야 하며, 볼린저밴드 0.3 보다 작으며, 위치에너지도 0.2보다 낮다면,
|
# 종가가 240일선 아래라면 매수한다.
|
||||||
if stochastic_score < 20 and bolingerband_score < 0.2 and positionalEnergy < 0.2:
|
if STOCK[last_index]['close'] < STOCK[last_index]['avg240']:
|
||||||
isbuy = 1
|
state = '2_' + state
|
||||||
|
|
||||||
# 종가가 240일선 아래라면 매수한다.
|
# 볼린저밴드 하단에 부딪혔다면,
|
||||||
if STOCK[last_index]['close'] < STOCK[last_index]['avg240']:
|
if (STOCK[last_index - 2]['low'] <= BOLINGERBAND[last_index - 2]['lower'] <= STOCK[last_index - 2]['high'] or
|
||||||
isbuy = 2
|
STOCK[last_index - 3]['low'] <= BOLINGERBAND[last_index - 3]['lower'] <= STOCK[last_index - 3]['high']):
|
||||||
|
|
||||||
if len(STOCK) > 5:
|
# 어제 양봉이거나
|
||||||
|
# 음봉이라면 그저깨 종가보다 어제 시가가 높거나 같고 그저깨 시가보다 어제 종가가 높다.
|
||||||
# 볼린저밴드 하단에 부딪혔다면,
|
# 음봉이라면 그저깨 시가보다 어제 시가가 높거나 같고 그저깨 종가보다 어제 종가가 높다.
|
||||||
if (STOCK[last_index - 2]['low'] <= BOLINGERBAND[last_index - 2]['lower'] <= STOCK[last_index - 2]['high'] or
|
if STOCK[last_index-1]['open'] < STOCK[last_index-1]['close'] or (
|
||||||
STOCK[last_index - 3]['low'] <= BOLINGERBAND[last_index - 3]['lower'] <= STOCK[last_index - 3]['high']):
|
(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']:
|
||||||
if STOCK[last_index-1]['open'] < STOCK[last_index-1]['close'] or (
|
state = '3_' + state
|
||||||
(STOCK[last_index-2]['close'] <= STOCK[last_index-1]['open'] and STOCK[last_index-2]['open'] < STOCK[last_index-1]['close']) or
|
# (KOSPI: 2011년 9월 26일)
|
||||||
(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]['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']):
|
||||||
# 오늘 양봉이어야 한다.
|
state = '4_' + state
|
||||||
if STOCK[last_index]['open'] < STOCK[last_index]['close']:
|
|
||||||
isbuy = 3
|
|
||||||
# (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 = 4
|
|
||||||
|
|
||||||
if isbuy==4 and stochastic_score < 10 and bolingerband_score < 0.1 and positionalEnergy < 0.1:
|
|
||||||
isbuy = 5
|
|
||||||
|
|
||||||
if (STOCHASTIC[last_index]['slow_k'] < 15 and
|
|
||||||
STOCHASTIC[last_index-1]['slow_k'] < STOCHASTIC[last_index-1]['slow_d'] and
|
|
||||||
STOCHASTIC[last_index]['slow_d'] < STOCHASTIC[last_index]['slow_k']):
|
|
||||||
isbuy = 9
|
|
||||||
|
|
||||||
if (STOCHASTIC[last_index]['slow_k'] < 15 and
|
if (STOCHASTIC[last_index]['slow_k'] < 15 and
|
||||||
STOCHASTIC[last_index - 1]['slow_k'] < STOCHASTIC[last_index - 1]['slow_d'] and
|
STOCHASTIC[last_index-1]['slow_k'] < STOCHASTIC[last_index-1]['slow_d'] and
|
||||||
STOCHASTIC[last_index]['slow_d'] < STOCHASTIC[last_index]['slow_k']):
|
STOCHASTIC[last_index]['slow_d'] < STOCHASTIC[last_index]['slow_k']):
|
||||||
isbuy = 8
|
state = '5_' + state
|
||||||
|
|
||||||
|
if (STOCHASTIC[last_index]['slow_k'] < 15 and
|
||||||
|
STOCHASTIC[last_index - 1]['slow_k'] < STOCHASTIC[last_index - 1]['slow_d'] and
|
||||||
|
STOCHASTIC[last_index]['slow_d'] < STOCHASTIC[last_index]['slow_k']):
|
||||||
|
state = '6_' + state
|
||||||
|
|
||||||
fig = self.draw(stock)
|
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)
|
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['layout'].update(title=title)
|
||||||
|
|
||||||
self.writeFile(fig, state, isbuy, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code)
|
self.writeFile(fig, state, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code)
|
||||||
|
|
||||||
for check_index in range(365):
|
for check_index in range(365):
|
||||||
if len(STOCK) > check_index and STOCK[last_index-check_index]['open'] < STOCK[last_index-check_index]['close']:
|
if len(STOCK) > check_index and STOCK[last_index-check_index]['open'] < STOCK[last_index-check_index]['close']:
|
||||||
|
|||||||
Reference in New Issue
Block a user