High-performance derivative pricing engine with 40+ algorithms
Project description
QuantKernel
QuantKernel is a C++17 quantitative pricing kernel with Python bindings. It focuses on fast scalar and batch option analytics across closed-form, lattice, finite-difference, Monte Carlo, Fourier, quadrature, regression-approximation, Greek-estimation, and ML-inspired methods.
Linux, macOS, and Windows are supported.
Scope
QuantKernel provides:
- C++ shared library (
libquantkernel.so/libquantkernel.dylib/libquantkernel.dll) with C ABI exports. - Python package (
quantkernel) with scalar and batch methods. - Optional Python-level accelerator (
QuantAccelerator) for backend selection (auto,cpu,gpu).
Install (Not available yet, more test needed)
End users (recommended):
python -m pip install --upgrade pip
python -m pip install quant-kernel
This installs a prebuilt wheel on supported platforms and does not require local C++ compilation.
Implemented Algorithm Families
Closed-form / Semi-analytical
- Black-Scholes-Merton
- Black-76
- Bachelier
- Heston characteristic-function pricing
- Merton jump-diffusion
- Variance-Gamma characteristic-function pricing
- SABR (Hagan lognormal IV + Black-76 pricing)
- Dupire local volatility inversion
Tree / Lattice
- CRR
- Jarrow-Rudd
- Tian
- Leisen-Reimer
- Trinomial tree
- Derman-Kani style local-vol tree entrypoints:
- Constant local vol surface (
derman_kani_const_local_vol_price) - Vanilla call-surface driven entrypoint (
derman_kani_call_surface_price)
- Constant local vol surface (
Finite Difference
- Explicit FD
- Implicit FD
- Crank-Nicolson
- ADI (Douglas, Craig-Sneyd, Hundsdorfer-Verwer)
- PSOR
Monte Carlo
- Standard Monte Carlo
- Euler-Maruyama
- Milstein
- Longstaff-Schwartz
- Quasi Monte Carlo (Sobol, Halton)
- Multilevel Monte Carlo
- Importance Sampling
- Control Variates
- Antithetic Variates
- Stratified Sampling
Fourier Transform Methods
- Carr-Madan FFT
- COS (Fang-Oosterlee)
- Fractional FFT
- Lewis Fourier inversion
- Hilbert transform pricing
Integral Quadrature
- Gauss-Hermite
- Gauss-Laguerre
- Gauss-Legendre
- Adaptive quadrature
Regression Approximation
- Polynomial Chaos Expansion
- Radial Basis Functions
- Sparse Grid Collocation
- Proper Orthogonal Decomposition
Greeks / Adjoint Methods
- Pathwise derivative delta
- Likelihood ratio delta
- AAD delta
Machine-learning Inspired Pricing
- Deep BSDE
- PINNs
- Deep Hedging
- Neural SDE calibration
Repository Layout
cpp/include/quantkernel/qk_api.h: C API declarationssrc/: implementations and API bridge (qk_api.cpp)tests/: C++ test executables
python/quantkernel/: Python API (QuantKernel,QuantAccelerator)tests/: pytest suiteexamples/: usage and benchmark scripts
Makefile: common build/test commands
Requirements
- CMake >= 3.14
- C++17 compiler
- Python >= 3.11
- NumPy
Optional:
- CuPy (for GPU backend in accelerator paths)
Build
From project root:
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
cmake -S . -B build
cmake --build build -j
Python Setup (from source checkout)
Point Python to the package and shared library:
export PYTHONPATH=$PWD/python
export QK_LIB_PATH=$PWD/build/cpp
Then use:
from quantkernel import QuantKernel, QK_CALL
qk = QuantKernel()
price = qk.black_scholes_merton_price(
100.0, 100.0, 1.0, 0.2, 0.03, 0.01, QK_CALL
)
print(price)
Batch Usage
import numpy as np
from quantkernel import QuantKernel, QK_CALL, QK_PUT
qk = QuantKernel()
n = 100_000
rng = np.random.default_rng(42)
spot = rng.uniform(80.0, 120.0, n)
strike = rng.uniform(80.0, 120.0, n)
t = rng.uniform(0.25, 2.0, n)
vol = rng.uniform(0.1, 0.6, n)
r = rng.uniform(0.0, 0.08, n)
q = rng.uniform(0.0, 0.04, n)
option_type = np.where((np.arange(n) & 1) == 0, QK_CALL, QK_PUT).astype(np.int32)
prices = qk.black_scholes_merton_price_batch(spot, strike, t, vol, r, q, option_type)
print(prices[:3])
Derman-Kani Call-Surface API (Python)
derman_kani_call_surface_price accepts:
surface_strikes: 1D strikessurface_maturities: 1D maturitiessurface_call_prices:- 2D array with shape
(len(surface_maturities), len(surface_strikes)), or - flattened 1D array of that size
- 2D array with shape
Example:
from quantkernel import QuantKernel, QK_CALL
qk = QuantKernel()
spot, r, q = 100.0, 0.03, 0.01
surface_strikes = [80, 90, 100, 110, 120]
surface_maturities = [0.5, 1.0, 1.5]
# Synthetic surface here; in production use observed call prices.
surface_call_prices = [
[qk.black_scholes_merton_price(spot, k, tau, 0.2, r, q, QK_CALL) for k in surface_strikes]
for tau in surface_maturities
]
price = qk.derman_kani_call_surface_price(
spot=spot,
strike=100.0,
t=1.0,
r=r,
q=q,
option_type=QK_CALL,
surface_strikes=surface_strikes,
surface_maturities=surface_maturities,
surface_call_prices=surface_call_prices,
steps=20,
)
print(price)
If QK_LIB_PATH is unset, the package also searches for a bundled shared library from an installed wheel.
Testing
From project root:
make test-cpp
make test-py
# or
make quick
Direct commands:
ctest --test-dir build --output-on-failure
PYTHONPATH=python QK_LIB_PATH=build/cpp pytest -q python/tests
Benchmark
PYTHONPATH=python QK_LIB_PATH=build/cpp \
python3 python/examples/benchmark_scalar_batch_cpp.py --n 50000 --repeats 3
Error Handling
C API
- Batch functions return ABI error codes (
QK_OK,QK_ERR_NULL_PTR,QK_ERR_BAD_SIZE,QK_ERR_INVALID_INPUT, etc.). - Use
qk_get_last_error()for thread-local error detail.
Python API
- Raises typed exceptions:
QKErrorQKNullPointerErrorQKBadSizeErrorQKInvalidInputError
License
LICENSE (WTFPL).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file quant_kernel-2.9.0.tar.gz.
File metadata
- Download URL: quant_kernel-2.9.0.tar.gz
- Upload date:
- Size: 139.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b6b43c076a55552772d297bb2dc3cfad837944f099f7c1dcee00de5a90bb692
|
|
| MD5 |
7292e4f4e38262a4a99ea25f311f0ae6
|
|
| BLAKE2b-256 |
6b2b01e5f1997f279fbc4c0057528cce5ec5d201e9e9aad2d7056788ac2395e8
|
Provenance
The following attestation bundles were made for quant_kernel-2.9.0.tar.gz:
Publisher:
wheels.yml on yluoc/Quant-Kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quant_kernel-2.9.0.tar.gz -
Subject digest:
1b6b43c076a55552772d297bb2dc3cfad837944f099f7c1dcee00de5a90bb692 - Sigstore transparency entry: 975594428
- Sigstore integration time:
-
Permalink:
yluoc/Quant-Kernel@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Branch / Tag:
refs/tags/v2.9.1 - Owner: https://github.com/yluoc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quant_kernel-2.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quant_kernel-2.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 232.5 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67c20f4b64d1014b19691bb1feb695b56ff81ed1b95fbe8c05e75873b16f487e
|
|
| MD5 |
d5ea2357740f87ff6998e187183b4a61
|
|
| BLAKE2b-256 |
7ff6baa75b27774b4078f95706be71270bd1487e565d32a0d82a4c9932267012
|
Provenance
The following attestation bundles were made for quant_kernel-2.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
wheels.yml on yluoc/Quant-Kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quant_kernel-2.9.0-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
67c20f4b64d1014b19691bb1feb695b56ff81ed1b95fbe8c05e75873b16f487e - Sigstore transparency entry: 975594446
- Sigstore integration time:
-
Permalink:
yluoc/Quant-Kernel@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Branch / Tag:
refs/tags/v2.9.1 - Owner: https://github.com/yluoc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quant_kernel-2.9.0-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: quant_kernel-2.9.0-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 126.0 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8158324e53bf463acca3a8d00857580925331cecf131732cc3f080af6b16f50e
|
|
| MD5 |
ff5c529948f3b3decc1f92e8e01b3990
|
|
| BLAKE2b-256 |
a1d65e8267243b5d5d51497979aad96f24fcdccc8d8276761ae616c48922a624
|
Provenance
The following attestation bundles were made for quant_kernel-2.9.0-cp313-cp313-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on yluoc/Quant-Kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quant_kernel-2.9.0-cp313-cp313-macosx_11_0_arm64.whl -
Subject digest:
8158324e53bf463acca3a8d00857580925331cecf131732cc3f080af6b16f50e - Sigstore transparency entry: 975594447
- Sigstore integration time:
-
Permalink:
yluoc/Quant-Kernel@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Branch / Tag:
refs/tags/v2.9.1 - Owner: https://github.com/yluoc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quant_kernel-2.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quant_kernel-2.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 232.5 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
705db4987af1bc126532c76f50b5ca3b6c44e58004fc1191ee83e28f015c5edc
|
|
| MD5 |
23b1431f360c48c9972bb5fb2949c63e
|
|
| BLAKE2b-256 |
b91d7f0bc9150676f866b7b66bacd011e6a45778eb01afa4528cf848f325a729
|
Provenance
The following attestation bundles were made for quant_kernel-2.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
wheels.yml on yluoc/Quant-Kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quant_kernel-2.9.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
705db4987af1bc126532c76f50b5ca3b6c44e58004fc1191ee83e28f015c5edc - Sigstore transparency entry: 975594442
- Sigstore integration time:
-
Permalink:
yluoc/Quant-Kernel@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Branch / Tag:
refs/tags/v2.9.1 - Owner: https://github.com/yluoc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quant_kernel-2.9.0-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: quant_kernel-2.9.0-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 126.0 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7092efd4f223b4c3cef60db632aa84ed12a4455f17ef12dff506cca432ac2cf
|
|
| MD5 |
f3c9881d0925373f0db591980ba29553
|
|
| BLAKE2b-256 |
7c918aa7484019ed48e3c6c35016e49c87f912e70f61355fc2566da33e2e1053
|
Provenance
The following attestation bundles were made for quant_kernel-2.9.0-cp312-cp312-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on yluoc/Quant-Kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quant_kernel-2.9.0-cp312-cp312-macosx_11_0_arm64.whl -
Subject digest:
e7092efd4f223b4c3cef60db632aa84ed12a4455f17ef12dff506cca432ac2cf - Sigstore transparency entry: 975594440
- Sigstore integration time:
-
Permalink:
yluoc/Quant-Kernel@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Branch / Tag:
refs/tags/v2.9.1 - Owner: https://github.com/yluoc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quant_kernel-2.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: quant_kernel-2.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 232.5 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
36befb7479469c59058ce6b70ad3cfd706f085b0afd18f02ceec1ad9bde4c8f0
|
|
| MD5 |
0baf1f288c3ef2a6ddf15a166e231033
|
|
| BLAKE2b-256 |
7ac6a77fdea1e97aeffd98c67f2f6ec7cdde5552784e8e0e523bb0bf92afd067
|
Provenance
The following attestation bundles were made for quant_kernel-2.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
wheels.yml on yluoc/Quant-Kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quant_kernel-2.9.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl -
Subject digest:
36befb7479469c59058ce6b70ad3cfd706f085b0afd18f02ceec1ad9bde4c8f0 - Sigstore transparency entry: 975594452
- Sigstore integration time:
-
Permalink:
yluoc/Quant-Kernel@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Branch / Tag:
refs/tags/v2.9.1 - Owner: https://github.com/yluoc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Trigger Event:
push
-
Statement type:
File details
Details for the file quant_kernel-2.9.0-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: quant_kernel-2.9.0-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 126.0 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba354514cd06d6a36b1a6ca5326d0a7383c1fd3a031aa57b568587be2f90f0af
|
|
| MD5 |
20cb35bc250bbc2629cf1effb626e0f3
|
|
| BLAKE2b-256 |
a1f72f90c267225b6ca4fce87593c3ed1604d0db0e3476eee30130018e564c48
|
Provenance
The following attestation bundles were made for quant_kernel-2.9.0-cp311-cp311-macosx_11_0_arm64.whl:
Publisher:
wheels.yml on yluoc/Quant-Kernel
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
quant_kernel-2.9.0-cp311-cp311-macosx_11_0_arm64.whl -
Subject digest:
ba354514cd06d6a36b1a6ca5326d0a7383c1fd3a031aa57b568587be2f90f0af - Sigstore transparency entry: 975594434
- Sigstore integration time:
-
Permalink:
yluoc/Quant-Kernel@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Branch / Tag:
refs/tags/v2.9.1 - Owner: https://github.com/yluoc
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
wheels.yml@b221cf90beb23517afcc102dca47aa63ec7a5b06 -
Trigger Event:
push
-
Statement type: