Theory of Assets
Inspiration
Theory of Assets began with a question: can quantum-generated proposals help us find strong investment portfolios more efficiently than traditional algorithms?
Portfolio selection becomes complicated as the number of possible combinations grows. Choosing 10 assets from 50 produces:
$$ \binom{50}{10} = \frac{50!}{10!\,40!} = 10{,}272{,}278{,}170 $$
possible portfolios. Each combination has a different balance of expected return, risk, and relationships between assets.
We wanted to explore this financial problem through a controlled comparison between a classical baseline and a quantum-assisted approach. To keep that comparison honest, we chose problem sizes small enough to check every portfolio, so every run could be scored against the true best answer.
What it does
Theory of Assets compares classical Markov Chain Monte Carlo (MCMC) with quantum-enhanced MCMC (QeMCMC) on a real portfolio problem: which ETFs should we hold long and which should we short so the book carries the least risk?
Both methods use the same historical market data, objective, and constraints. The only difference is how they propose the next candidate:
- Classical MCMC: proposes a trade by swapping one long and one short, or several at once, using conventional computation.
- QeMCMC: runs a Qiskit circuit from the current book and measures a proposed new book, followed by a classical acceptance decision.
Both methods use the same Metropolis acceptance rule, so the comparison isolates the effect of the proposal.
We hold 12 ETFs at equal size, 6 long and 6 short: SPY, IWM, EFA, EEM, IEF, TLT, GLD, DBC, VNQ, TIP, LQD and HYG. We test across 64 quarterly market windows from 2010 to 2025. For each window we know the exact best book, so we can measure two things:
- Mixing speed: how fast the chain explores all the good books.
- Race to the best book: how many attempts it takes to reach the single best book.
We also ran a small version on a real IBM quantum computer.
How we built it
We built the project in Python with Qiskit, NumPy and pandas, as one package (qemcmc/) plus a folder of experiment scripts. Each piece does one job:
- Market data (
data.py). Downloads adjusted daily closes from Yahoo Finance for a fixed basket of 20 ETFs (stocks, bonds, gold, commodities, real estate, sectors) from December 2008 to December 2025, and caches them locally. It cleans gaps (at most 2 missing days forward-filled) and computes daily returns. For each of 64 quarter ends (2010Q1–2025Q4) it estimates the annualised mean returns \(\mu\) and covariance \(\Sigma\) from the previous 252 trading days. Each window is one test problem. - Portfolio numbering (
states.py). Gives every valid book three equivalent labels: a rank (row in our tables), a list of held assets, and an integer whose bits match Qiskit's measurement keys (qubit \(i\) is asset \(i\)). This removes bit-order bugs between the circuit and the classical code, and it lists the swap neighbours of every book. - Exact answer key (
objective.py,longshort.py). Scores all books in every window, so we always know the true best book. It also rewrites the risk as single-asset terms \(h_i\) and pair terms \(J_{ij}\) for the circuit's phase, and tests confirm the two agree up to a constant. - Landscape check (
landscape.py). Counts local optima (books no single swap can improve) and measures how often greedy descent from a random start reaches the true best. We ran this before any quantum work to make sure the problem was worth searching. - Quantum proposal circuit (
circuits.py). Builds the palindromic circuit in Qiskit fromXXPlusYYGatemixers and RZ / RZZ phase gates. There are two mixer layouts (ring and complete) and four phase options (none, single-asset terms only, ring pairs, all pairs). To propose a move, we load the current book with X gates, run the circuit, and measure. - Fast simulator (
subspace.py). A full statevector run tracks all \(2^{11}\) bit strings. Because the circuit never changes the number of longs, we simulate only the 462 valid books. This builds the whole proposal table \(Q\) (every start × every outcome) in one matrix product. On a 4,368-book problem that takes about 1 second instead of about 350 seconds by full statevector, and it matches Qiskit statevector results to \(10^{-10}\). - Classical baselines. Single swap, multi-swap (jumps of up to \(m\) swaps), locally balanced informed swaps, and parallel tempering with 4 temperatures. All are built as exact transition matrices over the same 462 books.
- Exact diagnostics. For every method and window we form the full Metropolis transition matrix and compute its spectral gap exactly. We also run simulated races from matched random starts, logging attempts and score evaluations as separate fields.
- Experiments (
experiments/longshort/). One script per question:mixer_test.pycompares mixer layouts.phase_control.pyturns the score phase off.fair_tuning.pypicks one setting per method on even windows and tests on odd ones.race.pycounts attempts to reach the best book.compile_depth.pytranspiles each circuit to IBM device layouts and counts gates.
- Hardware pipeline (
hardware.py). Runs a dry run on the noisy FakeFez simulator, a 3-start pilot, then the full job onibm_marrakesh. The full job sent all 35 starting books × 1,024 shots in one SamplerV2 job with dynamical decoupling. It saves raw counts, job IDs and QPU time, rebuilds the measured proposal table, and compares it with the ideal one. - Tests (
tests/). About 60 offline tests on synthetic data, with no network. They check the numbering, that the circuit never changes the long count, that the proposals are symmetric (and that a non-mirrored circuit is not), that the fast simulator matches Qiskit, and that the hardware analysis works.
We tracked our tasks and findings with the beads issue tracker and wrote down each experiment's rules before running it, so tuning could not drift toward the result we wanted.
Our research covered quantum machine learning, market-volatility forecasting, QUBO, QAOA, and QeMCMC. We chose portfolio selection because it offered a concrete financial objective and a clear classical-versus-quantum experiment.
A key step was understanding that QUBO describes the problem, while QAOA and QeMCMC are different approaches for exploring solutions. Our implementation focuses on QeMCMC, while QAOA informed our research.
The mathematics behind our design
Version 1: long-only selection. We first represented each asset with a binary variable, where \(x_i=1\) means selected and \(x_i=0\) means excluded. To select exactly \(k\) assets and assign equal weights to the selected assets, we use:
$$ x_i \in {0,1}, \qquad \sum_{i=1}^{n}x_i=k, \qquad w_i=\frac{x_i}{k} $$
Our original QUBO objective was:
$$E(x) = \lambda \frac{x^{\top}\Sigma x}{k^2} - \frac{\mu^{\top}x}{k} + \rho \left(\sum_{i=1}^{n} x_i - k\right)^2$$
Here, \(\mu\) contains historical estimates of expected returns, \(\Sigma\) is the return covariance matrix, and \(\lambda\) controls the emphasis on risk. The penalty strength \(\rho\) discourages selecting the wrong number of assets. Lower objective values are preferred. In the end we did not need the penalty, because our circuit only ever produces portfolios with exactly \(k\) assets.
Version 2: market-neutral long–short book. Every asset is held at equal size, either long or short, with exactly half on each side:
$$ s_i \in {+1,-1}, \qquad \sum_{i=1}^{n}s_i=0, \qquad w_i=\frac{s_i}{n} $$
We minimise the book's variance, using only risk:
$$E(s) = \frac{s^{\top}\Sigma s}{n^2}$$
Assets that move together want to be on opposite sides, but with three mutually correlated assets that cannot hold for every pair. This conflict, called frustration, creates many competing near-best books. Under a one-factor market model the risk is approximately:
$$ E(s) \approx \frac{\sigma_m^2}{n^2}\left(\sum_{\text{long}}\beta_i - \sum_{\text{short}}\beta_i\right)^2 + \text{idiosyncratic terms} $$
Minimising it is close to balanced number partitioning of the assets' market betas \(\beta_i\), a classic hard problem. Flipping every sign gives the same risk, so we fix SPY long. The state is then which 5 of the other 11 ETFs are also long. That is an 11-qubit bit string with exactly five 1s:
$$ \binom{11}{5} = 462 \text{ valid books} $$
The quantum proposal. The circuit is a mixer, then a score phase, then the same mixer in reverse:
$$ U = M(\beta)^{\text{rev}}\; P(\gamma)\; M(\beta), \qquad Q(s \rightarrow s') = \left|\langle s' | U | s \rangle\right|^2 $$
The mixer \(M(\beta)\) applies XY gates (XXPlusYYGate) that trade a long for a short, so every measurement is a valid 6 / 6 book. Our best version uses a complete mixer, with XY gates between all 55 pairs of qubits. The phase \(P(\gamma)\) stamps each candidate with its score, \(e^{-i\gamma E(s)}\), using RZ and RZZ gates, with \(\gamma = g/\mathrm{std}(E)\). Because the circuit is a palindrome, \(Q(s \rightarrow s') = Q(s' \rightarrow s)\). We verified this symmetry in tests, which lets us use the simple acceptance rule below.
For symmetric proposals, the Metropolis–Hastings algorithm reduces to the following classical Metropolis acceptance step:
$$P_{\mathrm{accept}}(x \rightarrow x') = \min\left(1, \exp\left(-\frac{E(x') - E(x)}{T}\right)\right), \quad T > 0$$
Here, \(x\) is the current portfolio, \(x'\) is the proposed portfolio, and \(T\) is the algorithmic temperature. We set \(T = 0.1 \times \mathrm{std}(E)\). This accepts improvements and sometimes accepts worse candidates, allowing the chain to explore beyond immediately improving moves.
In QeMCMC, the quantum circuit proposes a candidate portfolio, and the classical Metropolis step decides whether it becomes the next state. If rejected, the chain keeps its current portfolio and proposes again from that state.
Measuring mixing speed. Because the problem is small enough to enumerate, we compute each chain's transition matrix \(P\) exactly and report its spectral gap:
$$1 - \lvert \lambda_2(P) \rvert, \quad \mathrm{gap\ ratio} = \frac{\mathrm{gap}(\mathrm{method})}{\mathrm{gap}(\mathrm{single\ swap})}$$
A larger gap means the chain forgets its starting point faster. A gap ratio above 1 means the method mixes faster than plain single-swap MCMC.
Research that guided us
Our study guide helped us work through four papers:
- Egger et al., Quantum Computing for Finance: State of the Art and Future Prospects — provided context for quantum applications in financial simulation, optimization, and machine learning.
- Giovagnoli, An Introduction to the Quantum Approximate Optimization Algorithm — helped us understand QUBO formulations, penalty terms, cost Hamiltonians, and quantum circuits.
- Marshall et al., Quantum-enhanced Markov Chain Monte Carlo for Combinatorial Optimization — motivated our focus on quantum-generated proposals within a classical search process. Its experiments concern Maximum Independent Set; applying the idea to portfolios is our project direction.
- Hellstern, Schacht, and Zaefferer, Comparing Classical and Quantum QUBO Solvers: Optimality, Trajectory Diagnostics, and Limits of Solver Selection — informed our emphasis on comparing solution quality, optimality, and computational cost separately.
As we tested, several more sources shaped our pivots:
- Layden et al., Quantum-enhanced Markov chain Monte Carlo (Nature, 2023) — the original QeMCMC mechanism and the palindromic circuit idea.
- Galluccio, Bouchaud, and Potters, Rational decisions, random matrices and spin glasses (1998) — showed that long/short portfolios behave like spin glasses, which pointed us to the long–short book.
- Plerou et al., Random matrix approach to cross correlations in financial data (2002) — explained the market mode that made our first problem easy.
- Zanella, Informed proposals for local MCMC in discrete spaces (2019) — the locally balanced proposal we used as the strongest classical baseline.
Challenges we ran into
We compared quantum machine learning, market-volatility forecasting, and quantum-assisted portfolio search before narrowing our scope to asset selection.
Our biggest challenge came after we started building was find proper use cases for QeMCMC. We counted local optima for every market window. With "pick 5 of 16 ETFs", all 64 windows had exactly one optimum, and simple greedy descent found it from every start. The quantum proposal mixed at only 0.48–0.80× the speed of single swaps. We traced the cause to the market factor: most ETFs move together, so the single-asset terms were about 13× larger than the pair terms, and one portfolio always wins.
Our trial and error before finding a hard problem:
| What we tried | Hard (many optima)? | Quantum vs single swap |
|---|---|---|
| Long-only mean–variance, ETFs | No, 1 optimum in every window | 0.48–0.80× |
| Same with 16 large stocks, other window lengths, shrunk returns | No (at most 5 optima) | — |
| Bayesian factor selection for SPY returns | No (> 1 optimum in 3–11% of windows) | 0.12–0.25× |
| Multi-factor hedge book (16 instruments) | No (> 1 optimum in 18%, max 3) | 0.43× |
| Real risk with the market factor removed, then random correlations | Only at the synthetic end | 1.10× (multi-swap 1.19×) |
| Market-neutral long–short book | Yes, in 100% of ETF windows | up to 2.67× |
The hedge book taught us that strong hedges are not enough. Real hedges come in independent pairs, so their benefits add up and one book wins. A hard landscape needs hedges that conflict. The long–short book creates exactly that.
Even then, our first long–short circuit used a ring mixer, which only lets neighbouring assets trade. It beat single swaps but lost to a tuned multi-swap baseline in every ETF window, because it jumped farther without jumping smarter. Switching to a complete mixer changed that result.
Another challenge was keeping the comparison fair. The quantum side was originally tuned over 12 settings per window and multi-swap over only 4. We redid the test with one fixed setting per method, chosen on half the windows and tested on the other half.
The last challenge was hardware. The winning circuit needs about 550 two-qubit gates on 11 qubits, far too many for today's noisy devices.
Accomplishments that we're proud of
We found a real-data portfolio problem that is genuinely hard. On the 6 long / 6 short ETF book, every window has several local optima (median 5.5, up to 10), and greedy search finds the best book only about a third of the time. At 8 long / 8 short the median rises to 13 optima.
Our quantum proposal mixes faster than the strongest blind classical method. With one fixed setting per method, tested on held-out windows:
| Method | ETFs gap ratio | Beats multi-swap | Stocks gap ratio | Beats multi-swap |
|---|---|---|---|---|
| Quantum, complete mixer + score phase | 2.67 | 81% | 1.93 | 91% |
| Multi-swap (tuned) | 2.22 | — | 1.21 | — |
| Quantum, hardware-cheap ring circuit | 1.42 | 3% | 0.55 | 3% |
| Locally balanced (30 score evaluations per step) | 3.42 | 91% | 6.01 | 97% |
We showed where the gain comes from. With the score phase turned off, the same circuit falls to 1.84 on ETFs and never beats multi-swap. Turning the phase on improves it in 100% of ETF windows. The advantage comes from the score information in the circuit, not from jumping farther.
We ran it on a real IBM quantum computer. On ibm_marrakesh we ran a 4 long / 4 short version on 8 ETFs (7 qubits, 35 books) with a hardware-friendly circuit of 86 two-qubit gates. All 35 starting books × 1,024 shots ran in one job using 12 QPU-seconds. The chain stayed nearly unbiased: it put 0.208 probability on the best book, against a target of 0.231.
We reported our negative results honestly. We decided before coding that a classical win would count as a real result, and we kept to that.
What we learned
We learned that the financial model and the search algorithm serve different roles. A solver searches the objective we provide; it does not establish that our risk estimates are accurate or that the selected book will perform well in the future.
We learned that the problem matters more than the algorithm. No proposal can help on a landscape with one peak, so checking the landscape first saved us from benchmarking on a problem where any method wins.
We also learned that finding a good solution, sampling accurately, and demonstrating computational advantage are different achievements, each needing its own evidence. Our results split cleanly along that line. In a race to the single best book, plain single swaps win:
| Median attempts to reach the best book | ETFs 6 / 6 | Stocks 6 / 6 | ETFs 8 / 8 | Stocks 8 / 8 |
|---|---|---|---|---|
| Single swap | 179 | 100 | 1,093 | 452 |
| Quantum, complete mixer | 184 | 125 | 1,264 | 890 |
| Parallel tempering | 199 | 139 | 1,405 | 887 |
| Multi-swap | 215 | 188 | 2,175 | 1,214 |
At low temperature, single swaps behave like a downhill search and arrive at the top quickly. Long jumps help a chain move between peaks, which is what mixing measures, but near the top they are usually rejected. So our claim is a sampling claim: the quantum proposal explores the many near-best books faster, which helps find robust positions and genuinely different alternatives. It does not find the single best book faster.
Finally, we learned that hardware noise matters. Only 43% of shots on the device came back with exactly 4 longs (the noisy simulator predicted 77%), and the hardware chain's spectral gap (0.043) was below single swap (0.061). Today's noise erases the gain.
What's next for Theory of Assets
- Error mitigation on hardware. About 586 QPU-seconds remain. We will rerun the 35-start table with gate twirling and readout mitigation to see how much mixing speed returns.
- Shallower circuits that keep the gain. We will try complete mixing on only the most strongly coupled pairs, better ring orderings, and multi-qubit long/short mixers.
- Tune for the race, not just mixing. We will choose \(\beta\), \(g\), and \(T\) by attempts to the best book, and try annealed temperatures.
- Larger books. We will repeat the 8 long / 8 short mixing test (15 qubits, 6,435 books) on all 64 windows.
- A real use case for sampling. We will set \(T\) from estimation noise and show which ETFs stay long or short across many near-best books, so a portfolio manager can see which positions are robust.
- Cost accounting. We will report shots and wall-clock time alongside attempts and score evaluations.
Our goal is still to determine when quantum-generated proposals help portfolio search, and to understand the cases where classical methods remain competitive. We now have a concrete answer for one hard, real problem. In simulation the quantum proposal samples faster, plain swaps find the best book faster, and hardware noise currently erases the gain.
Built With
- python
- qiskit