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

时间:2018-11-07 10:43:59

标签: quantlib

我想在Quantlib中找到ZeroCouponBond的NPV。我正在改编https://quant.stackexchange.com/q/32539中的FixedRateBonds代码。下面的代码运行(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()

1 个答案:

答案 0 :(得分:0)

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