Conclusions
This chapter develops all the tools and classes needed for the simulation of the three
stochastic processes of interest: geometric Brownian motions, jump diffusions, and
square-root diffusions. The chapter presents a function to conveniently generate standard
normally distributed random numbers. It then proceeds by introducing a generic model
simulation class. Based on this foundation, the chapter introduces three specialized
simulation classes and presents use cases for these classes.
To simplify future imports, we can again use a wrapper module called dx_simulation.py,
as presented in Example 16-6.
Example 16-6. Wrapper module for simulation components
DX Library Simulation
dx_simulation.py
import numpy as np
import pandas as pd
from dx_frame import *
from sn_random_numbers import sn_random_numbers
from simulation_class import simulation_class
from geometric_brownian_motion import geometric_brownian_motion
from jump_diffusion import jump_diffusion
from square_root_diffusion import square_root_diffusion
As with the first wrapper module, dx_frame.py, the benefit is that a single import
statement makes available all simulation components in a single step:
from dx_simulation import *
Since dx_simulation.py also imports everything from dx_frame.py, this single import in
fact exposes all functionality developed so far. The same holds true for the enhanced init
file in the dx directory, as shown in Example 16-7.
Example 16-7. Enhanced Python packaging file
DX Library
packaging file
init.py
import numpy as np
import pandas as pd
import datetime as dt
frame
from get_year_deltas import get_year_deltas
from constant_short_rate import constant_short_rate
from market_environment import market_environment
simulation
from sn_random_numbers import sn_random_numbers
from simulation_class import simulation_class
from geometric_brownian_motion import geometric_brownian_motion
from jump_diffusion import jump_diffusion
from square_root_diffusion import square_root_diffusion