1. An Overview of C++
C++ and Quantitative Finance
C++ 11: The Modern Era is Born
Open Source Mathematical Libraries
Debunking Myths About C++
Compiled vs Interpreted Code
The Components of C++
C++ Language Features
The C++ Standard Library
Compilers and IDE’s
Basic Review of C++
Good Old “Hello World!”
Simple Procedural Programming in C++
C++ Syntax and Style Guidelines
Mathematical Operators, Functions, and Constants in C++
Standard Arithmetic Operators
Mathematical Functions in the Standard Library
Constants
Conclusion
References
2. Some Mechanics of C++
The `vector` Container
Setting and Accessing Elements of a `vector`
Concluding Remarks on STL `vector`s
Enum Constants and Classes
Enum Constants
Potential Conflicts with Enums
Enum Classes
Control Structures
Conditional Branching
Iterative Statements
Aliases
Type Aliases
References
Pointers
Function and Operator Overloading
Function Overloading
Operator Overloading
Summary
References
3. Writing User-Defined Functions and Classes in Modules
Using Modules to Write User-Defined Functions
A First Example with Non-Member Functions
Standard Library Header Units
Modules Prevent Leaking into Other Modules
A Black-Scholes Module Example
User-Defined Class Implementation in Modules
Using Namespaces with Modules
Summary
4. Dates and Fixed Income Securities
Representation of a Date
1.1 Serial Representation and Date Differences
1.2 Accessor Functions for Year, Month, and Day
1.3 Validity of a Date
1.4 Leap Years and Last Day of the Month
1.5 Weekdays and Weekends
1.6 Adding Years, Months, and Days
1.6.1 Adding Years
1.6.2 Adding Months and End-of-the-Month Cases
1.6.3 Adding Days
A Date Class Wrapper
Class Declaration
Public Member Functions and Operators
Private Members and Helper Function
Class Implementation
Day Count Bases
Yield Curves
Deriving a Yield Curve from Market Data
A Yield Curve Class
A Linearly Interpolated Yield Curve Class Implementation
A Bond Class
Bond Payments and Valuation
A Bond Class
Bond Class Implementation
A Bond Valuation Example
Summary
References
5. Linear Algebra
Introduction
valarray and Matrix Operations
Arithmetic Operators and Math functions
valarray as a Matrix Proxy
Eigen
Lazy Evaluation
Eigen Matrices and Vectors
Matrix and Vector Math Operations
STL Compatibility
Matrix Decompositions and Applications
Future Directions: Linear Algebra in the Standard Library
mdspan (P0009)
BLAS Interface (P1673)
Linear Algebra (P1385)
Summary (Linear Algebra Proposals)
Chapter Summary
References
About the Author
This practical book demonstrates why C++ is still one of the dominant production-quality languages for financial applications and systems. Many programmers believe that C++ is too difficult to learn. Author Daniel Hanson demonstrates that this is no longer the case, thanks to modern features added to the C++ Standard beginning in 2011.
Financial programmers will discover how to leverage C++ abstractions that enable safe implementation of financial models. You’ll also explore how popular open source libraries provide additional weapons for attacking mathematical problems. C++ programmers unfamiliar with financial applications also benefit from this handy guide.
Learn C++ basics from a modern perspective: syntax, inheritance, polymorphism, composition, STL containers, and algorithms
Dive into newer features and abstractions including functional programming using lambdas, task-based concurrency, and smart pointers
Implement basic numerical routines in modern C++
Understand best practices for writing clean and efficient code