Soy nuevo en QuantLib y estoy confundido sobre ZeroCurve
en YieldTermStructureHandle
La fecha de inicio es el 20 de octubre de 2001. Suponiendo que la fecha de evaluación es el 8 de mayo de 2017, y puedo obtener el ytm, que es 4,3291. Creo que puedo construir una curva de rendimiento plana y descontar el flujo de caja. Sin embargo, dice que el tiempo negativo (-0,452055) dado.
from QuantLib import *
todaysDate = Date(8, 5, 2017)
Settings.instance().evaluationDate = todaysDate
spotDates = [Date(20, 4, 2017)+Period(i*6, Months) for i in range(1, 10)]
spotRates = [4.3291/100]*len(spotDates)
dayCount = ActualActual()
calendar = China()
interpolation = Linear()
compounding = Compounded
compoundingFrequency = 2
spotCurve = ZeroCurve(spotDates, spotRates, dayCount, calendar, interpolation, compounding, compoundingFrequency)
spotCurveHandle = YieldTermStructureHandle(spotCurve)
issueDate = Date(20, 10, 2001)
maturityDate = Date(20, 10, 2021)
tenor = Period(2)
bussinessConvention = Following
dateGeneration = DateGeneration.Backward
monthEnd = False
schedule = Schedule(issueDate, maturityDate, tenor, calendar, bussinessConvention, bussinessConvention, dateGeneration, monthEnd)
couponRate = 4.2/100
coupons = [couponRate]
settlementDays =
faceValue = 100
fixedRateBond = FixedRateBond(settlementDays, faceValue, schedule, coupons, dayCount)
bondEngine = DiscountingBondEngine(spotCurveHandle)
fixedRateBond.setPricingEngine(bondEngine)
fixedRateBond.NPV()