Skip to content
All library documents

Why QuantLib Zero-Yield Structures Use Continuous Compounding

Article Quant Q&A · Author: SmallChess

Summary

This document explains the convention used by QuantLib's zero-yield structure when it converts a zero rate into a discount factor. The implementation applies the exponential discount formula, which corresponds to continuous compounding. The question is whether this means zero rates must always be continuously compounded, even when a practitioner has bond rates quoted with a convention such as semiannual compounding.

The response clarifies that this is a requirement of the particular base class interface, not a general financial rule. Derived implementations are expected to provide continuously compounded zero rates because the class uses that convention to calculate discounts. Other compounding conventions remain valid, but their rates must be converted to discount factors using the appropriate formula; within QuantLib, that may require a custom adapter or extension. The document concerns library design and rate conversion, not a claim that one convention is financially superior.

Key ideas

  • QuantLib's zero-yield structure calculates discount factors from continuously compounded rates.
  • The convention follows from the base class implementation contract rather than a universal financial requirement.
  • Zero rates quoted under other compounding conventions can still be used.
  • Those rates need a matching discount formula, potentially implemented with a custom adapter in QuantLib.

Tags

Full text
# Why QuantLib assumes zero rates to discount factor is continuous?


# Why QuantLib assumes zero rates to discount factor is continuous?












https://github.com/lballabio/QuantLib/blob/0ec43027834220baf0a554d68de79a159a2c5489/ql/termstructures/yield/zeroyieldstructure.hpp

```
inline DiscountFactor ZeroYieldStructure::discountImpl(Time t) const {
    if (t == 0.0)     // this acts as a safe guard in cases where
        return 1.0;   // zeroYieldImpl(0.0) would throw.

    Rate r = zeroYieldImpl(t);
    return DiscountFactor(std::exp(-r*t));
}
```

The code is an adapter for zero rates because QuantLib does everything by discount factor. It converts a zero rate to a discount factor.

What I don't understand is why we always assume everything is continuously compounded? For example, if I have a bond I'd probably prefer semi-annual compounding.

Q: Is there a reason why when given zero rates, we can always assume it's continuous compounded? Does that mean if we have a set of zero rates for discounting, anything other than continuous compounded is invalid?

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

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

It's not an assumption; it's a requirement. The base class `ZeroYieldStructure` requires derived classes to implement a `zeroYieldImpl` method that returns continuously compounded rates, because that's what it uses in the implementation of `discountImpl`. I don't remember the discussion at the time we implemented this—it was quite a few years ago—but I assume (pun not intended) that we wanted to keep it simple, so we only covered the most usual case.

The constraint is not financial; it's simply due to the implementation. It's ok if you have a set of zero rates with some other compounding convention. But in that case, you'll have to calculate the discounts with some other formula (and in the context of the library, write your own adapter class or extend the existing one to manage different conventions).

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.