Python for Finance: Analyze Big Financial Data

(Elle) #1

Simulation


Monte Carlo simulation (MCS) is among the most important numerical techniques in


finance, if not the most important and widely used. This mainly stems from the fact that it


is the most flexible numerical method when it comes to the evaluation of mathematical


expressions (e.g., integrals), and specifically the valuation of financial derivatives. The


flexibility comes at the cost of a relatively high computational burden, though, since often


hundreds of thousands or even millions of complex computations have to be carried out to


come up with a single value estimate.


Random Variables


Consider, for example, the Black-Scholes-Merton setup for option pricing (cf. also


Chapter 3). In their setup, the level of a stock index ST at a future date T given a level S 0 as


of today is given according to Equation 10-1.


Equation 10-1. Simulating future index level in Black-Scholes-Merton setup


The variables and parameters have the following meaning:


ST


Index level at date T


r


Constant riskless short rate


σ


Constant volatility (= standard deviation of returns) of S


z


Standard normally distributed random variable


This simple financial model is easily parameterized and simulated as follows:


In  [ 10 ]: S0  =    100         #  initial value
r = 0.05 # constant short rate
sigma = 0.25 # constant volatility
T = 2.0 # in years
I = 10000 # number of random draws
ST1 = S0 * np.exp((r - 0.5 * sigma ** 2 ) * T
+ sigma * np.sqrt(T) * npr.standard_normal(I))

The output of this simulation code is shown in Figure 10-3:


In  [ 11 ]: plt.hist(ST1,   bins= 50 )
plt.xlabel(‘index level’)
plt.ylabel(‘frequency’)
plt.grid(True)
Free download pdf