# Specify fixing days for floating leg in Interest Rate Swap valuation using QuantLib Python

I am trying to price an Interest Rate Swap using QuantLib Python, and everything seems to be fine. However, I can't seem to understand where I can specify the number of fixing days.

Below are my codes. Kindly note that the curve used for discounting and for the US Libor is hypothetical, and only for illustration purpose.

import QuantLib as ql

valuationDate = ql.Date(30, 6, 2020)
ql.Settings.instance().evaluationDate = valuationDate

dayConvention = ql.Actual360()
calendar = ql.UnitedStates()

settlementDays = 3

zeroCurve = ql.ZeroCurve([ql.Date(30, 6, 2020), ql.Date(30, 6, 2021), ql.Date(30, 6, 2022), ql.Date(30, 7, 2025)], [0.05, 0.06, 0.06, 0.07], dayConvention, calendar, ql.Linear(), ql.Compounded)
handle = ql.YieldTermStructureHandle(zeroCurve)
fixedFrequency = ql.Annual
floatFrequency = ql.Semiannual

floatIndex = ql.USDLibor(ql.Period(floatFrequency), handle)

issueDate = ql.Date(1, 1, 2019)
maturityDate = ql.Date(1, 1, 2023)

fixedLegTenor = ql.Period(fixedFrequency)
fixedSchedule = ql.Schedule(settlementDate, maturityDate,
fixedLegTenor, calendar,
ql.DateGeneration.Forward, True)

floatLegTenor = ql.Period(floatFrequency)
floatSchedule = ql.Schedule(settlementDate, maturityDate,
floatLegTenor, calendar,
ql.DateGeneration.Forward, True)

notional = 34000
fixedRate = 0.03
fixedLegDayCount = ql.Actual365Fixed()
floatLegDayCount = ql.Actual360()

irs = ql.VanillaSwap(ql.VanillaSwap.Payer, notional, fixedSchedule,
fixedRate, fixedLegDayCount, floatSchedule,

discounting = ql.DiscountingSwapEngine(handle)
irs.setPricingEngine(discounting)


From QuantLib, the number of fixing days is 2 as shown below:

for i, cf in enumerate(irs.leg(1)):
c = ql.as_floating_rate_coupon(cf)
if c:
print(c.fixingDays())


which returns

2

2

2

2

2

Is there a way that I can specify another number of fixing days, say 1?

• Have you tried passing fixingdays to InterestRateIndex? Aug 18 '21 at 11:28
• You mean, passing fixingDays as a parameter in the function floatIndex? As far as I know, it is not possible... Aug 18 '21 at 11:32
• instead of floatIndex = ql.USDLibor(... , can you try floatIndex = ql.InterestRateIndex(... - looking at github.com/lballabio/QuantLib/blob/master/ql/indexes/… it takes settlementDays which is really fixingdays. Aug 18 '21 at 11:47
• This is what I get in return AttributeError: No constructor defined. Aug 18 '21 at 11:57

VanillaSwap models simple swaps, so it doesn't have a lot of bells and whistles. For more control, you can create the two legs separately and use the Swap class. In your case:

fixed_leg = ql.FixedRateLeg(fixedSchedule, fixedLegDayCount, [notional], [fixedRate])

floating_leg = ql.IborLeg([notional], floatSchedule, floatIndex, floatLegDayCount,

irs = ql.Swap(fixed_leg, floating_leg)
irs.setPricingEngine(discounting)


The constructor of Swap that takes two legs assumes that the first is paid and the second is received.

As for the fixing days:

for cf in floating_leg:
c = ql.as_floating_rate_coupon(cf)
if c:
print(c.fixingDays())


The output is:

1
1
1
1
1

• Thanks a lot Luigi! Oct 14 '21 at 2:54