0627787bfc
011 collided with the existing 011_add_regime_snapshots (duplicate revision id and a second head branching off 010), which broke `alembic upgrade head`. Chain the benchmark_prices migration after regime_snapshots so the history is linear again (010 -> 011 regime_snapshots -> 012 benchmark_prices, single head). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
42 lines
1.3 KiB
Python
42 lines
1.3 KiB
Python
"""add benchmark_prices
|
|
|
|
Stores daily closes for a benchmark index (SPY) so paper-trade alpha — trade
|
|
return minus the benchmark's return over the same holding period — can be
|
|
computed. Kept separate from the tradeable universe: the benchmark is not a
|
|
Ticker, so it never enters the scanner, momentum ranking, or rankings.
|
|
|
|
Revision ID: 012
|
|
Revises: 011
|
|
Create Date: 2026-06-28 00:00:00.000000
|
|
|
|
"""
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "012"
|
|
down_revision: Union[str, None] = "011"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"benchmark_prices",
|
|
sa.Column("id", sa.Integer(), nullable=False),
|
|
sa.Column("symbol", sa.String(length=20), nullable=False),
|
|
sa.Column("date", sa.Date(), nullable=False),
|
|
sa.Column("close", sa.Float(), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
sa.UniqueConstraint("symbol", "date", name="uq_benchmark_symbol_date"),
|
|
)
|
|
op.create_index("ix_benchmark_prices_symbol", "benchmark_prices", ["symbol"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_benchmark_prices_symbol", table_name="benchmark_prices")
|
|
op.drop_table("benchmark_prices")
|