feat: ticker search, watchlist momentum column, alpha vs S&P 500
Deploy / lint (push) Successful in 6s
Deploy / test (push) Failing after 12s
Deploy / deploy (push) Has been skipped

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:
2026-06-28 08:44:40 +02:00
parent 4a96f85cd9
commit 30effa89b7
21 changed files with 506 additions and 31 deletions
+19
View File
@@ -60,6 +60,25 @@ async def _make_ticker(session, symbol: str, *, score: float | None = None) -> i
return t.id
async def test_enrich_includes_momentum_percentile(session):
"""The watchlist row carries the ticker's momentum percentile (from its setup),
which replaces the old S/R-levels column in the UI."""
from app.models.trade_setup import TradeSetup
user_id = await _make_user(session)
tid = await _make_ticker(session, "AAA", score=70.0)
session.add(TradeSetup(
ticker_id=tid, direction="long", entry_price=100.0, stop_loss=95.0,
target=110.0, rr_ratio=2.0, composite_score=70.0,
momentum_percentile=88.0, detected_at=datetime.now(timezone.utc),
))
await session.commit()
await add_manual_entry(session, user_id, "AAA")
rows = await get_watchlist(session, user_id)
assert rows[0]["momentum_percentile"] == 88.0
async def test_add_and_remove_sticks(session):
user_id = await _make_user(session)
await _make_ticker(session, "AAA", score=80.0)