Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Numerix CAIL Interface Workflow Example Using Matrix, Data, and Call Objects

This example shows how to use the Numerix® CAIL API to create and price a vanilla European option.

Construct a numerixCrossAsset object.

c = numerixCrossAsset 
 c = 

numerixCrossAsset with properties:

Application: [1x1 com.numerix.pro.Application]
ApplicationWarning: [1x1 com.numerix.pro.ApplicationWarning]

Create and register data as a Matrix with the Numerix Cross Asset Integration Layer Application using the applicationMatrix method.

rowData = [41992, 42020, 42449, 42905, 43115];
colData = [390, 395, 400, 405];
volData = [0.35778, 0.35132, 0.34394, 0.33582;...
           0.33405, 0.32819, 0.32669, 0.31904;...
           0.31576, 0.31235, 0.30371, 0.30261;...
           0.29391, 0.29366, 0.28962, 0.28932;...
           0.28787, NaN,     0.28347, NaN    ];
applicationMatrix(c,'BYSTRIKEVOLDATA',rowData,colData,volData);

Create and register the yield curve data with the Application object. Use a table for optimal display purposes. Dates must be relative to '01/01/1900' and the Numerix Cross Asset Integration Layer API supports date number representation only. MATLAB® datetime's get converted automatically, otherwise date numbers must be input and based relative to '01/01/1900'.

dates = datetime({'18-Feb-2014';'20-May-2014';'18-Jun-2014';'16-Jul-2014';
                  '20-Aug-2014';'17-Sep-2014';'15-Oct-2014';'19-Nov-2014';
                  '17-Dec-2014';'18-Mar-2015';'17-Jun-2015';'16-Sep-2015';
                  '16-Dec-2015';'16-Mar-2016';'15-Jun-2016';'21-Sep-2016';
                  '21-Dec-2016';'15-Mar-2017';'20-Feb-2018';'20-Feb-2019';
                  '20-Feb-2020';'22-Feb-2021';'22-Feb-2022';'21-Feb-2023';
                  '20-Feb-2024';'20-Feb-2025';'20-Feb-2026';'20-Feb-2029';
                  '21-Feb-2034';'22-Feb-2039';'22-Feb-2044';'20-Feb-2054';
                  '20-Feb-2064'},'locale','en_US');

Define the corresponding discount factors.

discountFactors = [1;0.99942;0.999231;0.999037;0.998797;0.998616;0.998385;...
                  0.998122;0.997941;0.997159;0.996157;0.994825;0.993065;...
                  0.99078;0.987889;0.984092;0.979913;0.975459;0.952707;...
                  0.922223;0.888128;0.852291;0.816462;0.781228;0.746677;...
                  0.712892;0.680462;0.592285;0.474003;0.383493;0.312617;...
                  0.213809;0.152345];

Supported Numerix Cross Asset Integration Layer API names are DATE and DISCOUNTFACTOR for the creation of the data.

curveData = table(dates,discountFactors,'VariableNames',{'DATE','DISCOUNTFACTOR'});
applicationData(c,'USD_3MLIBOR_CURVE',curveData);

Define the headers for registering the RATESPEC and DIVSPEC call objects.

headers = {'ID','LOCAL ID','TIMER','TIMER CPU','UPDATED'};

Data is required to create dividend curve. Create and register the DIVSPEC call object using name-value pairs in this example.

applicationCall(c,headers,'ID','DIVSPEC','OBJECT','MARKET DATA','TYPE','DIVIDEND',...
                  'COMMENT','Comments here','SKIP',false,'NOWDATE',41688,...
                  'CURRENCY','USD','RATE/DIVIDEND',0,'BASIS','ACT/360');

Create the EQUITYVOLSPEC call object. BYSTRIKEVOLDATA denotes the volatility matrix object created previously, using an array of names and an array of values in this example.

applicationCall(c,headers,{'ID','OBJECT','TYPE','COMMENT','SKIP','NOWDATE','CURRENCY','VOLATILITYBASIS',...
                           'DATA','INTERPMETHOD','INTERPVARIABLE','EXTRAPOLATION'},...
                          {'EQVOLSPEC','MARKET DATA','EQ VOL','Comments here',...
                           false,41688,'USD','ACT/360','BYSTRIKEVOLDATA',...
                           'LINEAR','VOL','FLAT EXTRAPOLATION'});

Create the RATESPEC call object. USD_3MLIBOR_CURVE denotes yield curve data object created previously using name-value pairs.

applicationCall(c,headers,'ID','RATESPEC','OBJECT','MARKET DATA','TYPE','YIELD','COMMENT','Comments here',...
                  'SKIP',false,'INTERPMETHOD','LogLinear','INTERPVARIABLE','DF',...
                  'CURRENCY','USD','DATA','USD_3MLIBOR_CURVE','BASIS','ACT/360');

Create the EuropeanOptionEQ instrument. Create the STOCKSPEC call object using the applicationCall method.

applicationCall(c,headers,'ID','STOCKSPEC','OBJECT','INSTRUMENT','TYPE','EQ EUROPEAN',...
                  'COMMENT','Comments here','SKIP',false,'FLAVOR','PUT',...
                  'CURRENCY','USD','ENDDATE',43976,'SETTLEMENTDATE',43976,...
                  'STRIKE',112,'SIGMA1',0.2,'NOTIONAL',100);

Price the portfolio by creating and registering call object to run pricing analytics. Create the OPTIONSPEC_CLOSEFORM call object headers for registering the OPTIONSPEC_CLOSEFORM call object.

headers = {'ATM','DELTA','DELTA TRADER','FORWARD DELTA','FORWARD DELTA TRADER', ...
           'FUTURES DELTA','FUTURES DELTA TRADER','GAMMA','GAMMA TRADER', ...
           'ID','LOCAL ID','NOTIONAL','PRICE','PV','RHO','RHO TRADER', ...
           'SIGMA1','STRIKE','THETA','TIMER','TIMER CPU','UPDATED','VANNA', ...
           'VANNA TRADER','VEGA','VEGA TRADER','VOLGA','VOLGA TRADER'};

applicationCall(c,headers,'ID','OPTIONSPEC_CLOSEFORM','OBJECT','ANALYTIC',...
                  'TYPE','EUROPEAN OPTION','COMMENT','Comments here',...
                  'SKIP',false,'NOWDATE',41688,'OPTION','STOCKSPEC',...
                  'DIVIDENDCURVE','DIVSPEC','DOMESTICYIELDCURVE','RATESPEC',...
                  'SPOTPRICE',112,'SPOTDATE',41688,'MODEL','BLACK');

Create an output structure in MATLAB from the Application object using the getdata method.

appData = getdata(c);

Display the results.

[appData.OPTIONSPEC_CLOSEFORM.OUTPUT_HEADERS 
appData.OPTIONSPEC_CLOSEFORM.OUTPUT_VALUES]
ans =
 
  28×2 cell array
 
    'PRICE'                   [             1467.24]
    'PV'                      [             1467.24]
    'DELTA'                   [              -30.54]
    'FORWARD DELTA'           [              -30.54]
    'FUTURES DELTA'           [              -26.83]
    'GAMMA'                   [                0.62]
    'VEGA'                    [             9827.91]
    'VOLGA'                   [              205.45]
    'VANNA'                   [               -1.44]
    'DELTA TRADER'            [              -34.20]
    'FORWARD DELTA TRADER'    [              -34.20]
    'FUTURES DELTA TRADER'    [              -30.05]
    'GAMMA TRADER'            [                0.78]
    'VEGA TRADER'             [               98.28]
    'VOLGA TRADER'            [                0.02]
    'VANNA TRADER'            [               -0.02]
    'SIGMA1'                  [                0.20]
    'STRIKE'                  [              112.00]
    'NOTIONAL'                [              100.00]
    'RHO'                     [           -30638.08]
    'THETA'                   [               -0.15]
    'RHO TRADER'              [               -3.06]
    'ATM'                     [              127.48]
    'UPDATED'                 '12 @ 01:37:24 PM'    
    'ID'                      'OPTIONSPEC_CLOSEFORM'
    'TIMER'                   [                0.17]
    'TIMER CPU'               [                0.06]
    'LOCAL ID'                'OPTIONSPEC_CLOSEFORM' 

Close the numerixCrossAsset object.

cloce(c)

See Also

| | | | |

External Websites

Was this topic helpful?