Using Python to Program Portfolio Optimization on Quantum Computers

Multiverse Computing
3 min readJul 14, 2023

Multiverse Computing’s Singularity allows Python programmers to optimize portfolios with quantum annealers

In quantitative finance, static portfolio optimization is the challenge of selecting the best distribution of assets when an account is first opened to maximize expected returns while minimizing financial risk. Quantitative analysts are responsible for solving this problem at banks, insurance companies, hedge funds, and other financial institutions. This initial selection doesn’t change over the course of the investment period, so this first selection process has to be correct.

We are adding a new feature to Singularity, powered by the foundational engine Singularity Optimization, to make it easier for “quants” to build the best-performing portfolios. The Portfolio Optimization Python Package v0.5 brings this popular programming language to our quantum software platform.

The package is pip-installable, straightforward, and customizable. When analysts input forecasted returns, covariances, investment bands, and custom constraints, Singularity returns optimal holdings as well as key performance indicators for the constructed portfolio, including expected return, volatility, and the Sharpe ratio.

This new package opens a whole new user group for Singularity, given the ongoing popularity of Python. The language has attracted a significant user base over the last several years due to the increase in data science work and artificial intelligence. Python was the top language in June 2023 in the TIOBE Programming Index, and won the annual award three times in the last five years. The ranking tracks the rise and fall of programming languages based on how many software engineers are actively using a particular language to write code at any given time.

The Python package for Singularity provides an easy method for programmers to perform portfolio optimization without needing to know the technical details of how a quantum computer works. If you’re new to Singularity, our previous post on how to optimize a portfolio with Excel is a good starting point for learning about the platform.

Singularity Portfolio Optimization

Modern portfolio theory models the risk of an asset based on its volatility. The risk in each individual asset will have some level of correlation to every other asset in the portfolio. The goal of portfolio optimization is to produce a set of asset holdings that give high expected returns and diversify the risk by distributing the holdings across assets with low correlation. The balance between low risk and high reward is tuned according to the investor’s risk tolerance.

In practice, finding a portfolio that maximizes return for a given level of risk based on all possible configurations is challenging for classical computers, especially as more constraints are added. Quantum computers are well-suited to solving optimization problems, and Singularity’s Portfolio Optimization app enables finance professionals to use quantum systems to optimize portfolios via a simple interface.

For the set of financial assets under consideration, the user inputs the expected returns, volatility, correlations, and additional optional settings and the app takes it from there. Singularity transforms the problem into a form digestible by a quantum annealer, and runs it on a quantum computer accessible through a cloud service. The result of the optimization gives an optimal array of holdings that maximizes the return for a set target risk.

In our next post, we’ll share a tutorial about how to use Python with Singularity’s Optimization engine.

--

--

Multiverse Computing

Multiverse uses quantum and quantum-inspired software to tackle complex problems in finance, energy and manufacturing to deliver value today.