Portfolio Optimization via VQE
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, Filtering VQE (F-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.
Filtering VQE implements normalized
parameter-shift updates toward freshly filtered states. It supports inverse and
exponential filters, adaptive or fixed strength, and analytic or finite-shot
training through run_fvqe and FVQEConfig, or the f-vqe CLI command.
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, parallel tempering, 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 and Frank–Wolfe with away steps supply iterative classical comparators for the separate long-only fractional allocation track, alongside optional OSQP.
Repository structure
src/vqe_portfolio/
├── binary.py, fvqe.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.
Version 0.3.6 adds Filtering VQE and NumPy-only Frank–Wolfe with away steps, including comparison, validation, and execution-budget integration. The roadmap lists further algorithms and implementation requirements.
Version 0.3.7 adds NumPy-only parallel tempering for exact-K binary selection, with comparison, validation, execution budgets, and acceptance/work diagnostics.
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:
- Small-instance validation
- Allocator correction validation
- Before/after training
- Sampling allowances
- Training effort
- Failure diagnostics
- Solver reliability controls
- Fixed-deadline simulator pilot
- Fresh-instance deadline comparison
Author and support
Sid Richards · LinkedIn · Sponsor development
MIT License — see LICENSE.
Metadata
Release files for vqe-portfolio 0.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| vqe_portfolio-0.3.7.tar.gz | 132.9 kB | With provenance | Details for vqe_portfolio-0.3.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| vqe_portfolio-0.3.7-py3-none-any.whl | Python 3 | none | any | Details for vqe_portfolio-0.3.7-py3-none-any.whl |
Total release size: 229.1 kB
Release files / vqe_portfolio-0.3.7.tar.gz
| Download URL | vqe_portfolio-0.3.7.tar.gz |
|---|---|
| Size | 132.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
308667ca20bc55bbaf28e56ed5cd48dc33a03fc9c54170be2e4075357a0a75ec
|
|
BLAKE2b-256 checksum How to use checksums |
057bd84e87fc8156c8a016308a3841a7606346b0e2a709d455b8224e77ee8de3
|
| 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 logRelease files / vqe_portfolio-0.3.7-py3-none-any.whl
| Download URL | vqe_portfolio-0.3.7-py3-none-any.whl |
|---|---|
| Size | 96.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
508f6cc696e0d286f149a262d4a91808e72eb3f7dc7a8dd56b79fabe853fce25
|
|
BLAKE2b-256 checksum How to use checksums |
c73d8b6f9312e60118e7484caba28686ef7fb87b13e9eed176c712fc6d753765
|
| 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 logSecurity for vqe-portfolio 0.3.7
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.
Attestation for vqe_portfolio-0.3.7.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 logA 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.