Skip to content
All library documents

Using Historical Fixings and Forward Curves in QuantLib Swaps

Article Quant Q&A · Author: John83

Summary

The document asks how to value a swap when the valuation date falls within an accrual period: use historical index fixings for the elapsed portion and project later periods from discount-factor data. The answer recommends adding available fixings to the index supplied when constructing the swap. QuantLib can then look up historical rates for dates before the evaluation date, while subsequent rates are projected from the curve.

It distinguishes this case from compounded overnight indexed swaps. For a partially elapsed compounding period, the answer says QuantLib does not yet combine the already observed overnight fixings with projected rates inside the same compounding formula; the period may instead be treated as fully fixed using the overnight rate at its start. The document gives no code or numerical calculation, and its guidance is specifically framed around the behavior described for QuantLib.

Key ideas

  • Add historical rates to the swap's index using QuantLib's fixing mechanism.
  • Fixings supply rates for dates before the evaluation date, while later rates are projected from the curve.
  • A valuation date within a swap accrual period can require both observed and projected rates.
  • The answer notes a limitation for partially fixed compounded OIS periods in QuantLib.

Tags

Full text
# QuantLib: How to compute the forward rate using historical fixing rate and discount factor data


# QuantLib: How to compute the forward rate using historical fixing rate and discount factor data












Let's say the valuation date is 08/24/2023. The effective date and maturity date of the swap are 03/12/2022 and 01/10/2024. I want to apply the given historical fixing rates till the valuation date and thereafter apply the forwards from the valuation date till maturity using discount factor data. I want to compute the forward rate as of the valuation date. How can I achieve this without altering the given discount factor data?

```
Given discount factor data is

CurveDate   Curve   MaturityDate    Df
08/24/2023  DKK 08/24/2023  1
08/24/2023  DKK 08/25/2023  0.9994925
08/24/2023  DKK 08/26/2023  0.998985
08/24/2023  DKK 08/27/2023  0.998478

Given Fixing data as

Fixingdate  Fixingdate
3/11/2022   11.65
3/12/2022   13.65
 ------- so on
08/23/2023  17.45
08/24/2023  16.35
```

## Answer by Denys Usynin (score 1)

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

I think the problem you are trying to solve is that valuation date falls in the middle of a swap period and for that period you want fixing to be used while for all subsequent periods you want projected rates to be used. In QuantLib you achieve that by calling addFixing() method on the index that you are supplying when you construct the swap. Then the discounting engine will look up interest rates from the fixings if it needs rates before the evaluation date.

Note that if your swap is not IBOR based but is compounded OIS, then within the compounding formula itself some rates should be taken off fixings and some off the curve, and that is not yet implemented in QuantLib (although is on roadmap) so these partially fixed periods will look like fully fixed instead based on the ON rate at the beginning of the relevant period.

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.