- Remove hardcoded database_url/jwt_secret defaults, require env vars - Add DB indexes for stocks.market, market_cap, backtests.user_id - Optimize backtest engine: preload all prices, move stock_names out of loop - Fix backtest API auth: filter by user_id at query level (6 endpoints) - Add manual transaction entry modal on portfolio detail page - Replace console.error with toast.error in signals, backtest, data explorer - Add backtest delete button with confirmation dialog - Replace simulated sine chart with real snapshot data - Add strategy-to-portfolio apply flow with dialog - Add DC pension risk asset ratio >70% warning on rebalance page - Add backtest comparison page with metrics table and overlay chart
43 lines
1.3 KiB
Python
43 lines
1.3 KiB
Python
"""add missing performance indexes
|
|
|
|
Revision ID: c3d4e5f6a7b8
|
|
Revises: b7c8d9e0f1a2
|
|
Create Date: 2026-03-19 10:00:00.000000
|
|
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "c3d4e5f6a7b8"
|
|
down_revision: Union[str, None] = "59807c4e84ee"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# Stock universe filtering (strategy engine uses market + market_cap frequently)
|
|
op.create_index("idx_stocks_market", "stocks", ["market"])
|
|
op.create_index(
|
|
"idx_stocks_market_cap", "stocks", [sa.text("market_cap DESC NULLS LAST")]
|
|
)
|
|
|
|
# Backtest listing by user (always filtered by user_id + ordered by created_at)
|
|
op.create_index(
|
|
"idx_backtests_user_created",
|
|
"backtests",
|
|
["user_id", sa.text("created_at DESC")],
|
|
)
|
|
op.create_index("idx_backtests_status", "backtests", ["status"])
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("idx_backtests_status", table_name="backtests")
|
|
op.drop_index("idx_backtests_user_created", table_name="backtests")
|
|
op.drop_index("idx_stocks_market_cap", table_name="stocks")
|
|
op.drop_index("idx_stocks_market", table_name="stocks")
|