1
$\begingroup$

I am fairly new to QuantLib Python. I have generated the following cashflows from one AmortizingFloatingBond from QuantLib Python. But I am not able to identify which ones are Interest payments and which ones are Principal; I have more than 450 bonds and it is not possible to manually look into each. Is there any tag for Principal and Interest in the QuantLib output?

for j, cf in enumerate(amortizingfloatbond.cashflows()):
print((j + 1), cf.date(), cf.amount())
1 October 2nd, 2020 455855.3007039195
2 October 2nd, 2020 327494.6000000001
3 October 4th, 2021 368553.92597433936
4 October 4th, 2021 327494.6
5 October 3rd, 2022 260478.18044824633
6 October 3rd, 2022 327494.6
7 October 2nd, 2023 174560.1025981066
8 October 2nd, 2023 327494.6
9 October 2nd, 2024 88260.35700473993
10 October 2nd, 2024 327494.6

Will really appreciate any inputs. Thanks in advance.

$\endgroup$
2
$\begingroup$

Try casting, something like

c = as_coupon(cf)
if not c.__nonzero__():
    print "principal redemption"

You can likewise attempt casting the cf to as_fixed_rate_coupon(cf) or to as_floating_rate_coupon(cf), and if they work, then access other useful info. Also, redemptions is another available inspector.

Related question: how can i see the cashflows of a specific bond created in quantlib in Python? this is the code i have, how should i change it

$\endgroup$
1
  • $\begingroup$ Thanks a lot Dimitri...this indeed works. I could cast ql.as_coupon(cf) to an object 'c' with the below code flds = ['ql.as_coupon'] c = [] for j, cf in list(enumerate(amortizingfloatbond.cashflows())): c.append({fld: eval(f"{fld}(cf)") for fld in flds}) $\endgroup$
    – tran
    Jul 16 at 18:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.