@@ -83,6 +83,7 @@ class PortfolioConfig:
8383 max_pending_entries : Optional [int ] = None
8484 apply_leverage_to_crypto : bool = False
8585 sim_backend : str = "auto" # auto prefers native when safe, else falls back to python
86+ drawdown_profit_early_exit : bool = True
8687
8788
8889@dataclass
@@ -391,10 +392,14 @@ def _run_portfolio_simulation_native(
391392 trade_reason = np .asarray (out ["trade_reason" ], dtype = np .int8 )
392393 equity_values = np .asarray (out ["equity_values" ], dtype = np .float64 )
393394
394- stop_idx = _first_drawdown_profit_early_exit_index (
395- equity_values ,
396- total_steps = t_count ,
397- label = "unified_hourly_experiment.run_portfolio_simulation" ,
395+ stop_idx = (
396+ _first_drawdown_profit_early_exit_index (
397+ equity_values ,
398+ total_steps = t_count ,
399+ label = "unified_hourly_experiment.run_portfolio_simulation" ,
400+ )
401+ if bool (cfg .drawdown_profit_early_exit )
402+ else None
398403 )
399404 if stop_idx is not None :
400405 keep = trade_t_idx <= int (stop_idx )
@@ -555,6 +560,8 @@ def _required_move_to_fill(row, *, entry_price: float, is_long: bool) -> float:
555560
556561 def _append_equity_snapshot (ts : pd .Timestamp ) -> bool :
557562 equity_values .append ((ts , _equity ()))
563+ if not bool (cfg .drawdown_profit_early_exit ):
564+ return False
558565 early_exit = evaluate_drawdown_vs_profit_early_exit (
559566 [value for _ , value in equity_values ],
560567 total_steps = total_steps ,
0 commit comments