Posted by
Luigi Ballabio-4 on
Apr 25, 2002; 6:06am
URL: http://quantlib.414.s1.nabble.com/Forwards-tp2011p2017.html
At 11:42 AM +0200 4/25/02, Ferdinando Ametrano wrote:
>What about the following interface:
> //! discount factor at a given date
> DiscountFactor discount(const Date&, bool extrapolate = false) const;
> //! zero yield rate at a given date
> Rate zeroYield(const Date&, bool extrapolate = false) const;
> //! forward (zero) rate between two dates
> Rate forward(const Date&, const Date&, bool extrapolate =
>false) const;
> //! instantaneous forward (zero) rate at a given date
> Rate instantaneousForward(const Date&, bool extrapolate =
>false) const;
I completely agree on the interface. But since I can't write a mail
in which I simply agree with you, :) I'd like a clarification of:
>where of course zeroYield(myDate)==forward(settlementDate(), myDate) ?
If you're talking of a mathematical relationship, the "of course" holds.
But if you're meaning that the above would be the implementation of
zeroYield, it is a possibility, but there's also the possibility to
have
forward(t1,t2) = (t2*zeroYield(t2)-t1*zeroYield(t1))/(t2-t1)
which would be more natural and effective if one modeled zero yields
internally, and therefore had the latter available at no cost.
I haven't given this any detailed thought, but were I to follow my
gut instinct, I would declare all of the above methods purely virtual
in TermStructure and implement relations such as the ones above in
derived classes such as DiscountStructure, ZeroYieldStructure, and
ForwardStructure.
Bye,
Luigi
--