Skip to content
All library documents

Forward Bond Cashflows and Discounting with QuantLib

Article Quant Q&A · Author: peanut_butter_from_the_tub

Summary

The post describes pricing bond or loan cashflows at a future reference date using a discount curve built from today’s discount factors. It asks whether changing the reference date in QuantLib’s cashflow NPV calculation automatically produces the appropriate forward discounting, and whether the global evaluation date must also be changed. The cashflows are represented as simple cashflows, and the curve is built from supplied dates and discount factors.

The author reports resolving the issue by recalculating forward discount factors manually and matching the NPV obtained with the settlement-date inclusion setting enabled. That setting matters in this case because the instrument was issued earlier and a cashflow on the settlement date should be included. The post gives a specific implementation outcome, but does not explain curve construction assumptions or establish that changing the reference date alone is generally sufficient. Pricing conventions and the treatment of settlement-date cashflows must match the instrument and valuation setup.

Key ideas

  • The example constructs a discount curve from supplied dates and discount factors, then values a cashflow series at a reference date.
  • The author manually recalculated forward discount factors to check the forward valuation.
  • Including a cashflow on the settlement date changed the result for the previously issued asset in the example.
  • The discussion does not establish that simply moving the reference date always creates the required forward curve.

Tags

Full text
# Forward pricing of cashflows with QuantLib - Python


# Forward pricing of cashflows with QuantLib - Python












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:

- I take the discount factors and I build my Term structure object

- I build the series of ql.SimpleCashFlow(amount, date) object

- 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!

## Answer by peanut_butter_from_the_tub (score 2)

https://quant.stackexchange.com/a/74408

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.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.