Derivus
An xVA quantitative library written in pure python using pytorch, with adjoint algorithmic differentiation throughout.
A job is a JSON program: market data, deals and a calculation block go in, results come out. The engine compiles the job — factor discovery, dependency ordering, process construction — then executes it against Monte-Carlo scenarios. Sensitivities come from AAD rather than bumping, so a full greek vector costs one backward pass however many factors it covers.
Installation
pip install derivus
Requires python >= 3.8 and pytorch >= 2.0. A GPU build of pytorch is strongly recommended — the scenario engine is written for it.
Optional extras:
pip install "derivus[garch]" # GARCHSpotModel calibration (lazy import; the rest runs without it)
pip install "derivus[interactive]" # jupyter and matplotlib
pip install "derivus[docs]" # the mkdocs toolchain DV_Docs generates config for
To work on Derivus itself, install from a clone instead:
pip install -e .
Usage
import derivus as dv
cx = dv.Context()
cx.load_json('job.json')
calc, results = cx.run_job()
The JSON is the whole contract — every feature is reachable from it, and a user script should never need to import derivus internals. Three console scripts are installed:
DV_Batch |
CVA, CollVA and FVA over a folder of netting sets |
DV_Bootstrap |
calibration (currently Hull-White 2-factor from swaption vols) |
DV_Docs |
builds ./docs from ./docs_src |
Layout
derivus/ |
the library |
tests/ |
the suite |
tests/fixtures/ |
every input the suite needs — configs and small calibrated market data |
gates/ |
acceptance harnesses: end-to-end reproduction and bit-identity |
docs_src/ |
documentation sources, including the developer section |
experiments/ |
research and validation drivers; end-user scripts that only use load_json / run_job |
notebooks/ |
exploratory notebooks |
excel_integration/ |
xlwings add-in |
data/ |
untracked — where you drop real market data |
artifacts/ |
untracked — run outputs, fits, decks |
Scripts under experiments/ are run from the repo root, e.g. python experiments/production_solver.py.
Market data
No market data ships with the source. Exchange settlements, open interest and curve history are
licensed by their providers and are not ours to redistribute, so data/ is gitignored and you
supply your own.
The suite needs nothing from you. Its inputs live in tests/fixtures/ and are calibrated
parameters — HMM transition matrices, VAR coefficients, GARCH fits — because a fitted statistic
is not the series it was fitted to. A fresh clone runs the whole suite green, with two calibration
tests skipping and naming the file they want.
To run those two, put a CSV at data/pl_exp.csv with a date index and a CommodityPrice.PLATINUM
column. tests/fixtures/calibration_config.json shows the wider shape the calibration scripts
expect.
Documentation
Build it locally with DV_Docs, or read the sources under docs_src/. The developer section
(docs_src/developer/) is the internal view: architecture, the calculation lifecycle, the
dependency system, the resolver layer and the house conventions.
Licence
PolyForm Noncommercial License 1.0.0 — free for any noncommercial purpose, including research, teaching and personal projects. Commercial use requires a separate licence.
Derivus continues work previously published as RiskFlow under GPL-3.0. Anyone who received that release keeps their rights under those terms; this repository is licensed separately by the same copyright holder.
Metadata
Release files for derivus 0.4.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| derivus-0.4.2.tar.gz | 571.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| derivus-0.4.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 990.3 kB
Release files / derivus-0.4.2.tar.gz
| Download URL | derivus-0.4.2.tar.gz |
|---|---|
| Size | 571.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be00a021df02a6f1c8cfd605dc3e1ef30b1c1d77edac7816d0a04a0a78a6e3b8
|
|
BLAKE2b-256 checksum How to use checksums |
1e84c72099554f5f00825c91512e9f72f0f7fade80bd099d0e35481348a54fbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 5, 2026.
Transparency logRelease files / derivus-0.4.2-py3-none-any.whl
| Download URL | derivus-0.4.2-py3-none-any.whl |
|---|---|
| Size | 419.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f8d2e82940619f707c4fa687eedd20589cef7feea67f607a8f3154ada911ad21
|
|
BLAKE2b-256 checksum How to use checksums |
baf659e92b9ca5786df03667944dbae5342320fea4a33863837354a53b9c19dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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 Aug 5, 2026.
Transparency log