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?


1 Answer 1


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).


Your Answer

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

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