|
From: Luigi B. <lui...@gm...> - 2006-08-03 09:50:19
|
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 =20
> the economy of the first method but the ConvertibleBond class is =20
> designed the second way, so was not sure how to proceed.
>=20
> (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 =20
kind of bond it's being passed---or at least what kind of coupons it =20
contains. I.e., if you choose a tree engine, fixed-rate and =20
floating-rate coupons will be discounted in a different way on the =20
tree. Therefore, the above mightn't be as generic as it seems.
> (2)
> Analogous to the ConvertibleBond class, we would have three =20
> explicit constructors for each of three types of bonds ( =20
> CallableZeroCouponBond , CallableFloatingRateBond , =20
> CallableFixedCouponBond ).
This might be less nice, but it has the advantage of specifying the =20
kind of bond to be called. I would go for this one first; after the =20
code is done, we might try some refactoring to bring it closer to the =20
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 =20
look at the relevant classes---Callability and such---so that you can =20
reuse them.)
Later,
Luigi
----------------------------------------
Cogito ergo I'm right and you're wrong.
-- Blair Houghton
|