Search code examples
rdatefrequencyrep

constructing future coupon payment dates for bonds


I have a Problem and would be very grateful if you could help me.

starting Situation:

  • Bonds: "026351AZ9" "026351BC9"
  • First Coupon Date of These Bonds: "2029-02-15" "2010-09-11" (class date)
  • Count of the years where the bonds pay coupons: 3 years and 1 years
  • each years has also a Coupon frequency: 2 and 4, that means that during the next year there will be 2 payments (4 payments)

First case: 3 years and each year 2 times Coupon payment -> so every 6 month Coupon payment for the next 3 years. Same with 1 year and 4 times coupn payment.

Result: It should be look like this:

datesBond1 = "2029-02-15" "2029-08-15" "2030-02-15" "2030-08-15" "2031-02-15" "2031-08-15"

datesBond2 = "2010-09-11" "2010-12-11" "2010-03-11" "2010-06-11"

This is just a sample. In my case I have a lot more ISINS, Dates, and various years and Coupon frequencies.

Thank you


Solution

  • You can use the months function to contruct future coupon payments dates and wrap the calculation in a custom function that could be accessed for individual bonds.

    There is typo in your expected output for bond 2 where last two values should correspond to year 2011.

    fn_cpnPayDates = function(cpnStartDt = as.Date("2029-02-15"),numYears = 3, freq = 6) {
    
    # number of coupon payments per year
    numPayPerYear = 12 / freq
    
    #total payments
    numPayments = numYears * numPayPerYear
    
    cpnDatesAll = rep(cpnStartDt, numPayments)
    
    for(i in 1:numPayments) cpnDatesAll[i] = cpnDatesAll[i] + months((i-1)* freq)
    
    
    return(cpnDatesAll)
    
    }
    
    datesBond1 = fn_cpnPayDates(cpnStartDt = as.Date("2029-02-15"),numYears = 3, freq = 6)
    datesBond1
    #[1] "2029-02-15" "2029-08-15" "2030-02-15" "2030-08-15" "2031-02-15" "2031-08-15"
    
    datesBond2 = fn_cpnPayDates(cpnStartDt = as.Date("2010-09-11"),numYears = 1, freq = 3)
    datesBond2
    #[1] "2010-09-11" "2010-12-11" "2011-03-11" "2011-06-11"