|
From: Michael (D. portal) <mi...@da...> - 2023-09-07 14:42:25
|
Hi All,
I am pricing a bond using a SOFR yieldcurve (see code below) but getting *time
is past max curve time *run time error on bond.cleanPrice() function. When
I use a simple (not SOFR) curve (valCurve_test) there is no error.
I would appreciate any help.
Thanks,
Michael
***********************************************************************************************************************************
import QuantLib as ql
today = ql.Date(9,6,2023)
# Curve
marketQuotes=[['1Y',0.05],['5Y',0.05]]
# Bond
schedule = ql.Schedule(today, ql.Date(1,ql.February,2031),
ql.Period(ql.Semiannual), ql.UnitedStates(),
ql.ModifiedFollowing, ql.ModifiedFollowing,
ql.DateGeneration.Backward, False)
bond = ql.FixedRateBond(3, 100.0, schedule, [0.03625], ql.Actual360())
# OIS Helper
oisHelper = []
for quote in marketQuotes:
oisHelper.append(ql.OISRateHelper(2, ql.Period(quote[0]),
ql.QuoteHandle(ql.SimpleQuote(quote[1]/100)), ql.Sofr()))
# Curves Specifications
sofrCurve = ql.PiecewiseLinearZero(2, ql.UnitedStates(), oisHelper,
ql.Actual360())
valCurve = ql.YieldTermStructureHandle(sofrCurve)
sofrIndex = ql.Sofr(valCurve)
swapEngine = ql.DiscountingSwapEngine(valCurve)
valCurve_test=ql.YieldTermStructureHandle(ql.FlatForward(2, ql.TARGET(),
0.10, ql.Actual360()))
# Price Bond
bond_engine = ql.DiscountingBondEngine(valCurve)
bond.setPricingEngine(bond_engine)
bond_price = bond.cleanPrice()
print(bond_price)
|