跟特征数量没关系
Some checks are pending
Update Docker Hub Description / dockerHubDescription (push) Waiting to run

This commit is contained in:
zhangkun9038@dingtalk.com 2025-04-28 14:13:16 +08:00
parent 8448ab40f5
commit 144615b7a8

View File

@ -144,10 +144,12 @@ class FreqaiExampleStrategy(IStrategy):
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
# 生成更复杂的目标变量 up_or_down
# Ensure the target variable is reshaped correctly
dataframe["up_or_down"] = np.where(
dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
).reshape(-1, 1) # Reshape to 2D array
)
# 确保目标变量是二维数组
if dataframe["up_or_down"].ndim == 1:
dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
# 生成 %-volatility 特征
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()