feat: adopt Phase 3 gate and paper-trade exit policy
Deploy / lint (push) Successful in 7s
Deploy / test (push) Successful in 56s
Deploy / deploy (push) Successful in 33s

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:
2026-07-02 15:20:34 +02:00
parent 29a61cb2ca
commit 1e82dfad7f
10 changed files with 224 additions and 43 deletions
@@ -0,0 +1,50 @@
"""Phase 3 strategy adoption: time-based exit + confidence floor removed.
The July 2026 backtest (gate ablation graded under both exit models, plus the
capital-constrained portfolio simulation) concluded:
- The best exit is hold-to-horizon: keep the initial ATR stop and exit at the
30th trading day's close (+0.50R net/trade vs +0.13R for the S/R target
exit; simulated book +31.9% vs +23.7% CAGR at the same drawdown). The paper
trade exit-policy default is now ``time`` (30 trading days).
- The confidence floor adds nothing (identical net/trade with it removed,
under both exit models) while cutting ~25% of qualified trades. Its default
is now 0 (off).
Stored rows for these two settings were written under the old semantics, so
they are cleared here and the new code defaults take effect. Re-tune in
Admin -> Activation / Paper-Trade Exit if desired. Note: this changes which
setups qualify and how paper trades close, so Track Record comparability
resets from this deploy.
Revision ID: 015
Revises: 014
Create Date: 2026-07-02 00:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = "015"
down_revision: Union[str, None] = "014"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.execute(
sa.text(
"DELETE FROM system_settings "
"WHERE key IN ('activation_min_confidence', 'paper_exit_mode')"
)
)
def downgrade() -> None:
# One-way data reset: the old per-key values aren't recoverable. Code
# defaults apply until re-tuned, so there is nothing to restore.
pass