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.
git clone --recursive git@github.com: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, Web UI, and troubleshooting,
see the installation guide.
dal-cpp (DAL::cpp)
└─ dal-public (DAL::public)
├─ dal-python
│ └─ dal-web backend ← REST ← React frontend
└─ 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. The web backend is native-only and
imports the compiled dal Python package through one gateway.
| 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) |
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
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.
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_perf=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)
Portfolio management web app in dal-web/. Install the native dal package into
the backend environment first; the launchers run an import preflight and stop with
actionable guidance when it is unavailable.
./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 the canonical installation guide for setup and dal-web/README.md for application details.
- Installation Guide — Canonical setup workflows
- Architecture Guide — Components, ownership, and execution flows
- Public API Guide — C++, Python, and Excel entry points
- Contributing Guide — Development and review workflow
- Documentation Index — All methodology and component guides
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
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)