to be modeled. This is the first time that the DX analytics library comes into play;
everything else so far was “just” preparation for the following derivatives analytics tasks.
We begin by importing the library:
In [ 27 ]: from dx import *
The first task is then the definition of a market_environment object for the VSTOXX
index, in which we mainly store the previously collected and/or defined data:
In [ 28 ]: me_vstoxx = market_environment(‘me_vstoxx’, pricing_date)
In [ 29 ]: me_vstoxx.add_constant(‘initial_value’, initial_value)
me_vstoxx.add_constant(‘final_date’, maturity)
me_vstoxx.add_constant(‘currency’, ‘EUR’)
In [ 30 ]: me_vstoxx.add_constant(‘frequency’, ‘B’)
me_vstoxx.add_constant(‘paths’, 10000 )
In [ 31 ]: csr = constant_short_rate(‘csr’, 0.01)
# somewhat arbitrarily chosen here
In [ 32 ]: me_vstoxx.add_curve(‘discount_curve’, csr)
The major goal of the calibration procedure is to derive optimal parameters for the
square_root_diffusion simulation class, namely kappa, theta, and volatility. These
are the, so to say, degrees of freedom that this class offers. All other parameters are in
general dictated by the market or the task at hand.
Although the three (optimal) parameters are to be numerically derived, we need to provide
some dummy values to instantiate the simulation class. For the volatility parameter, we
take the historical volatility given our data set:
In [ 33 ]: # parameters to be calibrated later
me_vstoxx.add_constant(‘kappa’, 1.0)
me_vstoxx.add_constant(‘theta’, 1.2 * initial_value)
vol_est = vstoxx_index[‘V2TX’].std() \
* np.sqrt(len(vstoxx_index[‘V2TX’]) / 252.)
me_vstoxx.add_constant(‘volatility’, vol_est)
In [ 34 ]: vol_est
Out[34]: 1.0384283035169406
Then we provide the market_environment object to the simulation class:
In [ 35 ]: vstoxx_model = square_root_diffusion(‘vstoxx_model’, me_vstoxx)
Although the DX library is designed to be completely modular, to model risk factors
independently (and nonredundantly) from the derivatives to be valued, this does not
necessarily have to be the case when it comes to a market_environment object. A single
such object can be used for both the underlying risk factor and the option to be valued. To
complete the market environment for use with a valuation class, just add values for the
strike and the option maturity:
In [ 36 ]: me_vstoxx.add_constant(‘strike’, forward)
me_vstoxx.add_constant(‘maturity’, maturity)
Of course, a payoff function is also needed to instantiate the valuation class:
In [ 37 ]: payoff_func = ‘np.maximum(maturity_value - strike, 0)’
In [ 38 ]: vstoxx_eur_call = valuation_mcs_european(‘vstoxx_eur_call’,
vstoxx_model, me_vstoxx, payoff_func)
A brief sanity check to see if the modeling so far works “in principle”:
In [ 39 ]: vstoxx_eur_call.present_value()
Out[39]: 0.379032
To calibrate the model to the previously selected option quotes, we need to model all