No announcement yet.
  • Filter
  • Time
  • Show
Clear All
new posts

  • calculating yield to maturity for coupon bonds


    I do a research on bond market. Searching on the net, I could not find any stata cammand which calculate YTM (for each day) based on price, time to maturity, coupon rate, and par value of some bonds. I appreciate if there is a stata command to do so or any other suggestion for obtaining YTM for such a big (daily) data set.

  • #2
    I found
    almost instantly. However, this website charges.

    might also be helpful.

    If this is not what you want, then you may be able to start with this code and then modify it to fit your problem. Alternatively, write out what you want to calculate, try to program it, and then ask Statalist for help. Don't assume we know the formula you want to program - tell us.


    • #3
      Thank you Phil;

      I will try to say what I am searching for more exactly.
      I have about 7000 daily observations containing price of some (20) different coupon bonds (panel data). Additionally, I have issuing date, maturity date, date of first coupon payment, time period between coupons, nominal rate of each coupon, and par value for each bond in a separated data set which I have merged it with the former. So I have current price, par value, time to maturity or time to receiving par value (T), coupon value (cf_{t}), and time to receiving each coupon (t_{i}= t_{1}, t_{2},…) [or time to first coupon, number of remained coupon, and time interval between coupons which as will be shown in following paragraphs I think are more convenient information].

      I want to calculate yield to maturity for each observation which is the R solving following equation.

      \[ Current Price= \frac{cf_{t_{1}}}{{(1+R)}^{ t_{1}}}+\frac{cf_{ t_{2}}}{{(1+R)}^{ t_{2}}}+...+\frac{par value}{{(1+R)}^{T}} =\sum_{t_{i}= t_{1}, t_{2},…}\frac{cf_{t_{i}}}{{(1+R)}^{ t_{i}}}+\frac{par value}{{(1+R)}^{T}} \]

      At first sight I thought it will be easy to define a user defined ado file which receives aforementioned information and uses solvenl() to calculate yield to maturity; However, there is a problem. With this in mind that some coupons will be paid after some specific days, each bond has different remained coupon bond in different days. Thus ado file should make and solve a different equation with respect to remained coupons. I have no idea how I can write such ado file.

      Would you mind helping me?


      • #4
        You can think of the yield to maturity (YTM) as the bond's internal rate of return (IRR). While it is possible to write a program that can calculate this for a fixed number of periods (see here, for example), even the most seasoned programmers might struggle to come up with a routine that handles arbitrary number of periods and varying coupons. Stata is not built for this kind of optimization - you are better off computing the YTM in Excel or elsewhere and exporting the result to Stata. However, there is a formula which approximates the YTM that you can easily implement in Stata.

        Searching a bit further, there seems to be such a program in existence. Have not downloaded it or used it, so I can't vouch for it.
        Last edited by Andrew Musau; 15 Feb 2019, 08:09.