首页 > 解决方案 > 使用债券投资组合在 QuantLib 中引导收益率曲线

问题描述

我正在尝试使用 2021 年、2022 年、2023 年等到期的债券批次在 Quantlib 中引导政府债券收益率曲线,但收益率曲线引导通常会失败,并显示“根不括号”消息,即使捆绑中的单个债券似乎被市场合理定价。我还注意到,例如,Quantlib 将我的第一个捆绑包(大约 2021 年到期债券)的 YTM 计算为大约 3%,即使其中没​​有一个超过 YTM 0.5%。

这是我创建债券投资组合/捆绑的代码:

for i, row in rows.iterrows():
        newMaturityDate = parse_date(row["MaturityDate"])
        date = parse_date(row["CouponPeriodEndDate"])
        if date == newMaturityDate and date != maturityDate:
            if date in amortizingPayments:
                amortizingPayments[date] += 100.0
            else:
                amortizingPayments[date] = 100.0
            notional += 100.0
        elif date == maturityDate:
            notionalAtMaturity += 100.0
            notional += 100.0
            
    for d in amortizingPayments:
        p = amortizingPayments[d]
        cashflows += [ql.AmortizingPayment(p, d)]
            
    for i, row in rows.iterrows():
        rate = parse_perc_float(row["couponrate"])
        startDate = parse_date(row["CouponPeriodStartDate"])
        date = parse_date(row["CouponPeriodEndDate"])
        cashflows += [ql.FixedRateCoupon(date, 100.0, rate, dayCounter,
                                      startDate, date,
                                      startDate, date,
                                        date)]
        
    cashflows += [ql.Redemption(notionalAtMaturity, maturityDate)]
      
    bundle = ql.Bond(3, ql.TARGET(), notional, maturityDate, issueDate, cashflows) 

在进行引导时,我将捆绑的净价格等于单个债券的净价格的平均值。

有什么方法可以在 QuantLib 中完成我想要实现的目标,还是有一些基本/技术原因没有?

标签: bootstrappingquantlib

解决方案


推荐阅读