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.
🟧 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.
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.
For each year, where did the previous year's best
and worst sector finish the following year?
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. 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 roughly fourth place the following year, and
last year's losers averaged sixth, which is about where a random draw would put them.
Five handoffs is far too few to call that a pattern. What the table shows clearly 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 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.
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
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