Parallel Computing
Nowadays, even the most compact notebooks have mainboards with processors that have
multiple cores. Moreover, modern cloud-based computing offerings, like Amazon’s EC2
or Microsoft’s Azure, allow for highly scalable, parallel architectures at rather low,
variable costs. This brings large-scale computing to the small business, the researcher, and
even the ambitious amateur. However, to harness the power of such offerings, appropriate
tools are necessary. One such tool is the IPython.parallel library.
The Monte Carlo Algorithm
A financial algorithm that leads to a high computational burden is the Monte Carlo
valuation of options. As a specific example, we pick the Monte Carlo estimator for a
European call option value in the Black-Scholes-Merton setup (see also Chapter 3 for the
same example). In this setup, the underlying of the option to be valued follows the
stochastic differential equation (SDE), as in Equation 8-2. St is the value of the underlying
at time t; r is the constant, riskless short rate; is the constant instantaneous volatility;
and Zt is a Brownian motion.
Equation 8-2. Black-Scholes-Merton SDE
The Monte Carlo estimator for a European call option is given by Equation 8-3, where
ST(i) is the ith simulated value of the underlying at maturity T.
Equation 8-3. Monte Carlo estimator for European call option
A function implementing the Monte Carlo valuation for the Black-Scholes-Merton set-up
could look like the following, if we only allow the strike of the European call option to
vary:
In [ 35 ]: def bsm_mcs_valuation(strike):
”’ Dynamic Black-Scholes-Merton Monte Carlo estimator
for European calls.
Parameters
==========
strike : float
strike price of the option
Results
=======
value : float
estimate for present value of call option
”’
import numpy as np
S0 = 100.; T = 1.0; r = 0.05; vola = 0.2
M = 50 ; I = 20000