使用ZeroSpreadedTermStructure将常量扩展添加到收益率曲线

时间:2016-08-19 15:47:52

标签: python quantlib

从收益率曲线ycHandleYieldTermStructureHandle对象)开始,我想使用ZeroSpreadedTermStructure方法添加常量点差。我做了以下(使用QuantLib 1.8在Python中工作):

shift = 0
spread = ql.SimpleQuote(shift)
shiftedCurve = ql.ZeroSpreadedTermStructure(ycHandle,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)

不幸的是,两条曲线不重叠虽然我已将ycHandle移动了0.我怀疑这可能与复合相关联,试图将所有曲线都更改为ql.Annualql.Continuous但不幸的是没有成功。

0 个答案:

没有答案