feat: sector rotation map — GICS-11 (AI tool + API route + Market UI) (ANG-80)#273
Merged
Conversation
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>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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— purecomputeSectorRotation(multi-period returns, rel-strength vs SPY,momentum_acceleration,dollar_volume,dv_share+dv_share_change,rvol, blended cross-sectionalrotation_score) + afetchSectorRotation(equityClient)service shared by the tool and route.sectorRotationAI tool — one-liner over the service.GET /api/market/sector-rotation— thin route;equityClientnow exposed onEngineContext(likemarketSearch).Frontend (Market activity)
MarketRotationPage— momentum × volume-share quadrant scatter (recharts): x = rel-strength vs SPY (1M), y = dollar-volume-share change, dots colored byrotation_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.market-rotationview kind (types / registry /UrlAdopterdeep link/market/rotation); sidebar row under Browse.SectorRotationResult(canonical type imported, no ad-hoc shape).Design decisions (with Ame)
Live verification
Test plan
npx tsc --noEmit(Alice) cleancd ui && npx tsc -bclean (strict)pnpm test— 1769 passed (incl. 10 sector-rotation compute specs)Boundary touch
New analysis domain module, market route, agent tool, and Market UI. Adds
equityClienttoEngineContext. No trading / auth / broker-credential / migration paths.🤖 Generated with Claude Code