feat: trailing-stop exit sweep in the backtest
Deploy / lint (push) Successful in 6s
Deploy / test (push) Successful in 55s
Deploy / deploy (push) Successful in 32s

Third exit model alongside target-vs-stop and the fixed take-profit. The TP sweep
showed the edge lives in the fat tail (avg R keeps rising as you let winners run),
but a fixed wide target is win-rate-brutal and gives everything back on a reversal.
A trailing stop harvests the tail while protecting gains.

Per setup the replay computes the realized R for several trail widths (3/5/7/10/
15/20%) in a single conservative pass — stop ratchets up via max(initial_stop,
peak*(1-trail)), exit on the pullback or at the horizon close, R vs the initial
risk. Aggregated into a trailing sweep (win rate = share closed in profit, avg R,
total R) over the qualified set and shown as a new table in the Backtest panel.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-06-30 17:33:17 +02:00
parent c5f6b07a3e
commit ab9ce18809
4 changed files with 179 additions and 0 deletions
+10
View File
@@ -239,6 +239,15 @@ export interface BacktestTakeProfitRow {
total_r: number | null;
}
export interface BacktestTrailingRow {
trail_pct: number;
total: number;
wins: number;
win_rate: number | null;
avg_r: number | null;
total_r: number | null;
}
export interface BacktestSignalEvalRow {
signal: string;
weeks: number;
@@ -262,6 +271,7 @@ export interface BacktestReport {
min_momentum_percentile: number;
sweep: BacktestSweepRow[];
take_profit_sweep?: BacktestTakeProfitRow[];
trailing_sweep?: BacktestTrailingRow[];
calibration: BacktestCalibrationRow[];
signal_eval?: BacktestSignalEvalRow[];
signal_eval_note?: string;