feat: ticker search, watchlist momentum column, alpha vs S&P 500
Three usability fixes: 1. Global ticker search in the sidebar (TickerSearch) — typeahead over the tracked universe that opens a ticker's detail page without adding it to the watchlist. Also wired into the mobile nav. 2. Watchlist table shows the ticker's 12-1 momentum percentile (the top-pick selector) instead of the noisy full S/R-level list. Enriched from the setup already loaded in watchlist_service._enrich_entry — no extra query. 3. Alpha vs the S&P 500 on paper trades (open + closed). New benchmark_prices table + benchmark_service store SPY daily closes (a standalone series, not a Ticker, so it never enters the scanner / momentum ranking / rankings) via a new daily-pipeline step. paper_trade_service computes per-trade benchmark_return / alpha_pct / alpha_usd over each holding period; the open- trades table, dashboard, and closed-trades panel surface per-trade and total alpha. The list read path never makes a provider call. Deploy: alembic upgrade head, then run the benchmark/daily job once to populate SPY closes (alpha shows "—" until then). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,7 @@ from app.models.settings import SystemSetting, IngestionProgress
|
||||
from app.models.alert import AlertLog
|
||||
from app.models.paper_trade import PaperTrade
|
||||
from app.models.regime_snapshot import RegimeSnapshot
|
||||
from app.models.benchmark_price import BenchmarkPrice
|
||||
|
||||
__all__ = [
|
||||
"Ticker",
|
||||
@@ -28,4 +29,5 @@ __all__ = [
|
||||
"AlertLog",
|
||||
"PaperTrade",
|
||||
"RegimeSnapshot",
|
||||
"BenchmarkPrice",
|
||||
]
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
from datetime import date as date_type
|
||||
|
||||
from sqlalchemy import Date, Float, String, UniqueConstraint
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class BenchmarkPrice(Base):
|
||||
"""Daily close for a benchmark index (e.g. SPY), used to compute trade alpha.
|
||||
|
||||
A standalone price series, deliberately NOT a tracked ``Ticker`` — so the
|
||||
benchmark never enters the scanner, the momentum-percentile ranking, or the
|
||||
rankings table. One row per (symbol, date).
|
||||
"""
|
||||
|
||||
__tablename__ = "benchmark_prices"
|
||||
__table_args__ = (
|
||||
UniqueConstraint("symbol", "date", name="uq_benchmark_symbol_date"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
symbol: Mapped[str] = mapped_column(String(20), nullable=False, index=True)
|
||||
date: Mapped[date_type] = mapped_column(Date, nullable=False)
|
||||
close: Mapped[float] = mapped_column(Float, nullable=False)
|
||||
Reference in New Issue
Block a user