def macd_rule(df, index = -1):
try:
if not {'macd_dif', 'macd_dea', 'macd'}.issubset(df.columns):
df = MACD(df)
except Exception as e:
print(e)
return False
input_1 = -3
input_2 = 0.05
# df['macd_dif_1'] = df['macd_dif'].shift(1)
# df['macd_dea_1'] = df['macd_dea'].shift(1)
#(df['macd_dif'][-input_3:].min() < input_2) & \
return (df['macd_dif'][index] > input_1) & \
(df['macd_dif'][index] < input_2) & \
(df['macd_dif'][index] > df['macd_dea'][index]) & \
((df['macd_dea'][index-1] > df['macd_dif'][index-1]) | (abs(df['macd_dea'][index-1] - df['macd_dif'][index-1]) < 0.007))
评论列表
文章目录