C++ for Quantitative Finance: Hands-On from Foundations to Model Implementation
APLIED COMPUTATIO, QUANT METHODS
RELEVANT FOR QUANTITATIVE FINANCE
Basic notion of programming required
[WORK IN PROGRESS]
This blog adopts a hands-on, laboratory-based approach: concepts are developed through direct implementation and problem solving. And practice with real data, implementing calculations and models. The objective is to accelerate the practical application of C++ in computational quantitative finance, emphasizing efficiency, numerical rigor, and real-world modeling.
The content is organized as follows:
- Setup and Configuration
- Language and Syntax (moderm C++, C++20)
- Object-Oriented Programming (OOP)
- Efective and Functional Programming
- Generic Programming (GP)
- Applications in Computational Finance
- Boost C++ Libraries
- Data Strcutures and Algorithms
# --------------------------------------------------------------------------------------------------------------- #
1 - Fast Setup and Configuration
Software
Standard Environment
It’s most efficient for the staff if everyone uses the same environment:
- Compiling: gcc, g++
- Debugging: gdb, some use valgrind
- About IDEs for programing: If you prefer using a GUI—which is often beneficial—Visual Studio Code is a versatile option. You may also explore other alternatives if time permits. Regardless of the IDE, your code must run correctly and be properly tested across and in standard environments.
Windows
- Use MSYS2 is a collection of tools. Or the most frequent necessary packages are available in cygwin (gcc-core, gcc-g++, gdb).
- Cywing : a large collection of GNU and Open Source tools which provide functionality similar to a Linux distribution on Windows.
- Check your availability or version:
- Install your IDE and C++ extension in a necesari case. If you use Visual Studio Code consult the public instructions.
Linux
- In the case of linux the componenst are integrate in the build essential; and you will need gdb. If you use Visual Studio Code equally you can use the public intructions.
Setup c++ standar to 20 (linux or windows)
- Change the c_cpp_properties.json file with ["cppStandard": "gnu++20",] or add [-std=c++20], in task.json (thes files will be generate after the first execution or configuration).
# --------------------------------------------------------------------------------------------------------------- #
2 - C++ syntax
Library importation:# include-
Execution starts (main function) and group of statement (scope or blocks):intmain() { } - In the scope will be the:
- Variable declaration
- Output definition
- Return Statement
- The required at end of statement
:; - Namespace, functions, class and identifiers
A simple and a complex sample:
[WORKING - IMPROVING THE CASE CODE SAMPLES]
# --------------------------------------------------------------------------------------------------------------- #
3 - Object Oriented Programming
- functions
- Class
- memory management
- pointer and references
- inheritance and polymorphism
- preprocessor macros
- object-oriented programming and modeling
lambda functions
auto
namespaces
preprocessor
exception handling.
Standard Template Library (STL)
# --------------------------------------------------------------------------------------------------------------- #
4 - Efective and Functional Programming
Modern design patterns (functional programming= OOP, templates
I can use only what I declare above
# --------------------------------------------------------------------------------------------------------------- #
5 - Generic programming (GP)
containers and algorithms
combining OOP and GP.
# --------------------------------------------------------------------------------------------------------------- #
6 - Applications in Computational Finance
Black Scholes pricing and Greeks
Monte Carlo methods
Finite difference methods (Euler, Crank-Nicolson)
Lattice methods
Exact methods (Barone-Adesi-Whaley, bonds, swaps,
swaptions).
Monte Carlo and partial differential equations
# --------------------------------------------------------------------------------------------------------------- #
7 - Boost C++ Libraries
continuous and discrete statistical distribution
random number generator.
8 - Data Strcutures / Algorithms
# --------------------------------------------------------------------------------------------------------------- #
REFERENCE SOURCE:
Lippman, S. and J. Lajoie. C++ Primer. 3rd ed. Reading, MA: Addison Wesley Professional. April 1998.
MIT - Introduction to C and C++ : basic sytax and programming flow base notion.
MIT - C++ efective programming
Additional source to consult:
Deitel, H. and P. Deitel. C++ How to Program. 4th ed. Upper Saddle River, NJ: Prentice Hall PTR. August 2002.Stroustrup, B. The C++ Programming Language. 3rd ed.
Winston, H. On to C++. 2nd ed.
Johnsonbaugh & Kalin. Object Oriented Programming in C++. 2nd ed. Upper Saddle River, NJ: Prentice Hall, August 1999.
Cline, M., M. Girou, and G. Lomow. C++ FAQs. Reading, MA: Addison Wesley Professional, December 1998.
To go a little deep:
MIT-computation_structures_course: don't lose, get the notions and idea
MIT-Students_guide_Computation_Structures
6.01SC Introduction to Electrical Engineering and Computer Science - Book - focus in chapter 3
Applied in Data Structures and Algorithms:
Sedgewick, R. Algorithms in C++. Reading, MA: Addison-Wesley Longman, Incorporated. June 2001. ISBN: 0201849380.
Weiss, M. Algorithms, Data Structures and Problem Solving with C++. Reading, MA: Addison Wesley, November 1999.
