Python for Finance: Analyze Big Financial Data

(Elle) #1

The variable z is a standard normally distributed random variable, 0 < t < T, a (small


enough) time interval. It also holds 0 < t ≤ T with T the final time horizon.


[ 17 ]

We parameterize the model with the values S 0 = 100, K = 105, T = 1.0, r = 0.05, = 0.2.


Using the Black-Scholes-Merton formula as in Equation 3-1 and Example 3-1 from the


previous example, we can calculate the exact option value as follows:


In  [ 19 ]: from bsm_functions import bsm_call_value
S0 = 100.
K = 105.
T = 1.0
r = 0.05
sigma = 0.2
bsm_call_value(S0, K, T, r, sigma)
Out[19]: 8.0213522351431763

This is our benchmark value for the Monte Carlo estimators to follow. To implement a


Monte Carlo valuation of the European call option, the following recipe can be applied:


1 . Divide the time interval [0,T] in equidistant subintervals of length t.


2 . Start iterating i = 1, 2,..., I.


1 . For every time step t ∈ { t, 2 t,..., T}, draw pseudorandom numbers zt(i).


2 . Determine the time T value of the index level ST(i) by applying the pseudo-


random numbers time step by time step to the discretization scheme in


Equation 3-6.


3 . Determine the inner value hT of the European call option at T as hT(ST(i)) =


max(ST(i) – K,0).


4 . Iterate until i = I.


3 . Sum up the inner values, average, and discount them back with the riskless short rate


according to Equation 3-7.


Equation 3-7 provides the numerical Monte Carlo estimator for the value of the European


call option.


Equation 3-7. Monte Carlo estimator for European call option


Pure Python


Example 3-2 translates the parametrization and the Monte Carlo recipe into pure Python.


The code simulates 250,000 paths over 50 time steps.

Free download pdf