reindex and merge
This commit is contained in:
parent
b1e9aef36f
commit
7a582f6b71
@ -174,14 +174,19 @@ class FreqaiPrimer(IStrategy):
|
||||
df_1h['macd_1h'] = macd_1h['MACD_12_26_9']
|
||||
df_1h['macd_signal_1h'] = macd_1h['MACDs_12_26_9']
|
||||
df_1h['macd_hist_1h'] = macd_1h['MACDh_12_26_9']
|
||||
|
||||
# 新增 StochRSI 指标
|
||||
stochrsi_1h = ta.stochrsi(df_1h['close'], length=14, rsi_length=14)
|
||||
df_1h['stochrsi_k_1h'] = stochrsi_1h['STOCHRSIk_14_14_3_3']
|
||||
df_1h['stochrsi_d_1h'] = stochrsi_1h['STOCHRSId_14_14_3_3']
|
||||
|
||||
# 将 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']].fillna(method='ffill')
|
||||
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')
|
||||
|
||||
# 合并 1h 数据
|
||||
dataframe = dataframe.merge(df_1h, how='left', on='date')
|
||||
dataframe = dataframe.merge(df_1h, how='left', on='date').fillna(method='ffill')
|
||||
|
||||
# K线形态:看涨吞没
|
||||
dataframe['bullish_engulfing'] = (
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user