|
From: Luigi B. <lui...@gm...> - 2021-05-31 10:33:32
|
Hello,
yes, the curve should be extended as suggested — the second bond coupon
fixes in February 2015, and the zero curve starts at `mydate +
Period("6M")` which is April 8th 2015, so it can't forecast that index
fixing. If you don't have other information on the rates, you'll have to
pick a sensible way to extrapolate back. Doing it with flat rates, as in
your second working example, sounds defensible. Starting at 0.0, less so.
Luigi
On Sat, Apr 10, 2021 at 1:47 AM Brian Smith <bri...@gm...>
wrote:
> Hi,
>
> I have below code to price a floating rate bond:
>
> import math
> import datetime
>
> mydate = Date(8, 10, 2014)
> issueDate = Date(8, August, 2014)
> maturityDate = Date(8, August, 2019)
>
> Settings.instance().evaluationDate = mydate
>
> spots = [mydate + Period("6m"), mydate + Period("1y"), mydate +
> Period("2y"), mydate + Period("5y")]
> spotsdate = [0.002, 0.002, 0.002, 0.002]
> curveHandle = YieldTermStructureHandle(ZeroCurve(spots, spotsdate,
> Actual360(), TARGET(), Linear(), Compounded, Semiannual))
> myindex = Euribor6M(curveHandle)
> myindex.addFixing(Date(6, August, 2014), spotsdate[1], True)
>
> bond_schedule = Schedule(issueDate, maturityDate, Period(6, Months),
> TARGET(), Following, Following, DateGeneration.Backward, False)
>
> mybond = FloatingRateBond(3, 100, bond_schedule, myindex, Actual360())
>
> mybond.setPricingEngine(DiscountingBondEngine(curveHandle))
> mybond.NPV()
>
> When I run this code, I get error as
>
> RuntimeError: negative time (-0.161111) given
>
> In one of the earlier discussions, it was suggested to use some dummy
> rate corresponding to pricing date, during the curve construction. But
> if I use a dummy rate as 0 then I get different value for bond from
> using some other rate. So below 2 choices give me 2 different results
> -
>
> spots = [mydate, mydate + Period("6m"), mydate + Period("1y"), mydate
> + Period("2y"), mydate + Period("5y")]
> spotsdate = [0.00, 0.002, 0.002, 0.002, 0.002]
>
> and
>
> spots = [mydate, mydate + Period("6m"), mydate + Period("1y"), mydate
> + Period("2y"), mydate + Period("5y")]
> spotsdate = [0.002, 0.002, 0.002, 0.002, 0.002]. ### simple backfilling
>
> So I wonder, what is the right way to correct the RuntimeError:
> negative time (-0.161111) given?
>
>
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|