Skip to main content

Quantum-inspired quantitative finance workflows and algorithms

Project description

Double Quant logo

Quantum Quantitative


Python Version GitHub License

Double Quant

Double Quant is a Python library for quantitative finance workflows built around quantum-inspired and quantum-backed algorithms.

Overview

Double Quant bridges quantum computing and quantitative finance with reusable data transforms, HHL-based solvers, Shapley-value algorithms, and higher-level portfolio and risk applications.

Key Features

  • Quantum-aware algorithms for linear solving and Shapley attribution
  • Layered package design across data, common utilities, algorithms, and applications
  • Full type hints for stronger IDE support and safer integrations
  • Portfolio and risk workflows built on top of reusable primitives
  • Experiment-friendly components that can be composed outside the core package

Architecture

Double Quant is organized as a four-part package:

double_quant.data
double_quant.common
double_quant.algorithm
double_quant.application

Layer Responsibilities

  • Data layer (double_quant.data): price sources and transforms from prices to returns, covariances, and expected returns
  • Common layer (double_quant.common): shared models and metrics such as LinearSystem and risk helpers
  • Algorithm layer (double_quant.algorithm): HHL solver variants plus classical and quantum Shapley calculators
  • Application layer (double_quant.application): higher-level workflows such as portfolio optimization and risk attribution

Installation

  • Python 3.11 or higher

Install from PyPI with uv

uv add double-quant

Install with pip

pip install double-quant

Install from source for development

git clone https://github.com/11D-Beyonder/double-quant.git
cd double-quant
uv sync

Quick Start

Example: Solving a Linear System

import numpy as np

from double_quant import HHLSolver

A = np.array([[2.0, 1.0], [1.0, 2.0]])
b = np.array([1.0, 1.0])

solution = HHLSolver.solve(A, b)
print(solution)

Example: Classical Risk Attribution

import pandas as pd

from double_quant import BinaryEnumerationCalculator, RiskAttributor

returns = pd.DataFrame(
    {
        "AAPL": [0.01, -0.03, 0.02, 0.015],
        "MSFT": [0.008, -0.01, 0.018, 0.012],
        "TLT": [0.002, 0.001, -0.002, 0.003],
    }
)

src = RiskAttributor(
    returns,
    BinaryEnumerationCalculator,
    alpha=0.95,
    mode="es",
).attribute()

print(src)

Core Components

HHL Solver

HHLSolver is the main entry point for solving Hermitian linear systems with the project's HHL-based workflow.

Shapley Calculators

Double Quant includes exact, Monte Carlo, and quantum Shapley-value calculators for attribution problems.

Risk Attribution

RiskAttributor supports both direct expected-shortfall attribution (mode="es") and the quantum-compatible risk-saving formulation (mode="rs").

Documentation

Project documentation lives in the docs/ directory, including:

Development

Running Tests

uv run pytest

Building the Package

uv build

Code Style

This project uses ruff for linting and basedpyright for type checking.

Contributing

We welcome contributions. If you would like to contribute:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat(scope): add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Commit Message Format

We follow the Angular commit message convention:

<type>(<scope>): <description>

[optional body]

[optional footer]

Types: feat, fix, docs, style, refactor, test, chore

License

This project is licensed under the GPLv3. See LICENSE for details.

Acknowledgments

This project draws inspiration from:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

double_quant-0.0.1a3.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

double_quant-0.0.1a3-py3-none-any.whl (49.7 kB view details)

Uploaded Python 3

File details

Details for the file double_quant-0.0.1a3.tar.gz.

File metadata

  • Download URL: double_quant-0.0.1a3.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for double_quant-0.0.1a3.tar.gz
Algorithm Hash digest
SHA256 8e07982e904ae5cc4af44cd7c2149d941622f3b5f1155015f13588c6d7590398
MD5 de79907c6649bd3f301574e27aa73541
BLAKE2b-256 6ec73bea096cf8da7ff7f7d8e3e6e71f1c53f87c5d041d8ff443b0b242116bfe

See more details on using hashes here.

File details

Details for the file double_quant-0.0.1a3-py3-none-any.whl.

File metadata

  • Download URL: double_quant-0.0.1a3-py3-none-any.whl
  • Upload date:
  • Size: 49.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for double_quant-0.0.1a3-py3-none-any.whl
Algorithm Hash digest
SHA256 aca428d03ef7ed0e09ca11088b06514f0411df9bacec41d5b2d98607dfc54050
MD5 98e90801b0bd7a27b578d6801fddc6d0
BLAKE2b-256 5a47ec989923f71c421418fc163b60e4bc72f66714cd2c24f5227d6797e74b57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page