Skip to content
Companion code for "Modern Computational Finance: AAD and Parallel Simulations" (Antoine Savine, Wiley, 2018)
C++ C Jupyter Notebook
Branch: master
Clone or download
Latest commit 08645c4 Nov 2, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
AAD and Parallel Simulations examples Toy examples from chapters 9 and 15 (#4) Sep 24, 2019
Workshop prebuilt + sheets Feb 28, 2019
xlCpp Update xlOper.h Jan 8, 2019
.gitattributes 💥🐫 Added .gitattributes & .gitignore files Aug 21, 2017
.gitignore vs17 Jun 27, 2018
AAD.cpp Comments Aug 6, 2018
AAD.h Comments Aug 6, 2018
AADExpr.h Comments Aug 6, 2018
AADNode.h Comments Aug 6, 2018
AADNumber.h Comments Aug 6, 2018
AADTape.h comments Aug 22, 2018
ConcurrentQueue.h comments Aug 22, 2018
Intro2AADinMachineLearningAndFinance.pdf Add files via upload Mar 26, 2019 Update Nov 2, 2019
ThreadPool.cpp Comments Aug 6, 2018
VC_redist.x64.exe redistributables Jul 6, 2018
VC_redist.x86.exe redistributables Jul 6, 2018
analytics.h Comments Aug 6, 2018
back.jpg Add files via upload Nov 2, 2019
blocklist.h comments Aug 22, 2018
gaussians.h sobol and mrg Aug 8, 2018
interp.h Comments Aug 6, 2018
ivs.h Comments Aug 6, 2018
matrix.h comments Aug 22, 2018
mcBase.cpp Comments Aug 6, 2018
mcBase.h Comments Aug 23, 2018
mcMdl.h Better inter, last before box-muller Jun 27, 2018
mcMdlBS.h comments Aug 22, 2018
mcMdlDupire.h Comments Aug 6, 2018
mcPrd.h Comments Aug 6, 2018
mrg32k3a.h comments Aug 22, 2018
sobol.cpp sobol and mrg Aug 8, 2018
sobol.h comments Aug 22, 2018
store.h comments Aug 22, 2018
threadPool.h Comments Aug 6, 2018
toyCode.h adjProp in toy code Dec 4, 2018
utility.h Update utility.h (#2) Mar 18, 2019
xlComp.sln Revert faulty merge Jul 16, 2018
xlComp.vcxproj toy code Oct 29, 2018
xlComp.vcxproj.filters toy code Oct 29, 2018
xlComp.xll prebuilt + sheets Feb 28, 2019
xlMemoryManager.cpp Better inter, last before box-muller Jun 27, 2018
xlMemoryPool.cpp Better inter, last before box-muller Jun 27, 2018
xlMemoryPool.h Revert faulty merge Jul 16, 2018
xlOper.h Revert faulty merge Jul 16, 2018
xlTest.xlsx prebuilt + sheets Feb 28, 2019
xlcall.cpp vs17 Jun 27, 2018
xlcall.h initial Aug 21, 2017
xlframework.h Better inter, last before box-muller Jun 27, 2018
xlmemorymanager.h Better inter, last before box-muller Jun 27, 2018

Companion code for "Modern Computational Finance: AAD and Parallel Simulations" (Antoine Savine, Wiley, 2018)


This is the professional implementation in C++ of the book Modern Computational Finance: AAD and Parallel Simulations by Antoine Savine. The code is freely available to anyone. Any person who purchased a copy of the book is authorized to use, modify and distribute the code for any application, as long as the credits remain on the top of the files.

In this repository, readers will find:

The source code listed or referenced in the publication.

The files AAD*.* (with a dependency on gaussians.h for the analytic differentiation of Gaussian functions, and blocklist.h for memory management, both included) constitute a self contained, general purpose AAD library. The code builds on the advanced techniques exposed in this publication, in particular those of chapters 10, 14 and 15 to produce a particularly fast differentiation library, applicable to many contexts. The code is progressively built and explained in part III.

The files mc*.* (with dependency on various utility files, all included in the project) form a generic, parallel, financial simulation library. The code and its theoretical foundations are described in part II. Various files with support code for memory management, interpolation or concurrent data structures, such as threadPool.h, which is developed in part I and used throughout the book to execute tasks in parallel.

A file main.h that lists all the higher level functions that provide an entry point into the combined library.

A Visual Studio 2017 project wrapping all the source files, with project settings correctly set for maximum optimization. The code uses some C++ 17 constructs, so the project setting "C++ Language Standard" on the project property "C/C++ / Language / C++ Language Standard" must be set to "ISO C++ 17 standard". This setting is correctly set on the project file xlComp.vcxproj, but readers who compile the files by other means must be aware of this.

A number of xl*.* files that contain utilities and wrappers to export the main functions to Excel, as a particularly convenient front end for the library. The project file xlComp.vcxproj is set to build an xll, a file that is opened from Excel and makes the exported library functions callable from Excel like its standard functions. We wrote a tutorial that explains how to export C++ code to Excel. The tutorial ExportingCpp2xl.pdf is available in the the folder xlCpp along with the necessary source files. The wrapper xlExport.cpp file in our project precisely follows the directives of the tutorial and readers can inspect it to better understand these techniques.

Finally, we provide a pre-built xlComp.xll (to run xlComp.xll, readers may need to install Visual Studio redistributables VC_redist.x86.exe and VC_redist.x64.exe, also included in the repository) and a spreadsheet xlTest.xlsx that demonstrates the main functions of the library. All the figures and numerical results in this publication were obtained with this spreadsheet and this xll, so readers can reproduce them immediately. The computation times were measured on an iMac Pro (Xeon W 2140B, 8 cores, 3.20 GHz, 4.20 max) running Windows 10. We also carefully checked that we have \emph{consistent} calculation times on a recent quad core laptop (Surface Book 2, i7-8650U, 4 cores, 1.90 GHz, 4.20 max), that is, (virtually) identical time in single threaded mode, twice the time in multi-threaded mode.

The code is entirely written in standard C++, and compiles on Visual Studio 2017 out of the box, without any dependency to a third party library.

The branch 'AADBook' is frozen and reflects the code in the book as published. The master branch may evolve. Other branches contain specific implementations based on the library. For example, the 'MutliAssets' branch contains developments to extend the library to support multiple underlying assets, like basket options or autocalls. They will eventually merge into Master but not AADBook.

Comp Fin Lecture

Computational Finance and Machine Learning in Finance

The repo 'CompFinLecture' contains the slides and material for the lectures based on the book. This is a softer introduction to some of the themes covered in the book, which also introduces deep learning and its application to derivatives finance, and establishes parallels between the back-propagation algorithm, at the core of deep learning, and AAD. This parallel, in turn, provides further intuition into the mechanics of AAD.

These lectures are delivered as courses or workshops at Copenhagen University, Aarhus University and Kings College London. The lecture notes, C++ code and TensorFlow notebooks are freely available in the 'CompFinLectures' repo.

The lectures demonstrate AAD and its application to finance with "toy code", which is particularly easy to understand and reproduce, but is not efficient or scalable to professional standard, and not suitable for production. The code in this repo ('CompFinance'), on the contrary, is efficient, compliant with professional C++ development standards and designed to scale to production.

You can’t perform that action at this time.