Python for Finance: Analyze Big Financial Data

(Elle) #1

Square-Root Diffusion


The third stochastic process to be simulated is the square-root diffusion as used by Cox,


Ingersoll, and Ross (1985) to model stochastic short rates. Equation 16-5 shows the


stochastic differential equation of the process (see also Equation 10-4 in Chapter 10 for


further details).


Equation 16-5. Stochastic differential equation of square-root diffusion


We use the discretization scheme as presented in Equation 16-6 (see also Equation 10-5 in


Chapter 10, as well as Equation 10-6, for an alternative, exact scheme).


Equation 16-6. Euler discretization for square-root diffusion (full truncation scheme)


The Simulation Class


Example 16-5 presents the Python code for the square_root_diffusion simulation class.


Apart from, of course, a different model and discretization scheme, the class does not


contain anything new compared to the other two specialized classes.


Example 16-5. Simulation class for square-root diffusion



DX Library Simulation


square_root_diffusion.py



import numpy as np


from sn_random_numbers import sn_random_numbers
from simulation_class import simulation_class


class square_root_diffusion(simulation_class):
”’ Class to generate simulated paths based on
the Cox-Ingersoll-Ross (1985) square-root 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 :
Free download pdf