Hi: 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. Thanks, Allen (1) class CallableBond : public Bond { public: CallableBond(const boost::shared_ptr<Bond> bond& const boost::shared_ptr<PricingEngine>& engine, const CallabilitySchedule& callability, ); etc. } i.e. first need to construct a FixedCouponBond, FloatingRateBond or ZeroCouponBond and then pass it in to the CallableBond constructor (which then implicitly defines the callable bond). Theoretically, a ConvertibleBond could also be passed into the constructor to make it callable, though some equity/interest rate correlations would have to be handled/modeled within it. (2) Analogous to the ConvertibleBond class, we would have three explicit constructors for each of three types of bonds ( CallableZeroCouponBond , CallableFloatingRateBond , CallableFixedCouponBond ). Doing it this way, in the future though, we might need three more constructors for convertible bonds: CallableConvertibleFloatingRateBond, CallableConvertibleFixedCouponBond, CallableConvertibleZeroCouponBond. Example below, analogous to ConvertibleBond class: class CallableBond : public Bond { public: CallableBond( .... ); } class CallableZeroCouponBond : public CallableBond { public: CallableZeroCouponBond( .... ); } class CallableFloatingRateBond : public CallableBond { public: CallableFloatingRateBond( .... ); } class CallableFixedCouponBond : public CallableBond { public: CallableFixedCouponBond( .... ); }
See the all-new, redesigned Yahoo.com. Check it out. |
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 |
In reply to this post by Allen Kuo-2
Hi, I've just ripped some code out of my current framework which prices callable or puttable fixed coupon bonds. I've assumed that callability can only take place on coupon dates. As I've just stripped out the code pertaining to my infrastructure, you may find that it doesn't immediatly compile, but the logic is there. I've tested some prices against FinancialCAD and they match. It doesn't use some of the latest framework code as this was written towards the end of last year. Hope it's useful, Toy out... >From: Luigi Ballabio <[hidden email]> >To: Allen Kuo <[hidden email]> >CC: [hidden email] >Subject: Re: [Quantlib-dev] callable bonds >Date: Thu, 03 Aug 2006 11:48:12 +0200 > > >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 > >------------------------------------------------------------------------- >Take Surveys. Earn Cash. Influence the Future of IT >Join SourceForge.net's Techsay panel and you'll get the chance to share >your >opinions on IT & business topics through brief surveys -- and earn cash >http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV >_______________________________________________ >QuantLib-dev mailing list >[hidden email] >https://lists.sourceforge.net/lists/listinfo/quantlib-dev DiscretizedCallableBond.cpp (2K) Download Attachment DiscretizedCallableBond.hpp (696 bytes) Download Attachment TreeCallableBondEngine.cpp (1K) Download Attachment TreeCallableBondEngine.hpp (724 bytes) Download Attachment |
Toyin: Yes, it will definitely be useful. Thanks. I will try to put in the Callability schedule and wrap the whole thing up nicely- will let you know how it goes. Best, A
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates starting at 1¢/min. |
Free forum by Nabble | Edit this page |