熊市 Crash 抄底+1
This commit is contained in:
parent
2a418b478c
commit
9bfb7b86d7
@ -394,11 +394,14 @@ class FreqaiPrimer(IStrategy):
|
||||
# ========== 入场置信度标签 ==========
|
||||
# 基于未来收益率估算入场好坏,使用 S 型函数映射到 0-1
|
||||
future_return = dataframe["close"].shift(-label_period) / dataframe["close"] - 1
|
||||
dataframe["&-entry_confidence"] = 1 / (1 + np.exp(-future_return * 50))
|
||||
# 先填充 NaN 再计算 sigmoid,避免 NaN 传播
|
||||
future_return_filled = future_return.ffill().fillna(0)
|
||||
dataframe["&-entry_confidence"] = 1 / (1 + np.exp(-future_return_filled * 50))
|
||||
|
||||
# ========== 统一处理 NaN,避免训练数据被全部过滤 ==========
|
||||
# ========== 二次保险:确保最终标签没有 NaN ==========
|
||||
if "&-entry_confidence" in dataframe.columns:
|
||||
dataframe["&-entry_confidence"] = dataframe["&-entry_confidence"].fillna(method='ffill').fillna(0)
|
||||
# 使用 0.5(中性置信度)填充任何剩余的 NaN
|
||||
dataframe["&-entry_confidence"] = dataframe["&-entry_confidence"].fillna(0.5)
|
||||
|
||||
return dataframe
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user