QuantLib Floating Swap Coupons Use the Coupon Rate, Including Spread
Summary
This note explains why a QuantLib floating-rate coupon amount may differ from nominal multiplied by accrual period and the index forward. The coupon amount is calculated using the coupon’s rate, which can include a contractual spread; the index fixing or forward alone therefore need not reproduce the cash flow. The displayed cash-flow table motivates the question, and the answer identifies the spread as the relevant distinction.
The explanation is brief and gives no details about how to inspect or configure the spread, nor does it discuss day-count conventions, gearing, or other coupon features that can also affect amounts. It is useful as a diagnostic point when comparing a floating coupon’s reported rate, fixing, and amount, but the snippet does not establish which of those additional terms apply to the example shown.
Key ideas
- A floating coupon amount is based on its coupon rate rather than necessarily on the index forward alone.
- A spread in the coupon rate can explain why nominal times accrual period times forward does not match the amount.
- Inspect the coupon rate and its contractual terms when reconciling reported floating cash flows.
Tags
Full text
# Quantlib Vanilla Swap Amount not based on Forwards
# Quantlib Vanilla Swap Amount not based on Forwards
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 |
## Answer by lieweHenksie (score 0)
https://quant.stackexchange.com/a/73749
As commented by Mr Ballabio, the Amount column is determined by nominal x accrualperiod x rate, not forward, when a spread occurs.Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.