Build the Treynor ratio in Python to separate skill from market exposure.
By PyQuant News
Published: 2026-06-20
URL: https://pyquantnews.substack.com/p/big-returns-dont-mean-good-trading
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.

Most traders think performance means making money.
Thatâs only half the picture. A trader who earns 20% by betting everything on one position isnât performing the same as a trader who earns 15% with careful, measured risk. The difference between those two traders only shows up when you measure returns relative to the risk taken.
Without that measurement, you canât tell skill from luck, and youâll keep repeating strategies that feel profitable but are actually fragile.
A ratio that changed everything
Early in my career, a team of analysts started digging into why certain traders were making so much money. What they found wasnât just high returns. It was high returns paired with high risk. Once the firm started measuring performance against the risk each trader was taking, everything changed.
Most beginners skip this step entirely. They look at total return and assume bigger is better.
Professionals donât evaluate strategies by return alone. They divide the return by the risk to see if the performance is actually worth it.
What youâll build today
In this post, youâll use Python to calculate a stockâs risk relative to a benchmark, then use that to compute a ratio that tells you how much return youâre getting for each unit of risk you canât avoid.
Letâs go.