Skip to content
All library documents

Representing a Shifted FRA Start Date in QuantLib

Article Quant Q&A · Author: user2770287

Summary

This exchange explains how to represent an FRA whose start date does not fall an integer number of months after the valuation date when constructing a yield curve with QuantLib. The suggested approach is to calculate the interval from the valuation date to the FRA start date using a chosen day-count convention, then express that interval as a Period measured in days for the FRARateHelper constructor.

The example uses a January valuation date and a March FRA start date, but the guidance is pseudocode rather than a complete implementation. The answer does not specify which day-count convention is appropriate, explain how to handle calendars or business-day adjustments, or discuss whether a particular constructor supports every such setup. Those details need to be checked against the instrument conventions and QuantLib API in use.

Key ideas

  • A shifted FRA start can be represented as a period measured in days.
  • Calculate the date interval using an explicitly selected day-count convention.
  • Pass the resulting Period to an appropriate FRARateHelper constructor.
  • The example is pseudocode and leaves conventions and implementation details to the user.

Tags

Full text
# Quantlib FRA with shifted start date


# Quantlib FRA with shifted start date












I'm new to quantlib. I am trying to construct a PiecewiseYieldCurve. I been looking at the implementation of FRA. It seems that the start date of the FRA must be an integer number of month from the valuation date. How do I implement an FRA with a start date that is shifted.

For example,

Valuation date: Jan 9, 2012

Start date of the first 3m FRA: Mar 19, 2012

Rate of the first 3m FRA: 0.01

Thanks

## Answer by SmallChess (score 2, accepted)

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

FRARateHelper takes a number of constructors. You should take a look at the ones that take Period.

The definition for Period is:

```
class Period {
  public:
    Period()
    : length_(0), units_(Days) {}
    Period(Integer n, TimeUnit units)
    : length_(n), units_(units) {}
    explicit Period(Frequency f);
    Integer length() const { return length_; }
    TimeUnit units() const { return units_; }
    Frequency frequency() const;
    Period& operator+=(const Period&);
    Period& operator-=(const Period&);
    Period& operator/=(Integer);
    void normalize();
  private:
    Integer length_;
    TimeUnit units_;
};
```

Period encapsulates a time-frame, the frame can be specified by Days. In your example, you might want to do something like:

```
int days = Actual360(Mar 19, 2012 - Jan 9, 2012)
Period p = Period(days, Days)
FRARateHelper(0.01, p, ...)
```

The pseudo-code should give you enough information to complete your code. You'd decide a day-counting convention, and use it to count number of days, then use the Period class to start FRARateHelper.

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.