抬高门槛

This commit is contained in:
zhangkun9038@dingtalk.com 2025-05-28 19:00:11 +00:00
parent d34de4d0d8
commit 714f278cf6

View File

@ -151,7 +151,7 @@ class FreqaiPrimer(IStrategy):
if "&-buy_signal" in df.columns:
# 这个原先逻辑, 轻量持仓: buy_condition = df["&-buy_signal"] > 0.5
# 使用过去 20 根 K 线中 buy_signal 的 80 分位作为阈值, 这个按说算是次轻量持仓
df["buy_threshold"] = df["&-buy_signal"].rolling(20).quantile(0.8)
df["buy_threshold"] = df["&-buy_signal"].rolling(40).quantile(0.9)
buy_condition = df["&-buy_signal"] >= df["buy_threshold"]
# 根据市场状态调整买入信号
@ -174,11 +174,11 @@ class FreqaiPrimer(IStrategy):
def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
# Compute sell_signal_high outside the conditions list
df["sell_signal_high"] = (df["&-sell_signal"] > 0.3).rolling(3).sum() >= 2
conditions = [
# 容易过早离场 df["&-sell_signal"] > 0.5,
# 只有当 sell_signal 持续高于某个较低阈值时才触发
df["sell_signal_high"] = (df["&-sell_signal"] > 0.3).rolling(3).sum() >= 2
conditions.append(df["sell_signal_high"])
df["sell_signal_high"] # Append the condition, not an assignment
]
if "&-market_condition" in df.columns: