Skip to content
All library documents

Adding Historical Rate Fixings When Pricing a Swap in QuantLib

Article Quant Q&A · Author: sumit_uk1

Summary

The document explains an error encountered when valuing a swap after a floating-rate coupon’s fixing date has passed. In the example, the valuation date follows the required Euribor three-month fixing date, so the coupon rate is historical and cannot be projected from the yield curve. QuantLib therefore reports that the fixing is missing.

The answer clarifies that the constructor argument identified as a fixing in the question is actually the floating-leg spread. The historical rate must instead be added to the relevant index instance, where it can then be accessed by Euribor three-month instances. The example establishes the distinction between past observed fixings and forward rates inferred from a curve. It addresses this specific missing-fixing error; users still need to supply the correct historical rate and ensure the index, date, calendar conventions, and valuation setup match their instrument.

Key ideas

  • A floating coupon whose fixing date is in the past requires an observed fixing.
  • A yield curve cannot forecast a rate that has already fixed.
  • The swap constructor parameter in the example represents a spread, not the past fixing.
  • Store the historical rate on the relevant index so the swap can retrieve it.

Tags

Full text
# Quantlib: Getting error trying to price a Swap


# Quantlib: Getting error trying to price a Swap












I have bootstrapped my curve based on end-of-day data for 24th Nov, 2017

I am then using that to price a off-market swap as below:

```
swap = VanillaSwap(VanillaSwap.Payer, 10000.0,
                       fixed_schedule,
                       fixed_coupon/100,
                       Thirty360(),
                       floating_schedule,
                       index,
                       0.0, # <-- libor fixing
                       Actual360())
```

My swap details are:-

```
Valuation date: 27th Nov, 2017
Fixed_coupon = 2.2575
Maturity Date = 27th Nov, 2027
float freq = Period(3, Months)
fixed freq = Period(6, Months)
```

When I call the below:-

```
swap.NPV()
```

I get : {Runtime error} 2nd leg: Missing Euribor3M Actual/360 fixing for November 23rd, 2017

Does this mean I have to pass in a libor fixing when I create my VanillaSwap object?

## Answer by Luigi Ballabio (score 2, accepted)

https://quant.stackexchange.com/a/37115

Yes, you have to pass an Euribor fixing because your coupon is fixing in the past with respect to the valuation date and thus its rate can't be forecast on the interest-rate curve. However, it's not passed through the construtor argument you have commented in your code; that one is used to pass any additional spread (for instance, if the floating leg swap were to pay Euribor plus 10 bps).

The way to store a past fixing is through the `index` instance. You can do it as

```
index.addFixing(Date(23,November,2017), rate);
```

after which it will be available to all `Euribor3M` instances.

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.