The Python Quants

DX Analytics Library

Calibration Series for VSTOXX Volatility Options

In [1]:
import numpy as np
import pandas as pd

VSTOXX Data & Basic Functions

Load VSTOXX data from Eurex.

In [2]:
h5 = pd.HDFStore('./data/vstoxx_march_2014.h5', 'r')
vstoxx_index = h5['vstoxx_index'] 
vstoxx_futures = h5['vstoxx_futures'] 
vstoxx_options = h5['vstoxx_options']
h5.close()

VSTOXX index for first quarter of 2014.

In [3]:
%matplotlib inline
vstoxx_index['V2TX'].plot()
Out[3]:
<matplotlib.axes.AxesSubplot at 0x1084ebb90>

The VSTOXX futures data.

In [4]:
vstoxx_futures.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 504 entries, 0 to 503
Data columns (total 5 columns):
DATE         504 non-null datetime64[ns]
EXP_YEAR     504 non-null int64
EXP_MONTH    504 non-null int64
PRICE        504 non-null float64
MATURITY     504 non-null datetime64[ns]
dtypes: datetime64[ns](2), float64(1), int64(2)

The VSTOXX options data.

In [5]:
vstoxx_options.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 46960 entries, 0 to 46959
Data columns (total 7 columns):
DATE         46960 non-null datetime64[ns]
EXP_YEAR     46960 non-null int64
EXP_MONTH    46960 non-null int64
TYPE         46960 non-null object
STRIKE       46960 non-null float64
PRICE        46960 non-null float64
MATURITY     46960 non-null datetime64[ns]
dtypes: datetime64[ns](2), float64(2), int64(2), object(1)

Function to calculate all relevant third Fridays.

In [6]:
import datetime as dt
import calendar

def third_friday(date):
    day = 21 - (calendar.weekday(date.year, date.month, 1) + 2) % 7
    return dt.datetime(date.year, date.month, day)
In [7]:
third_fridays = {}
for month in set(vstoxx_futures['EXP_MONTH']):
    third_fridays[month] = third_friday(dt.datetime(2014, month, 1))
In [8]:
third_fridays
Out[8]:
{1: datetime.datetime(2014, 1, 17, 0, 0),
 2: datetime.datetime(2014, 2, 21, 0, 0),
 3: datetime.datetime(2014, 3, 21, 0, 0),
 4: datetime.datetime(2014, 4, 18, 0, 0),
 5: datetime.datetime(2014, 5, 16, 0, 0),
 6: datetime.datetime(2014, 6, 20, 0, 0),
 7: datetime.datetime(2014, 7, 18, 0, 0),
 8: datetime.datetime(2014, 8, 15, 0, 0),
 9: datetime.datetime(2014, 9, 19, 0, 0),
 10: datetime.datetime(2014, 10, 17, 0, 0),
 11: datetime.datetime(2014, 11, 21, 0, 0)}

Model Calibration

Relevant Market Data

In [9]:
def get_option_selection(pricing_date, maturity, tol=0.125):
    ''' Function selects relevant options data. '''
    forward = vstoxx_futures[(vstoxx_futures.DATE == pricing_date)
                & (vstoxx_futures.MATURITY == maturity)]['PRICE'].values[0]
    option_selection = \
        vstoxx_options[(vstoxx_options.DATE == pricing_date)
                     & (vstoxx_options.MATURITY == maturity)
                     & (vstoxx_options.TYPE == 'C')
                     & (vstoxx_options.STRIKE > (1 - tol) * forward)
                     & (vstoxx_options.STRIKE < (1 + tol) * forward)]
    return option_selection, forward

Option Modelling

In [10]:
from dx import *
In [11]:
def get_option_models(pricing_date, maturity, option_selection):
    ''' Models traded options for given option_selection object. '''
    me_vstoxx = market_environment('me_vstoxx', pricing_date)
    initial_value = vstoxx_index['V2TX'][pricing_date]
    me_vstoxx.add_constant('initial_value', initial_value)
    me_vstoxx.add_constant('final_date', maturity)
    me_vstoxx.add_constant('currency', 'EUR')
    me_vstoxx.add_constant('frequency', 'W')
    me_vstoxx.add_constant('paths', 25000)
    csr = constant_short_rate('csr', 0.01)
      # somewhat arbitrarily chosen here
    me_vstoxx.add_curve('discount_curve', csr)
    
    # parameters to be calibrated later
    me_vstoxx.add_constant('kappa', 1.0)
    me_vstoxx.add_constant('theta', 1.2 * initial_value)
    me_vstoxx.add_constant('volatility', 1.0)
    
    vstoxx_model = square_root_diffusion('vstoxx_model', me_vstoxx)
      # square-root diffusion for volatility modeling
      # mean-reverting, positive process
    
    # option parameters and payoff
    me_vstoxx.add_constant('maturity', maturity)
    payoff_func = 'np.maximum(maturity_value - strike, 0)'
    
    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_single(
                                    'eur_call_%d' % strike,
                                    vstoxx_model,
                                    me_vstoxx,
                                    payoff_func)
    return vstoxx_model, option_models
In [12]:
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

Calibration Procedure

In [13]:
i = 0
def mean_squared_error(p0):
    ''' Returns the mean-squared error given
    the model and market values.
    
    Parameters
    ===========
    p0 : tuple/list
        tuple of kappa, theta, volatility
    
    Returns
    =======
    MSE : float
        mean-squared error
    '''
    if p0[0] < 0 or p0[1] < 5. or p0[2] < 0 or p0[2] > 10.:
        return 100
    global i, option_selection, vstoxx_model, option_models, first, last
    pd = dt.datetime.strftime(
            option_selection['DATE'].iloc[0].to_pydatetime(),
            '%d-%b-%Y')
    mat = dt.datetime.strftime(
            option_selection['MATURITY'].iloc[0].to_pydatetime(),
            '%d-%b-%Y')
    model_values = calculate_model_values(p0)
    option_diffs = {}
    for option in model_values:
        option_diffs[option] = (model_values[option]
                              - option_selection['PRICE'].loc[option])
    MSE = np.sum(np.array(option_diffs.values()) ** 2) / len(option_diffs)
    if i % 50 == 0:
        if i == 0:
            print '%12s %13s %4s  %6s  %6s  %6s --> %6s' % \
                 ('pricing_date', 'maturity_date', 'i', 'kappa',
                  'theta', 'vola', 'MSE')
        print '%12s %13s %4d  %6.3f  %6.3f  %6.3f  --> %6.3f' % \
                (pd, mat, i, p0[0], p0[1], p0[2], MSE)
    i += 1
    return MSE
In [14]:
import scipy.optimize as spo
def get_parameter_series(pricing_date_list, maturity_list):
    global i, option_selection, vstoxx_model, option_models, first, last
    # collects optimization results for later use (eg. visualization)
    parameters = pd.DataFrame()
    for maturity in maturity_list:
        first = True
        for pricing_date in pricing_date_list:
            option_selection, forward = \
                    get_option_selection(pricing_date, maturity)
            vstoxx_model, option_models = \
                    get_option_models(pricing_date, maturity, option_selection)
            if first is True:
                # use brute force for the first run
                i = 0
                opt = spo.brute(mean_squared_error,
                    ((0.5, 2.51, 1.),   # range for kappa
                     (10., 20.1, 5.),   # range for theta
                     (0.5, 10.51, 5.0)),  # range for volatility
                     finish=None)
            i = 0
            opt = spo.fmin(mean_squared_error, opt,
                 maxiter=150, maxfun=250, xtol=0.0000001, ftol=0.0000001)
            parameters = parameters.append(
                     pd.DataFrame(
                     {'pricing_date' : pricing_date,
                      'maturity' : maturity,
                      'initial_value' : vstoxx_model.initial_value,
                      'kappa' : opt[0],
                      'theta' : opt[1],
                      'sigma' : opt[2],
                      'MSE' : mean_squared_error(opt)}, index=[0,]),
                     ignore_index=True)
            first = False
            last = opt
    return parameters
In [15]:
%%time
pricing_date_list = pd.date_range('2014/1/2', '2014/3/31', freq='B')
maturity_list = [third_fridays[7]]
parameters = get_parameter_series(pricing_date_list, maturity_list)
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 02-Jan-2014   18-Jul-2014    0   0.500  10.000   0.500  -->  8.822
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 02-Jan-2014   18-Jul-2014    0   1.500  15.000   5.500  -->  0.031
 02-Jan-2014   18-Jul-2014   50   1.389  20.877   3.824  -->  0.001
 02-Jan-2014   18-Jul-2014  100   1.388  20.774   3.836  -->  0.001
 02-Jan-2014   18-Jul-2014  150   1.388  20.775   3.835  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000676
         Iterations: 85
         Function evaluations: 189
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 03-Jan-2014   18-Jul-2014    0   1.388  20.775   3.835  -->  0.039
 03-Jan-2014   18-Jul-2014   50   1.373  21.295   3.920  -->  0.000
 03-Jan-2014   18-Jul-2014  100   1.375  21.275   3.926  -->  0.000
 03-Jan-2014   18-Jul-2014  150   1.375  21.275   3.926  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000436
         Iterations: 72
         Function evaluations: 172
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 06-Jan-2014   18-Jul-2014    0   1.375  21.275   3.926  -->  0.031
 06-Jan-2014   18-Jul-2014   50   1.442  20.978   3.831  -->  0.000
 06-Jan-2014   18-Jul-2014  100   1.401  20.927   3.830  -->  0.000
 06-Jan-2014   18-Jul-2014  150   1.223  21.164   3.704  -->  0.000
 06-Jan-2014   18-Jul-2014  200   1.228  21.155   3.708  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
 06-Jan-2014   18-Jul-2014  250   1.228  21.155   3.708  -->  0.000
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 07-Jan-2014   18-Jul-2014    0   1.228  21.155   3.708  -->  0.010
 07-Jan-2014   18-Jul-2014   50   1.242  21.591   3.721  -->  0.000
 07-Jan-2014   18-Jul-2014  100   1.242  21.703   3.694  -->  0.000
 07-Jan-2014   18-Jul-2014  150   1.242  21.703   3.694  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000047
         Iterations: 78
         Function evaluations: 177
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 08-Jan-2014   18-Jul-2014    0   1.242  21.703   3.694  -->  0.001
 08-Jan-2014   18-Jul-2014   50   1.280  21.475   3.713  -->  0.000
 08-Jan-2014   18-Jul-2014  100   1.279  21.446   3.721  -->  0.000
 08-Jan-2014   18-Jul-2014  150   1.279  21.446   3.721  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000047
         Iterations: 70
         Function evaluations: 166
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 09-Jan-2014   18-Jul-2014    0   1.279  21.446   3.721  -->  0.012
 09-Jan-2014   18-Jul-2014   50   1.270  21.446   3.844  -->  0.000
 09-Jan-2014   18-Jul-2014  100   1.273  21.456   3.843  -->  0.000
 09-Jan-2014   18-Jul-2014  150   1.273  21.456   3.843  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000063
         Iterations: 77
         Function evaluations: 176
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 10-Jan-2014   18-Jul-2014    0   1.273  21.456   3.843  -->  0.013
 10-Jan-2014   18-Jul-2014   50   1.284  21.664   3.920  -->  0.001
 10-Jan-2014   18-Jul-2014  100   1.283  21.627   3.929  -->  0.001
 10-Jan-2014   18-Jul-2014  150   1.283  21.627   3.929  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000938
         Iterations: 69
         Function evaluations: 167
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 13-Jan-2014   18-Jul-2014    0   1.283  21.627   3.929  -->  0.013
 13-Jan-2014   18-Jul-2014   50   1.348  21.269   3.901  -->  0.001
 13-Jan-2014   18-Jul-2014  100   1.345  21.216   3.913  -->  0.001
 13-Jan-2014   18-Jul-2014  150   1.345  21.216   3.912  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000523
         Iterations: 67
         Function evaluations: 155
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 14-Jan-2014   18-Jul-2014    0   1.345  21.216   3.912  -->  0.004
 14-Jan-2014   18-Jul-2014   50   1.375  21.431   3.932  -->  0.001
 14-Jan-2014   18-Jul-2014  100   1.399  21.647   3.882  -->  0.001
 14-Jan-2014   18-Jul-2014  150   1.399  21.648   3.881  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000500
         Iterations: 81
         Function evaluations: 187
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 15-Jan-2014   18-Jul-2014    0   1.399  21.648   3.881  -->  0.009
 15-Jan-2014   18-Jul-2014   50   1.336  21.108   4.106  -->  0.000
 15-Jan-2014   18-Jul-2014  100   1.310  20.788   4.186  -->  0.000
 15-Jan-2014   18-Jul-2014  150   1.420  20.600   4.262  -->  0.000
 15-Jan-2014   18-Jul-2014  200   1.704  20.224   4.459  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
 15-Jan-2014   18-Jul-2014  250   1.900  20.018   4.601  -->  0.000
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 16-Jan-2014   18-Jul-2014    0   1.900  20.018   4.601  -->  0.000
 16-Jan-2014   18-Jul-2014   50   1.948  19.897   4.656  -->  0.000
 16-Jan-2014   18-Jul-2014  100   2.030  19.792   4.736  -->  0.000
 16-Jan-2014   18-Jul-2014  150   2.473  19.590   5.048  -->  0.000
 16-Jan-2014   18-Jul-2014  200   2.443  19.601   5.028  -->  0.000
 16-Jan-2014   18-Jul-2014  250   2.444  19.601   5.028  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 17-Jan-2014   18-Jul-2014    0   2.444  19.601   5.028  -->  0.005
 17-Jan-2014   18-Jul-2014   50   2.479  19.714   5.084  -->  0.001
 17-Jan-2014   18-Jul-2014  100   2.483  19.615   5.133  -->  0.001
 17-Jan-2014   18-Jul-2014  150   2.483  19.615   5.133  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000611
         Iterations: 73
         Function evaluations: 173
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 20-Jan-2014   18-Jul-2014    0   2.483  19.615   5.133  -->  0.001
 20-Jan-2014   18-Jul-2014   50   2.562  19.553   5.157  -->  0.000
 20-Jan-2014   18-Jul-2014  100   2.566  19.577   5.149  -->  0.000
 20-Jan-2014   18-Jul-2014  150   2.566  19.577   5.149  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000436
         Iterations: 62
         Function evaluations: 152
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 21-Jan-2014   18-Jul-2014    0   2.566  19.577   5.149  -->  0.005
 21-Jan-2014   18-Jul-2014   50   2.649  19.381   5.176  -->  0.001
 21-Jan-2014   18-Jul-2014  100   2.657  19.352   5.193  -->  0.001
 21-Jan-2014   18-Jul-2014  150   2.671  19.339   5.205  -->  0.001
 21-Jan-2014   18-Jul-2014  200   2.671  19.339   5.205  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000606
         Iterations: 99
         Function evaluations: 217
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 22-Jan-2014   18-Jul-2014    0   2.671  19.339   5.205  -->  0.004
 22-Jan-2014   18-Jul-2014   50   2.688  18.945   5.477  -->  0.000
 22-Jan-2014   18-Jul-2014  100   2.686  18.785   5.559  -->  0.000
 22-Jan-2014   18-Jul-2014  150   2.570  18.816   5.476  -->  0.000
 22-Jan-2014   18-Jul-2014  200   2.575  18.816   5.479  -->  0.000
 22-Jan-2014   18-Jul-2014  250   2.575  18.816   5.479  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 23-Jan-2014   18-Jul-2014    0   2.575  18.816   5.479  -->  0.016
 23-Jan-2014   18-Jul-2014   50   2.686  18.619   5.473  -->  0.001
 23-Jan-2014   18-Jul-2014  100   2.768  18.978   5.346  -->  0.000
 23-Jan-2014   18-Jul-2014  150   2.768  18.979   5.346  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000449
         Iterations: 83
         Function evaluations: 189
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 24-Jan-2014   18-Jul-2014    0   2.768  18.979   5.346  -->  0.023
 24-Jan-2014   18-Jul-2014   50   2.822  18.414   5.463  -->  0.001
 24-Jan-2014   18-Jul-2014  100   2.819  18.330   5.488  -->  0.001
 24-Jan-2014   18-Jul-2014  150   2.819  18.329   5.489  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000944
         Iterations: 87
         Function evaluations: 183
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 27-Jan-2014   18-Jul-2014    0   2.819  18.329   5.489  -->  0.004
 27-Jan-2014   18-Jul-2014   50   2.860  18.641   5.459  -->  0.001
 27-Jan-2014   18-Jul-2014  100   3.110  18.749   5.641  -->  0.001
 27-Jan-2014   18-Jul-2014  150   3.543  18.857   5.968  -->  0.001
 27-Jan-2014   18-Jul-2014  200   4.139  18.959   6.398  -->  0.001
Warning: Maximum number of function evaluations has been exceeded.
 27-Jan-2014   18-Jul-2014  250   4.985  19.067   6.966  -->  0.001
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 28-Jan-2014   18-Jul-2014    0   4.985  19.067   6.966  -->  0.050
 28-Jan-2014   18-Jul-2014   50   5.166  18.646   6.990  -->  0.000
 28-Jan-2014   18-Jul-2014  100   5.189  18.788   6.892  -->  0.000
 28-Jan-2014   18-Jul-2014  150   5.190  18.789   6.892  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000409
         Iterations: 81
         Function evaluations: 184
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 29-Jan-2014   18-Jul-2014    0   5.190  18.789   6.892  -->  0.003
 29-Jan-2014   18-Jul-2014   50   5.254  18.862   6.983  -->  0.000
 29-Jan-2014   18-Jul-2014  100   5.296  18.909   6.975  -->  0.000
 29-Jan-2014   18-Jul-2014  150   5.326  18.912   6.994  -->  0.000
 29-Jan-2014   18-Jul-2014  200   5.910  18.989   7.337  -->  0.000
 29-Jan-2014   18-Jul-2014  250   5.938  18.967   7.372  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 30-Jan-2014   18-Jul-2014    0   5.938  18.967   7.372  -->  0.007
 30-Jan-2014   18-Jul-2014   50   6.271  19.014   7.367  -->  0.000
 30-Jan-2014   18-Jul-2014  100   6.272  19.019   7.365  -->  0.000
 30-Jan-2014   18-Jul-2014  150   6.272  19.019   7.365  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000358
         Iterations: 60
         Function evaluations: 157
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 31-Jan-2014   18-Jul-2014    0   6.272  19.019   7.365  -->  0.020
 31-Jan-2014   18-Jul-2014   50   6.266  18.742   7.914  -->  0.001
 31-Jan-2014   18-Jul-2014  100   6.706  18.851   8.096  -->  0.001
 31-Jan-2014   18-Jul-2014  150   6.647  18.830   8.076  -->  0.001
 31-Jan-2014   18-Jul-2014  200   6.649  18.827   8.081  -->  0.001
Warning: Maximum number of function evaluations has been exceeded.
 31-Jan-2014   18-Jul-2014  250   6.649  18.827   8.081  -->  0.001
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 03-Feb-2014   18-Jul-2014    0   6.649  18.827   8.081  -->  0.047
 03-Feb-2014   18-Jul-2014   50   6.621  19.116   8.273  -->  0.001
 03-Feb-2014   18-Jul-2014  100   6.638  19.215   8.197  -->  0.001
 03-Feb-2014   18-Jul-2014  150   6.638  19.215   8.196  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000699
         Iterations: 73
         Function evaluations: 177
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 04-Feb-2014   18-Jul-2014    0   6.638  19.215   8.196  -->  0.002
 04-Feb-2014   18-Jul-2014   50   6.721  19.280   8.286  -->  0.000
 04-Feb-2014   18-Jul-2014  100   6.753  19.371   8.219  -->  0.000
 04-Feb-2014   18-Jul-2014  150   6.752  19.366   8.224  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000179
         Iterations: 87
         Function evaluations: 198
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 05-Feb-2014   18-Jul-2014    0   6.752  19.366   8.224  -->  0.009
 05-Feb-2014   18-Jul-2014   50   6.922  19.830   8.083  -->  0.001
 05-Feb-2014   18-Jul-2014  100   6.972  20.099   7.861  -->  0.001
 05-Feb-2014   18-Jul-2014  150   6.972  20.098   7.862  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000563
         Iterations: 74
         Function evaluations: 184
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 06-Feb-2014   18-Jul-2014    0   6.972  20.098   7.862  -->  0.019
 06-Feb-2014   18-Jul-2014   50   7.017  19.737   7.938  -->  0.000
 06-Feb-2014   18-Jul-2014  100   6.878  19.766   7.831  -->  0.000
 06-Feb-2014   18-Jul-2014  150   6.704  19.772   7.729  -->  0.000
 06-Feb-2014   18-Jul-2014  200   6.704  19.772   7.729  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000400
         Iterations: 100
         Function evaluations: 221
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 07-Feb-2014   18-Jul-2014    0   6.704  19.772   7.729  -->  0.155
 07-Feb-2014   18-Jul-2014   50   7.118  19.385   7.451  -->  0.001
 07-Feb-2014   18-Jul-2014  100   7.119  19.398   7.439  -->  0.001
 07-Feb-2014   18-Jul-2014  150   7.119  19.398   7.439  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000857
         Iterations: 66
         Function evaluations: 159
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 10-Feb-2014   18-Jul-2014    0   7.119  19.398   7.439  -->  0.001
 10-Feb-2014   18-Jul-2014   50   7.278  19.443   7.408  -->  0.000
 10-Feb-2014   18-Jul-2014  100   7.310  19.505   7.356  -->  0.000
 10-Feb-2014   18-Jul-2014  150   7.310  19.505   7.356  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000054
         Iterations: 73
         Function evaluations: 177
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 11-Feb-2014   18-Jul-2014    0   7.310  19.505   7.356  -->  0.045
 11-Feb-2014   18-Jul-2014   50   7.570  19.082   7.399  -->  0.000
 11-Feb-2014   18-Jul-2014  100   7.546  18.943   7.535  -->  0.000
 11-Feb-2014   18-Jul-2014  150   7.444  18.954   7.480  -->  0.000
 11-Feb-2014   18-Jul-2014  200   7.393  18.950   7.461  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
 11-Feb-2014   18-Jul-2014  250   7.392  18.950   7.461  -->  0.000
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 12-Feb-2014   18-Jul-2014    0   7.392  18.950   7.461  -->  0.001
 12-Feb-2014   18-Jul-2014   50   7.530  18.885   7.553  -->  0.000
 12-Feb-2014   18-Jul-2014  100   7.600  18.824   7.644  -->  0.000
 12-Feb-2014   18-Jul-2014  150   7.302  18.828   7.505  -->  0.000
 12-Feb-2014   18-Jul-2014  200   7.305  18.828   7.507  -->  0.000
 12-Feb-2014   18-Jul-2014  250   7.305  18.828   7.507  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 13-Feb-2014   18-Jul-2014    0   7.305  18.828   7.507  -->  0.002
 13-Feb-2014   18-Jul-2014   50   7.409  18.896   7.577  -->  0.001
 13-Feb-2014   18-Jul-2014  100   7.421  19.000   7.480  -->  0.001
 13-Feb-2014   18-Jul-2014  150   7.534  19.000   7.530  -->  0.001
 13-Feb-2014   18-Jul-2014  200   7.537  19.000   7.530  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000741
         Iterations: 110
         Function evaluations: 240
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 14-Feb-2014   18-Jul-2014    0   7.537  19.000   7.530  -->  0.005
 14-Feb-2014   18-Jul-2014   50   7.983  18.993   7.550  -->  0.000
 14-Feb-2014   18-Jul-2014  100   8.622  18.994   7.802  -->  0.000
 14-Feb-2014   18-Jul-2014  150   8.947  18.961   7.959  -->  0.000
 14-Feb-2014   18-Jul-2014  200   8.924  18.964   7.947  -->  0.000
 14-Feb-2014   18-Jul-2014  250   8.924  18.964   7.947  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 17-Feb-2014   18-Jul-2014    0   8.924  18.964   7.947  -->  0.001
 17-Feb-2014   18-Jul-2014   50   8.940  18.918   8.077  -->  0.001
 17-Feb-2014   18-Jul-2014  100   8.961  18.942   8.057  -->  0.001
 17-Feb-2014   18-Jul-2014  150   8.961  18.942   8.057  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000670
         Iterations: 73
         Function evaluations: 170
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 18-Feb-2014   18-Jul-2014    0   8.961  18.942   8.057  -->  0.001
 18-Feb-2014   18-Jul-2014   50   9.386  18.611   8.562  -->  0.000
 18-Feb-2014   18-Jul-2014  100   9.378  18.655   8.514  -->  0.000
 18-Feb-2014   18-Jul-2014  150   9.916  18.650   8.729  -->  0.000
 18-Feb-2014   18-Jul-2014  200   9.904  18.649   8.726  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
 18-Feb-2014   18-Jul-2014  250   9.904  18.649   8.726  -->  0.000
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 19-Feb-2014   18-Jul-2014    0   9.904  18.649   8.726  -->  0.004
 19-Feb-2014   18-Jul-2014   50  10.600  18.868   8.580  -->  0.001
 19-Feb-2014   18-Jul-2014  100  10.374  18.872   8.494  -->  0.001
 19-Feb-2014   18-Jul-2014  150  10.367  18.871   8.493  -->  0.001
 19-Feb-2014   18-Jul-2014  200  10.367  18.871   8.493  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000902
         Iterations: 83
         Function evaluations: 201
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 20-Feb-2014   18-Jul-2014    0  10.367  18.871   8.493  -->  0.003
 20-Feb-2014   18-Jul-2014   50  10.497  18.915   8.598  -->  0.001
 20-Feb-2014   18-Jul-2014  100   8.821  18.594   8.311  -->  0.001
 20-Feb-2014   18-Jul-2014  150   8.292  18.541   8.140  -->  0.001
 20-Feb-2014   18-Jul-2014  200   8.228  18.543   8.110  -->  0.001
Warning: Maximum number of function evaluations has been exceeded.
 20-Feb-2014   18-Jul-2014  250   8.228  18.543   8.110  -->  0.001
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 21-Feb-2014   18-Jul-2014    0   8.228  18.543   8.110  -->  0.041
 21-Feb-2014   18-Jul-2014   50   8.640  18.303   8.064  -->  0.001
 21-Feb-2014   18-Jul-2014  100   9.123  18.760   7.714  -->  0.000
 21-Feb-2014   18-Jul-2014  150   9.122  18.760   7.714  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000298
         Iterations: 91
         Function evaluations: 199
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 24-Feb-2014   18-Jul-2014    0   9.122  18.760   7.714  -->  0.000
 24-Feb-2014   18-Jul-2014   50   9.906  18.471   8.323  -->  0.000
 24-Feb-2014   18-Jul-2014  100  10.046  18.478   8.371  -->  0.000
 24-Feb-2014   18-Jul-2014  150  11.115  18.454   8.774  -->  0.000
 24-Feb-2014   18-Jul-2014  200  11.368  18.448   8.867  -->  0.000
 24-Feb-2014   18-Jul-2014  250  11.375  18.449   8.869  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 25-Feb-2014   18-Jul-2014    0  11.375  18.449   8.869  -->  0.002
 25-Feb-2014   18-Jul-2014   50  11.566  18.298   9.017  -->  0.000
 25-Feb-2014   18-Jul-2014  100  11.505  18.246   9.067  -->  0.000
 25-Feb-2014   18-Jul-2014  150  11.505  18.246   9.067  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000403
         Iterations: 73
         Function evaluations: 178
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 26-Feb-2014   18-Jul-2014    0  11.505  18.246   9.067  -->  0.000
 26-Feb-2014   18-Jul-2014   50  11.870  18.416   8.944  -->  0.000
 26-Feb-2014   18-Jul-2014  100  11.775  18.451   8.860  -->  0.000
 26-Feb-2014   18-Jul-2014  150  11.370  18.458   8.721  -->  0.000
 26-Feb-2014   18-Jul-2014  200  11.365  18.458   8.719  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000023
         Iterations: 104
         Function evaluations: 243
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 27-Feb-2014   18-Jul-2014    0  11.365  18.458   8.719  -->  0.004
 27-Feb-2014   18-Jul-2014   50  11.497  18.484   8.892  -->  0.001
 27-Feb-2014   18-Jul-2014  100  11.413  18.237   9.183  -->  0.000
 27-Feb-2014   18-Jul-2014  150  11.413  18.238   9.181  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000425
         Iterations: 82
         Function evaluations: 195
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 28-Feb-2014   18-Jul-2014    0  11.413  18.238   9.181  -->  0.002
 28-Feb-2014   18-Jul-2014   50  11.644  18.139   9.281  -->  0.000
 28-Feb-2014   18-Jul-2014  100  11.585  18.110   9.296  -->  0.000
 28-Feb-2014   18-Jul-2014  150  11.585  18.110   9.296  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000276
         Iterations: 68
         Function evaluations: 163
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 03-Mar-2014   18-Jul-2014    0  11.585  18.110   9.296  -->  0.126
 03-Mar-2014   18-Jul-2014   50  10.781  18.236   9.836  -->  0.001
 03-Mar-2014   18-Jul-2014  100  10.870  18.304   9.791  -->  0.001
 03-Mar-2014   18-Jul-2014  150  10.870  18.304   9.791  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000680
         Iterations: 79
         Function evaluations: 183
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 04-Mar-2014   18-Jul-2014    0  10.870  18.304   9.791  -->  0.121
 04-Mar-2014   18-Jul-2014   50  11.750  18.080   9.421  -->  0.001
 04-Mar-2014   18-Jul-2014  100  11.781  18.097   9.417  -->  0.001
 04-Mar-2014   18-Jul-2014  150  11.782  18.098   9.416  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000954
         Iterations: 76
         Function evaluations: 178
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 05-Mar-2014   18-Jul-2014    0  11.782  18.098   9.416  -->  0.006
 05-Mar-2014   18-Jul-2014   50  13.271  18.344   9.363  -->  0.001
 05-Mar-2014   18-Jul-2014  100  13.674  18.321   9.517  -->  0.001
 05-Mar-2014   18-Jul-2014  150  13.669  18.322   9.514  -->  0.001
 05-Mar-2014   18-Jul-2014  200  13.669  18.322   9.514  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000803
         Iterations: 86
         Function evaluations: 203
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 06-Mar-2014   18-Jul-2014    0  13.669  18.322   9.514  -->  0.003
 06-Mar-2014   18-Jul-2014   50  14.198  18.301   9.546  -->  0.001
 06-Mar-2014   18-Jul-2014  100  14.256  18.326   9.527  -->  0.001
 06-Mar-2014   18-Jul-2014  150  14.256  18.327   9.527  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000774
         Iterations: 71
         Function evaluations: 180
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 07-Mar-2014   18-Jul-2014    0  14.256  18.327   9.527  -->  0.007
 07-Mar-2014   18-Jul-2014   50  14.436  18.461   9.630  -->  0.001
 07-Mar-2014   18-Jul-2014  100  14.441  18.480   9.615  -->  0.001
 07-Mar-2014   18-Jul-2014  150  14.441  18.480   9.615  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000514
         Iterations: 67
         Function evaluations: 159
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 10-Mar-2014   18-Jul-2014    0  14.441  18.480   9.615  -->  0.064
 10-Mar-2014   18-Jul-2014   50  13.627  18.690   9.787  -->  0.002
 10-Mar-2014   18-Jul-2014  100  11.671  18.063   9.990  -->  0.000
 10-Mar-2014   18-Jul-2014  150  11.539  18.017   9.985  -->  0.000
 10-Mar-2014   18-Jul-2014  200  11.532  18.014   9.985  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 11-Mar-2014   18-Jul-2014    0  11.532  18.014   9.985  -->  0.007
 11-Mar-2014   18-Jul-2014   50  12.047  18.491   9.366  -->  0.000
 11-Mar-2014   18-Jul-2014  100  12.042  18.490   9.365  -->  0.000
 11-Mar-2014   18-Jul-2014  150  12.042  18.490   9.365  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000346
         Iterations: 81
         Function evaluations: 181
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 12-Mar-2014   18-Jul-2014    0  12.042  18.490   9.365  -->  0.001
 12-Mar-2014   18-Jul-2014   50  12.233  18.427   9.470  -->  0.001
 12-Mar-2014   18-Jul-2014  100  12.423  18.360   9.626  -->  0.001
 12-Mar-2014   18-Jul-2014  150  13.289  18.375   9.902  -->  0.001
 12-Mar-2014   18-Jul-2014  200  13.281  18.367   9.909  -->  0.001
 12-Mar-2014   18-Jul-2014  250  13.281  18.367   9.909  -->  0.001
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 13-Mar-2014   18-Jul-2014    0  13.281  18.367   9.909  -->  0.040
 13-Mar-2014   18-Jul-2014   50  13.322  19.022   9.652  -->  0.000
 13-Mar-2014   18-Jul-2014  100  13.344  19.077   9.584  -->  0.000
 13-Mar-2014   18-Jul-2014  150  13.344  19.078   9.583  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000443
         Iterations: 71
         Function evaluations: 174
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 14-Mar-2014   18-Jul-2014    0  13.344  19.078   9.583  -->  0.062
 14-Mar-2014   18-Jul-2014   50  13.321  19.693   9.521  -->  0.001
 14-Mar-2014   18-Jul-2014  100  13.242  19.317   9.975  -->  0.001
 14-Mar-2014   18-Jul-2014  150  13.244  19.318   9.973  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000710
         Iterations: 87
         Function evaluations: 195
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 17-Mar-2014   18-Jul-2014    0  13.244  19.318   9.973  -->  0.102
 17-Mar-2014   18-Jul-2014   50  13.924  18.834   9.896  -->  0.001
 17-Mar-2014   18-Jul-2014  100  13.631  18.695   9.997  -->  0.001
 17-Mar-2014   18-Jul-2014  150  12.054  18.270   9.985  -->  0.001
 17-Mar-2014   18-Jul-2014  200  10.919  18.284   9.507  -->  0.001
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 18-Mar-2014   18-Jul-2014    0  10.744  18.288   9.422  -->  0.020
 18-Mar-2014   18-Jul-2014   50  11.154  18.109   9.436  -->  0.001
 18-Mar-2014   18-Jul-2014  100  11.891  18.349   9.408  -->  0.001
 18-Mar-2014   18-Jul-2014  150  11.886  18.348   9.408  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000528
         Iterations: 85
         Function evaluations: 200
 18-Mar-2014   18-Jul-2014  200  11.887  18.348   9.408  -->  0.001
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 19-Mar-2014   18-Jul-2014    0  11.887  18.348   9.408  -->  0.008
 19-Mar-2014   18-Jul-2014   50  12.173  18.157   9.519  -->  0.001
 19-Mar-2014   18-Jul-2014  100  12.096  18.155   9.495  -->  0.001
 19-Mar-2014   18-Jul-2014  150  11.716  18.142   9.376  -->  0.001
 19-Mar-2014   18-Jul-2014  200  10.737  18.156   8.983  -->  0.001
 19-Mar-2014   18-Jul-2014  250  10.342  18.169   8.808  -->  0.001
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 20-Mar-2014   18-Jul-2014    0  10.349  18.169   8.811  -->  0.011
 20-Mar-2014   18-Jul-2014   50  10.874  18.206   8.677  -->  0.000
 20-Mar-2014   18-Jul-2014  100  10.752  18.180   8.667  -->  0.000
 20-Mar-2014   18-Jul-2014  150  10.625  18.179   8.620  -->  0.000
 20-Mar-2014   18-Jul-2014  200  10.622  18.179   8.619  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000425
         Iterations: 104
         Function evaluations: 230
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 21-Mar-2014   18-Jul-2014    0  10.622  18.179   8.619  -->  0.002
 21-Mar-2014   18-Jul-2014   50  11.036  18.341   8.638  -->  0.001
 21-Mar-2014   18-Jul-2014  100  10.586  18.330   8.509  -->  0.001
 21-Mar-2014   18-Jul-2014  150  10.521  18.327   8.488  -->  0.001
 21-Mar-2014   18-Jul-2014  200  10.521  18.327   8.488  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000804
         Iterations: 105
         Function evaluations: 234
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 24-Mar-2014   18-Jul-2014    0  10.521  18.327   8.488  -->  0.060
 24-Mar-2014   18-Jul-2014   50  10.405  18.617   8.768  -->  0.001
 24-Mar-2014   18-Jul-2014  100  10.343  18.048   9.402  -->  0.000
 24-Mar-2014   18-Jul-2014  150  10.349  18.051   9.400  -->  0.000
 24-Mar-2014   18-Jul-2014  200  10.349  18.051   9.400  -->  0.000
Optimization terminated successfully.
         Current function value: 0.000144
         Iterations: 98
         Function evaluations: 215
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 25-Mar-2014   18-Jul-2014    0  10.349  18.051   9.400  -->  0.022
 25-Mar-2014   18-Jul-2014   50  10.742  17.856   9.384  -->  0.001
 25-Mar-2014   18-Jul-2014  100  10.947  18.164   9.106  -->  0.001
 25-Mar-2014   18-Jul-2014  150  10.875  18.164   9.078  -->  0.001
 25-Mar-2014   18-Jul-2014  200  10.874  18.164   9.077  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000911
         Iterations: 104
         Function evaluations: 234
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 26-Mar-2014   18-Jul-2014    0  10.874  18.164   9.077  -->  0.025
 26-Mar-2014   18-Jul-2014   50  11.257  17.909   9.098  -->  0.000
 26-Mar-2014   18-Jul-2014  100  11.465  18.087   8.946  -->  0.000
 26-Mar-2014   18-Jul-2014  150  11.775  18.077   9.067  -->  0.000
 26-Mar-2014   18-Jul-2014  200  11.969  18.079   9.132  -->  0.000
 26-Mar-2014   18-Jul-2014  250  11.962  18.078   9.132  -->  0.000
Warning: Maximum number of function evaluations has been exceeded.
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 27-Mar-2014   18-Jul-2014    0  11.962  18.078   9.132  -->  0.004
 27-Mar-2014   18-Jul-2014   50  12.212  18.192   9.239  -->  0.001
 27-Mar-2014   18-Jul-2014  100  12.259  18.240   9.186  -->  0.001
 27-Mar-2014   18-Jul-2014  150  12.238  18.241   9.178  -->  0.001
 27-Mar-2014   18-Jul-2014  200  12.238  18.241   9.178  -->  0.001
Optimization terminated successfully.
         Current function value: 0.001119
         Iterations: 88
         Function evaluations: 219
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 28-Mar-2014   18-Jul-2014    0  12.238  18.241   9.178  -->  0.004
 28-Mar-2014   18-Jul-2014   50  13.173  18.472   9.011  -->  0.001
 28-Mar-2014   18-Jul-2014  100  13.152  18.449   9.033  -->  0.001
 28-Mar-2014   18-Jul-2014  150  13.152  18.449   9.033  -->  0.001
Optimization terminated successfully.
         Current function value: 0.000820
         Iterations: 77
         Function evaluations: 186
pricing_date maturity_date    i   kappa   theta    vola -->    MSE
 31-Mar-2014   18-Jul-2014    0  13.152  18.449   9.033  -->  0.003
 31-Mar-2014   18-Jul-2014   50  13.560  18.388   9.096  -->  0.001
 31-Mar-2014   18-Jul-2014  100  12.155  18.389   8.668  -->  0.001
 31-Mar-2014   18-Jul-2014  150  10.847  18.435   8.180  -->  0.001
 31-Mar-2014   18-Jul-2014  200  10.688  18.431   8.135  -->  0.001
 31-Mar-2014   18-Jul-2014  250  10.686  18.431   8.135  -->  0.001
Warning: Maximum number of function evaluations has been exceeded.
CPU times: user 10min 33s, sys: 1min 37s, total: 12min 11s
Wall time: 12min 12s

Calibration Results

In [16]:
paramet = parameters.set_index('pricing_date')
paramet.tail()
Out[16]:
MSE initial_value kappa maturity sigma theta
pricing_date
2014-03-25 0.000911 18.2637 10.874119 2014-07-18 9.077175 18.164419
2014-03-26 0.000263 17.5869 11.962237 2014-07-18 9.131638 18.077615
2014-03-27 0.001119 17.6397 12.237540 2014-07-18 9.177992 18.241441
2014-03-28 0.000820 17.0324 13.151912 2014-07-18 9.033388 18.448611
2014-03-31 0.000504 17.6639 10.685725 2014-07-18 8.134671 18.430522

5 rows × 6 columns

Visualization of time series of calibrated parameter values. All MSEs pretty low (i.e. pretty good model fit).

In [17]:
%matplotlib inline
paramet[['kappa', 'theta', 'sigma', 'MSE']].plot(subplots=True, color='b', figsize=(10, 12))
plt.tight_layout()

Calibration results for the last calibration day.

In [18]:
index = paramet.index[-1]
opt = np.array(paramet[['kappa', 'theta', 'sigma']].loc[index])
option_selection = get_option_selection(index, maturity_list[0], tol=0.125)[0]
model_values = np.sort(np.array(calculate_model_values(opt).values()))[::-1]
import matplotlib.pyplot as plt
%matplotlib inline
fix, (ax1, ax2) = plt.subplots(2, sharex=True, figsize=(8, 8))
strikes = option_selection['STRIKE'].values
ax1.plot(strikes, option_selection['PRICE'], label='market quotes')
ax1.plot(strikes, model_values, 'ro', label='model values')
ax1.set_ylabel('option values')
ax1.grid(True)
ax1.legend(loc=0)
wi = 0.25
ax2.bar(strikes - wi / 2., model_values - option_selection['PRICE'],
        label='market quotes', width=wi)
ax2.grid(True)
ax2.set_ylabel('differences')
ax2.set_xlabel('strikes')
Out[18]:
<matplotlib.text.Text at 0x102970990>