Python for Finance: Analyze Big Financial Data

(Elle) #1

relevant European call options. They only differentiate themselves by the relevant strike


price; everything else in the market environment is the same. We store the single valuation


objects in a dict object. As keys for the dict object, we take the index values of the


option quotes in the DataFrame object option_selection for unique identification:


In  [ 40 ]: option_models   =   {}
for option in option_selection.index:
strike = option_selection[‘STRIKE’].ix[option]
me_vstoxx.add_constant(‘strike’, strike)
option_models[option] = \
valuation_mcs_european(
‘eur_call_%d’ % strike,
vstoxx_model,
me_vstoxx,
payoff_func)

A single step in the calibration routine makes the updating of all valuation objects and a


revaluation of all options necessary. For convenience, we put this functionality into a


separate function:


In  [ 41 ]: def calculate_model_values(p0):
”’ Returns all relevant option values.

                                                    Parameters
===========
p0 : tuple/list
tuple of kappa, theta, volatility

                                                    Returns
=======
model_values : dict
dictionary with model values
”’
kappa, theta, volatility = p0
vstoxx_model.update(kappa=kappa,
theta=theta,
volatility=volatility)
model_values = {}
for option in option_models:
model_values[option] = \
option_models[option].present_value(fixed_seed=True)
return model_values

Providing a parameter tuple of kappa, theta, and volatility to the function


calculate_model_values gives back, ceteris paribus, model option values for all relevant


options:


In  [ 42 ]: calculate_model_values((0.5,    27.5,   vol_est))
Out[42]: {46482: 3.206401,
46483: 2.412354,
46484: 1.731028,
46485: 1.178823,
46486: 0.760421,
46487: 0.46249,
46488: 0.263662,
46489: 0.142177,
46490: 0.07219}

Calibration Procedure


Calibration of an option pricing model is, in general, a convex optimization problem. The


most widely used function used for the calibration — i.e., the minimization — is the


mean-squared error (MSE) for the model option values given the market quotes of the


options. Assume there are N relevant options, and also model and market quotes. The


problem of calibrating a financial model to the market quotes based on the MSE is then


given in Equation 19-1. There, and are the market price and the model price of the

Free download pdf