Starting from a yield curve ycHandle (a YieldTermStructureHandle object), I would like to add a constant spread using the ZeroSpreadedTermStructure method. I did the following (working in Python with QuantLib 1.8):
shift = 0
spread = ql.SimpleQuote(shift)
shiftedCurve = ql.ZeroSpreadedTermStructure(zcHandle,ql.QuoteHandle(spread))
def plotCurve(ycHandle, maxTen=25, lab=''):
    # function taking a yield curve handle and plotting it
    call = ql.TARGET()
    tv = [] # tenor vector
    rv = [] # rate vector
    for _ in range(12*1,12*maxTen):
        dt = call.advance(ql.Date.todaysDate(), 2, ql.Days) + 30*_
        tv.append(dc.yearFraction(today,dt))
        rv.append(ycHandle.zeroRate(dt,dc,ql.Compounded,ql.Annual).rate())
    plt.plot(tv,rv, label=lab)
plt.figure()
plotCurve(ycHandle)
plotCurve(shiftedCurve)
Unfortunately the two curves do not overlap although I have shifted ycHandle by 0. I suspect this might be linked to the compounding, have tried to change all to ql.Annual or ql.Continuous but unfortunately was unsuccessful.
 
------------------------------------------------------------------------------
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users