Files
AlphaPulse/backend/alembic/versions/20261016_c5e8a1b3d207_news_signals.py
T
eezd 23a9a5175e Record news signals forward for a no-trade edge test
The trader labels crypto news published after 2026-10-16 15:00 with
the configured model (category and BTC direction) and, four hours
later, backfills BTC/ETH 1m opens at publish, +5m, +1h and +4h from
the klines table. A drawer on the trading page shows the cumulative
returns of trading the labelled direction, after fees. Nothing is
traded; this only collects an out-of-sample record.
2026-10-16 14:47:06 +08:00

40 lines
1.2 KiB
Python

"""news signals
Revision ID: c5e8a1b3d207
Revises: a7d3e5f20c18
Create Date: 2026-10-16 16:00:00.000000
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = 'c5e8a1b3d207'
down_revision: Union[str, Sequence[str], None] = 'a7d3e5f20c18'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
op.create_table(
'news_signals',
sa.Column('news_id', sa.BigInteger(), nullable=False),
sa.Column('category', sa.String(length=16), nullable=False),
sa.Column('direction', sa.String(length=8), nullable=False),
sa.Column('model', sa.String(length=64), nullable=False),
sa.Column('labeled_at', sa.DateTime(timezone=True), server_default=sa.text('now()'), nullable=False),
sa.Column('prices', postgresql.JSONB(astext_type=sa.Text()), nullable=True),
sa.ForeignKeyConstraint(['news_id'], ['news_items.id']),
sa.PrimaryKeyConstraint('news_id'),
)
def downgrade() -> None:
"""Downgrade schema."""
op.drop_table('news_signals')