I have bootstrapped a curve using several depo and swap rates and am trying to use that curve to get the NPV of a swap over a period of time. The generation of prices iteratively through time is incredibly slow. Given that i'm only pricing over a 4 month period I wouldn't expect it to take 30 minutes. Am I doing something silly here? I saw a previous post commenting on a bug in the SWIG wrapper from python to c++, but according to one of the project maintainers it was patched years ago. See the below:
test_curve.referenceDate() == Date(4,1,2023)
ts = ql.RelinkableYieldTermStructureHandle() yts.linkTo(test_curve) engine = ql.DiscountingSwapEngine(yts)
Swap Definition and Creation
swapTenor = ql.Period('1Y') overnightIndex = ql.Sofr(yts) fixedRate = 0.01 ois_swap = ql.MakeOIS(swapTenor, overnightIndex, fixedRate, pricingEngine=engine, discountingTermStructure=yts)
new_prices =  instance = ql.Settings.instance() start_date = ql.Date(1,1,2024) success_counter = 0 while date < start_date: # Update eval date in sim instance.evaluationDate = date price = ois_swap.NPV() new_prices.append(price) # Increment date forward date += ql.Period('1D') new_curve = test_model.get_curve_by_date(date.to_date().strftime('%Y-%m-%d')) count = 0 # Check for new_curve to exist while new_curve is None: date += ql.Period('1D') new_curve = test_model.get_curve_by_date(date.to_date().strftime('%Y-%m-%d')) count += 1 if count == 100: break yts.linkTo(new_curve) engine = ql.DiscountingSwapEngine(yts) overnightIndex = ql.Sofr(yts) ois_swap = ql.MakeOIS(swapTenor, overnightIndex, fixedRate, pricingEngine=engine, discountingTermStructure=yts, effectiveDate=ql.Date(2,1,2024))
The maturity date on the swap is set to May 2024. Thanks!