init
This commit is contained in:
@@ -380,8 +380,9 @@ class Analyzer:
|
|||||||
def getPositionalEnergy(self, stock, last_index):
|
def getPositionalEnergy(self, stock, last_index):
|
||||||
# 260 (= 52 * 5)일 중 가장 찾은 금액과 가장 높았던 금액 중 현재가의 위치 계산
|
# 260 (= 52 * 5)일 중 가장 찾은 금액과 가장 높았던 금액 중 현재가의 위치 계산
|
||||||
|
|
||||||
top = stock[last_index]['close']
|
close = stock[last_index]['close']
|
||||||
bottom = stock[last_index]['close']
|
top = close
|
||||||
|
bottom = close
|
||||||
|
|
||||||
for i in range(1, 260):
|
for i in range(1, 260):
|
||||||
if i > len(stock) or not stock[-i]:
|
if i > len(stock) or not stock[-i]:
|
||||||
@@ -391,7 +392,10 @@ class Analyzer:
|
|||||||
if bottom > stock[-i]["close"]:
|
if bottom > stock[-i]["close"]:
|
||||||
bottom = stock[-i]["close"]
|
bottom = stock[-i]["close"]
|
||||||
|
|
||||||
energy = round(bottom / top, 2)
|
if top-close == 0:
|
||||||
|
energy = 100.0
|
||||||
|
else:
|
||||||
|
energy = round((close-bottom) / (top-close), 2)
|
||||||
|
|
||||||
return energy
|
return energy
|
||||||
|
|
||||||
@@ -512,22 +516,19 @@ class Analyzer:
|
|||||||
|
|
||||||
# 위치 에너지
|
# 위치 에너지
|
||||||
positionalEnergy = self.getPositionalEnergy(STOCK, last_index)
|
positionalEnergy = self.getPositionalEnergy(STOCK, last_index)
|
||||||
if STOCK[last_index]['volume'] > 100000 and STOCK[last_index]['close'] > 1000:
|
if STOCK[last_index]['volume'] > 100000 and STOCK[last_index]['close'] > 1000 and positionalEnergy < 0.3:
|
||||||
# 종목 상태 체크 분석
|
# 종목 상태 체크 분석
|
||||||
state, buy_price = self.analyzeFinalScore(last_index, STOCK, STOCHASTIC)
|
state, buy_price = self.analyzeFinalScore(last_index, STOCK, STOCHASTIC)
|
||||||
|
|
||||||
isbuy = 0
|
isbuy = 0
|
||||||
|
|
||||||
# 스토케스틱이 20이하이어야 하며, 볼린저밴드 0.3 보다 작으며, 위치에너지도 0.2보다 낮다면,
|
# 스토케스틱이 20이하이어야 하며, 볼린저밴드 0.3 보다 작으며, 위치에너지도 0.2보다 낮다면,
|
||||||
if stochastic_score < 30 and bolingerband_score < 0.3 and positionalEnergy < 0.3:
|
if stochastic_score < 20 and bolingerband_score < 0.2 and positionalEnergy < 0.2:
|
||||||
isbuy = 1
|
isbuy = 1
|
||||||
|
|
||||||
# 종가가 240일선 아래라면 매수한다.
|
# 종가가 240일선 아래라면 매수한다.
|
||||||
if STOCK[last_index]['close'] < STOCK[last_index]['avg240']:
|
if STOCK[last_index]['close'] < STOCK[last_index]['avg240']:
|
||||||
if state == "":
|
|
||||||
isbuy = 2
|
isbuy = 2
|
||||||
else:
|
|
||||||
isbuy = 3
|
|
||||||
|
|
||||||
if len(STOCK) > 5:
|
if len(STOCK) > 5:
|
||||||
|
|
||||||
@@ -544,21 +545,21 @@ class Analyzer:
|
|||||||
# (KOSPI: 2011년 8월 11일)
|
# (KOSPI: 2011년 8월 11일)
|
||||||
# 오늘 양봉이어야 한다.
|
# 오늘 양봉이어야 한다.
|
||||||
if STOCK[last_index]['open'] < STOCK[last_index]['close']:
|
if STOCK[last_index]['open'] < STOCK[last_index]['close']:
|
||||||
isbuy = 4
|
isbuy = 3
|
||||||
# (KOSPI: 2011년 9월 26일)
|
# (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']):
|
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
|
isbuy = 5
|
||||||
|
|
||||||
if isbuy==5 and stochastic_score < 10 and bolingerband_score < 0.1 and positionalEnergy < 0.1:
|
if (STOCHASTIC[last_index]['slow_k'] < 15 and
|
||||||
isbuy = 6
|
|
||||||
|
|
||||||
if (STOCHASTIC[last_index]['slow_k'] < 30 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 = 9
|
isbuy = 9
|
||||||
|
|
||||||
if (STOCHASTIC[last_index]['slow_k'] < 30 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
|
isbuy = 8
|
||||||
|
|||||||
Reference in New Issue
Block a user