init
This commit is contained in:
@@ -399,31 +399,26 @@ class Analyzer:
|
||||
|
||||
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 != "":
|
||||
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)
|
||||
|
||||
if bolingerband_score < 0.15:
|
||||
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)
|
||||
|
||||
if stochastic_score < 15:
|
||||
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)
|
||||
|
||||
if positionalEnergy < 0.5:
|
||||
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)
|
||||
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)
|
||||
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)
|
||||
|
||||
return
|
||||
@@ -520,17 +515,13 @@ class Analyzer:
|
||||
# 종목 상태 체크 분석
|
||||
state, buy_price = self.analyzeFinalScore(last_index, STOCK, STOCHASTIC)
|
||||
|
||||
isbuy = 0
|
||||
|
||||
# 스토케스틱이 20이하이어야 하며, 볼린저밴드 0.3 보다 작으며, 위치에너지도 0.2보다 낮다면,
|
||||
if stochastic_score < 20 and bolingerband_score < 0.2 and positionalEnergy < 0.2:
|
||||
isbuy = 1
|
||||
# 스토케스틱이 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
|
||||
|
||||
# 종가가 240일선 아래라면 매수한다.
|
||||
if STOCK[last_index]['close'] < STOCK[last_index]['avg240']:
|
||||
isbuy = 2
|
||||
|
||||
if len(STOCK) > 5:
|
||||
state = '2_' + state
|
||||
|
||||
# 볼린저밴드 하단에 부딪혔다면,
|
||||
if (STOCK[last_index - 2]['low'] <= BOLINGERBAND[last_index - 2]['lower'] <= STOCK[last_index - 2]['high'] or
|
||||
@@ -545,30 +536,27 @@ class Analyzer:
|
||||
# (KOSPI: 2011년 8월 11일)
|
||||
# 오늘 양봉이어야 한다.
|
||||
if STOCK[last_index]['open'] < STOCK[last_index]['close']:
|
||||
isbuy = 3
|
||||
state = '3_' + state
|
||||
# (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
|
||||
state = '4_' + 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']):
|
||||
isbuy = 9
|
||||
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']):
|
||||
isbuy = 8
|
||||
state = '6_' + state
|
||||
|
||||
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, buy_price, bolingerband_score, stochastic_score, positionalEnergy, item_name, item_code)
|
||||
|
||||
for check_index in range(365):
|
||||
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