Skip to content

feat: sector rotation map — GICS-11 (AI tool + API route + Market UI) (ANG-80)#273

Merged
luokerenx4 merged 1 commit into
masterfrom
feat/sector-rotation-ang80
Jun 5, 2026
Merged

feat: sector rotation map — GICS-11 (AI tool + API route + Market UI) (ANG-80)#273
luokerenx4 merged 1 commit into
masterfrom
feat/sector-rotation-ang80

Conversation

@luokerenx4
Copy link
Copy Markdown
Contributor

@luokerenx4 luokerenx4 commented Jun 5, 2026

Summary

Implements ANG-80 end-to-end: a right-side "where is capital rotating" surface across the 11 GICS sector ETFs (+ SPY anchor), as an AI tool, an HTTP route, and a Market-area visualization. Scope expanded from the original tool-only cut to include the UI (per Ame's "直接做轮动图吧, 放到 Market").

Backend

  • domain/analysis/sector-rotation.ts — pure computeSectorRotation (multi-period returns, rel-strength vs SPY, momentum_acceleration, dollar_volume, dv_share + dv_share_change, rvol, blended cross-sectional rotation_score) + a fetchSectorRotation(equityClient) service shared by the tool and route.
  • sectorRotation AI tool — one-liner over the service.
  • GET /api/market/sector-rotation — thin route; equityClient now exposed on EngineContext (like marketSearch).

Frontend (Market activity)

  • MarketRotationPage — momentum × volume-share quadrant scatter (recharts): x = rel-strength vs SPY (1M), y = dollar-volume-share change, dots colored by rotation_score, four labeled quadrants (rotating in / improving / weakening / rotating out) — plus a ranked table sorted by score, and the methodology + fund-flow-proxy caveat inline. Polls every 5 min.
  • Registered market-rotation view kind (types / registry / UrlAdopter deep link /market/rotation); sidebar row under Browse.
  • i18n en/zh/ja (SPY / RVOL / GICS kept English per the accuracy-over-coverage convention).
  • Demo: snapshot fixture + MSW handler matching SectorRotationResult (canonical type imported, no ad-hoc shape).

Design decisions (with Ame)

  • Enumerate only broad sectors; specific themes via the ETF tools (ANG-79), not enumerated.
  • Score = momentum acceleration + volume-share change, not raw return — surfaces the turn, not what's extended.
  • Quadrant + table; UI shipped now (was deferred, pulled forward at Ame's request).

Live verification

  • Backend over live yahoo: XLF tops the score (volume-share +7.6%, RVOL 1.63) while XLK (strongest raw momentum, 3M +37.8%) ranks mid — extended, not accelerating.
  • The quadrant visually separates "rotating in" (top-right) from "rotating out" (bottom-left).

Test plan

  • npx tsc --noEmit (Alice) clean
  • cd ui && npx tsc -b clean (strict)
  • pnpm test — 1769 passed (incl. 10 sector-rotation compute specs)
  • Live yahoo run; demo fixture validated against the API contract

Boundary touch

New analysis domain module, market route, agent tool, and Market UI. Adds equityClient to EngineContext. No trading / auth / broker-credential / migration paths.

🤖 Generated with Claude Code

A right-side "where is capital rotating" tool. Cross-sectionally compares the 11
SPDR sector ETFs (+ SPY anchor) across 1D/1W/1M/3M/6M on price momentum and the
two volume axes, ranked by a blended rotation score.

- domain/analysis/sector-rotation.ts — pure compute. Per-ETF: multi-period
  returns + rel_strength vs SPY, momentum_acceleration (1W per-day pace minus 3M
  per-day pace), dollar_volume, dv_share + dv_share_change (slice of the
  11-sector volume vs its 20-day norm — the rotation signal), rvol. Blended
  rotation_score = mean of cross-sectional z(accel) and z(dv_share_change);
  sorted desc. Methodology + fund-flow-proxy caveat returned inline.
- tool/sector-rotation.ts — thin orchestration: fetch the 12 daily histories,
  hand to compute. Registered in main.ts.

Design (decided with Ame): enumerate ONLY broad sectors; themes are reached via
the ETF tools (etfSearch/etfGetInfo, ANG-79), not enumerated. Score = momentum
acceleration + volume-share change, NOT raw return — so it surfaces the *turn*,
not what's already extended. First cut is tool/data only; UI quadrant is a later
ticket.

Live check: XLF tops the score (volume-share +7.6%, RVOL 1.63 — fresh inflow)
while XLK, despite the strongest raw momentum (3M +37.8%), ranks mid because it's
extended not accelerating — exactly what raw-return sorting would miss.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openalice-demo Ready Ready Preview, Comment Jun 5, 2026 7:11am

Request Review

@luokerenx4 luokerenx4 merged commit 76acb27 into master Jun 5, 2026
5 checks passed
@luokerenx4 luokerenx4 changed the title feat(analysis): sector rotation map — GICS-11 cross-section (ANG-80) feat: sector rotation map — GICS-11 (AI tool + API route + Market UI) (ANG-80) Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant