Skip to content

ccjeremylo/FinEng-in-IRFX

Repository files navigation

Financial Engineering in IRFX in C++

Repo Status

Following structure of this course.

Topics Include:

  • Binomial tree/pricer
  • American & path-dependent options
  • Monte Carlo methods
  • Non linear solvers for implied vol
  • Curve construction
  • Short rate modelling
  • HJM
  • LMM
  • SABR
  • etc...

Contributions are more than welcome!

The current format/set-up is largely based on this repo. Special thanks to Kelvin for letting me copy his set up.

Features

Requirements

  • CMake
  • C++11 compliant compiler
  • Python3.7 or above
  • Gtest

Install, Build & Run

All commands below are assumed to be run from root of the repo, unless specified otherwise.

Build

cmake -S ./ -B build
cmake --build build
./build/exec

Run tests

ctest --test-dir ./build --output-on-failure

Build and run tests

The following script only works for linux/macOS users:

./build_and_test_proj.sh

Set up & using pybind11

See this separate readme file for details

The following scripts only work for linux/macOS users (and assumes dependencies have been installed) - best to refer to this readme file for set up.

Install our c++ python binding fineng_irfx into the virtual env .venv:

./deploy_cpp_module.sh

Now, you can also launch a jupyter lab session with the required virtual env:

./launch_jupyter.sh

Project Structure

  • The C++ code can be found here
  • The Python code can be found here
  • Example tests can be found here
  • Project to-do list are here

Lecture 1

  • Binomial tree option pricing
    • using function pointers to switch payoffs
    • different choices of tree structure
    • analysing prob distribution generated by binomial tree
    • computing Binomial coeff using recurrsion

Lecture 2

  • Binomial tree option pricing continued:
    • improve code design by using OO design patterns
    • pricing path-dependent (knock-out) options
    • CRR model, numerical/analytical implementation
    • connection to Black Scholes
    • risks computation via finite differencing

Lecture 3

  • Binomial tree option pricing continued:

    • pricing early excerise payoffs (American/Bermudans)
    • introduction of C++ templates
    • multiple inheritance in C++
    • numerical stability and convergence analysis
  • Monte Carlo methods:

    • pricing vanilla options
    • using Box-muller as RNG
    • discretisation via the Euler–Maruyama scheme
    • pricing path-dependent payoffs (barrier/Asian)
    • discretisation error in long stepping (terminal correlation)

Lecture 4

Lecture 5

  • Monte Carlo methods continued:

  • 1 factor short rate modelling:

    • introduction to short rate models - 1 factor models
    • Merton Model - bond pricing
    • Merton Model - implied yield curve

Lecture 6

  • 1 factor short rate modelling continued:
    • Vasicek Model - bond pricing
    • Vasicek Model - implied yield curve
    • calibration of the Vasicek model to the day-0 yield curve
    • intro to the Hull White model
    • calibration of the Hull White model to the day-0 yield curve