{"id":96536,"date":"2021-07-28T13:18:00","date_gmt":"2021-07-28T17:18:00","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=96536"},"modified":"2023-02-13T16:34:24","modified_gmt":"2023-02-13T21:34:24","slug":"delta-sensitivity-of-interest-rate-swap-part-i","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/","title":{"rendered":"Delta Sensitivity of Interest Rate Swap &#8211; Part I"},"content":{"rendered":"\n<p>This post explains how to calculate delta sensitivities or delta vector of interest rate swap. Delta can be calculated by either 1) zero delta or 2) market delta. To the best of our knowledge, FRTB can use these two methods but SIMM use the market Greeks. We implement R code for two approaches.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-introduction\">Introduction<\/h3>\n\n\n\n<p>For detailed information about the Libor IRS swap pricing and zero curve bootstrapping, refer to the following posts.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/kiandlee.blogspot.com\/2021\/07\/interest-rate-swap-pricing-using-r.html\" rel=\"noreferrer noopener\" target=\"_blank\">Interest Rate Swap Pricing using R code<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/kiandlee.blogspot.com\/2021\/07\/bootstrapping-zero-curve-from-irs-swap.html\" rel=\"noreferrer noopener\" target=\"_blank\">Bootstrapping the Zero Curve from IRS Swap Rates using R code<\/a><\/li>\n<\/ul>\n\n\n\n<p>In previous posts, we have priced a 5Y Libor IRS swap and generated a zero curve from market swap rates by using bootstrapping. Based on these works, we calculate Greeks of IRS. Since IRS does not have any option characteristics, our focus is to calculate the delta sensitivities or delta vector. And for convenience, swap value is defined as (floating leg &#8211; fixed leg).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-delta-sensitivity\">Delta Sensitivity<\/h3>\n\n\n\n<p>ISDA SIMM uses the following definitions of interest rate risk delta (xx&nbsp;is a risk factor). There are, of course, several versions of it but they are all essentially the same.<\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"583\" height=\"145\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-1.png\" alt=\"\" class=\"wp-image-96643 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-1.png 583w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-1-300x75.png 300w\" data-sizes=\"(max-width: 583px) 100vw, 583px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 583px; aspect-ratio: 583\/145;\" \/><\/figure>\n\n\n\n<p>For ease of notation, let&nbsp;<strong>z(t)<\/strong>&nbsp;and&nbsp;<strong>s(t)<\/strong>&nbsp;denote the (bootstrapped)&nbsp;<strong>zero rates or zero curve<\/strong>&nbsp;and (market observed)&nbsp;<strong>swap rates or swap curve<\/strong>&nbsp;at time t respectively.<\/p>\n\n\n\n<p>There are two approaches for the calculation of delta: 1) zero delta, 2) market delta.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Zero Delta<\/h4>\n\n\n\n<p>Zero delta approach calculates delta sensitivities by bumping up or down zero rates one by one in order.<\/p>\n\n\n\n<p>Once the zero curve <strong>(z(t))<\/strong> is generated from market swap rates <strong>(s(t))<\/strong>,<\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"590\" height=\"85\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-2.png\" alt=\"\" class=\"wp-image-96644 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-2.png 590w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-2-300x43.png 300w\" data-sizes=\"(max-width: 590px) 100vw, 590px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 590px; aspect-ratio: 590\/85;\" \/><\/figure>\n\n\n\n<p>Bumping up <strong>(z(t<sub>;<\/sub>&nbsp;t<sub>i<\/sub>&nbsp;+&nbsp;0.5bp)<\/strong> or down <strong>(z(t<sub>;<\/sub>&nbsp;t<sub>i<\/sub>\u22120.5bp))<\/strong>,&nbsp;<strong>delta(t<sub>i<\/sub>)<\/strong>&nbsp;is calculated and this process is applied for all&nbsp;<strong>t<sub>i<\/sub><\/strong>.<\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"586\" height=\"81\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-3.png\" alt=\"\" class=\"wp-image-96645 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-3.png 586w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-3-300x41.png 300w\" data-sizes=\"(max-width: 586px) 100vw, 586px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 586px; aspect-ratio: 586\/81;\" \/><\/figure>\n\n\n\n<p>Here,&nbsp;<strong>t<sub>i<\/sub>,&nbsp;i&nbsp;=&nbsp;1,&nbsp;2,&#8230;,&nbsp;n<sub>i<\/sub>&nbsp;=&nbsp;1,&nbsp;2,&#8230;,&nbsp;n&nbsp;<sub>i<\/sub><\/strong>&nbsp;are maturities or dates of market swap rates at which the corresponding zero rates are bootstrapped.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Market Delta<\/h4>\n\n\n\n<p>Market delta approach calculates delta sensitivities by bumping up or down market swap rates one by one in order. Unlike the zero delta, every time we bump one market swap rate of a selected maturity, we should run a bootstrapping for finding new zero curve. Using this newly generated zero curve, we can calculate delta sensitivity at time\u00a0\u00a0<strong>t<sub>i<\/sub><\/strong>\u00a0as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image img-twothird\"><img decoding=\"async\" width=\"583\" height=\"221\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-4.png\" alt=\"\" class=\"wp-image-96646 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-4.png 583w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/delta-interest-rates-4-300x114.png 300w\" data-sizes=\"(max-width: 583px) 100vw, 583px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 583px; aspect-ratio: 583\/221;\" \/><\/figure>\n\n\n\n<p>The following R code calculates delta sensitivities of IRS using these two approaches.<\/p>\n\n\n\n<pre class=\"wp-block-syntaxhighlighter-code\">#=========================================================================#\n# Financial Econometrics &amp; Derivatives, ML\/DL using R, Python, Tensorflow  \n# by Sang-Heon Lee \n#\n# https:\/\/kiandlee.blogspot.com\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-#\n# Calculate Delta Sensitivities of Libor IRS\n#=========================================================================#\n \ngraphics.off()  # clear all graphs\nrm(list = ls()) # remove all files from your workspace\n \n#=========================================================================\n# Functions \u2013 Definition\n#=========================================================================\n \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# Calculation of IRS swap price\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\nf_zero_prr_IRS &lt;\u2013 function(\n    fixed_rate,                   # fixed rate\n    vd.fixed_date, vd.float_date, # date for two legs\n    vd.zero_date,  v.zero_rate,   # zero curve (dates, rates)\n    d.spot_date,   no_amt,        # spot date, nominal amt\n    save_cf_yn) {                 # \u201cy\u201d : CF save                     \n \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\n    # 0) Preprocessing\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\n    \n    # convert spot date from date(d) to numeric(n)\n    n.spot_date &lt;\u2013 as.numeric(d.spot_date)\n    \n    # Interpolation of zero curve\n    vn.zero_date &lt;\u2013 as.numeric(vd.zero_date)\n    f_linear     &lt;\u2013 approxfun(vn.zero_date, v.zero_rate, \n                          method=\u201clinear\u201d)\n    vn.zero_date.inter &lt;\u2013 n.spot_date:max(vn.zero_date)\n    v.zero_rate.inter  &lt;\u2013 f_linear(vn.zero_date)\n    \n    # number of CFs\n    ni &lt;\u2013 length(vd.fixed_date)\n    nj &lt;\u2013 length(vd.float_date)\n    \n    # output data.frame with CF dates and its interpolated zero\n    df.fixed = data.frame(d.date = vd.fixed_date,\n                          n.date = as.numeric(vd.fixed_date))\n    df.float = data.frame(d.date = vd.float_date,\n                          n.date = as.numeric(vd.float_date))\n    \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\n    #  1)  Fixed Leg\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\n    \n    # zero rate for discounting\n    df.fixed$zero_DC = f_linear(as.numeric(df.fixed$d.date))\n    \n    # discount factor\n    df.fixed$DF &lt;\u2013 exp(\u2013df.fixed$zero_DC*\n                       (df.fixed$n.date\u2013n.spot_date)\/365)\n    \n    # tau, CF\n    for(i in 1:ni) {\n        \n        ymd      &lt;\u2013 df.fixed$d.date[i]\n        ymd_prev &lt;\u2013 df.fixed$d.date[i\u20131]\n        if(i==1) ymd_prev &lt;\u2013 d.spot_date\n        \n        d &lt;\u2013 as.numeric(strftime(ymd, format = \u201c%d\u201d))\n        m &lt;\u2013 as.numeric(strftime(ymd, format = \u201c%m\u201d))\n        y &lt;\u2013 as.numeric(strftime(ymd, format = \u201c%Y\u201d))\n        \n        d_prev &lt;\u2013 as.numeric(strftime(ymd_prev, format = \u201c%d\u201d))\n        m_prev &lt;\u2013 as.numeric(strftime(ymd_prev, format = \u201c%m\u201d))\n        y_prev &lt;\u2013 as.numeric(strftime(ymd_prev, format = \u201c%Y\u201d))\n        \n        # 30I\/360\n        tau &lt;\u2013 (360*(y\u2013y_prev) + 30*(m\u2013m_prev) + (d\u2013d_prev))\/360\n        \n        # cash flow rate\n        df.fixed$rate[i] &lt;\u2013 fixed_rate\n        \n        # Cash flow at time ti\n        df.fixed$CF[i] &lt;\u2013 fixed_rate*tau*no_amt # day fraction\n    }\n    \n    # Present value of CF\n    df.fixed$PV = df.fixed$CF*df.fixed$DF\n    \n    \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\n    #  2)  Floating Leg\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014-\n    \n    # zero rate for discounting\n    df.float$zero_DC = f_linear(as.numeric(df.float$d.date))\n    \n    # discount factor\n    df.float$DF &lt;\u2013 exp(\u2013df.float$zero_DC*\n                       (df.float$n.date\u2013n.spot_date)\/365)\n    \n    # tau, forward rate, CF\n    for(i in 1:nj) {\n        \n        date      &lt;\u2013 df.float$n.date[i]\n        date_prev &lt;\u2013 df.float$n.date[i\u20131]\n        \n        DF        &lt;\u2013 df.float$DF[i]\n        DF_prev   &lt;\u2013 df.float$DF[i\u20131]\n        \n        if(i==1) {\n            date_prev &lt;\u2013 n.spot_date\n            DF_prev   &lt;\u2013 1\n        }\n        \n        # ACT\/360\n        tau &lt;\u2013 (date \u2013 date_prev)\/360\n        \n        # forward rate\n        fwd_rate &lt;\u2013 (1\/tau)*(DF_prev\/DF\u20131)\n        \n        # cash flow rate\n        df.float$rate[i] &lt;\u2013 fwd_rate\n        \n        # Cash flow amount at time ti\n        df.float$CF[i] &lt;\u2013 fwd_rate*tau*no_amt # day fraction\n    }\n    \n    # Present value of CF\n    df.float$PV = df.float$CF*df.float$DF\n    \n    # check for cash flows\n    if (save_cf_yn == \u201cy\u201d) {\n        # print(df.float); print(df.fixed)\n        write.csv(df.float, \u201cCF_float.csv\u201d)\n        write.csv(df.fixed, \u201cCF_fixed.csv\u201d)\n    }\n \n    return(sum(df.float$PV) \u2013 sum(df.fixed$PV))\n}\n \n \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# IRS swap zero curve generator\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\nf_zero_maker_IRS &lt;\u2013 function(\n    df.mt,                    # market information data.frame\n                              # [d.date, swap_rate, source]]\n    v.unknown_swap_maty_all,  # all unknown swap maturity\n    vd.fixed_date,            # date for fixed leg\n    vd.float_date,            # date for float leg\n    d.spot_date,              # spot date\n    no_amt) {                 # nominal principal amount\n    \n    # convert spot date from date(d) to numeric(n)\n    n.spot_date &lt;\u2013 as.numeric(d.spot_date)\n    \n    # for bootstrapped zero curve\n    df.zr &lt;\u2013 data.frame(\n        d.date    = df.mt$d.date,\n        n.date    = as.numeric(df.mt$d.date),\n        tau       = as.numeric(df.mt$d.date) \u2013 n.spot_date,\n        taui      = as.numeric(df.mt$d.date) \u2013 n.spot_date,\n        swap_rate = df.mt$swap_rate, \n        zero_rate = rep(0,length(df.mt$d.date)),\n        DF        = rep(0,length(df.mt$d.date)))\n    \n    # tau(i) = t(i) \u2013 t(i-1)\n    df.zr$taui[2:nrow(df.zr)] &lt;\u2013 \n        df.zr$n.date[2:nrow(df.zr)] \u2013 \n        df.# semi-annual date[1: (nrow(df.zr)\u20131)]\n    \n    # divide rows according to its source or instrument type\n    rows_deposit &lt;\u2013 which(df.mt$source==\u201cdeposit\u201d)\n    rows_futures &lt;\u2013 which(df.mt$source==\u201cfutures\u201d)\n    rows_swap    &lt;\u2013 which(df.mt$source==\u201cswap\u201d)\n    \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n    # 3. Bootstrapping \u2013 Deposit\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n    \n    for(i in rows_deposit) {\n        \n        # 1) calculate discount factor for deposit\n        df.zr$DF[i] &lt;\u2013 1\/(1+df.zr$swap_rate[i]*df.zr$tau[i]\/360)\n        \n        # 2) convert DF to spot rate\n        df.zr$zero_rate[i] &lt;\u2013 365\/df.zr$tau[i]*log(1\/df.zr$DF[i])\n    }\n    \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n    # 4. Bootstrapping \u2013 Futures\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n    \n    # No convexity adjustment is made\n    for(i in rows_futures) {\n        \n        # 1) discount factor from t(i-1) to t(i)\n        df.zr$DF[i] &lt;\u2013 1\/(1+df.zr$swap_rate[i]*df.zr$taui[i]\/360)\n        \n        # 2) discount factor from spot date to t(i)\n        df.zr$DF[i] &lt;\u2013 df.zr$DF[i\u20131]*df.zr$DF[i]\n        \n        # 3) zero rate from discount factor\n        df.zr$zero_rate[i] &lt;\u2013 365\/df.zr$tau[i]*log(1\/df.zr$DF[i])\n    }\n    \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n    # 5. Bootstrapping \u2013 Swaps\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n    \n    k &lt;\u2013 1\n    for(i in rows_swap) {\n        \n        # unknown swap maturity in year\n        swap_maty &lt;\u2013 v.unknown_swap_maty_all[k]\n        \n        # 1) find one unknown zero rate for one swap maturity\n        m&lt;\u2013optim(0.01, objf,\n            control = list(abstol=10^(\u201320), reltol=10^(\u201320),\n                           maxit=50000, trace=2),\n            method = c(\u201cBrent\u201d),\n            lower = 0, upper = 0.1,               # for Brent\n            v.unknown_swap_maty = swap_maty,      # unknown zero maturity\n            v.swap_rate = df.zr$swap_rate[i],     # observed swap rate\n            vd.fixed_date = vd.fixed_date,        # date for fixed leg\n            vd.float_date = vd.float_date,        # date for float leg\n            vd.zero_date_all = df.zr$d.date[1:i], # all dates for zero curve\n            v.zero_rate_known  = df.zr$zero_rate[1: (i\u20131)], # known zero rates\n            d.spot_date = d.spot_date, \n            no_amt = no_amt)\n        \n        # 2) update this zero curve with the newly found zero rate\n        df.zr$zero_rate[i] &lt;\u2013 m$par\n        \n        # 3) convert this new zero rate to discount factor\n        df.zr$DF[i] &lt;\u2013 exp(\u2013df.zr$zero_rate[i]*df.zr$tau[i]\/365)\n        \n        k &lt;\u2013 k + 1\n    }\n    return(df.zr)\n}\n \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# objective function to be minimized\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\nobjf &lt;\u2013 function(\n    v.unknown_swap_zero_rate, # unknown zero curve (rates)\n    v.unknown_swap_maty,      # unknown swap maturity\n    v.swap_rate,              # fixed rate\n    vd.fixed_date,            # date for fixed leg\n    vd.float_date,            # date for float leg\n    vd.zero_date_all,         # all dates for zero curve\n    v.zero_rate_known,        # known zero curve (rates)\n    d.spot_date,              # spot date\n    no_amt) {                 # nominal principal amount\n \n    # zero curve augmented with zero rates for swaps\n    v.zero_rate_all &lt;\u2013 c(v.zero_rate_known,\n                         v.unknown_swap_zero_rate)\n    \n    v.swap_pr &lt;\u2013 NULL # vector of swap prices\n    \n    k &lt;\u2013 1\n    for(i in v.unknown_swap_maty) {\n        \n        # calculate IRS swap price\n        swap_pr &lt;\u2013 f_zero_prr_IRS(\n            v.swap_rate[k],          # fixed rate, \n            vd.fixed_date[1: (2*i)],  # semi-annual date\n            vd.float_date[1: (4*i)],  # quarterly   date\n            vd.zero_date_all,        # zero curve (dates)\n            v.zero_rate_all,         # zero curve (rates)\n            d.spot_date, no_amt, \u201cn\u201d)\n        \n        # concatenate swap prices\n        v.swap_pr &lt;\u2013 c(v.swap_pr, swap_pr)\n        k &lt;\u2013 k + 1\n    }\n    \n    return(sum(v.swap_pr^2))\n}\n \n#=========================================================================\n# Main \n#=========================================================================\n \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# 1. Market Information\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n \n# Zero curve from Bloomberg as of 2021-06-30 until 5-year maturity\ndf.mt &lt;\u2013 data.frame(\n    \n    d.date = as.Date(c(\u201c2021-10-04\u201d,\u201c2021-12-15\u201d,\n                       \u201c2022-03-16\u201d,\u201c2022-06-15\u201d,\n                       \u201c2022-09-21\u201d,\u201c2022-12-21\u201d,\n                       \u201c2023-03-15\u201d,\u201c2023-07-03\u201d,\n                       \u201c2024-07-02\u201d,\u201c2025-07-02\u201d,\n                       \u201c2026-07-02\u201d)),\n    \n    # we use swap rate not zero rate.\n    swap_rate= c(0.00145750000000000,\n                 0.00139609870272047,\n                 0.00203838571440434,\n                 0.00197747863867587,\n                 0.00266249271921742,\n                 0.00359490949297661,\n                 0.00512603194652204,\n                 0.00328354999423027,\n                 0.00571049988269806,\n                 0.00793000012636185,\n                 0.00964949995279312\n    ),\n \n    source = c(\u201cdeposit\u201d, rep(\u201cfutures\u201d,6), rep(\u201cswap\u201d, 4))\n)\n \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# 2. Libor Swap Specification\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n \nd.spot_date  &lt;\u2013 as.Date(\u201c2021-07-02\u201d)    # spot date (date type)\nn.spot_date  &lt;\u2013 as.numeric(d.spot_date)  # spot date (numeric type)\n \nno_amt     &lt;\u2013 10000000      # notional principal amount\n \n# swap cash flow schedule from Bloomberg \nlt.cf_date &lt;\u2013 list( \n    \n    fixed = as.Date(c(\u201c2022-01-04\u201d,\u201c2022-07-05\u201d,\n                      \u201c2023-01-03\u201d,\u201c2023-07-03\u201d,\n                      \u201c2024-01-02\u201d,\u201c2024-07-02\u201d,\n                      \u201c2025-01-02\u201d,\u201c2025-07-02\u201d,\n                      \u201c2026-01-02\u201d,\u201c2026-07-02\u201d)),\n    \n    float = as.Date(c(\u201c2021-10-04\u201d,\u201c2022-01-04\u201d,\n                      \u201c2022-04-04\u201d,\u201c2022-07-05\u201d,\n                      \u201c2022-10-03\u201d,\u201c2023-01-03\u201d,\n                      \u201c2023-04-03\u201d,\u201c2023-07-03\u201d,\n                      \u201c2023-10-02\u201d,\u201c2024-01-02\u201d,\n                      \u201c2024-04-02\u201d,\u201c2024-07-02\u201d,\n                      \u201c2024-10-02\u201d,\u201c2025-01-02\u201d,\n                      \u201c2025-04-02\u201d,\u201c2025-07-02\u201d,\n                      \u201c2025-10-02\u201d,\u201c2026-01-02\u201d,\n                      \u201c2026-04-02\u201d,\u201c2026-07-02\u201d))\n)\n \n \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# 3. 5-year swap price : base\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n \ni = 5 # 5-year swap\n \n# zero pricing\ndf.zr &lt;\u2013 f_zero_maker_IRS(\n           df.mt, c(2,3,4,5),\n           lt.cf_date$fixed, lt.cf_date$float, \n           d.spot_date, no_amt)\n \npr    &lt;\u2013 f_zero_prr_IRS(\n           df.mt$swap_rate[i+6],\n           lt.cf_date$fixed[1: (2*i)], \n           lt.cf_date$float[1: (4*i)],\n           df.zr$d.date, df.zr$zero_rate, \n           d.spot_date,no_amt, save_cf_yn = \u201cy\u201d)\n \nprint(paste0(i,\u201c-year Swap price at spot date = \u201c, pr))\n \ndf.zr_delta    &lt;\u2013 df.mt_delta    &lt;\u2013 df.zr[,\u2013c(2,3,4)]\ndf.zr_delta$pr &lt;\u2013 df.mt_delta$pr &lt;\u2013 pr\n    \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# 3. Bump and Reprice for Market Greeks\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n \ndf.mt_delta$delta &lt;\u2013 df.mt_delta$pr_up &lt;\u2013 df.mt_delta$pr_dn &lt;\u2013 NA\n \n# iteration for all market maturities\nfor(r in 1:11) {\n    \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    # bump up (1bp up)\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    df.mt_bump &lt;\u2013 df.mt   # initialization\n    df.mt_bump$swap_rate[r] &lt;\u2013 df.mt_bump$swap_rate[r] + 0.0001 \n    \n    # zero pricing\n    df.zr &lt;\u2013 f_zero_maker_IRS(df.mt_bump, c(2,3,4,5),\n               lt.cf_date$fixed, lt.cf_date$float, \n               d.spot_date, no_amt)\n    pr    &lt;\u2013 f_zero_prr_IRS(df.mt$swap_rate[i+6],\n               lt.cf_date$fixed[1: (2*i)], \n               lt.cf_date$float[1: (4*i)],\n               df.zr$d.date, df.zr$zero_rate, \n               d.spot_date, no_amt, \u201cn\u201d)\n    \n    # save price with bumping up\n    df.mt_delta$pr_up[r] &lt;\u2013 pr\n    \n    # check whether swap prices at spot date is at par\n    pr    &lt;\u2013 f_zero_prr_IRS(df.mt_bump$swap_rate[i+6],\n               lt.cf_date$fixed[1: (2*i)],\n               lt.cf_date$float[1: (4*i)],\n               df.zr$d.date, df.zr$zero_rate, \n               d.spot_date,no_amt, \u201cn\u201d)\n    \n    print(paste0(i,\u201c-year Swap price at spot date = \u201c, pr))\n    \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    # bump down (1bp down)\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    df.mt_bump &lt;\u2013 df.mt   # initialization\n    df.mt_bump$swap_rate[r] &lt;\u2013 df.mt_bump$swap_rate[r] \u2013 0.0001 \n    \n    # zero pricing\n    df.zr &lt;\u2013 f_zero_maker_IRS(df.mt_bump, c(2,3,4,5),\n               lt.cf_date$fixed, lt.cf_date$float, \n               d.spot_date, no_amt)\n    \n    pr &lt;\u2013 f_zero_prr_IRS(df.mt$swap_rate[i+6],\n            lt.cf_date$fixed[1: (2*i)], lt.cf_date$float[1: (4*i)],\n            df.zr$d.date, df.zr$zero_rate, d.spot_date,no_amt, \u201cn\u201d)\n    \n    # save price with bumping down\n    df.mt_delta$pr_dn[r] &lt;\u2013 pr\n    \n    # check whether swap prict at spot date is at par\n    pr &lt;\u2013 f_zero_prr_IRS(df.mt_bump$swap_rate[i+6],\n            lt.cf_date$fixed[1: (2*i)], lt.cf_date$float[1: (4*i)],\n            df.zr$d.date, df.zr$zero_rate, d.spot_date,no_amt, \u201cn\u201d)\n    \n    print(paste0(i,\u201c-year Swap price at spot date = \u201c, pr))\n}\n \n# Market Greeks : Delta calculation\ndf.mt_delta$delta &lt;\u2013 (df.mt_delta$pr_up \u2013 \n                      df.mt_delta$pr_dn)\/2 \n \ndf.mt_delta\n \nx11(width = 5, height = 3.5)\nbarplot(delta ~ substr(d.date,1,7), data = df.mt_delta, \n        width = 0.5, col = \u201cblue\u201d)\n \nx11(width = 5, height = 3.5)\nbarplot(delta ~ substr(d.date,1,7), data = df.mt_delta[1:10,],\n        width = 0.5, col = \u201cgreen\u201d)\n \n \n \n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n# 4. Bump and Reprice for Zero Greeks\n#\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013\n \ndf.zr_delta$delta &lt;\u2013 df.zr_delta$pr_up &lt;\u2013 df.zr_delta$pr_dn &lt;\u2013 NA\n \n# zero pricing\ndf.zr &lt;\u2013 f_zero_maker_IRS(df.mt, c(2,3,4,5),\n                            lt.cf_date$fixed, lt.cf_date$float, d.spot_date, no_amt)\n \nfor(r in 1:11) {\n \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    # bump up (1bp up)\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    df.zr_bump    &lt;\u2013 df.zr  # initialization\n    df.zr_bump$zero_rate[r] &lt;\u2013 df.zr_bump$zero_rate[r] + 0.0001\n \n    # zero pricing\n    pr   &lt;\u2013 f_zero_prr_IRS(df.mt$swap_rate[i+6],\n              lt.cf_date$fixed[1: (2*i)], lt.cf_date$float[1: (4*i)],\n              df.zr_bump$d.date, df.zr_bump$zero_rate, \n              d.spot_date, no_amt, \u201cn\u201d)\n    \n    # save price with bumping up\n    df.zr_delta$pr_up[r] &lt;\u2013 pr\n \n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    # bump down (1bp down)\n    #\u2014\u2014\u2014\u2014\u2014\u2014\u2014\n    df.zr_bump    &lt;\u2013 df.zr  # initialization\n    df.zr_bump$zero_rate[r] &lt;\u2013 df.zr_bump$zero_rate[r] \u2013 0.0001\n \n    # zero pricing\n    pr &lt;\u2013 f_zero_prr_IRS(df.mt$swap_rate[i+6],\n            lt.cf_date$fixed[1: (2*i)], lt.cf_date$float[1: (4*i)],\n            df.zr_bump$d.date, df.zr_bump$zero_rate, \n            d.spot_date,no_amt, \u201cn\u201d)\n    \n    # save price with bumping down\n    df.zr_delta$pr_dn[r] &lt;\u2013 pr\n}\n \n# Market Greeks : Delta calculation\ndf.zr_delta$delta &lt;\u2013 (df.zr_delta$pr_up \u2013 \n                      df.zr_delta$pr_dn)\/2\n \ndf.zr_delta\n \nx11(width = 5, height = 3.5)\nbarplot(delta ~ substr(d.date,1,7), data = df.zr_delta, \n        width = 0.5, col = \u201cblue\u201d)\n \nx11(width = 5, height = 3.5)\nbarplot(delta ~ substr(d.date,1,7), data = df.zr_delta[1:10,],\n        width = 0.5, col = \u201cgreen\u201d)\n \nColored by Color Scripter<\/pre>\n\n\n\n<p><em>Stay tuned for the next installment to learn about the output demonstrating zero delta vector along the maturities.<\/em><\/p>\n\n\n\n<p><em>For additional insight on this topic and to download the R scripts, visit  <a href=\"https:\/\/kiandlee.blogspot.com\/2021\/07\/delta-sensitivity-of-interest-rate-swap.html\">https:\/\/kiandlee.blogspot.com\/2021\/07\/delta-sensitivity-of-interest-rate-swap.html<\/a><\/em>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sang-Heon Lee demonstrates how to calculate delta sensitivities or delta vector of interest rate swap using R. Delta can be calculated by either 1) zero delta or 2) market delta. <\/p>\n","protected":false},"author":662,"featured_media":96704,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,338,350,341,352,344,342],"tags":[806,10062,10064,4922,10063,10067,852,10066,487,6591,508,10065],"contributors-categories":[13728],"class_list":{"0":"post-96536","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-data-science","8":"category-programing-languages","9":"category-ibkr-quant-news","10":"category-quant-asia-pacific","11":"category-quant-development","12":"category-quant-north-america","13":"category-quant-regions","14":"category-r-development","15":"tag-data-science","16":"tag-delta-sensitivity","17":"tag-delta-vector","18":"tag-econometrics","19":"tag-interest-rate-swap","20":"tag-libor-irs","21":"tag-machine-learning","22":"tag-market-delta","23":"tag-r","24":"tag-rstats","25":"tag-rstudio","26":"tag-swap-curve","27":"contributors-categories-sh-fintech-modeling"},"pp_statuses_selecting_workflow":false,"pp_workflow_action":"current","pp_status_selection":"publish","acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Delta Sensitivity of Interest Rate Swap &#8211; Part I<\/title>\n<meta name=\"description\" content=\"Sang-Heon Lee demonstrates how to calculate delta sensitivities or delta vector of interest rate swap using R. Delta can be calculated by either 1) zero...\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/96536\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Delta Sensitivity of Interest Rate Swap - Part I | IBKR Quant Blog\" \/>\n<meta property=\"og:description\" content=\"Sang-Heon Lee demonstrates how to calculate delta sensitivities or delta vector of interest rate swap using R. Delta can be calculated by either 1) zero delta or 2) market delta.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-28T17:18:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-02-13T21:34:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1000\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Sang-Heon Lee\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sang-Heon Lee\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\n\t    \"@context\": \"https:\\\/\\\/schema.org\",\n\t    \"@graph\": [\n\t        {\n\t            \"@type\": \"NewsArticle\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/\"\n\t            },\n\t            \"author\": {\n\t                \"name\": \"Sang-Heon Lee\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/0a959ff9de7f0465a07baa1fe1ae0200\"\n\t            },\n\t            \"headline\": \"Delta Sensitivity of Interest Rate Swap &#8211; Part I\",\n\t            \"datePublished\": \"2021-07-28T17:18:00+00:00\",\n\t            \"dateModified\": \"2023-02-13T21:34:24+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/\"\n\t            },\n\t            \"wordCount\": 458,\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"keywords\": [\n\t                \"Data Science\",\n\t                \"Delta Sensitivity\",\n\t                \"Delta Vector\",\n\t                \"Econometrics\",\n\t                \"Interest Rate Swap\",\n\t                \"Libor IRS\",\n\t                \"Machine Learning\",\n\t                \"Market Delta\",\n\t                \"R\",\n\t                \"rstats\",\n\t                \"RStudio\",\n\t                \"Swap Curve\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Quant\",\n\t                \"Quant Asia Pacific\",\n\t                \"Quant Development\",\n\t                \"Quant North America\",\n\t                \"Quant Regions\",\n\t                \"R Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/\",\n\t            \"name\": \"Delta Sensitivity of Interest Rate Swap - Part I | IBKR Quant Blog\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\"\n\t            },\n\t            \"primaryImageOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"datePublished\": \"2021-07-28T17:18:00+00:00\",\n\t            \"dateModified\": \"2023-02-13T21:34:24+00:00\",\n\t            \"description\": \"Sang-Heon Lee demonstrates how to calculate delta sensitivities or delta vector of interest rate swap using R. Delta can be calculated by either 1) zero delta or 2) market delta.\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"ReadAction\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"ImageObject\",\n\t            \"inLanguage\": \"en-US\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/delta-sensitivity-of-interest-rate-swap-part-i\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2021\\\/07\\\/r-programming-fintech.jpg\",\n\t            \"width\": 1000,\n\t            \"height\": 563,\n\t            \"caption\": \"Quant\"\n\t        },\n\t        {\n\t            \"@type\": \"WebSite\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#website\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"name\": \"IBKR Campus US\",\n\t            \"description\": \"Financial Education from Interactive Brokers\",\n\t            \"publisher\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\"\n\t            },\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"SearchAction\",\n\t                    \"target\": {\n\t                        \"@type\": \"EntryPoint\",\n\t                        \"urlTemplate\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/?s={search_term_string}\"\n\t                    },\n\t                    \"query-input\": {\n\t                        \"@type\": \"PropertyValueSpecification\",\n\t                        \"valueRequired\": true,\n\t                        \"valueName\": \"search_term_string\"\n\t                    }\n\t                }\n\t            ],\n\t            \"inLanguage\": \"en-US\"\n\t        },\n\t        {\n\t            \"@type\": \"Organization\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#organization\",\n\t            \"name\": \"Interactive Brokers\",\n\t            \"alternateName\": \"IBKR\",\n\t            \"url\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/\",\n\t            \"logo\": {\n\t                \"@type\": \"ImageObject\",\n\t                \"inLanguage\": \"en-US\",\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\",\n\t                \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/05\\\/ibkr-campus-logo.jpg\",\n\t                \"width\": 669,\n\t                \"height\": 669,\n\t                \"caption\": \"Interactive Brokers\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/logo\\\/image\\\/\"\n\t            },\n\t            \"publishingPrinciples\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/about-ibkr-campus\\\/\",\n\t            \"ethicsPolicy\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/cyber-security-notice\\\/\"\n\t        },\n\t        {\n\t            \"@type\": \"Person\",\n\t            \"@id\": \"https:\\\/\\\/ibkrcampus.com\\\/campus\\\/#\\\/schema\\\/person\\\/0a959ff9de7f0465a07baa1fe1ae0200\",\n\t            \"name\": \"Sang-Heon Lee\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/author\\\/sang-heonlee\\\/\"\n\t        }\n\t    ]\n\t}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Delta Sensitivity of Interest Rate Swap &#8211; Part I","description":"Sang-Heon Lee demonstrates how to calculate delta sensitivities or delta vector of interest rate swap using R. Delta can be calculated by either 1) zero...","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.interactivebrokers.com\/campus\/wp-json\/wp\/v2\/posts\/96536\/","og_locale":"en_US","og_type":"article","og_title":"Delta Sensitivity of Interest Rate Swap - Part I | IBKR Quant Blog","og_description":"Sang-Heon Lee demonstrates how to calculate delta sensitivities or delta vector of interest rate swap using R. Delta can be calculated by either 1) zero delta or 2) market delta.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/","og_site_name":"IBKR Campus US","article_published_time":"2021-07-28T17:18:00+00:00","article_modified_time":"2023-02-13T21:34:24+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","type":"image\/jpeg"}],"author":"Sang-Heon Lee","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sang-Heon Lee","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/"},"author":{"name":"Sang-Heon Lee","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200"},"headline":"Delta Sensitivity of Interest Rate Swap &#8211; Part I","datePublished":"2021-07-28T17:18:00+00:00","dateModified":"2023-02-13T21:34:24+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/"},"wordCount":458,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","keywords":["Data Science","Delta Sensitivity","Delta Vector","Econometrics","Interest Rate Swap","Libor IRS","Machine Learning","Market Delta","R","rstats","RStudio","Swap Curve"],"articleSection":["Data Science","Programming Languages","Quant","Quant Asia Pacific","Quant Development","Quant North America","Quant Regions","R Development"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/","name":"Delta Sensitivity of Interest Rate Swap - Part I | IBKR Quant Blog","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","datePublished":"2021-07-28T17:18:00+00:00","dateModified":"2023-02-13T21:34:24+00:00","description":"Sang-Heon Lee demonstrates how to calculate delta sensitivities or delta vector of interest rate swap using R. Delta can be calculated by either 1) zero delta or 2) market delta.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/delta-sensitivity-of-interest-rate-swap-part-i\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","width":1000,"height":563,"caption":"Quant"},{"@type":"WebSite","@id":"https:\/\/ibkrcampus.com\/campus\/#website","url":"https:\/\/ibkrcampus.com\/campus\/","name":"IBKR Campus US","description":"Financial Education from Interactive Brokers","publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ibkrcampus.com\/campus\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/ibkrcampus.com\/campus\/#organization","name":"Interactive Brokers","alternateName":"IBKR","url":"https:\/\/ibkrcampus.com\/campus\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/05\/ibkr-campus-logo.jpg","width":669,"height":669,"caption":"Interactive Brokers"},"image":{"@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/logo\/image\/"},"publishingPrinciples":"https:\/\/www.interactivebrokers.com\/campus\/about-ibkr-campus\/","ethicsPolicy":"https:\/\/www.interactivebrokers.com\/campus\/cyber-security-notice\/"},{"@type":"Person","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200","name":"Sang-Heon Lee","url":"https:\/\/www.interactivebrokers.com\/campus\/author\/sang-heonlee\/"}]}},"jetpack_featured_media_url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2021\/07\/r-programming-fintech.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/96536","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/users\/662"}],"replies":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/comments?post=96536"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/96536\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/96704"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=96536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=96536"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=96536"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=96536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}