0
$\begingroup$

I am calculating equivalentrate between two days in quantlib python using following functions but the output is not matching with the manual calculation.

couponrate = ql.InterestRate(.0675, ql.Actual365Fixed(), ql.Compounded, ql.Monthly)
coupon = couponrate.equivalentRate(ql.Actual365Fixed(),ql.Compounded, ql.Quarterly,ql.Date(14,1,2020), ql.Date(14,4,2020)).rate()
print(coupon)

0.06788039941406243

but correct equivalentRate value is 0.067879171338466

$\endgroup$

1 Answer 1

0
$\begingroup$

There are 91 days between January 14th and April 14th 2020, so the time between them is $T = 91/365$.

Given 1\$ today, a rate $r = 6.75\%$ compounded monthly over $T$ gives an amount $A = (1 + r/12)^{T \times 12}$, so:

>>> import math
>>> T = 91/365
>>> r = 0.0675
>>> A = math.pow(1 + r/12, T*12)
>>> print(A)
1.0169232152238288

The rate that gives the same amount when compounded quarterly is $R$ such that $(1 + R/4)^{T \times 4} = A$, so $R = 4 \times (A^{1/(T \times 4)} - 1)$:

>>> R = 4 * (math.pow(A, 1/(T*4)) - 1)
>>> print(R)
0.06788039941406243

You can check, of course, that this gives you the same compounded amount:

>>> print(math.pow(1 + R/4, T*4))
1.0169232152238288

How did you calculate your result?

$\endgroup$
3
  • $\begingroup$ Thank you @Luigi for your reply I have checked it from myside also,and would like to request you to go through my code. as for the same equivalentRate, I am getting different amount in quantlib which is 1.6923606429259497 and your value from above calculation is 1.0169232152238288 which is expected value. the code for this is as follows: $\endgroup$ Jan 24, 2022 at 4:43
  • $\begingroup$ issuedate = ql.Date(14,1,2020) maturitydate = ql.Date(14,4,2020) tenor = ql.Period(ql.Quarterly) bussinessConvention = ql.Unadjusted dateGeneration = ql.DateGeneration.Forward settlementdays = 0 schedule = ql.Schedule(issuedate,maturitydate,tenor,ql.NullCalendar(),bussinessConvention,bussinessConvention,dateGeneration,False) couponrates =0.06788039941406243(calulated as above) leg = ql.FixedRateLeg(schedule,ql.Actual365Fixed(),[100],[couponrates]) bond = ql.Bond(settlementdays,ql.NullCalendar(),issuedate,leg) print([c.amount() for c in bond.cashflows()]) [1.6923606429259497, 100.0] $\endgroup$ Jan 24, 2022 at 4:47
  • $\begingroup$ Oh, so that's what you're trying to do. Bond coupons are simple rates, not compounded (the formula for their compounding is just 1 + r * T). If you use ql.Simple in equivalentRate and pass the result to the bond you'll get a coupon amount of 1.692321522382878 as expected (which is A-1, because A includes the notional and the coupon only gives you the interest instead.) $\endgroup$ Jan 24, 2022 at 8:21

Your Answer

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

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