modifiedDuration¶
Evaluates the modified Macauley duration of a security.
Synopsis¶
modifiedDuration (settlement, maturity, couponRate, t_yield, frequency, basis)
Required Arguments¶
- date
settlement
(Input) - The date on which payment is made to settle a trade. For a more detailed discussion on dates see the Usage Notes section of this chapter.
- date
maturity
(Input) - The date on which the bond comes due, and principal and accrued interest are paid. For a more detailed discussion on dates see the Usage Notes section of this chapter.
- float
couponRate
(Input) - Annual interest rate set forth on the face of the security; the coupon rate.
- float
t_yield
(Input) - Annual yield of the security.
- int
frequency
(Input) - Frequency of the interest payments. It should be one of
ANNUAL
,SEMIANNUAL
orQUARTERLY
. For a more detailed discussion onfrequency
see the Usage Notes section of this chapter. - int
basis
(Input) - The method for computing the number of days between two dates. It should
be one of
DAY_CNT_BASIS_ACTUALACTUAL
,DAY_CNT_BASIS_NASD
,DAY_CNT_BASIS_ACTUAL360
,DAY_CNT_BASIS_ACTUAL365
, orDAY_CNT_BASIS_30E360
. For a more detailed discussion onbasis
see the Usage Notes section of this chapter.
Return Value¶
The modified Macauley duration of a security is returned. The security has an assumed par value of $100. If no result can be computed, NaN is returned.
Description¶
Function modifiedDuration
computes the modified Macauley duration for a
security with an assumed par value of $100.
It is computed using the following:
\[\frac{\mathit{duration}}{1 + \left(\frac{\mathit{yield}}{\mathit{frequency}}\right)}\]
where duration is calculated from duration.
Example¶
In this example, modifiedDuration
computes the modified Macauley
duration of a security with the settlement date of July 1, 1995, and
maturity date of July 1, 2005, using the Actual/365 day count method.
from __future__ import print_function
from numpy import *
from datetime import date
from pyimsl.math.modifiedDuration import modifiedDuration, DAY_CNT_BASIS_ACTUAL365, SEMIANNUAL
coupon = 0.075
yield_amt = 0.09
frequency = SEMIANNUAL
basis = DAY_CNT_BASIS_ACTUAL365
settlement = date(1995, 7, 1)
maturity = date(2005, 7, 1)
mduration = modifiedDuration(settlement, maturity,
coupon, yield_amt, frequency, basis)
print("The modified Macauley duration of the bond with ")
print("semiannual interest payments is %.4f." % (mduration))
Output¶
The modified Macauley duration of the bond with
semiannual interest payments is 6.7387.