Use PyPortfolioOpt to blend your return forecasts with market expectations.

By PyQuant News

Published: 2026-09-26

URL: https://pyquantnews.substack.com/p/improve-your-portfolio-construction


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


You can put your own opinion about a stock directly into the portfolio math.

Most beginners assume portfolio weights should come from historical returns and nothing else. You feed ten years of prices into a program that decides how much to hold of each stock, then you accept whatever it hands back. The math treats your own read on a company as random noise to ignore.

So you end up holding a portfolio you don’t believe in, and you abandon it the first bad month.

Where the math breaks

The first weight-picking program I built put almost all the money into two stocks. Nothing was broken in the code. The return estimates I fed it were just rough guesses, and small changes in those guesses swung the weights hard.

Most beginners hit this and start hand-editing weights in a spreadsheet, which defeats the purpose of running the program at all.

Professional investors who decide how money gets split across assets state their views as numbers and let the model blend those views with what the market already expects.

What you’ll build

In today’s post, you’ll use Python to turn your own forecasts for how much each stock will return into portfolio weights.

Let’s go.