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()
businessConvention = ql.Following
settlementDays = 3
settlementDate = calendar.advance(valuationDate, ql.Period(settlementDays, ql.Days))
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)
floatIndex.addFixing(ql.Date(30, 12, 2019), 0.01)
floatIndex.addFixing(ql.Date(29, 6, 2020), 0.02)
issueDate = ql.Date(1, 1, 2019)
maturityDate = ql.Date(1, 1, 2023)
fixedLegTenor = ql.Period(fixedFrequency)
fixedSchedule = ql.Schedule(settlementDate, maturityDate,
fixedLegTenor, calendar,
businessConvention, businessConvention,
ql.DateGeneration.Forward, True)
floatLegTenor = ql.Period(floatFrequency)
floatSchedule = ql.Schedule(settlementDate, maturityDate,
floatLegTenor, calendar,
businessConvention, businessConvention,
ql.DateGeneration.Forward, True)
notional = 34000
fixedRate = 0.03
fixedLegDayCount = ql.Actual365Fixed()
floatSpread = 0.01
floatLegDayCount = ql.Actual360()
irs = ql.VanillaSwap(ql.VanillaSwap.Payer, notional, fixedSchedule,
fixedRate, fixedLegDayCount, floatSchedule,
floatIndex, floatSpread, floatLegDayCount)
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?
Thanks for your help!
fixingdays
toInterestRateIndex
? $\endgroup$fixingDays
as a parameter in the functionfloatIndex
? As far as I know, it is not possible... $\endgroup$floatIndex = ql.USDLibor(...
, can you tryfloatIndex = ql.InterestRateIndex(...
- looking at github.com/lballabio/QuantLib/blob/master/ql/indexes/… it takessettlementDays
which is really fixingdays. $\endgroup$AttributeError: No constructor defined
. $\endgroup$