A C++17 quantitative finance library with built-in Automatic Adjoint Differentiation (AAD). Features include yield curve construction, cross-currency pricing and calibration, Monte Carlo simulation, finite difference PDE solvers, a scripting engine for exotic payoffs with tree-walk and compiled evaluators, and parallel model evaluation.
Pull requests with source, configuration, or build changes build and test the
native AAD compiler matrix below. Documentation-only changes run the
documentation integrity check and stable Linux/Windows gates without starting
the compile or sanitizer jobs. Pushes to master (merges and direct
master pushes) run a lean GCC 14 + Clang 20 subset,
because the pull request already covered every combination. GitHub publishes
one status badge per workflow; open a workflow run for per-job results.
Path-matched pull requests run Python wheel CI
for installed-package tests on Linux, Windows, and macOS (Intel and Apple
Silicon); PyPI publication remains in
the tag-only release workflow.
Benchmarks run in a separate scheduled workflow
at 06:00 and 18:00 Asia/Shanghai every day, with manual dispatch available.
Linux compares the current master commit with its first parent and runs the
Python and native regression checks; Windows runs benchmark executables on
MSVC/AADet. Results remain in the workflow summaries and 30-day artifacts.
Benchmark failures do not block pull-request or push CI.
| Platform | Compiler | Native AAD |
|---|---|---|
Ubuntu (ubuntu-latest) |
GCC 13 | ✓ |
Ubuntu (ubuntu-latest) |
GCC 14 | ✓ |
Ubuntu (ubuntu-latest) |
GCC 15 | ✓ |
Ubuntu (ubuntu-latest) |
Clang 18 | ✓ |
Ubuntu (ubuntu-latest) |
Clang 19 | ✓ |
Ubuntu (ubuntu-latest) |
Clang 20 | ✓ |
Windows (windows-latest) |
MSVC | ✓ |
- The GCC 14 + AADet leg additionally runs gcov coverage, tracked by Coveralls.
- Windows legs additionally build the
dal-pythonbindings and thedal-exceladd-in. - Separate Linux jobs cover native diagnostic OFF/ON and Python bindings with generated-source verification, documentation integrity, a warning-clean build, and ASan/UBSan/TSan spot tests.
git clone --recursive [email protected]:wegamekinglc/Derivatives-Algorithms-Lib.git
cd Derivatives-Algorithms-Lib
bash build_linux.shThe Linux default builds/tests core and public C++ and stages the install under
build/stage/Release-linux; use --full for Python plus benchmarks. For the
supported profiles, Windows workflow, Python bindings, and troubleshooting,
see the installation guide.
dal-cpp (DAL::cpp)
└─ dal-public (DAL::public)
├─ dal-python
└─ dal-excel
The native dependency graph is dal-cpp ← dal-public ← {dal-python, dal-excel}.
dal-public is a developer-facing convenience facade over core DAL types; it is
not an ABI-isolated compatibility boundary.
| Sub-project | Purpose |
|---|---|
dal-cpp/ |
Core library: math, curves, models, scripting, AAD |
dal-public/ |
Public C++ convenience facade over DAL::cpp |
dal-python/ |
pybind11 Python bindings |
dal-excel/ |
Excel .xll add-in (Windows-only) |
Core domains in dal-cpp/dal/:
- math/ — Interpolation, optimization, PDE solvers, random numbers, matrix ops
- math/aad/ — Built-in Automatic Adjoint Differentiation with scalar/vector adjoints
- curve/ — Yield curve construction, piecewise forward rates, calibration
- script/ — Expression scripting engine for exotic payoffs, with tree-walk and compiled evaluation modes
- model/ — Financial models (Black-Scholes, GSR, Hybrid), local-volatility surfaces, and Dupire calibration
- time/ — Dates, calendars, schedules, and day-count bases
- protocol/, currency/, indice/ — Market/contract conventions, currency data, and index/fixing management
- risk/ — Risk report types and aggregation
- storage/ — Storable objects, archives, and repository integration
- concurrency/ — Thread pool for parallel Monte Carlo
- platform/, io/, string/, utilities/ — Infrastructure: configuration, host init, Excel I/O helpers, strings, dictionaries
- auto/ — Machinist-generated enums and serialization (do not hand-edit)
The core C++ example catalog groups programs into products, curves, models and numerical methods, with build targets and run instructions.
The scripted Monte Carlo example
constructs a product and Black-Scholes model through the public C++ facade,
then calls ValueByMonteCarlo. The runnable
European and
American/Bermudan C++ examples compare
Monte Carlo prices with analytic or PDE references.
More examples: Python, Excel, C++. The C++ Monte Carlo script examples show both tree-walk and compiled evaluator output where applicable.
Cross-currency examples:
- reset-aware pricing
- staged basis calibration
- joint domestic/foreign/basis calibration
- Python joint calibration
Quote-space DV01 examples:
- C++ single-curve quote risk
- Python single-curve quote risk
- Excel worksheet recipe
- Generic joint multi-curve worksheet recipe
The quote-risk workflow freezes exact single-curve, generic joint multi-curve, joint-XCCY, or staged-XCCY-basis calibration provenance and aggregates portfolio price-per-decimal quote sensitivity plus DV01. Fingerprints reject stale curve state, and results remain separated by actual PV currency without FX conversion.
Monte Carlo script valuation defaults to the tree-walk evaluator (compiled=false).
Pass compiled=True in Python or compiled=true in C++ to select the flat-stream
evaluator. The compiled mode is a performance option; payoff values and AAD risks
are expected to match tree-walk results up to normal floating-point noise.
For implementation details and parity coverage, see Script Engine methodology. To compare runtime locally, build and run the script_mc_perf benchmark target:
bash ./build_linux.sh --benchmarks
./build/Release-linux/dal-cpp/benchmarks/script_mc_perf/script_mc_perfPublic C++ supports typed product and valuation settings for unquoted
FIX(index[,date]), explicit dates/snapshots, and BS/Hybrid EQ bindings while
preserving old call signatures. See the
settings contract and
runnable core C++ example in dal-cpp/examples/products/script_settings/.
fix_mc is a runnable Monte Carlo example covering
historical fixings (global store or explicit snapshot), future fixings
(simulated model paths), mixed payoffs, and the evaluation-date fixing policy.
DescribeScriptProduct returns contract JSON dal.script-product/2 with no
history/model/global-date access. ExplainScriptValuation returns
dal.script-valuation/1 from one default price preparation: it may read history,
submits no workers, and does not cache the next valuation.
ExplainScriptSimulation returns dal.script-simulation/1 from a full
double valuation on exercise products (plain products skip the run and
report an empty event array) with per-exercise-event statistics. Python projects the
same settings and diagnostics through keyword-only settings classes,
Product_Describe, ScriptValuation_Explain, and ScriptSimulation_Explain — see
Historical and Future FIX.
Excel exposes settings handles with PRODUCT.NEWWITHSETTINGS /
MONTECARLO.VALUEWITHSETTINGS plus the chunk-valued PRODUCT.DESCRIBE,
SCRIPTVALUATION.EXPLAIN, and SCRIPTSIMULATION.EXPLAIN — see
Excel FIX Settings and Diagnostics.
Legacy script dumps include the s-expression listing
(DebugScriptProduct in C++, Product_Debug in Python), a versioned JSON AST
for machine consumers (DebugScriptProductJson / Product_DebugJson, schema
dal.script-product/1, rejecting FIX or nonempty default indices), and a
width-aware Unicode tree with an ASCII fallback
(DebugScriptProductTree / Product_DebugTree). See
Product Debug Outputs
for the formats.
See the Excel interface chapter for worksheet formulas and handle conventions. Python examples are in the Python interface chapter.
- Installation Guide — Canonical setup workflows
- Architecture Guide — Components, ownership, and execution flows
- C++ Public API Guide — public facade entry points
- Python Interface — Python bindings and examples
- Excel Interface — worksheet functions and handles
- Contributing Guide — Development and review workflow
- Documentation Index — All methodology and component guides
- Web UI — portfolio management UI (separate repository)
Methodology notes (see the index above for the full list):
- AAD — Automatic adjoint differentiation: expression templates, tape, propagation
- Yield Curve and Yield-Curve Jacobian — discount curves, calibration, inverse-Jacobian transforms, and production quote-space DV01
- Cross-Currency Pricing and Calibration — fixed, resettable, and MTM swaps; immutable fixing snapshots; staged basis and simultaneous domestic/foreign/basis calibration
- Interpolation — linear, log-linear, cubic interpolators
- PDE — finite-difference framework and European option pricing
- Script Engine — expression scripting, fuzzy AAD evaluation, and compiled evaluator parity
- Monte Carlo — simulation, LSM, sampling, RQMC, and AAD
- Models — Black/Bachelier pricing, Black-Scholes, correlated-equity and hybrid simulation, and Dupire calibration
- Matrix — matrix and linear algebra
MIT License — see LICENSE
- Tom Hyer, Derivatives Algorithms: Volume 1: Bones (repo)
- Antoine Savine, Modern Computational Finance: AAD and Parallel Simulations (repo)
- Antoine Savine, Modern Computational Finance: Scripting for Derivatives and xVA (repo)
- Brian Huge and Jesper Andreasen, Finite Difference Methods for Financial PDEs (repo)