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?