Following the question that I have asked on this link and response obtained, I have managed to price a 3x6 FRA using QuantLib Python, using the following codes:
import QuantLib as ql
today = ql.Date(30, 6, 2020)
ql.Settings.instance().evaluationDate = today
calendar = ql.UnitedStates()
startDate = calendar.advance(today, ql.Period('3M'))
maturityDate = calendar.advance(startDate, ql.Period('3M'))
spotDates = [ql.Date(30, 6, 2020), ql.Date(31, 12, 2020), ql.Date(30, 6, 2021)]
spotRates = [0.05, 0.05, 0.05]
dayConvention = ql.Thirty360()
compounding = ql.Simple
compoundingFrequency = ql.Annual
spotCurve = ql.ZeroCurve(spotDates, spotRates, dayConvention, calendar, ql.Linear(), compounding, compoundingFrequency)
spotCurve.enableExtrapolation()
spotCurveHandle = ql.YieldTermStructureHandle(spotCurve)
index = ql.USDLibor(ql.Period('3M'), spotCurveHandle)
index.addFixing(ql.Date(26, 6, 2020), 0.05)
notional = 100000
rate = 0.06
fra = ql.ForwardRateAgreement(startDate, maturityDate, ql.Position.Long, rate, notional, index, spotCurveHandle)
print('NPV:', fra.NPV())
The NPV obtained is:
NPV: -288.3302632825472
However, when manually recomputing the answer, a slight difference from QuantLib's NPV is being obtained.
My manual computation is as follows, based on 30/360 day count convention:
My yearFraction
is obtained using the following line:
ql.Thirty360().yearFraction(startDate, maturityDate)
And my NPV is:
-288.8029442214667
Can someone please explain why this difference is arising?