Markets and trading · Edition No. 39 · 3 Oct 2026

cvxgrp/cvxportfolio

Computes portfolio weights by solving an optimisation problem, and replays the resulting policy over historical prices.

← Markets and tradingRead the whole edition →

1,247 stars · GPL-3.0 (read from /blob/master/LICENSE; full unmodified GPLv3 text, FSF 29 June 2007, no added clause and no commercial carve-out) · 1.5.1 (2025-07-06, year confirmed by PyPI) against a code date of 2026-04-27 · Track this in Scout

Computes portfolio weights by solving an optimisation problem, and replays the resulting policy over historical prices.

▶Repo detailsthe review · specs · pros & cons · install

What it is

Cvxportfolio is a Python library built on CVXPY, a tool for solving convex optimisation problems. Convex, here, means a shape of problem that a computer can solve reliably and provably, rather than by guessing. It takes forecasts of returns, a measure of how holdings move together, and a model of trading costs, and returns the holdings to aim for.

What it is good for. Anyone who has noticed that a simple allocation rule looks excellent on paper and loses money in practice, because the paper version does not pay the spread, the commission or the price impact of its own trades. This library's distinguishing feature is that the cost of trading is part of the problem rather than an afterthought.

Stars1,247
LicenceGPL-3.0 (read from /blob/master/LICENSE; full unmodified GPLv3 text, FSF 29 June 2007, no added clause and no commercial carve-out)
Latest1.5.1 (2025-07-06, year confirmed by PyPI) against a code date of 2026-04-27
Good
  • It comes from the group that wrote the standard textbook on convex optimisation, and it has a published paper behind it, so the method is written down and can be checked.
  • Trading costs and holding costs are first-class parts of the model, so a strategy that only works when trading is free will show up as not working.
  • It replays a whole policy over time, not just one allocation, which is a more honest test than optimising once on all of the history.
Watch for
  • ⚠ It is a research library, not a product. You must express what you want as a convex program. There is nothing to click and no list of ready-made strategies to pick from.
  • ⚠ GPL-3.0, read from the licence file. Anything you build on it and then distribute must also be GPL-3.0, which rules out most closed commercial use. This is the opposite trap from Beancount's above, and in the same edition.
  • The newest release, 1.5.1, is dated 6 July 2025, about fifteen months old, while the code moved on 27 April 2026. Note also that the development branch commits its example results into the repository every day, so the project looks busier than its code actually is. No memory or processor figure is published, and both time and memory grow with the number of holdings.
Similar repositories
  • PyPortfolio/PyPortfolioOpt

    The same allocation job and much easier to pick up, with MIT instead of GPL-3.0, but it solves for one moment in time and has no built-in replay of a policy over history; renamed from robertmartin8/PyPortfolioOpt.

    Track this in Scout
  • skfolio/skfolio

    Covered in Edition 33. The same optimisation, also through CVXPY, but presented in the shape of scikit-learn, which makes it familiar if you already work that way; needs Python 3.10 or later.

    Track this in Scout
  • polakowo/vectorbt

    Covered in Edition 31. It tests thousands of rule combinations very fast, which is a different job: it is a tester, not an optimiser, and its Apache-2.0 plus Commons Clause is not open source.

    Track this in Scout
Install
pip install -U cvxportfolio
Screenshots
cvxgrp/cvxportfolio: GitHub preview card

Get the next edition in your inbox

A dozen repositories, opened and checked. The licence read, the last release dated, and the ones that did not make it named with the reason. It is the half most lists leave out.

No tracking pixels. One click to leave. The archive stays free either way.

We use your address to send the edition and nothing else. Confirm by email, leave in one click. How we handle it.