Use AlphaLens to measure whether your stock ranks predicted next week's moves.

By PyQuant News

Published: 2026-08-08

URL: https://pyquantnews.substack.com/p/score-the-ranking-not-returns


Each week, I send out one Python tutorial to help you get started with algorithmic trading, market data analysis, and quant finance. Upgrade to a paid plan to access the Python code notebooks, Discord community, and code support.

Subscribe now


Ranking-based trading ideas often fail for a reason you can measure before you risk any money.

Beginners assume a strategy is good if the running total of profits goes up. So they test one idea, see a profit, and move straight to a broker account. The first thing to check is whether the ranking itself predicted next month’s returns.

Skip that measurement and you can spend months trading a rule whose ranking never predicted returns outside the 10 years you tested.

What I learned in grad school

In my master’s program, one professor ranked stocks at a hedge fund by company size and by price relative to book value, then correlated those ranks against the next month’s returns. My version took a semester of MATLAB, mostly because I kept lining up ranks with returns that had already happened.

New traders rarely score the ranking itself, because total return is the only number most strategy tutorials ever report.

A quantitative research team measures the correlation between the ranks it assigned and the returns that followed each month. A test on historical data that shows a profit doesn’t answer that question.

What you’ll build today

In today’s post, you’ll rank stocks by their trailing 12-month return and score that ranking against 1, 5, and 21-day forward returns using AlphaLens, an open-source Python library.

Let’s go.