0
$\begingroup$

I am trying to bootstrap the 6m sterling swap curve using the depos and swap rates codes are below. I am a newbie and have been following (or at least trying to!) the python cookbook. I wanted to know how do I add FRA to the mix?i.e. how do I create helpers for FRAs

assuming I have these FRAs

FRAs = {(1, 7): 0.037125, (2, 8): 0.037125, (3, 9): 0.037125}

(and also wanted to check if the below code makes sense)

import QuantLib as ql
import pandas as pd


today= ql.Date(1,4,2020)
ql.Settings.instance().evaluationDate = today


quote = ql.QuoteHandle(ql.SimpleQuote(0.72863/100))
tenor = ql.Period('6M')
fixingDays = 2
calendar = ql.TARGET()
convention = ql.ModifiedFollowing
endOfMonth = False
dayCounter = ql.Actual365Fixed()

GBPLibor = ql.GBPLibor(ql.Period('6M'))
depo_helper = [ql.DepositRateHelper(quote,tenor,fixingDays,calendar,convention,endOfMonth,dayCounter)]


swap_helpers = [ql.SwapRateHelper(ql.QuoteHandle(ql.SimpleQuote(rate/100.0)), ql.Period(*tenor), calendar,ql.Semiannual,ql.Following,ql.Actual365Fixed(),GBPLibor)
        for tenor, rate in [((1,ql.Years),.5635),
                            ((2,ql.Years),0.4929),
                            ((3,ql.Years),.4764),
                            ((4,ql.Years), .4917),
                            ((5,ql.Years), .5007),
                            ((6,ql.Years), .5136),
                            ((7,ql.Years), .5247),
                            ((8,ql.Years), .5331),
                            ((9,ql.Years), .5424),
                            ((10,ql.Years),.5489),
                            ((12,ql.Years),.5647),
                            ((15,ql.Years),.5843),
                            ((20,ql.Years),.5869),
                            ((25,ql.Years),.5690),
                            ((30,ql.Years),.5380),
                            ((40,ql.Years),.4761),
                            ((50,ql.Years),.4381)]]


rate_helpers = depo_helper + swap_helpers
GBP6mLiborCurve = ql.PiecewiseCubicZero(today,rate_helpers,ql.Actual365Fixed())
spots = []
tenors = []

for d in GBP6mLiborCurve.dates():
    yrs = ql.Actual365Fixed().yearFraction(today,d)
    compounding = ql.Simple
    freq = ql.Semiannual
    zero_rate=GBP6mLiborCurve.zeroRate(yrs,compounding,freq)
    tenors.append(yrs)
    eq_rate=zero_rate.equivalentRate(ql.Actual365Fixed(),compounding,freq,today,d).rate()
    spots.append(100*eq_rate)

datatable={'Dates':GBP6mLiborCurve.dates(),'Tenors':tenors,'spots':spots}

df=pd.DataFrame.from_dict((datatable))

print(df)

Output

                Dates     Tenors     spots
0     April 1st, 2020   0.000000  0.000000
1   October 5th, 2020   0.512329  0.728645
2     April 1st, 2021   1.000000  0.564059
3     April 1st, 2022   2.000000  0.494446
4     April 3rd, 2023   3.005479  0.478995
5     April 2nd, 2024   4.005479  0.495879
6     April 1st, 2025   5.002740  0.506411
7     April 1st, 2026   6.002740  0.521119
8     April 1st, 2027   7.002740  0.534104
9     April 3rd, 2028   8.010959  0.544392
10    April 3rd, 2029   9.010959  0.555760
11    April 1st, 2030  10.005479  0.564234
12    April 1st, 2032  12.008219  0.584600
13    April 2nd, 2035  15.010959  0.611500
14    April 3rd, 2040  20.019178  0.623278
15    April 3rd, 2045  25.021918  0.610436
16    April 1st, 2050  30.019178  0.580321
17    April 1st, 2060  40.027397  0.516318
18    April 1st, 2070  50.032877  0.479267
$\endgroup$

1 Answer 1

0
$\begingroup$

You can add this to your code:

FRAs = {(1, 7): 0.037125, (2, 8): 0.037125, (3, 9): 0.037125}

for fra in FRAs:
    rate = FRAs.get(fra)
    start = fra[0]
    helper = ql.FraRateHelper(rate, start, GBPLibor)
    rate_helpers.append(helper)
$\endgroup$
1
  • $\begingroup$ thanks David that was helpful. If am bootstrapping 3mLibor, assuming I just change tenor = ql.Period('3M') and freq = ql.Quarterly? $\endgroup$
    – TRex
    Apr 2, 2020 at 10:49

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.