|
From: Luigi B. <lui...@gm...> - 2021-08-24 08:36:44
|
Hello,
they are coupons, as you would expect; but the swap interface allows
for more types, so it returns them as their base class CashFlow instead.
If you want to access the derived class interface, you can downcast them
with:
coupons = [ ql.as_floating_rate_coupon(cf) for cf in sw2.floatingLeg() ]
Corresponding functions exist for other classes (e.g.,
ql.as_fixed_rate_coupon). You can look for them in <
https://github.com/lballabio/QuantLib-SWIG/blob/master/SWIG/cashflows.i>.
If you pass to any of these functions a coupon that can't be converted
(e.g., a floating-rate coupon to as_fixed_rate_coupon or the redemption of
a bond to as_floating_rate_coupon) you'll get None as the return value.
Hope this helps,
Luigi
On Mon, Aug 9, 2021 at 10:22 PM Gorazd Brumen <gor...@gm...>
wrote:
> Hi all,
>
> I'm new to the list, and have the following question: Why are elements
> of VanillaSwap leg CashFlow type, and not Coupon type? (please see
> below)
>
> Best regards,
> Gorazd
>
> In [11]: sw2
> Out[11]: <QuantLib.QuantLib.VanillaSwap; proxy of <Swig Object of type
> 'boost::shared_ptr< VanillaSwap > *' at 0x7f48a03c7780> >
>
> In [10]: list(sw2.floatingLeg())
> Out[10]:
> [<QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863cf0> >,
> <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863e40> >,
> <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863f00> >,
> <QuantLib.QuantLib.CashFlow; proxy of <Swig Object of type
> 'boost::shared_ptr< CashFlow > *' at 0x7f4895863870> >]
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|