Fix migration chain and clear stored paper exit mode
Migration 017 set down_revision to "016_add_signal_context_snapshots", but migration 016's revision id is "016", so `alembic upgrade head` could not resolve the chain and the deploy's auto-alembic step would fail. Point 017 at the real id "016". Add migration 018 to delete any persisted `paper_exit_mode` row. The July 2026 promotion changed the paper-trade exit default to `atr_trailing`, but `get_exit_policy` reads a stored value before the code default, so an environment that had ever saved the old `time` mode would silently keep it and never run the promoted 3x ATR trailing exit. Mirrors migration 015's one-way settings reset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
"""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
|
||||
Reference in New Issue
Block a user