我正在尝试使用 Quantlib (v1.2) SWIG 包装器在 python 中为一个非常基本的浮动利率债券定价。我修改了文档中包含的示例。
我的债券期限为 4 年。libor 设置为 10%,债券的利差为 0。我的问题是,如果我以 10% 的利率贴现,为什么债券的 PV 不是 100?我得到的值为 99.54。
谢谢!
from QuantLib import *
frequency_enum, settle_date = 4, Date(5, 1, 2010)
maturity_date = Date(5, 1, 2014)
face_amount = 100.0
settlement_days = 0
fixing_days = 0
calendar = NullCalendar()
settle_date = calendar.adjust(settle_date)
todays_date = calendar.advance(settle_date, -fixing_days, Days)
Settings.instance().evaluationDate = todays_date
rate = 10.0 / 100.0
flat_forward = FlatForward(settle_date,
rate,
Thirty360(),
Compounded,
frequency_enum)
discounting_term_structure = RelinkableYieldTermStructureHandle(flat_forward)
index_term_structure = RelinkableYieldTermStructureHandle(flat_forward)
index = USDLibor(Period(3, Months), index_term_structure)
schedule = Schedule(settle_date,
maturity_date, Period(frequency_enum),
NullCalendar(),
Unadjusted, Unadjusted,
DateGeneration.Forward, False)
floating_bond = FloatingRateBond(settlement_days,
face_amount,
schedule,
index,
Thirty360(),
Unadjusted,
fixing_days,
[], # Gearings
[0], # Spreads
[], # Caps
[], # Floors
False, # Fixing in arrears
face_amount,
settle_date)
bond_engine = DiscountingBondEngine(discounting_term_structure)
floating_bond.setPricingEngine(bond_engine)
# coupon pricers
pricer = BlackIborCouponPricer()
volatility = 0.0
vol = ConstantOptionletVolatility(settlement_days,
calendar,
Unadjusted,
volatility,
Thirty360())
pricer.setCapletVolatility(OptionletVolatilityStructureHandle(vol))
setCouponPricer(floating_bond.cashflows(), pricer)
print floating_bond.NPV(), floating_bond.cleanPrice(), floating_bond.dirtyPrice()