Python for Finance: Analyze Big Financial Data

(Elle) #1
”’

sta1    =   scs.describe(a1)
sta2 = scs.describe(a2)
print “%14s %14s %14s” % \
(‘statistic’, ‘data set 1’, ‘data set 2’)
print 45 * “-”
print “%14s %14.3f %14.3f” % (‘size’, sta1[ 0 ], sta2[ 0 ])
print “%14s %14.3f %14.3f” % (‘min’, sta1[ 1 ][ 0 ], sta2[ 1 ][ 0 ])
print “%14s %14.3f %14.3f” % (‘max’, sta1[ 1 ][ 1 ], sta2[ 1 ][ 1 ])
print “%14s %14.3f %14.3f” % (‘mean’, sta1[ 2 ], sta2[ 2 ])
print “%14s %14.3f %14.3f” % (‘std’, np.sqrt(sta1[ 3 ]),
np.sqrt(sta2[ 3 ]))
print “%14s %14.3f %14.3f” % (‘skew’, sta1[ 4 ], sta2[ 4 ])
print “%14s %14.3f %14.3f” % (‘kurtosis’, sta1[ 5 ], sta2[ 5 ])
In [ 16 ]: print_statistics(ST1, ST2)
Out[16]: statistic data set 1 data set 2
–––––––––––––––
size 10000.000 10000.000
min 27.936 27.266
max 410.795 358.997
mean 110.442 110.528
std 39.932 40.894
skew 1.082 1.150
kurtosis 1.927 2.273

Obviously, the statistics of both simulation results are quite similar. The differences are


mainly due to what is called the sampling error in simulation. Error can also be introduced


when discretely simulating continuous stochastic processes — namely the discretization


error, which plays no role here due to the static nature of the simulation approach.


Stochastic Processes


Roughly speaking, a stochastic process is a sequence of random variables. In that sense,


we should expect something similar to a sequence of repeated simulations of a random


variable when simulating a process. This is mainly true, apart from the fact that the draws


are in general not independent but rather depend on the result(s) of the previous draw(s).


In general, however, stochastic processes used in finance exhibit the Markov property,


which mainly says that tomorrow’s value of the process only depends on today’s state of


the process, and not any other more “historic” state or even the whole path history. The


process then is also called memoryless.


Geometric Brownian motion


Consider now the Black-Scholes-Merton model in its dynamic form, as described by the


stochastic differential equation (SDE) in Equation 10-2. Here, Zt is a standard Brownian


motion. The SDE is called a geometric Brownian motion. The values of St are log-


normally distributed and the (marginal) returns normally.


Equation 10-2. Stochastic differential equation in Black-Scholes-Merton setup


dSt = rStdt + StdZt


The SDE in Equation 10-2 can be discretized exactly by an Euler scheme. Such a scheme


is presented in Equation 10-3, with t being the fixed discretization interval and zt being a


standard normally distributed random variable.


Equation 10-3. Simulating index levels dynamically in Black-Scholes-Merton setup

Free download pdf