This week I shipped a sector rotation map for Indian stocks. It plots NSE sector and thematic indices against the Nifty 500 and sorts them into four corners: Leading, Weakening, Lagging and Improving.
Then the obvious question hit me: does it actually tell you anything? If you buy whatever is Leading, do you beat the market? And do sectors really travel clockwise around the map, the way every explainer says?
So I rebuilt the whole thing in Python, ran it over ten years of weekly data, and checked. This post is the build: the maths, the code, two bugs, and a shuffle test that took my favourite finding away. The story version, with more charts, is on Medium (linked at the end).
Not investment advice. I built the data platform and the map used here. Data runs from July 2016 to 23 October 2026.
The maths
Every week, for every sector:
rs = 100 * sector / nifty_500 # relative strength ratio = 100 * wma ( rs , 5 ) / wma ( rs , 15 ) # has it been gaining ground lately? mom = 100 * ratio / ratio .…