April 2019
Intermediate to advanced
426 pages
11h 13m
English
Since we will be writing the explicit, implicit, and Crank-Nicolson methods of finite differences in Python, let's write a base class that inherits the common properties and functions of all three methods.
We will create a class called FiniteDifferences that accepts and assigns all the required parameters in the __init__ constructor method. The price() method is the entry point for invoking the specific finite difference scheme implementation, and will invoke these methods in the following order: setup_boundary_conditions(), setup_coefficients(), traverse_grid(), and interpolate(). These methods are explained as follows:
Read now
Unlock full access