重新限定了confirm_trade_entry/exit规则根据ML ai结果,追加了波动率可能造成的影响
This commit is contained in:
parent
01ce5b0d90
commit
b722b13be3
@ -1701,13 +1701,23 @@ class FreqaiPrimer(IStrategy):
|
||||
if '&-target_volatility' in df.columns:
|
||||
predicted_volatility = float(last_row['&-target_volatility'])
|
||||
|
||||
# 获取未来波动率信号
|
||||
future_volatility = None
|
||||
if '&s-future_volatility' in df.columns:
|
||||
future_volatility = float(last_row['&s-future_volatility'])
|
||||
elif '&-future_volatility' in df.columns:
|
||||
future_volatility = float(last_row['&-future_volatility'])
|
||||
|
||||
# 获取趋势预测
|
||||
trend_prediction = None
|
||||
if '&-target_trend' in df.columns:
|
||||
trend_prediction = float(last_row['&-target_trend'])
|
||||
|
||||
# 优先使用 future_volatility,如果没有则使用 predicted_volatility
|
||||
volatility_to_use = future_volatility if future_volatility is not None else predicted_volatility
|
||||
|
||||
# 基于ML预测的智能决策(移除了对不可靠的current_profit的依赖)
|
||||
if current_entry_prob is not None and predicted_volatility is not None:
|
||||
if current_entry_prob is not None and volatility_to_use is not None:
|
||||
# 如果当前入场信号概率很高,说明市场条件仍然良好,可以继续持有
|
||||
if current_entry_prob > 0.6:
|
||||
# 高入场概率,建议继续持有
|
||||
@ -1720,13 +1730,15 @@ class FreqaiPrimer(IStrategy):
|
||||
return True # 支持出场
|
||||
|
||||
# 如果波动率预测很低但入场信号概率较高,可能不应该立即出场
|
||||
if predicted_volatility < 0.35 and current_entry_prob > 0.55:
|
||||
self.strategy_log(f"[{pair}] 低波动+高入场信号({current_entry_prob:.2f}),建议继续持有等待机会")
|
||||
if volatility_to_use < 0.35 and current_entry_prob > 0.55:
|
||||
volatility_source = "future_volatility" if future_volatility is not None else "predicted_volatility"
|
||||
self.strategy_log(f"[{pair}] 低波动({volatility_to_use:.2f},{volatility_source})+高入场信号({current_entry_prob:.2f}),建议继续持有等待机会")
|
||||
return False # 阻止因低波动而强制出场
|
||||
|
||||
# 如果波动率预测很低且入场信号概率也低,支持出场
|
||||
if predicted_volatility < 0.35 and current_entry_prob < 0.3:
|
||||
self.strategy_log(f"[{pair}] 低波动+低入场信号({current_entry_prob:.2f}),支持出场")
|
||||
if volatility_to_use < 0.35 and current_entry_prob < 0.3:
|
||||
volatility_source = "future_volatility" if future_volatility is not None else "predicted_volatility"
|
||||
self.strategy_log(f"[{pair}] 低波动({volatility_to_use:.2f},{volatility_source})+低入场信号({current_entry_prob:.2f}),支持出场")
|
||||
return True # 支持出场
|
||||
|
||||
# 如果有趋势预测且预测为下跌趋势,支持出场
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user