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 |