|
From: Luigi B. <lui...@gm...> - 2024-12-02 16:25:44
|
Hello Théodore,
if you want to retrieve forwards from the curve, using piecewise flat
spreads on the zero rates is probably not the best choice. Given your
setup, on the 9th of December the zero rates jump by 9 bps from one day
to the next. Since the forward rate is the derivative of zt (the zero rate
multiplied by time) the jump causes a spike in the forward for that day.
Depending on what you're trying to model, you might want to use another
interpolation between the spreads; for instance linear interpolation, which
wouldn't cause the jump. It's also possible that what you wanted was to
apply the spreads on the forwards, but there's no such curve at this time;
if that's the case, you can open an issue.
Hope this helps,
Luigi
On Fri, Nov 22, 2024 at 1:29 PM Théodore Montel <the...@gm...>
wrote:
> Hi,
>
> I am trying to build a short term curve and would like to add a flat
> time-dependent spread on top. I am however observing an odd feature where
> there is a significant jump at the date where the spread starts, and I am
> wondering if I am doing something wrong or if there's a bug. Please see
> example code below and observe the 1 day forward rate on 9dec2024
> specifically
>
> import matplotlib.pyplot as plt
> import QuantLib as ql
> evaldate = ql.Date(22, 11, 2024)
> ql.Settings.instance().setEvaluationDate(evaldate)
> curve = ql.FlatForward(evaldate, ql.QuoteHandle(ql.SimpleQuote(0.01)),
> ql.Actual360())
> dates = [ql.Date(9, 12, 2024), ql.Date(16, 11, 2025)]
> spreads = [ql.QuoteHandle(ql.SimpleQuote(s/10000) )for s in [13, 22]]
> handle = ql.YieldTermStructureHandle(curve)
> spreadcurve = ql.SpreadedBackwardFlatZeroInterpolatedTermStructure(handle,
> spreads, dates)
> spreadcurve.enableExtrapolation()
> #fig, ax = utils.plot()
> fwd_dates = [evaldate + ql.Period(i, ql.Days) for i in range(100)]
> fwd_rates = [spreadcurve.forwardRate(fwd_dates[i - 1], fwd_dates[i],
> ql.Actual360(), ql.Simple).rate() for i in
> range(1, 100)]
> #utils.plot_curve(ax, fwd_dates[1:], [(fwd_rates, '-')], format_rates=True)
>
> Kind regards,
> Théodore
> _______________________________________________
> QuantLib-users mailing list
> Qua...@li...
> https://lists.sourceforge.net/lists/listinfo/quantlib-users
>
|