init
This commit is contained in:
@@ -221,32 +221,44 @@ class BuySellChecker:
|
||||
def getBuyPriceAndWeight(self, i, data):
|
||||
buy, weight = -1, -1
|
||||
|
||||
# 1) 스토캐스틱 과매도
|
||||
slow_k_buy = False
|
||||
for idx in range(i, i-10, -1):
|
||||
if data['slow_k'][idx] < 20:
|
||||
slow_k_buy = True
|
||||
break
|
||||
if i < 40:
|
||||
return buy, weight
|
||||
|
||||
# 2) macd 교차 신호
|
||||
macd_buy = False
|
||||
if slow_k_buy:
|
||||
for idx in range(i, i-10, -1):
|
||||
if data['macd'][idx - 1] < 0 and data['macds'][idx - 1] < 0 and data['macd'][idx] < 0 and data['macds'][idx] < 0:
|
||||
if data['macd'][idx-1] < data['macds'][idx-1] and data['macd'][idx] > data['macds'][idx]:
|
||||
macd_buy = True
|
||||
max_vol_5 = max(data['volume'].to_list()[i - 4: i + 1])
|
||||
max_vol_30 = max(data['volume'].to_list()[i - 24: i - 4])
|
||||
if max_vol_30 < max_vol_5:
|
||||
if data['open'][i-1] < data['close'][i-1] and data['volume'][i-1] < data['volume'][i]:
|
||||
#if data['open'][i - 1] < data['close'][i - 1] and data['volume'][i - 1] < data['volume'][i]:
|
||||
|
||||
# 1) 스토캐스틱 과매도
|
||||
slow_k_buy = False
|
||||
for idx in range(i, i-10, -1):
|
||||
if data['slow_k'][idx] < 20:
|
||||
slow_k_buy = True
|
||||
break
|
||||
|
||||
# 3) RSI 지수가 50위로 올라갈 때
|
||||
if macd_buy:
|
||||
if data['rsi'][i-1] < 40 and data['rsi'][i] > 40:
|
||||
buy, weight = data['close'][i] , 1
|
||||
# 2) macd 교차 신호
|
||||
macd_buy = False
|
||||
if slow_k_buy:
|
||||
for idx in range(i, i-10, -1):
|
||||
if data['macd'][idx - 1] < 0 and data['macds'][idx - 1] < 0 and data['macd'][idx] < 0 and data['macds'][idx] < 0:
|
||||
if data['macd'][idx-1] < data['macds'][idx-1] and data['macd'][idx] > data['macds'][idx]:
|
||||
macd_buy = True
|
||||
break
|
||||
|
||||
# 3) RSI 지수가 50위로 올라갈 때
|
||||
if macd_buy:
|
||||
if data['rsi'][i-1] < 40 and data['rsi'][i] > 40:
|
||||
buy, weight = data['close'][i] , 1
|
||||
|
||||
"""
|
||||
min_macd = min(data['macd'])
|
||||
if i > 30 and data['macd'][i] < min_macd + (-min_macd * 0.5):
|
||||
if i > 30 and data['macd'][i] < min_macd + (-min_macd * 0.4):
|
||||
buy, weight = data['close'][i], 1
|
||||
|
||||
"""
|
||||
if data['macd'][i] < -4:
|
||||
if data['open'][i - 1] < data['close'][i - 1] and data['volume'][i - 1] < data['volume'][i]:
|
||||
buy, weight = data['close'][i], 1
|
||||
return buy, weight
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user