In [ 4 ]: csr = constant_short_rate(‘csr’, 0.06)
In [ 5 ]: me_gbm.add_curve(‘discount_curve’, csr)
In [ 6 ]: gbm = geometric_brownian_motion(‘gbm’, me_gbm)
In addition to a simulation object, we need to provide a market environment for the option
itself. It has to contain at least a maturity and a currency. Optionally, we can provide a
strike:
In [ 7 ]: me_call = market_environment(‘me_call’, me_gbm.pricing_date)
In [ 8 ]: me_call.add_constant(‘strike’, 40.)
me_call.add_constant(‘maturity’, dt.datetime( 2015 , 12 , 31 ))
me_call.add_constant(‘currency’, ‘EUR’)
A central element, of course, is the payoff function, provided here as a string object
containing Python code that the eval function can evaluate. We want to define a European
call option. Such an option has a payoff of hT = max(ST – K,0), with ST being the value of
the underlying at maturity and K being the strike price of the option. In Python and NumPy
— i.e., with vectorized storage of all simulated values — this takes on the following form:
In [ 9 ]: payoff_func = ‘np.maximum(maturity_value - strike, 0)’
We can now put all the ingredients together to instantiate the valuation_mcs_european
class:
In [ 10 ]: from valuation_mcs_european import valuation_mcs_european
In [ 11 ]: eur_call = valuation_mcs_european(‘eur_call’, underlying=gbm,
mar_env=me_call, payoff_func=payoff_func)
With this valuation object available, all quantities of interest are only one method call
away. Let us start with the present value of the option:
In [ 12 ]: %time eur_call.present_value()
Out[12]: CPU times: user 41.7 ms, sys: 11 ms, total: 52.7 ms
Wall time: 44.6 ms
Out[12]: 2.180511
The Delta of the option is, as expected for a European call option, positive — i.e., the
present value of the option increases with increasing initial value of the underlying:
In [ 13 ]: %time eur_call.delta()
Out[13]: CPU times: user 10.9 ms, sys: 1.09 ms, total: 12 ms
Wall time: 11.1 ms
0.4596
The Vega is calculated similarly. It shows the increase in the present value of the option
given an increase in the initial volatility of 1%; e.g., from 24% to 25%. The Vega is
positive for both European put and call options:
In [ 14 ]: %time eur_call.vega()
Out[14]: CPU times: user 15.2 ms, sys: 1.34 ms, total: 16.5 ms
Wall time: 15.6 ms
14.2782
Once we have the valuation object, a more comprehensive analysis of the present value
and the Greeks is easily implemented. The following code calculates the present value,
Delta, and Vega for initial values of the underlying ranging from 34 to 46 EUR:
In [ 15 ]: %%time
s_list = np.arange(34., 46.1, 2.)
p_list = []; d_list = []; v_list = []
for s in s_list: