fix issue
This commit is contained in:
parent
ff6a6150f6
commit
f60dce572b
@ -412,34 +412,6 @@ class FreqaiPrimer(IStrategy):
|
||||
if 'macd_1h' in dataframe.columns:
|
||||
logger.info(f"[{metadata['pair']}] 1小时 MACD 列: ['macd_1h', 'macd_signal_1h']")
|
||||
|
||||
# Validate that all required columns are present
|
||||
required_columns = ['date', 'rsi_1h', 'trend_1h', 'ema_50_1h', 'ema_200_1h',
|
||||
'bb_lower_1h', 'bb_upper_1h', 'stochrsi_k_1h', 'stochrsi_d_1h',
|
||||
'macd_1h', 'macd_signal_1h']
|
||||
missing_columns = [col for col in required_columns if col not in df_1h.columns]
|
||||
if missing_columns:
|
||||
logger.error(f"[{metadata['pair']}] 缺少以下列: {missing_columns}")
|
||||
raise KeyError(f"缺少以下列: {missing_columns}")
|
||||
|
||||
# 确保所有需要的列都被合并
|
||||
required_columns = ['date', 'rsi_1h', 'trend_1h', 'ema_50_1h', 'ema_200_1h',
|
||||
'bb_lower_1h', 'bb_upper_1h', 'stochrsi_k_1h', 'stochrsi_d_1h',
|
||||
'macd_1h', 'macd_signal_1h']
|
||||
|
||||
# 验证所需列是否存在
|
||||
missing_columns = [col for col in required_columns if col not in df_1h.columns]
|
||||
if missing_columns:
|
||||
logger.error(f"[{metadata['pair']}] 缺少以下列: {missing_columns}")
|
||||
raise KeyError(f"缺少以下列: {missing_columns}")
|
||||
|
||||
df_1h = df_1h[required_columns] # 确保包含 macd_1h 和 macd_signal_1h
|
||||
|
||||
# 合并 1h 数据
|
||||
dataframe = dataframe.merge(df_1h, how='left', on='date').fillna(method='ffill')
|
||||
|
||||
# 验证合并后的列
|
||||
logger.info(f"[{metadata['pair']}] 合并后的数据框列名: {list(dataframe.columns)}")
|
||||
|
||||
# K线形态:看涨吞没
|
||||
dataframe['bullish_engulfing'] = (
|
||||
(dataframe['close'].shift(1) < dataframe['open'].shift(1)) &
|
||||
@ -1077,7 +1049,7 @@ class FreqaiPrimer(IStrategy):
|
||||
levels = adjusted_levels
|
||||
logger.info(f"[{pair}] 使用FreqAI预测调整止盈水平,预测最优止盈阈值: {latest_prediction:.2%}")
|
||||
except Exception as e:
|
||||
logger.error(f"[{pair}] 使用FreqAI预测调整止盈时发生错误: {str(e)}")
|
||||
logger.error(f"[{pair}] 使用FreqAI预测进行出场决策时发生错误: {str(e)}")
|
||||
|
||||
# 确定当前应该止盈的比例
|
||||
exit_ratio = 0.0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user