wegamekinglc
Derivatives-Algorithms-Lib
C++

AAD enabled and scripting included derivatives modeling.

Last updated Jul 9, 2026
26
Stars
7
Forks
0
Issues
0
Stars/day
Attention Score
69
Language breakdown
No language data available.
โ–ธ Files click to expand
README

DAL - Derivatives Algorithms Library

CMake Linux CI Codacy Grade Coverage Status

A C++17 quantitative finance library with built-in Automatic Adjoint Differentiation (AAD). Features include yield curve construction, Monte Carlo simulation, finite difference PDE solvers, a scripting engine for exotic payoffs with tree-walk and compiled evaluators, and parallel model evaluation.

Quick Start

git clone --recursive git@github.com:wegamekinglc/Derivatives-Algorithms-Lib.git
cd Derivatives-Algorithms-Lib
bash buildlinux.sh          # or buildwindows.bat on Windows

For detailed installation instructions (Python bindings, Web UI, troubleshooting), see docs/installation.md.

Architecture

dal-cpp     โ†’ Core quant library (DAL::cpp)
  โ†‘
dal-public  โ†’ Stable public C++ API (DAL::public)
  โ†‘        โ†‘
dal-python  dal-excel
  โ†‘
dal-web     โ†’ FastAPI + React portfolio management UI

The dependency graph is dal-cpp โ† dal-public โ† {dal-python, dal-excel}. The dal-web backend imports the dal Python package but can also run against dal_stub.py for development without building the native bindings.

| Sub-project | Purpose | |---------------|----------------------------------------------------------------------------------------| | dal-cpp/ | Core library: math, curves, models, scripting, AAD | | dal-public/ | Stable public API wrapping DAL::cpp | | dal-python/ | pybind11 Python bindings | | dal-excel/ | Excel .xll add-in (Windows-only) | | dal-web/ | Portfolio management web app (FastAPI + React), uses DAL through the Python public API |

Core modules in dal-cpp/dal/:

  • math/ โ€” Interpolation, optimization, PDE solvers, random numbers, matrix ops
  • math/aad/ โ€” Automatic Adjoint Differentiation (native, XAD, Adept, CoDiPack backends)
  • 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, etc.)
  • concurrency/ โ€” Thread pool for parallel Monte Carlo

Examples

Python

from dal import *

today = Date_(2022, 9, 15) EvaluationDate_Set(today)

spot, vol, rate, div = 100.0, 0.15, 0.0, 0.0 strike = 120.0 maturity = Date_(2025, 9, 15)

events = [f"call pays MAX(spot() - {strike}, 0.0)"] product = Product_New([maturity], events) model = BSModelData_New(spot, vol, rate, div)

res = MonteCarlo_Value( product, model, 2**20, method="sobol", enable_aad=True, compiled=True, ) for k, v in res.items(): print(f"{k:<8}: {v:>10.4f}")

Output:

PV      :     4.0389 d_div   :   -85.2290 d_rate  :    73.1011 d_spot  :     0.2838 d_vol   :    58.7140

More examples: Python, Excel, C++. The C++ Monte Carlo script examples show both tree-walk and compiled evaluator output where applicable.

Script Engine Modes

Monte Carlo script valuation defaults to the tree-walk evaluator (compiled=false) to preserve historical behavior. Pass compiled=True in Python or compiled=true in C++ to opt into 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 scriptmcperf benchmark target:

cmake --build build --target scriptmcperf -j 4
./build/dal-cpp/benchmarks/scriptmcperf/scriptmcperf

Excel

=PRODUCT.NEW("my_product", A2, B2)
=BSMODELDATA.NEW("model", 100, 0.15, 0.0, 0.0)
=MONTECARLO.VALUE(A5, C7, 2^20, "sobol", FALSE, TRUE, 0.01)

Web UI

Portfolio management web app in dal-web/:

./dal-web/scripts/start.sh     # Start backend + frontend (Linux/macOS)
./dal-web/scripts/stop.sh      # Stop services (Linux/macOS)
./dal-web/scripts/setup-playwright.sh
cd dal-web/frontend && npm run test:e2e   # frontend e2e smoke tests
# Windows (requires PowerShell 7+)
pwsh -NoProfile -ExecutionPolicy Bypass -File dal-web/scripts/start.ps1
pwsh -NoProfile -ExecutionPolicy Bypass -File dal-web/scripts/stop.ps1
  • Frontend: http://localhost:5173
  • API docs: http://127.0.0.1:8001/docs
See dal-web/README.md for the full cross-platform guide (prerequisites, manual launch, troubleshooting).

Documentation

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, Jacobian / inverse-Jacobian risk
  • Interpolation โ€” linear, log-linear, cubic interpolators
  • PDE โ€” finite-difference meshers and coordinate maps
  • Script Engine โ€” expression scripting, fuzzy AAD evaluation, and compiled evaluator parity
  • Random โ€” random number generation and path construction
  • Black / Bachelier โ€” vanilla option pricing
  • Matrix โ€” matrix and linear algebra

License

MIT License โ€” see LICENSE

References

  • 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)
๐Ÿ”— More in this category

ยฉ 2026 GitRepoTrend ยท wegamekinglc/Derivatives-Algorithms-Lib ยท Updated daily from GitHub