DEV Community

Cover image for “The Market” Isn't One Thing: Watching Sectors Take Turns
Jaroslav Šmarda
Jaroslav Šmarda

Posted on Originally published at Medium

“The Market” Isn't One Thing: Watching Sectors Take Turns

Python for programmers, prompts for data analysts.


"The market was up 20% this year" is one of the most compressed sentences in finance. It blends technology companies, oil producers,
banks, utilities, and drugmakers into a single number — as if they all moved together.

They don't. Some years one corner of the market carries everything; other years that same corner drags. Traders call the pattern "sector
rotation." Let's pull the eleven sectors apart and watch who led, who lagged, and whether last year's winner tells you anything about
next year's.

Want to try this yourself? The EODHD MCP Server is what
pulled the data above — connect it to Claude and ask your own questions (affiliate link).

New here? The Setup covers
everything you need before your first prompt.


Pull the eleven sectors apart

🟧 PROMPT

Use the eodhd MCP to get yearly returns for the
eleven SPDR sector ETFs from 2021 to today, and
show the best and worst sector each year.
Enter fullscreen mode Exit fullscreen mode

Best and worst sector, year by year:

2021 — Energy (XLE) +53.3% · Communication (XLC) +16.0%

2022 — Energy (XLE) +64.3% · Communication (XLC) −37.6%

2023 — Technology (XLK) +56.0% · Utilities (XLU) −7.2%

2024 — Communication (XLC) +34.7% · Materials (XLB) +0.2%

2025 — Technology (XLK) +24.6% · Consumer Staples (XLP) +1.5%

2026 so far — Energy (XLE) +42.8% · Consumer Discretionary (XLY) −7.0%

Look at 2022 alone: the best sector gained 64%, the worst lost 38%. That's a gap of more than 100 percentage points, within the same
"market" and the same twelve months. Any single number describing "how the market did" that year was an average of two completely
different experiences.


Does last year's winner tell you anything?

🟧 PROMPT

For each year, where did the previous year's best
and worst sector finish the following year?
Enter fullscreen mode Exit fullscreen mode

Last year's best sector, ranked the next year (out of 11):

Energy, best in 2021 → #1 in 2022

Energy, best in 2022 → #9 in 2023

Technology, best in 2023 → #5 in 2024

Communication, best in 2024 → #2 in 2025

Technology, best in 2025 → #2 in 2026 so far

Last year's worst sector, ranked the next year:

Communication, worst in 2021 → #11 in 2022 (worst again)

Communication, worst in 2022 → #2 in 2023, up 52.8%

Utilities, worst in 2023 → #4 in 2024

Materials, worst in 2024 → #7 in 2025

Consumer Staples, worst in 2025 → #6 in 2026 so far

There's no clean rule here, but there is a tilt. Energy won two years running, then fell to ninth. Communication finished last two years in a row, then jumped to second with a 53% gain. Across these five handoffs, last year's winners averaged 3.8th place the following year, about two places better than the 6th a random pick would average. Last year's losers averaged exactly 6th, right where chance would put them.

Five handoffs is still a small sample. Five random picks would average 3.8th or better roughly one time in fourteen, so luck can't be ruled out, and the winners weren't independent draws: Energy led twice and Technology led twice. What the table shows beyond doubt is how fast the order reshuffles, and how badly "buy whatever led last year" or "avoid whatever lagged" could have gone in the wrong year. Chasing 2022's winner meant riding Energy into a flat 2023. Abandoning 2022's loser meant missing Communication's rebound.


A word of honesty

A few things about this comparison deserve naming.

Calendar years are an arbitrary way to slice the data. Measure the same eleven sectors from July to July, or quarter by quarter, and the
winners and losers would shuffle differently — some of 2022's 100-point gap between Energy and Communication came from where January 1st
happened to fall. The pattern of sectors taking turns holds up; the exact rankings depend on where you draw the lines.

The window is also short: under six years, five year-to-year handoffs. That's enough to show how much the order moves, and nowhere near
enough to prove whether it moves randomly or follows a cycle. People who study sector rotation seriously look at decades of data,
alongside interest rates and the business cycle, and still argue about how predictable it is.

And a sector ETF is less diversified than its name suggests. XLK, XLC, and XLY are each dominated by a handful of giant companies, so
"Technology had a great year" can mostly mean "two or three stocks had a great year." Treat each line in the table as the story of a few
heavyweights, not of an entire industry. Not investment advice.


Final Thoughts

This is the thirty-second article in the series Unlock Real-Time Market Intelligence with EODHD and Claude, and it takes apart a number every other article
has quietly leaned on: "the market."

Two prompts split one index into eleven sectors, then checked whether the leaders stayed in front.

So here's what they found: in 2022, the best sector gained 64% and the worst lost 38% — a gap of more than 100 percentage points inside the same market, in the same year. And the sector that finished last that year finished second the next. "The market" is an average of very different stories, and the order of those stories keeps reshuffling. Last year's leader tended to stay near the top in this sample, but not reliably enough to lean on: Energy went from first to ninth in a single year.


If this made you curious, the MCP Server is free to
try — The Setup walks you through
it.


← Part 31: Before You Panic About Insider Selling, Check the Code

Top comments (0)