Python for Finance: Analyze Big Financial Data

(Elle) #1

Geometric Brownian Motion


Geometric Brownian motion is a stochastic process as described in Equation 16-1 (see


also Equation 10-2 in Chapter 10, in particular for the meaning of the parameters and


variables). The drift of the process is already set equal to the riskless, constant short rate r,


implying that we operate under the equivalent martingale measure (see Chapter 15).


Equation 16-1. Stochastic differential equation of geometric Brownian motion


dSt = rStdt + StdZt


Equation 16-2 presents an Euler discretization of the stochastic differential equation for


simulation purposes (see also Equation 10-3 in Chapter 10 for further details). We work in


a discrete time market model, such as the general market model ℳ from Chapter 15, with


a finite set of relevant dates 0 < t 1 < t 2 < ... < T.


Equation 16-2. Difference equation to simulate the geometric Brownian motion


The Simulation Class


Example 16-3 now presents the specialized class for the GBM model. We present it in its


entirety first and highlight selected aspects afterward.


Example 16-3. Simulation class for geometric Brownian motion



DX Library Simulation


geometric_brownian_motion.py



import numpy as np


from sn_random_numbers import sn_random_numbers
from simulation_class import simulation_class


class geometric_brownian_motion(simulation_class):
”’ Class to generate simulated paths based on
the Black-Scholes-Merton geometric Brownian motion 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 simulation object

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