CNLMath : Special Functions : modified_duration
modified_duration
Evaluates the modified Macauley duration of a security.
Synopsis
#include <imsl.h>
float imsl_f_modified_duration (struct tm settlement, struct tm maturity, float coupon_rate, float yield, int frequency, int basis)
The type double function is imsl_d_modified_duration.
Required Arguments
struct tm 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.
struct tm 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 coupon_rate (Input)
Annual interest rate set forth on the face of the security; the coupon rate.
float yield (Input)
Annual yield of the security.
int frequency (Input)
Frequency of the interest payments. It should be one of IMSL_ANNUAL, IMSL_SEMIANNUAL or IMSL_QUARTERLY. For a more detailed discussion on frequency 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 IMSL_DAY_CNT_BASIS_ACTUALACTUAL, IMSL_DAY_CNT_BASIS_NASD, IMSL_DAY_CNT_BASIS_ACTUAL360, IMSL_DAY_CNT_BASIS_ACTUAL365, or IMSL_DAY_CNT_BASIS_30E360. For a more detailed discussion on basis 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 imsl_f_modified_duration computes the modified Macauley duration for a security with an assumed par value of $100.
It is computed using the following:
where duration is calculated from imsl_f_duration.
Example
In this example, imsl_f_modified_duration 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.
 
#include <stdio.h>
#include <imsl.h>
 
int main()
{
struct tm settlement, maturity;
float coupon = .075;
float yield = .09;
int frequency = IMSL_SEMIANNUAL;
int basis = IMSL_DAY_CNT_BASIS_ACTUAL365;
float mduration;
 
settlement.tm_year = 95;
settlement.tm_mon = 6;
settlement.tm_mday = 1;
 
maturity.tm_year = 105;
maturity.tm_mon = 6;
maturity.tm_mday = 1;
 
mduration = imsl_f_modified_duration (settlement, maturity,
coupon, yield, frequency, basis);
 
printf ("The modified Macauley duration of the bond with\n");
printf ("semiannual interest payments is %.4f.\n", mduration);
}
Output
 
The modified Macauley duration of the bond with
semiannual interest payments is 6.7387.