Skip to main content
edited tags
Link
Bogaso
  • 928
  • 1
  • 9
  • 21
Source Link
Bogaso
  • 928
  • 1
  • 9
  • 21

How to price an Annuity

When we price a fixed rate bond using Quantlib, we generally take below approach -

import QuantLib as ql import pandas as pd todaysDate = ql.Date(31, 8, 2019) ql.Settings.instance().evaluationDate = todaysDate spotDates = [ql.Date(1,9,2019), ql.Date(5,9,2019), ql.Date(7,9,2019)] spotRates = [0.066682, 0.067199, 0.067502] dayCount = ql.Actual365Fixed() calendar = ql.SouthAfrica() interpolation = ql.Linear() compounding = ql.Compounded compoundingFrequency = ql.Semiannual spotCurve = ql.ZeroCurve(spotDates, spotRates, dayCount, calendar, interpolation, compounding, compoundingFrequency) spotCurveHandle = ql.YieldTermStructureHandle(spotCurve) issueDate = ql.Date(20, 4, 2017) maturityDate = ql.Date(20, 4, 2019) tenor = ql.Period(ql.Semiannual) calendar = ql.SouthAfrica() bussinessConvention = ql.Following dateGeneration = ql.DateGeneration.Backward monthEnd = False schedule = ql.Schedule(issueDate, maturityDate, tenor, calendar, bussinessConvention, bussinessConvention, dateGeneration, monthEnd) dayCount = ql.Actual365Fixed() couponRate = 0.0925 coupons = [couponRate] settlementDays = 3 faceValue = 100 fixedRateBond = ql.FixedRateBond(settlementDays, faceValue, schedule, coupons, dayCount) bondEngine = ql.DiscountingBondEngine(spotCurveHandle) fixedRateBond.setPricingEngine(bondEngine) fixedRateBond.NPV() 

However my question is - instead of a typical bond if I need to price the Annuity (i.e. there is no Principal payment at the maturity), how can I modify above codebase?

Any pointer will be highly appreciated.