2
$\begingroup$

I am bootstrapping the shibor curve and fr007 curve using swap rates in China. I created my own index like following:

Shibor3M=IborIndex("Shibor3M",Period(3,Months),0,CNYCurrency(),
                    China(China.IB),Following,False,Actual360(),
                    discounting_curve)

and using to bootstrapping the spot rates. And code is:

today=Date(17,6,2019)
Settings.instance().evaluationDate = today
discounting_curve=RelinkableYieldTermStructureHandle()
forecasting_curve=RelinkableYieldTermStructureHandle()
quotes = [SimpleQuote(2.80763/100)]
#Shibor index
Shibor3M=IborIndex("Shibor-3M",Period(3,Months),0,
                   CNYCurrency(),China(China.IB), 
                   Following,False,Actual360(),
                   forecasting_curve)
depo_helper = [DepositRateHelper(
                   QuoteHandle(quotes[0]),Period(3,Months),0,China(China.IB),
                   Following,False,Actual360())]

swap_helpers = [ SwapRateHelper(QuoteHandle(SimpleQuote(rate/100.0)), Period(*tenor), China(China.IB),Quarterly,Following,Actual365Fixed(),Shibor3M())
        for tenor, rate in [((6,Months),2.985),((9,Months),3.0163),((1,Years),3.0475),((2,Years), 3.1638),
        ((3,Years), 3.2788),
        ((4,Years), 3.3813),
        ((5,Years), 3.4688),
        ((7,Years), 3.6175),((10,Years),3.765)] ]
rate_helpers=depo_helper+swap_helpers
curve1=PiecewiseCubicZero(today,rate_helpers,Actual360)
spots = []
tenors = []
for d in curve1.dates():
    yrs=Actual360.yearFraction(today,d)
    compounding=Simple
    freq=Quarterly
    zero_rate=curve1.zeroRate(yrs,compounding,freq)
    tenors.append(yrs)
eq_rate=zero_rate.equivalentRate(Actual360,compounding,freq,today,d).rate()
spots.append(100*eq_rate)
datatable={'Dates':curve1.dates(),'Tenors':tenors,'spots':spots}
df=pd.DataFrame.from_dict((datatable))

But I can not get the result. Can anyone give some help to me? Thanks.

$\endgroup$

1 Answer 1

1
$\begingroup$

There are a few errors in your code:

  1. You created an index object and pointed to it with a variable, therefore you should use it as Shibor3M and not Shibor3M(), ie, after created the index is not callable
  2. Everytime you use the daycounter class Actual360 you have to call it, i.e. Actual360()

Try this:

today=Date(17,6,2019)
Settings.instance().evaluationDate = today
discounting_curve=RelinkableYieldTermStructureHandle()
forecasting_curve=RelinkableYieldTermStructureHandle()
quotes = [SimpleQuote(2.80763/100)]
#Shibor index
Shibor3M=IborIndex("Shibor-3M",Period(3,Months),0,
                   CNYCurrency(),China(China.IB), 
                   Following,False,Actual360(),
                   forecasting_curve)
depo_helper = [DepositRateHelper(
                   QuoteHandle(quotes[0]),Period(3,Months),0,China(China.IB),
                   Following,False,Actual360())]

swap_helpers = [ SwapRateHelper(QuoteHandle(SimpleQuote(rate/100.0)), Period(*tenor), China(China.IB),Quarterly,Following,Actual365Fixed(),Shibor3M)
        for tenor, rate in [((6,Months),2.985),((9,Months),3.0163),((1,Years),3.0475),((2,Years), 3.1638),
        ((3,Years), 3.2788),
        ((4,Years), 3.3813),
        ((5,Years), 3.4688),
        ((7,Years), 3.6175),((10,Years),3.765)] ]
rate_helpers=depo_helper+swap_helpers
curve1=PiecewiseCubicZero(today,rate_helpers,Actual360())
spots = []
tenors = []
for d in curve1.dates():
    yrs=Actual360().yearFraction(today,d)
    compounding=Simple
    freq=Quarterly
    zero_rate=curve1.zeroRate(yrs,compounding,freq)
    tenors.append(yrs)
    eq_rate=zero_rate.equivalentRate(Actual360(),compounding,freq,today,d).rate()
    spots.append(100*eq_rate)
datatable={'Dates':curve1.dates(),'Tenors':tenors,'spots':spots}
df=pd.DataFrame.from_dict((datatable))
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.