Additional check to ensure no NaN values remain
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
64e2edfa4e
commit
05b65162a1
@ -162,8 +162,15 @@ class FreqaiExampleStrategy(IStrategy):
|
||||
# 派生其他目标
|
||||
dataframe["&-sell_rsi"] = dataframe["&-buy_rsi"] + 30
|
||||
dataframe["%-volatility"] = dataframe["close"].pct_change().rolling(20).std()
|
||||
dataframe["&-stoploss"] = -0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)
|
||||
dataframe["&-roi_0"] = (dataframe["close"] / dataframe["close"].shift(label_period) - 1).clip(0, 0.2)
|
||||
# Ensure proper calculation and handle potential NaN values
|
||||
dataframe["&-stoploss"] = (-0.1 - (dataframe["%-volatility"] * 10).clip(0, 0.25)).fillna(-0.1)
|
||||
dataframe["&-roi_0"] = ((dataframe["close"] / dataframe["close"].shift(label_period) - 1).clip(0, 0.2)).fillna(0)
|
||||
|
||||
# Additional check to ensure no NaN values remain
|
||||
for col in ["&-stoploss", "&-roi_0"]:
|
||||
if dataframe[col].isna().any():
|
||||
logger.warning(f"列 {col} 仍包含 NaN,填充为默认值")
|
||||
dataframe[col] = dataframe[col].fillna(-0.1 if col == "&-stoploss" else 0)
|
||||
|
||||
# 简化动态参数生成逻辑
|
||||
# 简化 buy_rsi 和 sell_rsi 的生成逻辑
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user