为债券构建未来的息票支付日期

constructing future coupon payment dates for bonds

我有一个问题,如果你能帮助我,我将不胜感激。

起始情况:

第一种情况:3 年,每年 2 次优惠券支付 -> 因此接下来的 3 年每 6 个月支付一次优惠券。与 1 年 4 倍的息票支付相同。

结果: 它应该是这样的:

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"

这只是一个示例。在我的例子中,我有更多的 ISINS、日期、不同的年份和优惠券频率。

谢谢

您可以使用 months 函数构造未来的息票支付日期并将计算包装在 可以为单个债券访问的自定义函数。

您对债券 2 的预期输出中存在错字,其中最后两个值应对应于 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"