April 2019
Intermediate to advanced
426 pages
11h 13m
English
The Python implementation of finite differences by using the explicit method is given in the following FDExplicitEu class, which inherits from the FiniteDifferences class and overrides the required implementation methods:
In [ ]: import numpy as np """ Explicit method of Finite Differences """ class FDExplicitEu(FiniteDifferences): def setup_boundary_conditions(self): if self.is_call: self.grid[:,-1] = np.maximum( 0, self.boundary_conds - self.K) self.grid[-1,:-1] = (self.Smax-self.K) * \ np.exp(-self.r*self.dt*(self.N-self.j_values)) else: self.grid[:,-1] = np.maximum( 0, self.K-self.boundary_conds) self.grid[0,:-1] = (self.K-self.Smax) * \ np.exp(-self.r*self.dt*(self.N-self.j_values)) ...
Read now
Unlock full access