"""Clear the stored paper exit mode so the promoted ATR-trail default applies. The July 2026 promotion moved the paper-trade auto-exit default from ``time`` (30-day hold on the initial stop) to ``atr_trailing`` (initial stop + 3x ATR trailing stop, max 30 trading days) — the exit the production backtest validated, now implemented live in ``paper_trade_service``. ``get_exit_policy`` reads a stored ``paper_exit_mode`` row before falling back to the code default, so any environment that persisted the old ``time`` value (e.g. via Admin -> Paper-Trade Exit, or an earlier deploy) would silently keep the old exit and never run the promoted ATR trail. Following the precedent of migration 015, the stored row is cleared here so the new code default takes effect. Admins can re-tune in Admin -> Paper-Trade Exit if desired. Note: this changes how open paper trades close, so Track Record comparability resets from this deploy. Revision ID: 018_clear_paper_exit_mode Revises: 017_add_trade_setup_strategy_rank Create Date: 2026-07-04 00:00:00.000000 """ from __future__ import annotations from alembic import op import sqlalchemy as sa revision = "018_clear_paper_exit_mode" down_revision = "017_add_trade_setup_strategy_rank" branch_labels = None depends_on = None def upgrade() -> None: op.execute( sa.text("DELETE FROM system_settings WHERE key = 'paper_exit_mode'") ) def downgrade() -> None: # One-way data reset: the prior stored value isn't recoverable. The code # default applies until re-tuned, so there is nothing to restore. pass