|
From: Steve H. <war...@gm...> - 2023-09-07 14:58:32
|
Hi Michael, Your bond’s maturity,2031/2/1, is beyond the curve horizon, 5yr, which is around 2028/6/9. Try to give a longer curve to cover bond length or enable extrapolation for sofrCurve. Best, Steve On Thu, Sep 7, 2023 at 10:44 PM Michael (DataDriven portal) < mi...@da...> wrote: > 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) > _______________________________________________ > QuantLib-users mailing list > Qua...@li... > https://lists.sourceforge.net/lists/listinfo/quantlib-users > |