Skip to content
All library documents

Zero-Coupon Bond Pricing Near Maturity in QuantLib

Article Quant Q&A · Author: pyCthon

Summary

This note explains why QuantLib may reject clean-price calculations for a zero-coupon bond when the settlement date falls after maturity. The library models the bond as no longer tradable on that settlement date, even though a holder immediately before maturity still has a claim to the final payment. The accepted answer distinguishes valuation from tradable price: net present value can represent the payment discounted over the remaining time, while clean-price methods assume a valid settlement and may return zero or raise an error.

The discussion also identifies limits to that convention. Bonds can sometimes continue trading at or after contractual maturity, such as when payment operations are inconvenient, during a high-yield grace period, or after default. In those cases, yield and accrued-interest conventions may be inappropriate. The examples are conceptual and do not provide a general QuantLib workaround or establish how every market handles such trades; users must match the instrument and pricing measure to the relevant market convention.

Key ideas

  • Clean-price calculations depend on a valid settlement date, which may fall beyond a near-maturity bond's life.
  • A bond can retain economic value just before maturity even when it is no longer tradable under standard settlement assumptions.
  • Net present value can value the remaining final payment when clean-price methods cannot.
  • Some distressed or operationally unusual bonds may continue trading beyond ordinary maturity conventions.

Tags

Full text
# Pricing near to expiration bonds using QuantLib


# Pricing near to expiration bonds using QuantLib












I want to get the theoretical price of a zero coupon bond each day using quantlib, I'm able do to this up to just before the maturity date where I get the following error: `# RuntimeError: non tradable at April 17th, 2023 settlement date (maturity being April 14th, 2023)` I'm not sure if this is a bug with quantlib or a misunderstanding of how conventions work in fixed income so I came here to post the example below as I'm not sure why the settlement dates need to be tradeable.

```
import QuantLib as ql

settlement_days = 2
eval_date = ql.Date(13, 4, 2023)
rf_rate = 4.75845 / 100.0

def zero_coupon_bond(rf, dt, maturity, settlement_days=2):
    ql.Settings.instance().evaluationDate = dt
    zcb = ql.ZeroCouponBond(settlement_days, ql.UnitedStates(), 100, maturity)
    crv = ql.FlatForward(settlement_days, ql.UnitedStates(), rf, ql.Actual360()) 
    zcb_price = ql.BondFunctions.cleanPrice(zcb, crv)
    return zcb_price

# Example showing code working

maturity = ql.Date(19, 4, 2023)
print(zero_coupon_bond(rf_rate, eval_date, maturity, settlement_days))

# Near to maturity QL error

maturity = ql.Date(14, 4, 2023)
print(zero_coupon_bond(rf_rate, eval_date, maturity, settlement_days))
```

## Answer by Luigi Ballabio (score 2, accepted)

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

One day before maturity, the bond has still value for you (because you'll receive the final payment tomorrow) but it can no longer be traded, because the deal would settle after two settlement days, when the bond no longer exists. Thus, you can call `bond.NPV()` which will give you the value of the final payment discounted by one day, but if you call `bond.cleanPrice()` you'll get 0, and if you call `ql.BondFunctions.cleanPrice(bond, curve)` you'll get the error you're seeing.

## Answer by Dimitri Vulis (score 2)

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

This is a convenient assumption for a library, but I can think of a few use cases when people do trade bonds close to or even after the maturity date, although "yield" makes no sense, and "clean price" or "accrued" might not either.

In some emerging markets, e.g. Argentina, some bondholders don't like the operational process of getting paid at bond's maturity, so they sell the bonds as late as maturity date, at a very small discount from face value, to other people who get paid for dealing with the perceived inconvenience.

High-yield bonds sometimes don't pay exactly at maturity, but continue to trade during the grace period. If investors expect possible default, the bonds may trade at material discount. (Example https://www.aljazeera.com/economy/2021/10/26/chinese-developer-modern-land-becomes-latest-builder-to-default )

And of course defaulted bonds can still trade.

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.