Posted by
Luigi Ballabio on
Aug 03, 2006; 10:48am
URL: http://quantlib.414.s1.nabble.com/callable-bonds-tp11222p11225.html
On 08/01/2006 09:03:20 AM, Allen Kuo wrote:
> I'm trying to build a callable bond class and was wondering what a
> QL preferred design would be. Two possibilities are below. I liked
> the economy of the first method but the ConvertibleBond class is
> designed the second way, so was not sure how to proceed.
>
> (1)
> class CallableBond : public Bond {
> public:
> CallableBond(const boost::shared_ptr<Bond> bond&
> const boost::shared_ptr<PricingEngine>& engine,
> const CallabilitySchedule& callability,
> );
> etc.
> }
I like this one, but the problem is that the engine should know what
kind of bond it's being passed---or at least what kind of coupons it
contains. I.e., if you choose a tree engine, fixed-rate and
floating-rate coupons will be discounted in a different way on the
tree. Therefore, the above mightn't be as generic as it seems.
> (2)
> Analogous to the ConvertibleBond class, we would have three
> explicit constructors for each of three types of bonds (
> CallableZeroCouponBond , CallableFloatingRateBond ,
> CallableFixedCouponBond ).
This might be less nice, but it has the advantage of specifying the
kind of bond to be called. I would go for this one first; after the
code is done, we might try some refactoring to bring it closer to the
first design.
> Doing it this way, in the future though, we
> might need three more constructors for convertible bonds:
No, convertible bonds manage callability already. (By the way, you can
look at the relevant classes---Callability and such---so that you can
reuse them.)
Later,
Luigi
----------------------------------------
Cogito ergo I'm right and you're wrong.
-- Blair Houghton