# 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?

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.