QuantLib (Python) ZeroCouponBond。合适的收益率曲线

QuantLib (Python) ZeroCouponBond. Appropriate yield curve

我想在 Quantlib 中找到 ZeroCouponBond 的 NPV。我正在为 FixedRateBonds 调整来自 https://quant.stackexchange.com/q/32539 的代码。下面的代码运行 (82.03),但我不确定在零息债券的情况下为期限结构设置哪个 compoundingFrequency。 对我来说唯一有意义的是将折扣因子设置为年度计算。或者我忽略了将 ZeroCouponBond 与 ZeroCurve 一起使用有什么特别之处吗?

    from QuantLib import *

    # Construct yield curve
    calc_date = Date(1, 1, 2017)
    Settings.instance().evaluationDate = calc_date

    spot_dates = [Date(1,1,2017), Date(1,1,2018), Date(1,1,2027)]
    spot_rates = [0.04, 0.04, 0.04]

    day_count = SimpleDayCounter()
    calendar = NullCalendar()
    interpolation = Linear()
    compounding = Compounded
    compounding_frequency = Annual
    spot_curve = ZeroCurve(spot_dates, spot_rates, day_count, calendar,
                           interpolation, compounding,
                           compounding_frequency)

    spot_curve_handle = YieldTermStructureHandle(spot_curve)

    # Construct bond schedule
    issue_date = Date(1, 1, 2017)
    maturity_date = Date(1, 1, 2022)

    settlement_days = 0
    face_value = 100

    bond = ZeroCouponBond(settlement_days,
                          # calendar
                          calendar,
                          # faceamout
                          face_value,
                          # maturity_date
                          maturity_date,
                          # paymentconvention
                          Following,
                          # redemption
                          face_value,
                          # issue date
                          issue_date
                          )

    # Set Valuation engine
    bond_engine = DiscountingBondEngine(spot_curve_handle)
    bond.setPricingEngine(bond_engine)

    # Calculate present value
    value = bond.NPV()

频率不取决于债券是零息债券的事实;这取决于您使用的费率是如何计算或报价的。如果 4% 是按年复合利率计算或引用的,那么您应该使用它;否则,您必须确定“4%”的含义。