Skip to main content

Portfolio Optimization via VQE

PyPI Version Python Versions Tests License Sponsor

PyPI: https://pypi.org/project/vqe-portfolio/

Website: https://sidrichardsquantum.github.io/VQE_Portfolio_Optimization/

A Python library for portfolio optimization with PennyLane. It provides Binary VQE and QAOA for selecting a fixed number of assets, and a variational quantum allocator for long-only allocation. Classical baselines and independent candidate evaluation support reproducible comparisons.

The allocator was historically called "Fractional VQE". It parameterises weights with a quantum circuit and evaluates the portfolio cost classically; it is not Hamiltonian-expectation VQE. Use run_variational_allocator and VariationalAllocatorConfig; the old Python and CLI names remain aliases.

The experiments use quantum simulation and do not establish quantum advantage or production readiness.

Binary VQE and QAOA support optional CVaR training with training_objective="cvar", cvar_alpha=0.25. This emphasizes the lowest-cost portion of circuit outcomes; mean-cost training remains the default.

Installation

pip install vqe-portfolio

Requires Python 3.10+ and PennyLane 0.42.3+. CI tests the minimum core dependencies and current compatible dependencies on Python 3.10–3.12.

Optional dependencies:

pip install "vqe-portfolio[data]"       # Market data utilities
pip install "vqe-portfolio[classical]"  # HiGHS, OSQP, and SCIP baselines
pip install "vqe-portfolio[scip]"       # SCIP only
pip install -e ".[dev,docs]"           # Development and documentation

Quickstart

Run a small synthetic asset-selection problem:

import numpy as np
from vqe_portfolio import BinaryVQEConfig, run_binary_vqe

mu = np.array([0.10, 0.12, 0.07, 0.09])
sigma = np.eye(4) * 0.02
config = BinaryVQEConfig(k=2, lam=4.0, alpha=2.0, steps=25, seed=0)
result = run_binary_vqe(mu, sigma, config)
print(result.x_topk)

The command-line interface supports the same solvers:

vqe-portfolio --help
python -m vqe_portfolio --help

See the usage guide for complete API and CLI examples, ansatz options, real-data workflows, and efficient frontiers.

Classical exact-K comparators include NumPy-only multistart swap search, simulated annealing, tabu search, memetic genetic search, iterated local search (ILS), GRASP, and variable neighbourhood search (VNS), plus optional QP relaxation with rounding and swap refinement, HiGHS linearised integer and SCIP quadratic integer optimisation. All support end-to-end execution budgets; see classical baselines.

NumPy projected gradient descent supplies an iterative classical comparator for the separate long-only fractional allocation track, alongside optional OSQP.

Repository structure

src/vqe_portfolio/
├── binary.py, qaoa.py, fractional.py   # Quantum solvers
├── problem.py, types.py               # Problem evaluation and solver types
├── ansatz.py, optimize.py             # Shared circuit and optimizer code
├── baselines/                        # Classical references and optional solvers
├── benchmark.py                      # Independent candidate evaluation/reporting
├── research/                         # Study logic and shared runner infrastructure
└── ...                               # CLI, data, plotting, frontier utilities
scripts/                              # Experiment entry points and report generation
experiments/                          # Study configuration and reproduction guide
results/                              # Saved research evidence
notebooks/                            # Tutorial and comparison clients
tests/                               # Solver, research, CLI, compatibility tests
docs/                                 # Sphinx documentation

See architecture and development for module boundaries and the v0.3.0 migration notes. Existing public imports remain supported. Version 0.3.1 adds opt-in solver reliability controls and end-to-end execution budgets; see the usage guide and changelog.

Version 0.3.3 adds simulated annealing, tabu search, and SCIP to the classical comparisons, small-instance validation, and budget CLI. Version 0.3.4 adds memetic genetic search, ILS, GRASP, QP rounding, VNS, and projected gradient descent; fixes selection and allocator boundaries; and introduces the canonical allocator names and individual algorithm guides. Archived research results retain their original methods and provenance.

Version 0.3.5 adds optional CVaR training for Binary VQE and QAOA, with analytic Adam or finite-shot SPSA optimization and objective metadata in solver results.

Documentation and research

Guide Contents
Usage Installation, API, CLI, benchmarks, and reproduction commands
Theory Portfolio formulations, circuit mappings, and derivations
Algorithms Concise descriptions of quantum and classical methods
Results Committed benchmark and diagnostic findings
Research protocol Evaluation design and limits on advantage claims
Experiments Validation, training, sampling, and failure diagnostics

Start with notebooks/Binary.ipynb, notebooks/QAOA.ipynb, or notebooks/Fractional.ipynb. Real-data examples are in notebooks/examples/.

Saved study reports:

Author and support

Sid Richards · LinkedIn · Sponsor development

MIT License — see LICENSE.

Metadata

Release files for vqe-portfolio 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for vqe-portfolio 0.3.5
File Size Uploaded Provenance Actions
vqe_portfolio-0.3.5.tar.gz 114.8 kB With provenance Details for vqe_portfolio-0.3.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for vqe-portfolio 0.3.5
File Interpreter ABI Platform Actions
vqe_portfolio-0.3.5-py3-none-any.whl Python 3 none any Details for vqe_portfolio-0.3.5-py3-none-any.whl

Total release size: 201.8 kB

Release files / vqe_portfolio-0.3.5.tar.gz

Download URL vqe_portfolio-0.3.5.tar.gz
Size 114.8 kB
Tags Source
SHA-256 checksum
How to use checksums
7f40b6575db9da2c0c6e3404a359be82e8171d22bc3851f4d64d50d9cdeffca0
BLAKE2b-256 checksum
How to use checksums
98817725137259a89d0b71d84efce75f8abb9a1e0f6edef328d10ef7c6cd3510
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Release files / vqe_portfolio-0.3.5-py3-none-any.whl

Download URL vqe_portfolio-0.3.5-py3-none-any.whl
Size 87.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
12aa1642e17fc1d8d9a3a3642d7ce7b9cddb11912af40d026a1056f3892234d1
BLAKE2b-256 checksum
How to use checksums
6d043b9f7f5910401b70e88520f1d9e2bf1b5d886fc1d5d1efb4f20fc9717c76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

Security for vqe-portfolio 0.3.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for vqe_portfolio-0.3.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 6, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page