Я хочу найти NPV ZeroCouponBond в Quantlib. Я адаптирую код от https://quant.stackexchange.com/q/32539 для FixedRateBonds. Приведенный ниже код запускается (82.03), но я не уверен, какое значение componentingFrequency установить для структуры сроков в случае облигации с нулевым купоном.
Единственное, что имеет для меня смысл, - это установить коэффициенты дисконтирования для ежегодного расчета. Или есть что-то особенное в использовании 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()