This commit is contained in:
aaron 2024-10-06 10:10:56 +08:00
parent e93ec6516c
commit d69261446e

View File

@ -36,8 +36,8 @@ def stratergy_run(symbol, interval, df, debug):
upperband, middleband, lowerband = talib.BBANDS(df['close'], timeperiod=bollinger_length, nbdevup=bollinger_mult, nbdevdn=bollinger_mult, matype=0)
# 生成交易信号
long_condition = (macd.shift(1) <= 0) & (macd > 0) & (df['high'] < upperband) & (df['close'] > fast_ema | df['close'] > slow_ema)
short_condition = (macd.shift(1) >= 0) & (macd < 0) & (df['low'] > lowerband) & (df['close'] < fast_ema | df['close'] < slow_ema)
long_condition = (macd.shift(1) <= 0) & (macd > 0) & (df['high'] < upperband) & ((df['close'] > fast_ema) | (df['close'] > slow_ema))
short_condition = (macd.shift(1) >= 0) & (macd < 0) & (df['low'] > lowerband) & ((df['close'] < fast_ema) | (df['close'] < slow_ema))
df['Long_Signal'] = np.where(long_condition, True, False)