Python for Finance: Analyze Big Financial Data

(Elle) #1

Jump Diffusion


Equipped with the background knowledge from the geometric_brownian_motion class, it


is now straightforward to implement a class for the jump diffusion model described by


Merton (1976). Recall the stochastic differential equation of the jump diffusion, as shown


in Equation 16-3 (see also Equation 10-8 in Chapter 10, in particular for the meaning of


the parameters and variables).


Equation 16-3. Stochastic differential equation for Merton jump diffusion model


dSt = (r – rJ)Stdt + StdZt + JtStdNt


An Euler discretization for simulation purposes is presented in Equation 16-4 (see also


Equation 10-9 in Chapter 10 and the more detailed explanations given there).


Equation 16-4. Euler discretization for Merton jump diffusion model


The Simulation Class


Example 16-4 presents the Python code for the jump_diffusion simulation class. This


class should by now contain no surprises. Of course, the model is different, but the design


and the methods are essentially the same.


Example 16-4. Simulation class for jump diffusion



DX Library Simulation


jump_diffusion.py



import numpy as np


from sn_random_numbers import sn_random_numbers
from simulation_class import simulation_class


class jump_diffusion(simulation_class):
”’ Class to generate simulated paths based on
the Merton (1976) jump diffusion model.


            Attributes
==========
name : string
name of the object
mar_env : instance of market_environment
market environment data for simulation
corr : Boolean
True if correlated with other model object

Methods
=======
update :
updates parameters
generate_paths :
Free download pdf