enter image description here

This is the code i have, what would be the way to see the cashflows of this specific bond i created

  • 1
    $\begingroup$ Have you tried the cashflows and redemptions inspectors for c in fixedRateBond.cashflows(): print('%18s %f' % (c.date(), c.amount())) $\endgroup$ Jun 5 '20 at 1:07

As Dimitri said, you can use the cashflows inspectors:

for cf in bond.cashflows():
    print(cf.date().ISO(), cf.amount())

2019-07-30 1.4999999999999902
2020-01-30 1.4999999999999902
2020-07-30 1.4999999999999902
2029-01-30 1.4999999999999902
2029-07-30 1.4999999999999902
2030-01-30 1.4999999999999902
2030-01-30 100.0

This way your cashflows will have a date and an amount, and you will see both the interest and redemptions.

If you need a bit more detail, you can use the ql.as_coupon, ql.as_fixed_rate_coupon or ql.as_floating_rate_coupon methods to extract additional fields:

import pandas as pd
fields = [
    'accrualDays', 'accrualEndDate', 'accrualPeriod', 'accrualStartDate',
    'amount',  'date', 'dayCounter', 'interestRate', 'nominal',  'rate'

data = []
for cf in list(map(ql.as_fixed_rate_coupon, bond.cashflows()))[:-1]:
    data.append({fld: eval(f"cf.{fld}()") for fld in fields})

enter image description here

Here I made a list of the map to avoid the last coupon because the redemption cashflows does not have these additional fields and will through an error.


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.