{"id":208425,"date":"2024-06-28T10:23:01","date_gmt":"2024-06-28T14:23:01","guid":{"rendered":"https:\/\/ibkrcampus.com\/?p=208425"},"modified":"2024-08-12T15:28:50","modified_gmt":"2024-08-12T19:28:50","slug":"coupon-bearing-bond-pricing-using-r-code","status":"publish","type":"post","link":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/","title":{"rendered":"Coupon Bearing Bond Pricing Using R Code"},"content":{"rendered":"\n<p>This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-introduction\">Introduction<\/h3>\n\n\n\n<p>There are pricing formula for coupon bond as well as discount bond which are used among practioners under the market convention.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"h-bond-pricing-formula\">Bond Pricing Formula<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"867\" height=\"364\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-discount-bond-formula.png\" alt=\"\" class=\"wp-image-208427 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-discount-bond-formula.png 867w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-discount-bond-formula-700x294.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-discount-bond-formula-300x126.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-discount-bond-formula-768x322.png 768w\" data-sizes=\"(max-width: 867px) 100vw, 867px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 867px; aspect-ratio: 867\/364;\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"903\" height=\"679\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-coupon-bond-formula.png\" alt=\"\" class=\"wp-image-208428 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-coupon-bond-formula.png 903w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-coupon-bond-formula-700x526.png 700w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-coupon-bond-formula-300x226.png 300w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-coupon-bond-formula-768x577.png 768w\" data-sizes=\"(max-width: 903px) 100vw, 903px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 903px; aspect-ratio: 903\/679;\" \/><\/figure>\n\n\n\n<p>From the above formula, denominator <img decoding=\"async\" width=\"179\" height=\"66\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-bond-formula-1.png\" alt=\"\" class=\"wp-image-208429 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 179px; aspect-ratio: 179\/66;\"> \nindicates that if valuation date t<sub>val<\/sub>\nfall on between interest payment dates <img decoding=\"async\" width=\"193\" height=\"42\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/shlee-bond-formula-2.png\" alt=\"\" class=\"wp-image-208430 lazyload\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 193px; aspect-ratio: 193\/42;\">\nthe simple interest rate calculation is applied to the period t<sub>val<\/sub> \u2212 t<sub>ni<\/sub>, not continously compounding.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Bond Pricing Example<\/h3>\n\n\n\n<p>The following table shows the cash flow schedule of coupon bond with&nbsp;<strong>in-advance<\/strong>&nbsp;interest payments. From the fact that the number of cash flow starts from 8 to 14, we can find that the recent settled cash flow payment is 6th not 7th. This contract is of in-advance interest payment features. See the accrual begin date and payment date.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"358\" height=\"199\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/CF_schdule-shlee.png\" alt=\"\" class=\"wp-image-208433 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/CF_schdule-shlee.png 358w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/CF_schdule-shlee-300x167.png 300w\" data-sizes=\"(max-width: 358px) 100vw, 358px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 358px; aspect-ratio: 358\/199;\" \/><\/figure>\n\n\n\n<p>Consider two cases :<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>valuation date = 7th interest payment date<\/li>\n\n\n\n<li>7th interet payment date &lt; valuation date &lt; 8th interest payment date<\/li>\n<\/ol>\n\n\n\n<p>The maturity date is 2019-07-29 which is 4 more days later than 2019-07-25 (last day in a quarterly basis). Taking this into account, we can draw cash flows time lines for two cases.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"550\" height=\"402\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/bond_cash_flow_time_line-shlee.png\" alt=\"\" class=\"wp-image-208434 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/bond_cash_flow_time_line-shlee.png 550w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/bond_cash_flow_time_line-shlee-300x219.png 300w\" data-sizes=\"(max-width: 550px) 100vw, 550px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 550px; aspect-ratio: 550\/402;\" \/><\/figure>\n\n\n\n<p>In other words, since maturity date is 2019-07-29, interet for 4 remaining days is paid at 2019-07-25 in advance. Of couse, principal redemption is made at 2019-07-29.<\/p>\n\n\n\n<p>But for calculation is done for the second case since the second case is more general than the first and the first case is simple to calculate. With these in-advance payment features, the pricing equation for this coupon bond (clean price) at 2018-03-22 is as follows.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"550\" height=\"149\" data-src=\"\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/bond_price_formula_application-shlee.png\" alt=\"\" class=\"wp-image-208435 lazyload\" data-srcset=\"https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/bond_price_formula_application-shlee.png 550w, https:\/\/ibkrcampus.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/06\/bond_price_formula_application-shlee-300x81.png 300w\" data-sizes=\"(max-width: 550px) 100vw, 550px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 550px; aspect-ratio: 550\/149;\" \/><\/figure>\n\n\n\n<p>The explanation of pricing process with cash flow timeline and equation above is<\/p>\n\n\n\n<p>1) Amount in [ ] is the discounted value of all cashflows since 2018\/04\/26 evaluating at 2018\/04\/26 (first payment date) not 2018\/03\/22 (valuation date).<\/p>\n\n\n\n<p>&nbsp; 2) Discount amount in [] with 35\/90 quarter simply compouding to 2018\/03\/22 value (dirty price).<\/p>\n\n\n\n<p>&nbsp; 3) The portion of 35\/90 in interest previously paid at 2018\/01\/26 should be returned to buyer. This is called as accrued interest and reflected to the last term.<\/p>\n\n\n\n<p>&nbsp; 4) Therefore, dirty price + accrued interest is the clean price which is equal to&nbsp;P????.<\/p>\n\n\n\n<p>It is a market convention that dirty and clean price of in-advance interest payments is the other way around of regular coupon bond with in-arrears interest payment.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">R code for Bond Pricing<\/h3>\n\n\n\n<p>The following R code is implemented using the above formula and specific considerations such as in-advance features, in-between settlement, &#8230; etc.<\/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# Financial Econometrics &amp; Derivatives, ML\/DL using R, Python, Tensorflow \n# by Sang-Heon Lee \n#\n# https:\/\/shleemodel.blogspot.com \n#-------------------------------------------------------------------------#\n# Coupon Bond Valuation with in advance interest payment\n#=========================================================================#\n \ngraphics.off()  # clear all graphs\nrm(list=ls())   # clear all datasets\n \n#-----------------------------------------------------------------#\n# Specification\n#-----------------------------------------------------------------#\n# valuation date   : 2018-03-22\n# maturity date    : 2019-07-29\n# coupon rate      : annual 6.2%, quarterly coupon with in advance\n# principal amount : Bullet repayment at maturity \n#-----------------------------------------------------------------#\n \n    cpn.rate &lt;- 0.062    # coupon rate\n    int.rate &lt;- 0.062    # interest rate\n    mat.qrt  &lt;- 6        # # of interest payments\n \n    # initialization\n    cpn.amt &lt;- 0  # coupon payments\n    prn.amt &lt;- 0  # principal amount\n    price   &lt;- 0  # bond price\n    \n    # 2018.04.26's discounted value of coupon payments\n    for (t in 0:(mat.qrt-2)) { \n        cpn.amt &lt;- cpn.amt + (cpn.rate\/4)*10000\/\n                             (1+int.rate\/4)^t\n    }\n    \n    # 2018.04.26's discounted value of \n    # 4-day coupon payment at 2019.07.25\n    cpn.amt &lt;- cpn.amt + (cpn.rate\/4)*(4\/93)*10000\/\n                         (1+int.rate\/4)^(mat.qrt-1)\n \n    # 2018.04.26's discounted value of \n    #principal amount at 2019.07.29\n    prn.amt &lt;- 10000\/\n              ((1+(int.rate\/4)*(4\/93))*(1+int.rate\/4)^(mat.qrt-1))\n    \n    # 2018.04.26's bond price\n    price &lt;- cpn.amt + prn.amt\n    \n    print(paste(\" bond price before discounting at pricing date:\", price))\n \n    #-----------------------------------------------------------------#\n    # 2018.03.22's discounted value of all cash flow\n    # = present value of all cash flow\n    # = bond price at valuation date\n    #-----------------------------------------------------------------#\n    # present value discounted at pricing date using simple interest \n    #-----------------------------------------------------------------#\n    price = price\/(1+(int.rate\/4)*(35\/90))\n    \n    print(paste(\"bond price discounting at pricing date using simple interest :\", price))\n    \n    dirty.price      &lt;- round(price,2)\n    accrued.interest &lt;- round((10000*int.rate\/4)*(35\/90),2)\n    clean.price      &lt;- round(dirty.price + accrued.interest,2)\n \n    print(\"clean price = dirty price + accrued interest\") \n    print(paste(clean.price, \"=\", price, \"+\", accrued.interest))<\/pre>\n\n\n\n<p>The result is as follows.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[1] \"price before discounting at pricing date: 10011.47\"\n[1] \"price discounting at pricing date using simple interest: 9951.49\"\n[1] \"clean price = dirty price + accrued interest\"\n[1] \"10011.77 = 9951.4922404715 + 60.28\"<\/pre>\n\n\n\n<p>This post has showed the pricing of some complicated coupon bond, not simple regular coupon bond. But the bottom line is to apply simple interest to incomplete accrual period and compound interest to complete accrual period.<\/p>\n\n\n\n<p>Next time, let&#8217;s dive into YTM(Yield to Maturity) and reinvestment risk with EXCEL illustrations and R code.<\/p>\n\n\n\n<p><em>Originally posted on <a href=\"https:\/\/shleeai.blogspot.com\/2021\/06\/coupon-bearing-bond-pricing-using-r-code.html\">SHLee AI Financial Model<\/a>.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.<\/p>\n","protected":false},"author":662,"featured_media":202214,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[339,343,338,341,342],"tags":[45,806,487],"contributors-categories":[13728],"class_list":{"0":"post-208425","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-development","11":"category-r-development","12":"tag-bonds","13":"tag-data-science","14":"tag-r","15":"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.4) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Coupon Bearing Bond Pricing Using R Code | IBKR Quant<\/title>\n<meta name=\"description\" content=\"This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.\" \/>\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\/208425\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Coupon Bearing Bond Pricing Using R Code\" \/>\n<meta property=\"og:description\" content=\"This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/\" \/>\n<meta property=\"og:site_name\" content=\"IBKR Campus US\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-28T14:23:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-12T19:28:50+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=\"4 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\\\/coupon-bearing-bond-pricing-using-r-code\\\/#article\",\n\t            \"isPartOf\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/coupon-bearing-bond-pricing-using-r-code\\\/\"\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\": \"Coupon Bearing Bond Pricing Using R Code\",\n\t            \"datePublished\": \"2024-06-28T14:23:01+00:00\",\n\t            \"dateModified\": \"2024-08-12T19:28:50+00:00\",\n\t            \"mainEntityOfPage\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/coupon-bearing-bond-pricing-using-r-code\\\/\"\n\t            },\n\t            \"wordCount\": 477,\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\\\/coupon-bearing-bond-pricing-using-r-code\\\/#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                \"bonds\",\n\t                \"Data Science\",\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\\\/coupon-bearing-bond-pricing-using-r-code\\\/#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\\\/coupon-bearing-bond-pricing-using-r-code\\\/\",\n\t            \"url\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/coupon-bearing-bond-pricing-using-r-code\\\/\",\n\t            \"name\": \"Coupon Bearing Bond Pricing Using R Code | 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\\\/coupon-bearing-bond-pricing-using-r-code\\\/#primaryimage\"\n\t            },\n\t            \"image\": {\n\t                \"@id\": \"https:\\\/\\\/www.interactivebrokers.com\\\/campus\\\/ibkr-quant-news\\\/coupon-bearing-bond-pricing-using-r-code\\\/#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-06-28T14:23:01+00:00\",\n\t            \"dateModified\": \"2024-08-12T19:28:50+00:00\",\n\t            \"description\": \"This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.\",\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\\\/coupon-bearing-bond-pricing-using-r-code\\\/\"\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\\\/coupon-bearing-bond-pricing-using-r-code\\\/#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":"Coupon Bearing Bond Pricing Using R Code | IBKR Quant","description":"This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.","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\/208425\/","og_locale":"en_US","og_type":"article","og_title":"Coupon Bearing Bond Pricing Using R Code","og_description":"This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.","og_url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/","og_site_name":"IBKR Campus US","article_published_time":"2024-06-28T14:23:01+00:00","article_modified_time":"2024-08-12T19:28:50+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":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"NewsArticle","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/#article","isPartOf":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/"},"author":{"name":"Sang-Heon Lee","@id":"https:\/\/ibkrcampus.com\/campus\/#\/schema\/person\/0a959ff9de7f0465a07baa1fe1ae0200"},"headline":"Coupon Bearing Bond Pricing Using R Code","datePublished":"2024-06-28T14:23:01+00:00","dateModified":"2024-08-12T19:28:50+00:00","mainEntityOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/"},"wordCount":477,"commentCount":0,"publisher":{"@id":"https:\/\/ibkrcampus.com\/campus\/#organization"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.jpg","keywords":["bonds","Data Science","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\/coupon-bearing-bond-pricing-using-r-code\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/","url":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/","name":"Coupon Bearing Bond Pricing Using R Code | IBKR Campus US","isPartOf":{"@id":"https:\/\/ibkrcampus.com\/campus\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/#primaryimage"},"image":{"@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/#primaryimage"},"thumbnailUrl":"https:\/\/www.interactivebrokers.com\/campus\/wp-content\/uploads\/sites\/2\/2024\/02\/bonds-quote-digital-screen.jpg","datePublished":"2024-06-28T14:23:01+00:00","dateModified":"2024-08-12T19:28:50+00:00","description":"This post explains how to calculate the price of some complicated coupon-bearing bonds using R code.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.interactivebrokers.com\/campus\/ibkr-quant-news\/coupon-bearing-bond-pricing-using-r-code\/#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\/208425","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=208425"}],"version-history":[{"count":0,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/posts\/208425\/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=208425"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/categories?post=208425"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/tags?post=208425"},{"taxonomy":"contributors-categories","embeddable":true,"href":"https:\/\/ibkrcampus.com\/campus\/wp-json\/wp\/v2\/contributors-categories?post=208425"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}