Skip to content

wegamekinglc/Derivatives-Algorithms-Lib

Repository files navigation

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, and parallel model evaluation.

Quick Start

git clone --recursive git@github.com:wegamekinglc/Derivatives-Algorithms-Lib.git
cd Derivatives-Algorithms-Lib
bash build_linux.sh          # or build_windows.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
  • 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, "sobol", False, True)
for k, v in res.items():
    print(f"{k:<8}: {v:>10.4f}")

Output:

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

More examples: Python, Excel, C++

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)

Web UI

Portfolio management web app in dal-web/:

./dal-web/scripts/start.sh     # Start backend + frontend
./dal-web/scripts/stop.sh      # Stop services
./dal-web/scripts/setup-playwright.sh
cd dal-web/frontend && npm run test:e2e   # frontend e2e smoke tests

Documentation

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)

Releases

No releases published

Packages

 
 
 

Contributors