calibrate shifted sabr model parameters for swaption instrument -凯发k8网页登录
calibrate model parameters for a instrument when you use a sabr
pricing method.
load market data
% zero curve valuationdate = datetime("5-mar-2016", 'locale', 'en_us'); zerodates = datemnth(valuationdate,[1 2 3 6 9 12*[1 2 3 4 5 6 7 8 9 10 12]])'; zerorates = [-0.33 -0.28 -0.24 -0.12 -0.08 -0.03 0.015 0.028 ... 0.033 0.042 0.056 0.095 0.194 0.299 0.415 0.525]'/100; compounding = 1; zerocurve = ratecurve("zero",valuationdate,zerodates,zerorates,'compounding',compounding)
zerocurve = ratecurve with properties: type: "zero" compounding: 1 basis: 0 dates: [16x1 datetime] rates: [16x1 double] settle: 05-mar-2016 interpmethod: "linear" shortextrapmethod: "next" longextrapmethod: "previous"
% define the swaptions swaptionsettle = datetime("5-mar-2016", 'locale', 'en_us'); swaptionexercisedate = datetime("5-mar-2017", 'locale', 'en_us'); swaptionstrikes = (-0.6:0.01:1.6)'/100; % include negative strikes swapmaturity = datetime("5-mar-2022", 'locale', 'en_us'); % maturity of underlying swap optspec = 'call';
compute forward swap rate by creating swap
instrument
use to create a instrument object.
legrate = [0 0]; swap = fininstrument("swap", 'maturity', swapmaturity, 'legrate', legrate, "legtype",["fixed" "float"],... "projectioncurve", zerocurve, "startdate", swaptionexercisedate)
swap = swap with properties: legrate: [0 0] legtype: ["fixed" "float"] reset: [2 2] basis: [0 0] notional: 100 latestfloatingrate: [nan nan] resetoffset: [0 0] daycountadjustedcashflow: [0 0] projectioncurve: [1x2 ratecurve] businessdayconvention: ["actual" "actual"] holidays: nat endmonthrule: [1 1] startdate: 05-mar-2017 maturity: 05-mar-2022 name: ""
forwardvalue = parswaprate(swap,zerocurve)
forwardvalue = 7.3271e-04
load the market implied volatility data
the market swaption volatilities are quoted in terms of shifted black volatilities with a 0.8
percent shift.
strikegrid = [-0.5; -0.25; -0.125; 0; 0.125; 0.25; 0.5; 1.0; 1.5]/100;
marketstrikes = forwardvalue strikegrid;
shift = 0.008; % 0.8 percent shift
marketshiftedblackvolatilities = [21.1; 15.3; 14.0; 14.6; 16.0; 17.7; 19.8; 23.9; 26.2]/100;
atmshiftedblackvolatility = marketshiftedblackvolatilities(strikegrid==0);
calibrate shifted sabr
model parameters
the beta
parameter is predetermined at 0.5
. use to compute the implied volatility.
beta = 0.5; % calibrate alpha, rho, and nu objfun = @(x) marketshiftedblackvolatilities - volatilities(finpricer("analytic", 'model', ... finmodel("sabr", 'alpha', x(1), 'beta', beta, 'rho', x(2), 'nu', x(3), 'shift', shift), ... 'discountcurve', zerocurve), swaptionexercisedate, forwardvalue, marketstrikes); x = lsqnonlin(objfun, [0.5 0 0.5], [0 -1 0], [inf 1 inf]);
local minimum possible. lsqnonlin stopped because the final change in the sum of squares relative to its initial value is less than the value of the function tolerance.
alpha = x(1); rho = x(2); nu = x(3);
create sabr
model using the calibrated parameters
use to create a sabr
model object.
sabrmodel = finmodel("sabr",'alpha',alpha,'beta',beta,'rho',rho,'nu',nu,'shift',shift)
sabrmodel = sabr with properties: alpha: 0.0135 beta: 0.5000 rho: 0.4654 nu: 0.4957 shift: 0.0080 volatilitytype: "black"
create sabr
pricer using calibrated sabr
model and compute volatilities
use to create a sabr
pricer object and use the ratecurve
object for the 'discountcurve'
name-value pair argument.
sabrpricer = finpricer("analytic", 'model', sabrmodel, 'discountcurve', zerocurve)
sabrpricer = sabr with properties: discountcurve: [1x1 ratecurve] model: [1x1 finmodel.sabr]
sabrshiftedblackvolatilities = volatilities(sabrpricer, swaptionexercisedate, forwardvalue, swaptionstrikes)
sabrshiftedblackvolatilities = 221×1
0.2978
0.2911
0.2848
0.2787
0.2729
0.2673
0.2620
0.2568
0.2518
0.2470
⋮
figure; plot(marketstrikes, marketshiftedblackvolatilities, 'o', ... swaptionstrikes, sabrshiftedblackvolatilities); h = gca; line([0,0],[min(h.ylim),max(h.ylim)],'linestyle','--'); ylim([0.13 0.31]) xlabel('strike'); legend('market quotes','shifted sabr', 'location', 'southeast'); title (['shifted black volatility (',num2str(shift*100),' percent shift)']);
price swaption
instruments using calibrated sabr
model and sabr
pricer
% create swaption instruments numinst = length(swaptionstrikes); swaptions(numinst, 1) = fininstrument("swaption", ... 'strike', swaptionstrikes(1), 'exercisedate', swaptionexercisedate(1), 'swap', swap); for k = 1:numinst swaptions(k) = fininstrument("swaption", 'strike', swaptionstrikes(k), ... 'exercisedate', swaptionexercisedate, 'swap', swap, 'optiontype', optspec); end swaptions
swaptions=221×1 object
16x1 swaption array with properties:
optiontype
exercisestyle
exercisedate
strike
swap
name
⋮
% price swaptions using the sabr pricer swaptionprices = price(sabrpricer,swaptions); figure; plot(swaptionstrikes, swaptionprices, 'r'); h = gca; line([0,0],[min(h.ylim),max(h.ylim)],'linestyle','--'); xlabel('strike'); title ('swaption price');