PyQuant News

PyQuant News

🐍 Position sizing kills more traders than bad picks

Use scipy to compute Kelly criterion fractions on S&P 500 returns

May 23, 2026
∙ Paid

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 don’t blow up because they picked the wrong stock.

They blow up because they bet too much on the right one. Position sizing, which means deciding how much of your account to put into a single trade, is the part of trading that separates people who last from people who don’t. Beginners almost always skip it. They spend weeks finding a strategy, then risk half their account on the first trade without thinking twice.

That habit is how accounts go to zero, usually faster than anyone expects.

The lesson nobody wants to learn first

In 2006, on my first day trading professionally, someone was walking out for their last. A week later, two more people left their screens for good. The managing director eventually told us the one thing that ruins traders’ careers faster than anything else. Trading too big.

Most beginners I talk to treat risk management as something they’ll figure out later, after they’ve found a “winning strategy.”

Professionals think about it the other way around. They figure out how much to risk first, then look for trades that fit inside those limits.

What you’ll build today

In today’s post, you’ll use Python to calculate the optimal position size for the S&P 500 using a formula called the Kelly criterion, which tells you exactly how much of your account to bet to grow it as fast as possible without taking on unnecessary risk.

Let’s go.

A formula for how much to bet

The Kelly criterion is a formula that tells you the best size for a bet, meaning the amount that grows your account as fast as possible over many repeated bets. John Kelly, a researcher at Bell Labs, invented it in the 1950s to solve problems in information theory and gambling. In the 1960s, a mathematician named Edward Thorp made it famous by using it to beat casinos at blackjack and then applying it to the stock market. He wrote about it in two well-known books, Beat the Dealer and Beat the Market.

Warren Buffett and the legendary bond investor Bill Gross have both reportedly used versions of the Kelly criterion to size their positions. The idea has been around for decades because it works, at least when you can estimate your odds with reasonable accuracy.

How professionals use it

Trading teams at hedge funds and proprietary firms use the Kelly criterion as a starting point for deciding how much capital to put into each trade or strategy.

The formula works best when you have a good estimate of your expected returns, which means you need to know roughly how often your strategy wins and how much it wins or loses on average. Professional firms get these estimates by running their strategies on thousands of historical trades, then adjusting the Kelly number downward (often using half the suggested size) because real markets are messier than any model assumes. The formula also assumes you can make an unlimited number of bets, which nobody actually can, so professionals treat it as an upper bound rather than a target.

Why this matters when you’re starting out

If you’re learning Python for trading, the Kelly criterion is one of the first practical tools worth understanding because it forces you to think about risk before you think about returns.

Most beginners focus entirely on finding trades and ignore how much to risk on each one. That’s the fastest way to wipe out an account. The Kelly criterion gives you a concrete, mathematical answer to “how much should I bet?” Building it in Python teaches you how to work with return data, probability distributions (the range of possible outcomes and how likely each one is), and optimization. You’ll use all of these skills constantly. Even if you never use the exact Kelly number in live trading, the process of calculating it will change how you think about sizing every position you take.

Let’s see how it works with Python.

User's avatar

Continue reading this post for free, courtesy of PyQuant News.

Or purchase a paid subscription.
© 2026 PyQuant News, LLC · Privacy ∙ Terms ∙ Collection notice
Start your SubstackGet the app
Substack is the home for great culture