0
$\begingroup$

I'm trying to bootstrap and to get a zero coupon yield curve with maturities ranging from 2019 to 2059

Here is my code: `

import QuantLib as ql


def print_curve(xlist, ylist, precision=3):
    """
    Method to print curve in a nice format
    """
    print ("----------------------")
    print ("Maturities\tCurve")
    print ("----------------------")
    for x,y in zip(xlist, ylist):
    print (x,"\t\t", round(y, precision))
    print ("----------------------")

# Deposit rates
depo_maturities = [ql.Period(1,ql.Days), ql.Period(1, ql.Months), ql.Period(2, ql.Months), ql.Period(3,ql.Months), ql.Period(6,ql.Months), ql.Period(9,ql.Months)]
depo_rates = [-0.0037, -0.00377, -0.00348, -0.00318, -0.00259, -0.00314]

# swap rates
swap_maturities = [ql.Period(i, ql.Years) for i in range(1,16)]+[ql.Period(20+5*i, ql.Years) for i in range(5)]
swap_rates = [-0.00373, -0.00393, -0.00363, -0.00306, -0.00233, -0.00152, -0.00066, -0.00024, 0.00114, 0.002, 
          0.00274, 0.00354, 0.00417, 0.00478, 0.00536, 0.00711, 0.00782, 0.00803, 0.00801]


# some constants and conventions

calc_date = ql.Date(15, 1, 2015)
ql.Settings.instance().evaluationDate = calc_date

calendar = ql.UnitedStates()
bussiness_convention = ql.Unadjusted
day_count = ql.Thirty360()
end_of_month = True
settlement_days = 0
face_amount = 100
coupon_frequency = ql.Period(ql.Semiannual)
settlement_days = 0


# create deposit rate helpers from depo_rates
depo_helpers = [ql.DepositRateHelper(ql.QuoteHandle(ql.SimpleQuote(r/100.0)),
                                 m,
                                 settlement_days,
                                 calendar,
                                 bussiness_convention,
                                 end_of_month,
                                 day_count )
            for r, m in zip(depo_rates, depo_maturities)]


# create swap rate helpers
swap_helpers = []
for r, m in zip(swap_rates, swap_maturities):
    termination_date = calc_date + m
    schedule = ql.Schedule(calc_date,
               termination_date,
               coupon_frequency,
               calendar,
               bussiness_convention,
               bussiness_convention,
               ql.DateGeneration.Backward,
               end_of_month)

    helper = ql.SwapRateHelper(ql.QuoteHandle(ql.SimpleQuote(r/100.0)),
                                    m,
                                    calendar,
                                    coupon_frequency,           
                                    bussiness_convention,
                                    day_count,
                                    ql.Euribor3M())

    swap_helpers.append(helper)

rate_helpers = depo_helpers + swap_helpers
yieldcurve = ql.PiecewiseLogCubicDiscount(calc_date,
                         rate_helpers,
                         day_count)   

# get spot rates
spots = []
tenors = []
for d in yieldcurve.dates():
yrs = day_count.yearFraction(calc_date, d)
compounding = ql.Compounded
freq = ql.Semiannual
zero_rate = yieldcurve.zeroRate(yrs, compounding, freq)
tenors.append(yrs)
eq_rate = zero_rate.equivalentRate(day_count,
                                   compounding,
                                   freq,
                                   calc_date,
                                   d).rate()
spots.append(100*eq_rate)

print_curve(tenors, spots)

`

I get the following error: "Wrong number or type of arguments for overloaded function 'new_SwapRateHelper'."

I think it may be because of the last argument used in the fonction. (actually I used a tutorial about bootstrapping but I had to modify it because it was made for bonds and not for swaps)

(I don't really know what this "Euribor3M()" argument is, I let it there but it may be the source of the problem, is it to specify what index my rates come from? )

Have a good day

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.