reindex and merge
This commit is contained in:
parent
94fc93c7ee
commit
aed02ad8e9
@ -195,7 +195,17 @@ class FreqaiPrimer(IStrategy):
|
||||
# 将 1h 数据重新索引到主时间框架 (3m)
|
||||
df_1h = df_1h.set_index('date').reindex(dataframe['date']).reset_index()
|
||||
df_1h = df_1h.rename(columns={'index': 'date'})
|
||||
df_1h = df_1h[['date', 'rsi_1h', 'trend_1h', 'ema_50_1h', 'ema_200_1h', 'bb_lower_1h', 'bb_upper_1h', 'stochrsi_k_1h', 'stochrsi_d_1h']].fillna(method='ffill')
|
||||
# Include macd_1h and macd_signal_1h in the column selection
|
||||
df_1h = df_1h[['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']].ffill()
|
||||
|
||||
# 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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user