Based on M. Joshi's C++ Design Patterns and Derivatives Pricing (a practical companion to his Concepts and Practice of Mathematical Finance), making use of updated paradigms wherever possible.
C++17 strongly recommended.
cmake repository for the CMake scripts; included as a submodule.
common repository for utility classes & functions.
The project is built via CMake. One can, of course, modify the CMake configuration at will or use one's own. The documentation is to be built with Doxygen from the provided doxyfile.
The project roughly follows the second edition of the aforementioned book, which was published in 2008. While the numerics and mathematics haven't changed, C++ has gone through quite a bit of a revolution in the time since. Due to this fact, the original book includes some now archaic elements, such as a self-implemented smart pointer. All such were replaced with their modern equivalents. Some chapters do not correspond to a concrete problem and have been excluded; in others, the sub-problems have often been consolidated/handled in a more generic way.
The code itself is separated into two directories:
- src: the library itself - this contains all the actual relevant code
- mains: auxiliary driver/playground code - this merely calls the above for some toy examples
The mains correspond to each relevant chapter. Take a look at the list of includes corresponding to each executable in CMakeLists.txt, to follow along with the development of the library as the book progresses.
These perform Monte-Carlo pricing of various derivatives, with an increasing degree of software architecture.
This chapter implements custom random number generators and integrates them with the architecture developed in preceding chapters.
Deals with the pricing of exotic, more specifically, path-dependent, options via Monte-Carlo using all the preceding infrastructure.
Switches gears and introduces pricing on trees (or lattices). For this, I have developed a helper static recombinant tree class that is found in the common repository (see above). This allows us to price early-exercise options.
Deals with the concept of implied volatility and introduces two simple numerical root-finding routines.
Introduce the factory pattern & apply it to the existing architecture. The latter improves on the former by making the factory completely generic.
As an exercise, I added pricing on trinomial trees. In the future, I might add low-level parallelization as an additional feature (c.f. the barrier class in common).
NOTE: I have stayed away from C-like input/output parameters and have replaced them with rvalue reference inputs that get moved into, modified in place, and returned by value (moved out). I feel that this syntax is clearer and also mirrors the approach popular Python numerics packages, such as Pandas, are taking with regards to in-place modification. There is also the added benefit of zero additional performance costs, afforded to us by modern C++.
Dr. Mark Joshi (RIP)