The deploy's `alembic upgrade head` failed at 016->017 with StringDataRightTruncationError: the revision id "017_add_trade_setup_strategy_rank" is 33 chars, but Postgres's alembic_version.version_num is VARCHAR(32). Offline/SQLite checks don't enforce the length, so this only surfaced against prod Postgres. Rename the revision ids to the repo's short numeric convention (017, 018); descriptive filenames are kept. down_revision links updated to match. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
44 lines
1.4 KiB
Python
44 lines
1.4 KiB
Python
"""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
|
|
Revises: 017
|
|
Create Date: 2026-07-04 00:00:00.000000
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision = "018"
|
|
down_revision = "017"
|
|
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
|