Skip to content

Commit 5cec5c3

Browse files
committed
allow full binance pack validation runs
1 parent a01c8b1 commit 5cec5c3

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

scripts/sweep_binance_hourly_portfolio_pack.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ def evaluate_pack(
569569
max_pending_entries=int(cfg.max_pending_entries),
570570
apply_leverage_to_crypto=True,
571571
sim_backend="python",
572+
drawdown_profit_early_exit=not bool(args.disable_drawdown_profit_early_exit),
572573
)
573574
result = run_portfolio_simulation(bars, actions, sim_cfg, horizon=int(label_horizon))
574575
start = pd.Timestamp(bars["timestamp"].min())
@@ -1062,6 +1063,7 @@ def main() -> int:
10621063
parser.add_argument("--entry-allocator-max-single-position-fraction", type=float, default=0.35)
10631064
parser.add_argument("--entry-allocator-reserve-fraction", type=float, default=0.05)
10641065
parser.add_argument("--min-result-trades", type=int, default=10)
1066+
parser.add_argument("--disable-drawdown-profit-early-exit", action="store_true")
10651067

10661068
parser.add_argument("--render-days", type=int, default=14)
10671069
parser.add_argument("--num-pairs", type=int, default=6)

unified_hourly_experiment/marketsimulator/portfolio_simulator.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)