The conventional wisdom in quantitative finance is clear: prototype in Python, rewrite in C++ for production. This dual-language workflow is expensive: maintaining two implementations of every model, ensuring they produce identical results, and managing the impedance mismatch between research and production teams.
Python All the Way
This case study describes a live risk platform built entirely in Python. The pricing models, curve construction, and risk calculations are all written in Python/NumPy. AADC’s Python integration records the computation graph from the Python code, JIT-compiles it to native AVX-optimized machine code, and replays the compiled kernel at C++ speed.
The result is sub-second portfolio updates in Python. When market data changes, the platform feeds new inputs into the pre-compiled kernel and receives updated prices and Greeks in milliseconds. No C++ code exists anywhere in the stack.
Development Velocity
The single-language approach transforms the development workflow. Model changes made by quants in Python are immediately available in production. No C++ translation step, no build cycle, no integration testing between languages. A model fix or enhancement goes from research notebook to production kernel in minutes.
Trade-offs
The approach requires AADC’s recording overhead (typically under one second for Python models) each time the model structure changes. Market data updates reuse the existing kernel at zero overhead. For platforms where the model structure is stable and market data changes frequently (which describes most live risk systems), this trade-off is overwhelmingly favorable.
The platform demonstrates that the Python-vs-C++ dichotomy is a false choice when JIT AD compilation is available.
Published by MatLogica. Implemented using AADC, a commercial adjoint AD compiler (matlogica.com).