init
This commit is contained in:
134
stockpredictor/analysis/Common.py
Normal file
134
stockpredictor/analysis/Common.py
Normal file
@@ -0,0 +1,134 @@
|
||||
|
||||
class Common:
|
||||
|
||||
# 상향
|
||||
def checkUpward(self, type, data):
|
||||
check = True
|
||||
if type != None:
|
||||
for i in range(len(data)-1):
|
||||
# 만약 이전이 이후보다 크다면, 상승이 아님
|
||||
if data[i][type] > data[i+1][type]:
|
||||
check = False
|
||||
break
|
||||
else:
|
||||
for i in range(len(data)-1):
|
||||
# 만약 이전이 이후보다 크다면, 상승이 아님
|
||||
if data[i] > data[i+1]:
|
||||
check = False
|
||||
break
|
||||
return check
|
||||
|
||||
# 하향
|
||||
def checkDownward(self, type, data):
|
||||
check = True
|
||||
for i in range(len(data)-1):
|
||||
# 만약 이전이 이후보다 작다면, 하락이 아님
|
||||
if data[i][type] < data[i+1][type]:
|
||||
check = False
|
||||
break
|
||||
return check
|
||||
|
||||
# 상향 돌파
|
||||
def checkUpwardBreakthrough(self, type1, type2, data):
|
||||
if (type1 in data[0] and type1 in data[1] and type1 in data[2] and
|
||||
type2 in data[0] and type2 in data[1] and type2 in data[2]):
|
||||
|
||||
if ((data[0][type1] < data[1][type1] < data[2][type1]) and
|
||||
(data[0][type1] < data[0][type2] and data[2][type1] > data[2][type2])):
|
||||
return True
|
||||
return False
|
||||
|
||||
# 하향 돌파
|
||||
def checkDownwardBreakthrough(self, type1, type2, data):
|
||||
if (type1 in data[0] and type1 in data[1] and type1 in data[2] and
|
||||
type2 in data[0] and type2 in data[1] and type2 in data[2]):
|
||||
|
||||
if ((data[0][type1] > data[1][type1] > data[2][type1]) and
|
||||
(data[0][type1] > data[0][type2] and data[2][type1] < data[2][type2])):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def getStochasticScore(self, stock, i):
|
||||
score = 0
|
||||
|
||||
if (stock[i - 1]['slow_k'] < stock[i]['slow_k'] and
|
||||
stock[i]['slow_d'] < stock[i]['slow_k']):
|
||||
if stock[i]['slow_k'] < 5:
|
||||
score = 8
|
||||
elif 5 <= stock[i]['slow_k'] < 10:
|
||||
score = 7
|
||||
elif 10 <= stock[i]['slow_k'] < 15:
|
||||
score = 6
|
||||
elif 15 <= stock[i]['slow_k'] < 20:
|
||||
score = 5
|
||||
elif 20 <= stock[i]['slow_k'] < 30:
|
||||
score = 4
|
||||
elif 30 <= stock[i]['slow_k'] < 40:
|
||||
score = 3
|
||||
elif 40 <= stock[i]['slow_k'] < 50:
|
||||
score = 2
|
||||
else:
|
||||
score = 1
|
||||
|
||||
if (stock[i - 1]['slow_k'] > stock[i]['slow_k'] and
|
||||
stock[i - 1]['slow_k'] > stock[i - 1]['slow_d'] and
|
||||
stock[i]['slow_k'] < stock[i]['slow_d']):
|
||||
if stock[i]['slow_k'] > 90:
|
||||
score = -6
|
||||
elif 90 >= stock[i]['slow_k'] > 80:
|
||||
score = -5
|
||||
elif 80 >= stock[i]['slow_k'] > 70:
|
||||
score = -4
|
||||
elif 70 >= stock[i]['slow_k'] > 60:
|
||||
score = -3
|
||||
elif 60 >= stock[i]['slow_k'] > 50:
|
||||
score = -2
|
||||
else:
|
||||
score = -1
|
||||
|
||||
return score
|
||||
|
||||
def getIchimokuCloudScore(self, stock, i):
|
||||
score = 0
|
||||
|
||||
if stock[i - 1]['leadingSpan1'] != 0 and stock[i - 1]['leadingSpan2'] != 0:
|
||||
|
||||
# 후행스팬 > 선행스펜 일때, 후행스펜 > 어제 주가 > 선행스팬 이고, 오늘 주가 > 후행스팬 < 선행스팬 이라면, 매수 2점
|
||||
if (stock[i - 1]['leadingSpan2'] > stock[i - 1]['leadingSpan1'] and stock[i]['leadingSpan2'] > stock[i]['leadingSpan1']):
|
||||
if (stock[i - 1]['leadingSpan2'] > stock[i - 1]['close'] > stock[i - 1]['leadingSpan1'] and
|
||||
stock[i]['close'] > stock[i]['leadingSpan2'] > stock[i - 1]['leadingSpan1']):
|
||||
score = 2
|
||||
|
||||
# 후행스팬 > 선행스펜 일때, 후행스펜 > 선행스팬 > 어제 주가 이고, 오늘 주가 > 후행스팬 < 선행스팬 이라면, 매수 4점
|
||||
if (stock[i - 1]['leadingSpan2'] > stock[i - 1]['leadingSpan1'] and stock[i]['leadingSpan2'] > stock[i]['leadingSpan1']):
|
||||
if (stock[i - 1]['leadingSpan2'] > stock[i - 1]['leadingSpan1'] > stock[i - 1]['close'] and
|
||||
stock[i]['close'] > stock[i]['leadingSpan2'] > stock[i - 1]['leadingSpan1']):
|
||||
score = 4
|
||||
|
||||
# 선행스팬 > 후행스팬 일때, 선행스팬 > 어제 주가 > 후행스팬 이고, 오늘 주가 > 선행스팬 < 후행스팬 이라면, 매수 1점
|
||||
if (stock[i - 1]['leadingSpan1'] > stock[i - 1]['leadingSpan2'] and stock[i]['leadingSpan1'] > stock[i]['leadingSpan2']):
|
||||
if (stock[i - 1]['leadingSpan1'] > stock[i - 1]['close'] > stock[i - 1]['leadingSpan2'] and
|
||||
stock[i]['close'] > stock[i]['leadingSpan1'] > stock[i - 1]['leadingSpan2']):
|
||||
score = 1
|
||||
|
||||
# 선행스팬 > 후행스팬 일때, 선행스팬 > 후행스팬 > 어제 주가 이고, 오늘 주가 > 선행스팬 < 후행스팬 이라면, 매수 3점
|
||||
if (stock[i - 1]['leadingSpan1'] > stock[i - 1]['leadingSpan2'] and stock[i]['leadingSpan1'] > stock[i]['leadingSpan2']):
|
||||
if (stock[i - 1]['leadingSpan1'] > stock[i - 1]['leadingSpan2'] > stock[i - 1]['close'] and
|
||||
stock[i]['close'] > stock[i]['leadingSpan1'] > stock[i - 1]['leadingSpan2']):
|
||||
score = 3
|
||||
|
||||
# 어제는 주가가 선행이나 후행스팬 위에 있었지만, 오늘은 두 스팬 모두 아래로 내려왔을 때 매도
|
||||
if (stock[i - 1]['close'] > stock[i - 1]['leadingSpan1'] or stock[i - 1]['close'] > stock[i - 1]['leadingSpan2']):
|
||||
if (stock[i]['close'] < stock[i]['leadingSpan1'] and stock[i]['close'] < stock[i]['leadingSpan2']):
|
||||
score = -1
|
||||
|
||||
return score
|
||||
|
||||
def checkLongYangBongAfterUmBong(self, stock, i):
|
||||
if i > 0:
|
||||
if stock[i-1]['open'] > stock[i-1]['close']: # 어제가 음봉인지 체크
|
||||
if stock[i]['open'] < stock[i]['close'] and stock[i]['close'] == stock[i]['high']: # 오늘 장대양봉인지 체크
|
||||
if stock[i-1]['volume']*2 < stock[i]['volume']: # 어제 거래량 보다 두배 이상일 때
|
||||
return True
|
||||
return False
|
||||
Reference in New Issue
Block a user