0
$\begingroup$

I am building a tool with Quantlib (Python) to work on the forward pricing of different types of assets (inflation linked, amortizing, vanilla, zero coupon bonds).

For a number of reasons I am using the bonds cashflow series as provided by an internal system. From the same system I can get the discount factors associated to each cashflow. So from the start date to the maturity of the bond I have the date schedule, the cashflow amount and the discount factors.

At this stage I do the following:

  1. I take the discount factors and I build my Term structure object
  2. I build the series of ql.SimpleCashFlow(amount, date) object
  3. I compute the npv of the cashflow series with ql.CashFlows.npv(cfs, discountTermStructure, False, reference_date), where cfs is the series of ql.SimpleCashflow, discountTermStructure is my discount curve and reference date is the as of date of the npv.

My doubt is when it comes to moving the reference date forward. At high level I expect that the discountTermStructure is built from the today discount curve (discount factors taken from the internal system at today date) and then when I use a reference date equal to the forward date, this makes the implied discount curve in the discountTermStructure to be the forward discount curve, so that the discounting is performed only for the cashflows following the reference date and with the forward discount factors (implied in today discount curves).

Is the above correct?

Following my code (I will avoid displaying the inputs for simplicity)

'''
my discount curve object
'''
discountCurve = ql.DiscountCurve(dates_schedule, discount_factors, dayCount)
discountTermStructure = ql.RelinkableYieldTermStructureHandle()
discountTermStructure.linkTo(discountCurve)

''' my cashflow series, leg is a list of cashflow amounts'''
cfs = [ql.SimpleCashFlow(cashflow, d) for d, cashflow in zip(dates, leg) ]

''' NPV calculation, as at reference_date which can be today or forward date '''
P = ql.CashFlows.npv(cfs, discountTermStructure, False, reference_date)

Should I also insert

ql.Settings.instance().setEvaluationDate(reference_date)

before the calculation of the NPV?

Thanks!

$\endgroup$
1
  • $\begingroup$ Can you please put your solution as an answer instead of an edit? $\endgroup$
    – Bob Jansen
    Jan 19 at 15:02

1 Answer 1

1
$\begingroup$

Solved: I manually recalculated the forward discount factors and the NPV that I get matches the one that I get with

P = ql.CashFlows.npv(cfs, discountTermStructure, True, reference_date)

Note that in the above I have changed the boolean value False to True, as in my case, the asset (loan or bond) was issued at a previous date. In this case you want to include the cashflow that occurs on the settlement date.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.