|
From: Luigi B. <lui...@gm...> - 2021-02-12 08:19:58
|
Given a bond in general, you can't. For instance, you might have a convertible fixed-to-floater where the first part of the bond pays annual fixed coupons and the second part pays semiannual floating-rate coupons, possibly with a different day count. What you might do is examine the coupons themselves: call bond.cashflows(), iterate over it, and for each of the cash flows try to downcast it to a coupon (using ext::dynamic_pointer_cast<Coupon>) and call its methods. Luigi On Fri, Feb 12, 2021 at 6:29 AM jian Xu <jia...@gm...> wrote: > So given a bond in general, how to find out its accrual day count and > the payment frequency? > > On Thu, Feb 11, 2021 at 3:33 PM Luigi Ballabio <lui...@gm...> > wrote: > > > > Hello, > > as Matthias says, FixedRateCoupon and FloatingRateCoupon are > convenience classes used to build a bond, but don't have specific > behavior. I'm not opposed to having them return some info, but I'd try to > avoid storing too much extra data in them just for that purpose... > > > > Luigi > > > > > > On Thu, Feb 11, 2021 at 9:44 PM <mat...@gm...> wrote: > >> > >> Hello Jian, > >> > >> I can only guess, but maybe the classes FixedRateBond and > FloatingRateBond were thought of as "easy wrappers" around the main Bond > class - making it more convenient for users to create a Bond instance with > floating or fixed coupon legs (or none, in case of ZeroCouponBond). > >> > >> Actually I can only find one reference for the "frequency" accessor - > and that one is in a unit test to ensure that frequency setting is sort of > ignored for a custom schedule. > >> > >> Curious to hear other opinions. > >> > >> Thanks, > >> > >> Matthias > >> > >> > >> -----Original Message----- > >> From: jian Xu <jia...@gm...> > >> Sent: Thursday, 11 February 2021 21:13 > >> To: QuantLib users <qua...@li...> > >> Subject: [Quantlib-users] Why doesn't FloatingRateBond has dayCounter() > and frequency()? > >> > >> Hi, > >> > >> I noticed that FixedRateBond has dayCounter() and frequency() methods, > but the FloatingRateBond does not. What's the reason for that? It seems > to me that dayCounter and frequency are equally valid concepts for floating > and fixed rate bonds. Or am I missing something? > >> Thanks. > >> > >> Jian > >> > >> > >> _______________________________________________ > >> QuantLib-users mailing list > >> Qua...@li... > >> https://lists.sourceforge.net/lists/listinfo/quantlib-users > >> > >> > >> > >> _______________________________________________ > >> QuantLib-users mailing list > >> Qua...@li... > >> https://lists.sourceforge.net/lists/listinfo/quantlib-users > |