How In-Arrears Fixing Changes QuantLib Floating Coupons
Summary
The note explains the effect of the isInArrears setting on floating-rate coupons in a QuantLib IborLeg. When enabled, the coupon’s fixing date is based on the accrual period’s end date, adjusted backward by the index’s fixing days and calendar rules. When disabled, the fixing date is based on the accrual start date. The setting changes which observed or forecast rate determines the coupon; it does not itself shift the accrual or payment dates.
The example compares cash flows under the two settings. In the first period, the arrears version uses the later fixing and produces a different coupon amount from the start-fixed version; subsequent example rates happen to match. The illustration uses a particular schedule, index, curve, and supplied fixings, so its cash-flow values are not general. A request to model a two-day arrears shift is not resolved separately; the explanation describes the Boolean setting and QuantLib’s fixing-day adjustment.
Key ideas
- With isInArrears enabled, the fixing date is anchored to the accrual period’s end.
- With it disabled, the fixing date is anchored to the accrual period’s start.
- The index fixing calendar and fixing-day count adjust the resulting date.
- The example shows that a changed fixing can alter coupon rates and amounts without moving accrual or payment dates.
- The displayed cash flows depend on the example’s specific schedule, curve, and fixings.
Tags
Full text
# How does the isInArrears affect the quantlib IborLeg?
# How does the isInArrears affect the quantlib IborLeg?
#### Deal details
```
issue_date = ql.Date(31, 1, 2011)
maturity_date = ql.Date(31, 1, 2016)
coupon_rate = 6.23/100
face_value = 250000
calendar = ql.NullCalendar()
calendar.addHoliday(ql.Date(31,7,2011))
calendar.addHoliday(ql.Date(30,7,2011))
day_count = ql.Actual365Fixed()
payment_frequency = ql.Semiannual
schedule = ql.Schedule(issue_date,maturity_date,ql.Period(payment_frequency),calendar,ql.ModifiedFollowing,ql.ModifiedFollowing,ql.DateGeneration.Forward,False)
forcast_curve = ql.RelinkableYieldTermStructureHandle()
curve = ql.FlatForward(0,ql.NullCalendar(),coupon_rate,ql.Actual365Fixed(),ql.Continuous)
forcast_curve.linkTo(curve)
index = ql.IborIndex("myindex",ql.Period(ql.Semiannual),0, ql.INRCurrency(),ql.NullCalendar(),ql.ModifiedFollowing,False,day_count,forcast_curve)
index.clearFixings()
adates = [a for a in schedule]
arates = [0.055,0.0623,0.0623,0.0623,0.0623,0.0623,0.0623,0.0623,0.0623,0.0623,0.0623]
index.addFixings(adates, arates, True)
iborleg = ql.IborLeg([face_value],schedule,index,day_count,ql.ModifiedFollowing,isInArrears=True)
#Coupon pricer
pricer = ql.BlackIborCouponPricer()
volatility = 1.0
vol = ql.ConstantOptionletVolatility(0,
calendar,
ql.ModifiedFollowing,
volatility,
ql.Actual365Fixed())
pricer.setCapletVolatility(ql.OptionletVolatilityStructureHandle(vol))
ql.setCouponPricer(iborleg, pricer)
cashflows = pd.DataFrame([(a.accrualStartDate(),a.accrualEndDate(),a.date(),a.amount(),a.accrualDays(),a.rate())
for a in [ql.as_coupon(c) for c in iborleg]],index=['']*len(iborleg))
cashflows.columns =["Start_Date","End_Date","Payment_Date","Amount","No_of_Days","Rate"]
cashflows
```
#### Output
```
Start_Date End_Date Payment_Date Amount Days Rate
31/01/2011 29/07/2011 29/07/2011 7638.150685 179 0.0623
29/07/2011 31/01/2012 31/01/2012 7936.849315 186 0.0623
31/01/2012 31/07/2012 31/07/2012 7766.164384 182 0.0623
31/07/2012 31/01/2013 31/01/2013 7851.506849 184 0.0623
31/01/2013 31/07/2013 31/07/2013 7723.493151 181 0.0623
31/07/2013 31/01/2014 31/01/2014 7851.506849 184 0.0623
31/01/2014 31/07/2014 31/07/2014 7723.493151 181 0.0623
31/07/2014 31/01/2015 31/01/2015 7851.506849 184 0.0623
31/01/2015 31/07/2015 31/07/2015 7723.493151 181 0.0623
31/07/2015 31/01/2016 31/01/2016 7851.506849 184 0.0623
```
How does isInArrears affect the cashflows and its dates? If I have 2 days isInarreas, how will it affect?
## Answer by Xiarpedia (score 1, accepted)
https://quant.stackexchange.com/a/78341
In QuantLib the following occurs for the floating coupon if isInArrears is true:
```
Date FloatingRateCoupon::fixingDate() const {
// if isInArrears_ fix at the end of period
Date refDate = isInArrears_ ? accrualEndDate_ : accrualStartDate_;
return index_->fixingCalendar().advance(refDate,
-static_cast<Integer>(fixingDays_), Days, Preceding);
}
```
i.e. the fixing is picked at the end of the accrual date or if false it is set at the start of the accrual period. This can be also observed in your code, if isInArrears is true then cashflows yield:
| | Start_Date | End_Date | Payment_Date | Amount | No_of_Days | Rate |
| 0 | 2011-01-31 | 2011-07-29 | 2011-07-29 | 7638.150685 | 179 | 0.0623 |
| 1 | 2011-07-29 | 2012-01-31 | 2012-01-31 | 7936.849315 | 186 | 0.0623 |
| 2 | 2012-01-31 | 2012-07-31 | 2012-07-31 | 7766.164384 | 182 | 0.0623 |
| 3 | 2012-07-31 | 2013-01-31 | 2013-01-31 | 7851.506849 | 184 | 0.0623 |
| 4 | 2013-01-31 | 2013-07-31 | 2013-07-31 | 7723.493151 | 181 | 0.0623 |
| 5 | 2013-07-31 | 2014-01-31 | 2014-01-31 | 7851.506849 | 184 | 0.0623 |
| 6 | 2014-01-31 | 2014-07-31 | 2014-07-31 | 7723.493151 | 181 | 0.0623 |
| 7 | 2014-07-31 | 2015-01-31 | 2015-01-31 | 7851.506849 | 184 | 0.0623 |
| 8 | 2015-01-31 | 2015-07-31 | 2015-07-31 | 7723.493151 | 181 | 0.0623 |
| 9 | 2015-07-31 | 2016-01-31 | 2016-01-31 | 7851.506849 | 184 | 0.0623 |
and if set false:
| | Start_Date | End_Date | Payment_Date | Amount | No_of_Days | Rate |
| 0 | 2011-01-31 | 2011-07-29 | 2011-07-29 | 6743.150685 | 179 | 0.055 |
| 1 | 2011-07-29 | 2012-01-31 | 2012-01-31 | 7936.849315 | 186 | 0.0623 |
| 2 | 2012-01-31 | 2012-07-31 | 2012-07-31 | 7766.164384 | 182 | 0.0623 |
| 3 | 2012-07-31 | 2013-01-31 | 2013-01-31 | 7851.506849 | 184 | 0.0623 |
| 4 | 2013-01-31 | 2013-07-31 | 2013-07-31 | 7723.493151 | 181 | 0.0623 |
| 5 | 2013-07-31 | 2014-01-31 | 2014-01-31 | 7851.506849 | 184 | 0.0623 |
| 6 | 2014-01-31 | 2014-07-31 | 2014-07-31 | 7723.493151 | 181 | 0.0623 |
| 7 | 2014-07-31 | 2015-01-31 | 2015-01-31 | 7851.506849 | 184 | 0.0623 |
| 8 | 2015-01-31 | 2015-07-31 | 2015-07-31 | 7723.493151 | 181 | 0.0623 |
| 9 | 2015-07-31 | 2016-01-31 | 2016-01-31 | 7851.506849 | 184 | 0.0623 |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.