Photo by Antonio Gabola on Unsplash

How to use Python and the Kelly Criterion to Optimize your Stock Portfolio

Use Python for advanced, dynamic portfolio optimization

--

Position Sizing is often overlooked by the retail trader. Most wind up over betting and taking on too much risk and blowing up their account. On the other hand, investing in very small amounts in too many places can also ruin your gains (but hey, at least you will stay in the game!) In both cases, the size of your positions significantly shapes the risk profile of your portfolio.

So how do you determine the position size that optimizes your risk and returns?

Enter the Kelly Criterion.

Developed by John Kelly to de-noise telephone lines while working for Bell Labs in the 1950’s, the Kelly Criterion is a formula that has been applied to both gambling and investing. It’s been used by traders on Wall Street as well as mob bosses running horse races and casinos. (For a great read on the fascinating history of this equation, check out Poundstone’s Fortune’s Formula.)

So what is this magic formula? If you do a quick Google search for how to apply the Kelly Criterion to stocks, you’ll probably come across a formula like this one:

This technically is a formula for the Kelly Criterion, but it’s only relevant if…

--

--