Prevent torch forecast fee churn exits
This commit is contained in:
@@ -901,6 +901,9 @@ def _torch_forecast_exit_signal(
|
||||
"estimated_exit_net_percent": round(estimated_exit_net_percent, 4),
|
||||
"atr_14": latest.atr_14 if latest else None,
|
||||
}
|
||||
hold_seconds = (utc_now() - position.opened_at).total_seconds()
|
||||
diagnostics["hold_seconds"] = hold_seconds
|
||||
diagnostics["min_hold_seconds"] = settings.min_hold_seconds
|
||||
if effective_stop_loss is not None and price <= effective_stop_loss:
|
||||
return Signal(position.symbol, "SELL", 1.0, "torch_forecast: stop-loss hit", diagnostics)
|
||||
if price >= position.take_profit:
|
||||
@@ -928,12 +931,33 @@ def _torch_forecast_exit_signal(
|
||||
)
|
||||
return Signal(position.symbol, "SELL", 0.78, "torch_forecast: no valid PyTorch forecast to hold", diagnostics)
|
||||
if bool(forecast.get("block_entry", False)) or expected_return <= 0.0 or probability_up <= 0.50:
|
||||
if hold_seconds < settings.min_hold_seconds:
|
||||
diagnostics["forecast_exit_blocked_by_min_hold"] = True
|
||||
return Signal(
|
||||
position.symbol,
|
||||
"HOLD",
|
||||
0.46,
|
||||
"torch_forecast: minimum hold protects against fee churn",
|
||||
diagnostics,
|
||||
)
|
||||
forecast_exit = _forecast_exit_signal(
|
||||
forecast=forecast,
|
||||
position=position,
|
||||
price=price,
|
||||
estimated_exit_net_percent=estimated_exit_net_percent,
|
||||
stop_loss_percent=stop_loss_percent,
|
||||
min_edge_percent=min_edge,
|
||||
)
|
||||
if forecast_exit is not None:
|
||||
action, confidence, reason = forecast_exit
|
||||
return Signal(position.symbol, action, confidence, reason, diagnostics)
|
||||
diagnostics["forecast_exit_blocked_by_cost"] = True
|
||||
return Signal(
|
||||
position.symbol,
|
||||
"SELL",
|
||||
0.86,
|
||||
"HOLD",
|
||||
0.44,
|
||||
(
|
||||
"torch_forecast: PyTorch forecast turned negative; "
|
||||
"torch_forecast: forecast weakened, but exit is not worth fees; "
|
||||
f"p_up={probability_up:.3f}, expected={expected_return:.4f}%"
|
||||
),
|
||||
diagnostics,
|
||||
|
||||
Reference in New Issue
Block a user