feat: adopt Phase 3 gate and paper-trade exit policy
Production strategy change based on the July 2026 backtest: paper trades now default to a 30-trading-day hold with the initial stop (classic momentum hold-and-rerank), while target and trailing exits remain available in Admin. The exit policy API/UI now carries hold_days and close_reason can be 'time'. The activation confidence floor default is now 0/off because the gate ablation showed it added no per-trade edge while filtering out usable setups. Migration 015 clears stored activation_min_confidence and paper_exit_mode so the new defaults take effect; this intentionally resets Track Record comparability from this deploy. Verification: 451 backend tests pass, ruff check app/ clean, frontend npm run build clean. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -6,13 +6,15 @@ import { SkeletonCard } from '../ui/Skeleton';
|
||||
export function ExitPolicySettings() {
|
||||
const { data, isLoading } = useExitPolicy();
|
||||
const update = useUpdateExitPolicy();
|
||||
const [mode, setMode] = useState<ExitPolicy['mode']>('trailing');
|
||||
const [mode, setMode] = useState<ExitPolicy['mode']>('time');
|
||||
const [pct, setPct] = useState(12);
|
||||
const [holdDays, setHoldDays] = useState(30);
|
||||
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
setMode(data.mode);
|
||||
setPct(data.trailing_pct);
|
||||
setHoldDays(data.hold_days ?? 30);
|
||||
}
|
||||
}, [data]);
|
||||
|
||||
@@ -24,12 +26,14 @@ export function ExitPolicySettings() {
|
||||
<h3 className="text-sm font-semibold text-gray-200">Paper-Trade Exit</h3>
|
||||
<p className="mt-1 text-xs text-gray-500">
|
||||
How open paper trades auto-close (in the nightly/intraday outcome job).{' '}
|
||||
<span className="text-gray-300">Trailing</span> rides a trailing stop — the backtest's best exit,
|
||||
it lets winners run; <span className="text-gray-300">Target / stop</span> closes at the setup's
|
||||
target or stop. The setup's initial stop is always the floor.
|
||||
<span className="text-gray-300">Hold</span> keeps the initial stop and exits at the Nth trading
|
||||
day's close — the backtest-validated exit (classic momentum: hold ~a month, re-rank);{' '}
|
||||
<span className="text-gray-300">Trailing</span> rides a trailing stop;{' '}
|
||||
<span className="text-gray-300">Target / stop</span> closes at the setup's target or stop.
|
||||
The setup's initial stop is always the floor.
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid gap-4 md:grid-cols-2">
|
||||
<div className="grid gap-4 md:grid-cols-3">
|
||||
<label className="block space-y-1">
|
||||
<span className="text-xs text-gray-400">Exit mode</span>
|
||||
<select
|
||||
@@ -37,10 +41,25 @@ export function ExitPolicySettings() {
|
||||
onChange={(e) => setMode(e.target.value as ExitPolicy['mode'])}
|
||||
className="w-full input-glass px-3 py-2 text-sm"
|
||||
>
|
||||
<option value="time">Hold N days + stop</option>
|
||||
<option value="trailing">Trailing stop</option>
|
||||
<option value="target">Target / stop</option>
|
||||
</select>
|
||||
</label>
|
||||
<label className="block space-y-1">
|
||||
<span className="text-xs text-gray-400">Hold (trading days)</span>
|
||||
<input
|
||||
type="number"
|
||||
min={2}
|
||||
max={250}
|
||||
step={1}
|
||||
value={holdDays}
|
||||
onChange={(e) => setHoldDays(Number(e.target.value))}
|
||||
disabled={mode !== 'time'}
|
||||
className="w-full input-glass px-3 py-2 text-sm disabled:opacity-50"
|
||||
/>
|
||||
<span className="text-[11px] text-gray-600">Backtest optimum: 30 (its evaluation horizon).</span>
|
||||
</label>
|
||||
<label className="block space-y-1">
|
||||
<span className="text-xs text-gray-400">Trailing width (%)</span>
|
||||
<input
|
||||
@@ -53,13 +72,13 @@ export function ExitPolicySettings() {
|
||||
disabled={mode !== 'trailing'}
|
||||
className="w-full input-glass px-3 py-2 text-sm disabled:opacity-50"
|
||||
/>
|
||||
<span className="text-[11px] text-gray-600">Give-back from the peak. Backtest sweet spot ~12–15%.</span>
|
||||
<span className="text-[11px] text-gray-600">Give-back from the peak. ≥15% ≈ the hold exit.</span>
|
||||
</label>
|
||||
</div>
|
||||
<button
|
||||
className="btn-primary px-4 py-2 text-sm disabled:opacity-50"
|
||||
disabled={update.isPending}
|
||||
onClick={() => update.mutate({ mode, trailing_pct: pct })}
|
||||
onClick={() => update.mutate({ mode, trailing_pct: pct, hold_days: holdDays })}
|
||||
>
|
||||
{update.isPending ? 'Saving…' : 'Save Exit Policy'}
|
||||
</button>
|
||||
|
||||
@@ -211,14 +211,15 @@ export interface PaperTrade {
|
||||
benchmark_return_pct: number | null;
|
||||
alpha_pct: number | null;
|
||||
alpha_usd: number | null;
|
||||
close_reason: 'trailing' | 'stop' | 'target' | 'manual' | null;
|
||||
close_reason: 'time' | 'trailing' | 'stop' | 'target' | 'manual' | null;
|
||||
trailing_stop: number | null;
|
||||
trailing_distance_pct: number | null;
|
||||
}
|
||||
|
||||
export interface ExitPolicy {
|
||||
mode: 'trailing' | 'target';
|
||||
mode: 'time' | 'trailing' | 'target';
|
||||
trailing_pct: number;
|
||||
hold_days: number;
|
||||
}
|
||||
|
||||
export interface BacktestBucket {
|
||||
|
||||
Reference in New Issue
Block a user