I am trying to price a Cap with Quantlib in Python. I have the following lists given:
My code so far looks like this:
ref_date = ql.Date(25,11,2019)
calendar = ql.TARGET()
curve_ois = ql.ZeroCurve(dates_ois, rates_ois, ql.Actual360(), calendar, ql.Linear(), ql.Compounded, ql.Annual)
curve_ois_handle = ql.YieldTermStructureHandle(curve_ois)
curve_3M = ql.ZeroCurve(dates_3M, rates_3M, ql.Actual360(), calendar, ql.Linear(), ql.Compounded, ql.Annual)
curve_3M_handle = ql.YieldTermStructureHandle(curve_3M)
startDate = ref_date + 2
endDate = calendar.advance(ref_date, ql.Period('72M')
schedule = ql.Schedule(startDate, endDate, ql.Period(ql.Quarterly), calendar, ql.ModifiedFollowing, ql.ModifiedFollowing, ql.DateGeneration.Forward, False)
nom = 1000000
capRate = 0.03
cap = ql.Cap(ql.IborLeg([nominal], schedule, ql.Euribor3M(curve_3M_handle)), [capRate])
engine = ql.BachelierCapFloorEngine(curve_ois_handle, ql.QuoteHandle(ql.SimpleQuote(0.3439))
cap.setPricingEngine(engine)
print(cap.NPV())
I get the error: "Missing Euribor3M Actual/360 fixing for February 25th, 2025."
My Euribor Curve starts with the reference date 25.11.2025 and goes until 27.11.2079. In the beginning I have a data point every month but from 2022 only once a year. I got 28.11.2022, 27.11.2023, 27.11.2024, 27.11.2025, ... The cap I am trying to price starts at reference_date + 2 days and goes for 72 Months. So it should end in November 2025. However, the missing fixing is in February 2025.
You didn't provide the values from dates_3M
etc., so I can't actually run your code and check what happens.
In any case, from your line
ref_date = ql.Date(25,11,2019)
and from your description, I'm guessing that you want to price the cap as of that date. To do so, you need to set the global evaluation date:
ql.Settings.instance().evaluationDate = ref_date
otherwise, the library will assume that the evaluation date is today, March 10th 2025. With that assumption, your cap starts in the past; and the current caplet requires a fixing for February 25th which is also in the past, and the library expects you to provide it (and not the curve to forecast it).