This commit is contained in:
dsyoon
2024-02-12 20:27:20 +09:00
parent 28a1914424
commit 7803c131ec

View File

@@ -4,39 +4,39 @@ from stock.analysis.MovingAverage import MovingAverage
class Common:
# 상향
def getDirection(self, data, idx, until=10):
def getDirection(self, stock, idx, until=10):
up, down = 0, 0
for i in range(idx, idx-(until+1), -1):
if data[i - 1] < data[i]:
if stock[i - 1] < stock[i]:
up += 1
if data[i - 1] > data[i]:
if stock[i - 1] > stock[i]:
down += 1
if down < up:
if data[idx - 3] < data[idx]:
if stock[idx - 3] < stock[idx]:
return 'UP'
elif up < down:
if data[idx - 3] > data[idx]:
if stock[idx - 3] > stock[idx]:
return 'DOWN'
return 'EVEN'
# 상향 돌파
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]):
def checkUpwardBreakthrough(self, type1, type2, stock):
if (type1 in stock[0] and type1 in stock[1] and type1 in stock[2] and
type2 in stock[0] and type2 in stock[1] and type2 in stock[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])):
if ((stock[0][type1] < stock[1][type1] < stock[2][type1]) and
(stock[0][type1] < stock[0][type2] and stock[2][type1] > stock[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]):
def checkDownwardBreakthrough(self, type1, type2, stock):
if (type1 in stock[0] and type1 in stock[1] and type1 in stock[2] and
type2 in stock[0] and type2 in stock[1] and type2 in stock[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])):
if ((stock[0][type1] > stock[1][type1] > stock[2][type1]) and
(stock[0][type1] > stock[0][type2] and stock[2][type1] < stock[2][type2])):
return True
return False
@@ -626,14 +626,25 @@ class Common:
if len(stock['trend']) < 10:
return check
if stock['upper'][0] < stock['high'][0]:
# 볼린저 밴드 width 로 매수 시점
for i in range(10):
if stock['width'][i + 1] < 20 < stock['width'][i]:
if np.average(stock['trend'][1:21]) < stock['trend'][0] and np.average(stock['trend_k'][1:21]) < stock['trend_k'][0]:
# 1일 트렌드가 시그널 위로 상승 돌파 할 때
if stock['trend_k'][1] <= stock['trend_s'][1] and stock['trend_s'][0] < stock['trend_k'][0]:
# 1일 트렌드가 7일 트렌드보다 작을 때 (상승 초/중기 매수를 위해서)
if stock['trend_k'][0] < stock['trend'][0]:
# 상승을 체크하기 위해서 선행 스팬 활용
check = True
break
# 볼린저 밴드 %B와 MFI로 매수 시점
if 80 < stock['pb'][0] and 80 < stock['mfi'][0]:
# 추세가 상승 중일 때 매수의 관점 (소추세가 하락해 있을 때 매수의 기회)
# macd가 0 이하에서 macd 매수 체크 (macd가 macds를 상승 돌파)
if stock['macd'][1] < stock['macds'][1] and stock['macds'][0] < stock['macd'][0] and stock['macd'][0] < np.min(stock['macd'][1:]) * 0.5:
if stock['avg120'][0] < stock['trend_k'][0]:
# slow_k가 50이하에서 상승 중이고 slow_d를 상승 돌파 할 때
check = True
# slow_k가 10이하에서 상승 중이고 slow_d를 상승 돌파 할 때
if stock['slow_k'][1] < stock['slow_d'][1] and stock['slow_d'][0] < stock['slow_k'][0] and stock['slow_k'][0] < 10:
if stock['avg120'][0] < stock['trend_k'][0]:
check = True
return check