GitHubBlog

Search Documentation

Search for a page in the docs

Sector Rotation

sectorRotation is a single-call, top-of-funnel read of where money is moving across the market right now. It takes the 11 GICS sector ETFs plus SPY as a benchmark, measures momentum and volume across five horizons, and ranks each sector by a blended rotation score.

It takes no parameters — it's a fixed cross-section:

You: What's rotating right now?

Alice: [calls sectorRotation()]

       Rotating in:   XLK Technology (+score)   XLE Energy
       Rotating out:  XLU Utilities (−score)    XLP Staples
       …

The Universe

Eleven GICS sector ETFs, measured against SPY for relative strength:

ETFSectorETFSector
XLKTechnologyXLIIndustrials
XLCCommunication ServicesXLBMaterials
XLYConsumer DiscretionaryXLREReal Estate
XLPConsumer StaplesXLUUtilities
XLEEnergyXLVHealth Care
XLFFinancials

What Each Row Carries

For every sector, across the 1D / 1W / 1M / 3M / 6M horizons:

FieldMeaning
returnsPrice return per horizon
rel_strengthReturn vs SPY per horizon (is it leading or lagging the market?)
momentum_accelerationShort-horizon pace minus long-horizon pace (>0 = accelerating)
dollar_volumeLatest close × volume — traded notional
dv_shareThis sector's share of the 11-set's total dollar volume
dv_share_changedv_share minus its 20-day baseline — the rotation signal (capital flowing in or out)
rvolRelative volume (today vs the 20-day average)
rotation_scoreBlended z-score of momentum acceleration + dollar-volume-share change

Rows come back sorted by rotation_score, descending — the sectors capital is flowing into at the top, the ones it's leaving at the bottom.

The Quadrant Map

The Web UI plots the same data as a rotation map. Each sector is a dot:

  • X-axis — 1-month relative strength vs SPY (leading ← → lagging)
  • Y-axisdv_share_change (losing volume share ↓ ↑ gaining)
  • Colorrotation_score (green positive, red negative)

That yields the classic four quadrants: rotating in (strong + gaining volume, upper-right), improving (weak but gaining, upper-left), weakening (strong but losing, lower-right), and rotating out (weak + losing, lower-left).

In the Pre-Trade Pipeline

sectorRotation is the wide, top-down first pass of a two-step research pipeline shipped as agent skills:

  1. sector-rotation — read what's moving across the whole market; hand the standouts down.
  2. build-thesis — evaluate a specific name on both its left side (fundamentals / valuation) and right side (price, volume, structure).

From the standout sectors you'd typically drill in with Equity Research (movers, ETF holdings) and the Quant Calculator (per-name momentum, volume confirmation).

Next Steps