{"id":202057,"date":"2024-02-09T10:14:58","date_gmt":"2024-02-09T15:14:58","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=202057"},"modified":"2024-02-09T10:14:58","modified_gmt":"2024-02-09T15:14:58","slug":"bond-convexity-in-excel-and-r","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/","title":{"rendered":"Bond Convexity in Excel and R"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A&nbsp;<strong>convexity<\/strong>&nbsp;is needed to describe a non-linearity of a bond price, which is absent in a duration. This post explains the meaning and calculation process of the convexity by using Excel and R.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We have calculated a bond duration in the previous post <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/shleeai.blogspot.com\/2021\/09\/bond-modified-duration-in-excel-and-r.html\" target=\"_blank\" rel=\"noreferrer noopener\">Bond Modified Duration in Excel and R<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-bond-price\">Bond Price<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Bond price with unit notional amount, coupon C, YTM y, annual frequency is as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"585\" height=\"102\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-price-shleefintech.png\" alt=\"\" class=\"wp-image-202060 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-price-shleefintech.png 585w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-price-shleefintech-300x52.png 300w\" data-sizes=\"(max-width: 585px) 100vw, 585px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 585px; aspect-ratio: 585\/102;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Convexity<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">As a bond yield decreases, its&nbsp;<strong>price rises at an increasing rate<\/strong>, whereas a bond&#8217;s&nbsp;<strong>price falls at a decreasing rate<\/strong>&nbsp;as its yield increases. This asymmetric behavior is known as&nbsp;<strong>convexity<\/strong>. Let&#8217;s derive convexity in the same manner by which duration is derived.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">At first, the second order derivative of&nbsp;<em>P<\/em>&nbsp;with respect to&nbsp;<em>y<\/em>.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"601\" height=\"89\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-shleefintech.png\" alt=\"\" class=\"wp-image-202061 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-shleefintech.png 601w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-shleefintech-300x44.png 300w\" data-sizes=\"(max-width: 601px) 100vw, 601px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 601px; aspect-ratio: 601\/89;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Like the duration, factoring out <img decoding=\"async\" width=\"49\" height=\"38\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech.png\" alt=\"\" class=\"wp-image-202062 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 49px; aspect-ratio: 49\/38;\"> in the above equation yields<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"572\" height=\"148\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-2.png\" alt=\"\" class=\"wp-image-202064 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-2.png 572w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-2-300x78.png 300w\" data-sizes=\"(max-width: 572px) 100vw, 572px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 572px; aspect-ratio: 572\/148;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">To avoid lengthy expression, we substitute&nbsp;<strong>STT1DC<\/strong>&nbsp;for the bracketed term.&nbsp;<strong>STT1DC<\/strong>&nbsp;is the abbreviation of the&nbsp;<strong>s<\/strong>um of multiplications of&nbsp;<strong>t<\/strong>ime and&nbsp;<strong>t<\/strong>ime +&nbsp;<strong>1<\/strong>&nbsp;and&nbsp;<strong>d<\/strong>iscounted&nbsp;<strong>c<\/strong>ash flow (only coupon or coupon + principal amount).<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Similar to the duration in the previous post, let&#8217;s modify it by&nbsp;<strong>a ratio of its initial bond price<\/strong>.&nbsp;<strong>Dividing<\/strong> <img decoding=\"async\" width=\"59\" height=\"38\" class=\"wp-image-202065 lazyload\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-3.png\" alt=\"\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 59px; aspect-ratio: 59\/38;\"> <strong>by&nbsp;P<\/strong>&nbsp;gives the following expression for the&nbsp;<strong>convexity (C)<\/strong>&nbsp;of a bond.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"579\" height=\"142\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-4.png\" alt=\"\" class=\"wp-image-202068 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-4.png 579w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-4-300x74.png 300w\" data-sizes=\"(max-width: 579px) 100vw, 579px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 579px; aspect-ratio: 579\/142;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Rearranging this equation, we can get the following expression.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"563\" height=\"78\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-5.png\" alt=\"\" class=\"wp-image-202070 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-5.png 563w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-5-300x42.png 300w\" data-sizes=\"(max-width: 563px) 100vw, 563px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 563px; aspect-ratio: 563\/78;\" \/><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-generalization\">Generalization<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">When interest conversion period is less than one year such as one quarter, convexity is redefined as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"577\" height=\"124\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-6.png\" alt=\"\" class=\"wp-image-202071 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-6.png 577w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-6-300x64.png 300w\" data-sizes=\"(max-width: 577px) 100vw, 577px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 577px; aspect-ratio: 577\/124;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here,&nbsp;<strong>k<\/strong>&nbsp;is the number of compounding periods per year.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Effective Convexity and Duration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Effective convexity (C) is obtained from the numerical differentiation like the effective duration (D).<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"566\" height=\"121\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-7.png\" alt=\"\" class=\"wp-image-202073 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-7.png 566w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-7-300x64.png 300w\" data-sizes=\"(max-width: 566px) 100vw, 566px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 566px; aspect-ratio: 566\/121;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Here,&nbsp;<em>P<sub>0<\/sub><\/em>&nbsp;denotes an initial bond price with yield to maturity <em>(y)<\/em>.&nbsp;<em>P<sub>u<\/sub><\/em>&nbsp;and&nbsp;<em>P<sub>d<\/sub><\/em>&nbsp;represent bond prices after downward <em>(y \u2212 \u0394y)<\/em> and upward <em>(y + \u0394y)<\/em> shocks to interest rates (yield to maturity) respectively.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-excel-illustration\">Excel Illustration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To the best of our knowledge, Excel does not provides a built-in function for the calculation of convexity. Therefore, we calculate convexity by using the definition and the numerical differentiation for our clear understanding. As an example, we use the same specification of bond as in the previous post. Specifically, coupon rate <em>(C)<\/em>, YTM <em>(y)<\/em>, maturity <em>(m)<\/em>, and interest rate change <em>(\u0394y)<\/em> are 5%, 3%, 5-year, and 0.0001 (1bp) respectively.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The following Excel spreadsheet shows the case of k=1.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"650\" height=\"558\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-8.png\" alt=\"\" class=\"wp-image-202075 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-8.png 650w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-8-300x258.png 300w\" data-sizes=\"(max-width: 650px) 100vw, 650px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 650px; aspect-ratio: 650\/558;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The following Excel spreadsheet shows the case of k=4.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"650\" height=\"1246\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-9.png\" alt=\"\" class=\"wp-image-202077 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-9.png 650w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bond-convexity-formula-shleefintech-9-300x575.png 300w\" data-sizes=\"(max-width: 650px) 100vw, 650px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 650px; aspect-ratio: 650\/1246;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">It is worthwhile to note that when k &gt; 1,&nbsp;t + 1&nbsp;in the convexity definition means&nbsp;<strong>t + 1\/k<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">R code<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The following R code use&nbsp;<strong>derivmkts<\/strong>&nbsp;R package library which provides functions for the calculations of price, yield, duration, and convexity of a coupon bond. The reason why we use this library is that manual implementation of convexity in R is not very different from the case of the duration in the previous post.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">#========================================================#\n# Quantitative ALM, Financial Econometrics &amp; Derivatives \n# ML\/DL using R, Python, Tensorflow by Sang-Heon Lee \n#\n# https:\/\/shleeai.blogspot.com\n#--------------------------------------------------------#\n# Convexity and (modified) Duration\n#========================================================#\n \ngraphics.off()  # clear all graphs\nrm(list = ls()) # remove all files from your workspace\n \nlibrary(derivmkts) # price, yield, duration, convexity\n \n#-------------------------------------------------------\n# Input\n#-------------------------------------------------------\nC   &lt;- 0.05       # coupon rate\ny   &lt;- 0.03       # YTM\nm   &lt;- 5          # maturity\nP   &lt;- 1          # principal amount\ncpn &lt;- C*P       # annual coupon amount\n \n# k = 1 : coupon payments annually\nfreq  &lt;- 1\nprice &lt;- bondpv(cpn, m, y, P, freq)\nduration (price, cpn, m, P, freq, modified = TRUE)\nconvexity(price, cpn, m, P, freq)\n \n# k = 4 : coupon payments quarterly\nfreq  &lt;- 4\nprice &lt;- bondpv(cpn, m, y, P, freq)\nduration (price, cpn, m, P, freq, modified = TRUE)\nconvexity(price, cpn, m, P, freq)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Running the above R code results in the same output as those of Excel illustration.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"r\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&gt; freq  &lt;- 1\n&gt; price &lt;- bondpv(cpn, m, y, P, freq)\n&gt; duration(price, cpn, m, P, freq, modified = TRUE)\n[1] 4.43501\n&gt; convexity(price, cpn, m, P, freq)\n[1] 25.03265\n&gt; \n&gt; freq  &lt;- 4\n&gt; price &lt;- bondpv(cpn, m, y, P, freq)\n&gt; duration(price, cpn, m, P, freq, modified = TRUE)\n[1] 4.450557\n&gt; convexity(price, cpn, m, P, freq)\n[1] 22.32152\n&gt; <\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Final Thoughts<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">From this post, we have understood the meaning of convexity by using an simple derivation and Excel illustration. Finally owing to&nbsp;<strong>derivmkt<\/strong>&nbsp;R package, we can easily implement R code for the calculation of convexity not to mention duration and price of a bond. Now we are ready to describes the&nbsp;<strong>percent(%) change of bond price<\/strong>&nbsp;more precisely with the help of duration and convexity. This topic will be covered in the next post.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>Originally posted on <a href=\"https:\/\/shleeai.blogspot.com\/2021\/09\/bond-convexity-in-excel-and-r.html\">SHLee AI Financial Model<\/a> blog.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post explains the meaning and calculation process of the convexity by using Excel and R.<\/p>\n","protected":false},"author":662,"featured_media":202214,"comment_status":"open","ping_status":"closed","sticky":true,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[339,343,338,341,342],"tags":[16681,806,16682,4922,5878,3918,1006,487],"contributors-categories":[13728],"class_list":["post-202057","post","type-post","status-publish","format-standard","has-post-thumbnail","category-data-science","category-programing-languages","category-ibkr-quant-news","category-quant-development","category-r-development","tag-bond-convexity","tag-data-science","tag-derivmkts-r","tag-econometrics","tag-excel","tag-financial-modeling","tag-fintech","tag-r","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.8) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Bond Convexity in Excel and R | IBKR Quant<\/title>\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\/202057\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Bond Convexity in Excel and R\" \/>\n<meta property=\"og:description\" content=\"This post explains the meaning and calculation process of the convexity by using Excel and R.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-09T15:14:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.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=\"5 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\\\/bond-convexity-in-excel-and-r\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/bond-convexity-in-excel-and-r\\\/\"\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\": \"Bond Convexity in Excel and R\",\n\t            \"datePublished\": \"2024-02-09T15:14:58+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/bond-convexity-in-excel-and-r\\\/\"\n\t            },\n\t            \"wordCount\": 605,\n\t            \"commentCount\": 0,\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\\\/bond-convexity-in-excel-and-r\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/02\\\/bonds-quote-digital-screen.jpg\",\n\t            \"keywords\": [\n\t                \"Bond Convexity\",\n\t                \"Data Science\",\n\t                \"derivmkts R\",\n\t                \"Econometrics\",\n\t                \"Excel\",\n\t                \"Financial Modeling\",\n\t                \"fintech\",\n\t                \"R\"\n\t            ],\n\t            \"articleSection\": [\n\t                \"Data Science\",\n\t                \"Programming Languages\",\n\t                \"Quant\",\n\t                \"Quant Development\",\n\t                \"R Development\"\n\t            ],\n\t            \"inLanguage\": \"en-US\",\n\t            \"potentialAction\": [\n\t                {\n\t                    \"@type\": \"CommentAction\",\n\t                    \"name\": \"Comment\",\n\t                    \"target\": [\n\t                        \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/bond-convexity-in-excel-and-r\\\/#respond\"\n\t                    ]\n\t                }\n\t            ]\n\t        },\n\t        {\n\t            \"@type\": \"WebPage\",\n\t            \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/bond-convexity-in-excel-and-r\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/bond-convexity-in-excel-and-r\\\/\",\n\t            \"name\": \"Bond Convexity in Excel and R | IBKR Campus US\",\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\\\/bond-convexity-in-excel-and-r\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/bond-convexity-in-excel-and-r\\\/#primaryimage\"\n\t            },\n\t            \"thumbnailUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/02\\\/bonds-quote-digital-screen.jpg\",\n\t            \"datePublished\": \"2024-02-09T15:14:58+00:00\",\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\\\/bond-convexity-in-excel-and-r\\\/\"\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\\\/bond-convexity-in-excel-and-r\\\/#primaryimage\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/02\\\/bonds-quote-digital-screen.jpg\",\n\t            \"contentUrl\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/wp-content\\\/uploads\\\/sites\\\/2\\\/2024\\\/02\\\/bonds-quote-digital-screen.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":"Bond Convexity in Excel and R | IBKR Quant","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\/202057\/","og_locale":"en_US","og_type":"article","og_title":"Bond Convexity in Excel and R","og_description":"This post explains the meaning and calculation process of the convexity by using Excel and R.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/","og_site_name":"IBKR Campus US","article_published_time":"2024-02-09T15:14:58+00:00","og_image":[{"width":1000,"height":563,"url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.jpg","type":"image\/jpeg"}],"author":"Sang-Heon Lee","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Sang-Heon Lee","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/"},"author":{"name":"Sang-Heon Lee","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200"},"headline":"Bond Convexity in Excel and R","datePublished":"2024-02-09T15:14:58+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/"},"wordCount":605,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.jpg","keywords":["Bond Convexity","Data Science","derivmkts R","Econometrics","Excel","Financial Modeling","fintech","R"],"articleSection":["Data Science","Programming Languages","Quant","Quant Development","R Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/","name":"Bond Convexity in Excel and R | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.jpg","datePublished":"2024-02-09T15:14:58+00:00","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/bond-convexity-in-excel-and-r\/#primaryimage","url":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.jpg","contentUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.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\/2024\/02\/bonds-quote-digital-screen.jpg","_links":{"self":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/202057","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=202057"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/202057\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media\/202214"}],"wp:attachment":[{"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/media?parent=202057"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=202057"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=202057"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=202057"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}