Skip to main content

GPU-accelerated quantitative research kernels. Kernel × quant.

Project description

kuant

GPU-accelerated quantitative research kernels. kernel × quant.

Vision

Standard quant libraries stop at technical indicators and portfolio math. kuant additionally exposes:

  • Sparse Identification of Nonlinear Dynamics (SINDy) — null-testing tools for feature discovery, distilled from real production research
  • Quantum-inspired regime discovery — HMM state machines, Bell- inequality-style aggregation tests, retrain-frequency (Zeno) scans
  • Topological Data Analysis (TDA) — persistent homology, Mapper algorithm (planned)

Combined with GPU-batched primitives (Black-Scholes, rolling statistics, implied-vol solvers), kuant is a research-grade toolkit for signal discovery — not just an implementation of textbook indicators.

Status

Alpha. 955 tests across 5 shipped subpackages:

Subpackage Kernels Highlights
kuant.core 16 BS pricing (bscall/bsput) + full Gaussian family (normcdf/normpdf/normppf + log-tails) + Student-t (tcdf/tpdf/tppf + log-tails) + Generalized Pareto (gpdcdf/gpdpdf/gpdppf) + logsumexp
kuant.options 21 First-order Greeks (delta/gamma/vega/rho/theta/charm) + second-order (vanna/volga/speed/zomma/color) + payoffs + chain filters + Newton and bisection implied-vol solvers
kuant.stats 19 Rolling primitives with strict-window NaN, plus Hurst (R/S) and rolling Hurst
kuant.qm 5 + hmm/ghmm subpackages HMM/GHMM inference (forward/backward/viterbi/posterior) + belltest, zenoscan, posteriorentropy, nocloningscan, decoherencescan
kuant.sindy 6 permtest, grangerscan, sindylasso, pinnscan, symbolicscan, accelerationscan

Each kernel has:

  • Full API doc under docs/kernels/
  • CPU fallback (numpy path — works on any machine)
  • GPU path (cupy — same math, verified for parity)
  • Cross-checked test suite (golden values, library reference, cross-kernel identities, machine-precision fd tolerances)

Install

# CPU-only
pip install kuant

# With GPU
pip install kuant[gpu]

# Some tools have optional heavy dependencies (scikit-learn for belltest,
# statsmodels for grangerscan). Install those separately when needed:
pip install scikit-learn statsmodels

Documentation

Start at docs/README.md.

Quick start

import numpy as np
from kuant.core import bsput, bsputdelta, normcdf
from kuant.stats import rollmean, rollstd, zscore, rollcorr
from kuant.options import impvol
from kuant.qm.hmm import forward, viterbi

# Vectorized Black-Scholes put pricing
strikes = np.linspace(80, 120, 41)
prices = bsput(S=100.0, K=strikes, T=1.0, r=0.05, sigma=0.20)

# Invert market prices to implied vol
sigma_iv = impvol(prices, S=100.0, K=strikes, T=1.0, r=0.05, is_call=False)

# Rolling z-score of returns
z = zscore(returns, window=252)

# HMM state decoding
states, log_prob = viterbi(observations, pi, A, B)

Repository layout

kuant/
├── core/         Mathematical primitives (BS family, normal CDF/PDF)
├── options/      Options analytics (impvol solver)
├── stats/        Rolling and windowed statistics (18 kernels)
├── qm/           Quantum-inspired tools (HMM, belltest, zenoscan)
├── sindy/        SINDy-adjacent null-testing tools (permtest, grangerscan)
├── portfolio/    P&L, drawdown, Sharpe (skeleton)
├── backtest/     Simulation engine (skeleton)
├── signals/      Signal computation (skeleton)
├── topology/     TDA (skeleton)
├── text/         Text parsing (skeleton)
├── data/         Bar aggregation (skeleton)
├── edgecases/    Edge case utilities (skeleton)
└── queueing/     Hardware throttle + coordination layer

docs/
├── kernels/      One doc per kernel (grouped by subpackage)
├── design/       Cross-cutting design docs
└── examples/     Worked examples

tests/            1:1 with kernel files; 887 tests total

Design principles

  1. CPU-first, GPU-second — every kernel has a numpy fallback so development works on any machine
  2. Batched by default — kernels operate on tensors, not scalars; single scalar case is a special call
  3. Explicit edge cases — NaN, zero denominators, empty arrays, past-expiry options all handled in-kernel; callers don't need defensive wrappers
  4. Composable primitives — each kernel does one thing; complex operations build up from atoms
  5. Reproducible — kernels don't touch global state; same inputs guarantee same outputs
  6. No underscores in the API surfacebsput, not bs_put; belltest, not bell_test. Improves typing flow

Contributing

Contribution guidelines coming as project matures.

License

Apache 2.0. See LICENSE.

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

kuant-0.1.0.tar.gz (81.8 kB view details)

Uploaded Source

Built Distribution

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

kuant-0.1.0-py3-none-any.whl (131.5 kB view details)

Uploaded Python 3

File details

Details for the file kuant-0.1.0.tar.gz.

File metadata

  • Download URL: kuant-0.1.0.tar.gz
  • Upload date:
  • Size: 81.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kuant-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a668c843f4a43cf4e298a8461876c75e661d7746da16d1ce5acae5ea1a9d1281
MD5 fb1e404a452c3dbfe15c90848cca78d4
BLAKE2b-256 7e0f9128a6a2079982c9c904872491b80cbcb9405aa976ae0b7b7acadc481065

See more details on using hashes here.

File details

Details for the file kuant-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: kuant-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 131.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for kuant-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 86851b757c9d415fe4d135738e9c77765fc81da6c7ee589c0f99bf68eca0ba04
MD5 2e66645fdf5da6c272bc6a0c609e676b
BLAKE2b-256 fc435baad293b553d62d7012ab1e5604d8bcaa6bd064b2b9d28631ac11d19ad9

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