up3
Some checks are pending
Update Docker Hub Description / dockerHubDescription (push) Waiting to run
Some checks are pending
Update Docker Hub Description / dockerHubDescription (push) Waiting to run
This commit is contained in:
parent
96b76ffcc0
commit
b20684b5b1
@ -130,6 +130,15 @@ class FreqaiExampleStrategy(IStrategy):
|
|||||||
try:
|
try:
|
||||||
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
|
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
|
||||||
|
|
||||||
|
# 定义目标变量为未来价格变化百分比(连续值)
|
||||||
|
dataframe["up_or_down"] = (
|
||||||
|
dataframe["close"].shift(-label_period) - dataframe["close"]
|
||||||
|
) / dataframe["close"]
|
||||||
|
|
||||||
|
# 数据清理:处理 NaN 和 Inf 值
|
||||||
|
dataframe["up_or_down"] = dataframe["up_or_down"].replace([np.inf, -np.inf], np.nan)
|
||||||
|
dataframe["up_or_down"] = dataframe["up_or_down"].ffill().fillna(0)
|
||||||
|
|
||||||
# 确保目标变量是二维数组
|
# 确保目标变量是二维数组
|
||||||
if dataframe["up_or_down"].ndim == 1:
|
if dataframe["up_or_down"].ndim == 1:
|
||||||
dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
|
dataframe["up_or_down"] = dataframe["up_or_down"].values.reshape(-1, 1)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user