0
$\begingroup$

I have the following code:

        cashflows = pd.DataFrame({
            'Nominal': cf.nominal(),
            'AccrualStartDate': cf.accrualStartDate().ISO(),
            'AccrualEndDate': cf.accrualEndDate().ISO(),
            'AccrualPeriod': cf.accrualPeriod(),
            'Price': cf.price(disco_yts),
            'Rate': cf.rate(),
            'Amount': cf.amount(),
            'Forward': cf.indexFixing(),
            'FloatAccruedAmount': cf.accruedAmount(valuation_date+1)
        } for cf in map(ql.as_floating_rate_coupon, swap.leg(1)))

        fixed_cashflows = pd.DataFrame({
            'FixedAmount': cf.amount(),
            'FixedAccruedAmount': cf.accruedAmount(valuation_date+1)
        } for cf in map(ql.as_fixed_rate_coupon, swap.leg(0)))

swap.NPV()

My issue is that amount (from floating leg) is not as expected.

Mathematically I want amount to be

amount = nominal x accrualperiod x forward ,

but instead it seems as though Quantlib is doing something completely different? This is strange because 99% of the time it does create amounts as expected. What am I missing?

TradeId Nominal AccrualPeriod Price Forward Amount ExpectedAmount
0 bob -2421350000 0.084931507 -20443249.84 0.06458 - 20 478 517.87 -  13 280 806.23
1 bob -2421350000 0.252054795 -61382112.76 0.067465903 - 62 536 259.86 -  41 175 309.17
2 bob -2421350000 0.243835616 -63886355.38 0.077314926 - 66 312 009.20 -  45 647 611.25
3 bob -2421350000 0.252054795 -65823488.94 0.079179836 - 69 685 424.07 -  48 324 473.39
4 bob -2421350000 0.252054795 -65385660.54 0.080726366 - 70 629 291.20 -  49 268 340.52
$\endgroup$
2
  • 1
    $\begingroup$ May you share the code you're using to build the swap? And may you also show the column for Rate in the table? $\endgroup$ Commented Nov 10, 2022 at 14:27
  • $\begingroup$ Thanks @LuigiBallabio, I just figured out that I have a spread for that specific trade. So the amount is determined by the rate, not the forward. $\endgroup$ Commented Nov 10, 2022 at 18:10

1 Answer 1

0
$\begingroup$

As commented by Mr Ballabio, the Amount column is determined by nominal x accrualperiod x rate, not forward, when a spread occurs.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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