Excel MDURATION function: modified duration of a bond
The modified Macaulay duration of a bond with periodic coupons, as Excel's MDURATION: the percentage change in price for a change in yield.
- Version 1
- Checked against 1 published value
- Free, no sign-up
Result: Microsoft's example: 8% coupon, 9% yield, 2008 to 2016, actual/actual
| Mduration Modified duration in years. |
5.736 rounded |
|---|---|
| Coupons remaining Coupons from settlement to maturity (N). |
16 |
Rounding: Half even, 3 decimal places. Calculator excel/mduration@1.
How it is calculated
DURATION(settlement, maturity, coupon, yld, frequency, basis) ÷ (1 + yld/frequency)MDURATION(settlement, maturity, coupon, yld, frequency, [basis]): the modified duration for an assumed par value of 100, which is DURATION divided by 1 + yld/frequency. A modified duration of 5.7 means the price falls by about 5.7% when the yield rises by one percentage point.
- Between coupon dates, the time to each coupon is counted as in PRICE: the days from settlement to the next coupon divided by the days in the coupon period, plus whole periods. Microsoft does not publish this detail. On a coupon date it is the textbook formula and gives Microsoft's documented examples exactly.
- Arguments are named and ordered as in Excel. Excel computes in binary floating point; this API computes the exact value of the same formula and rounds it once, so it agrees with Excel to the digits Excel can show, and where Excel's own rounding error reaches the 15th digit this answer is the correct one.
- Dates are ISO 8601 (YYYY-MM-DD) from 1900-03-01 to 9999-12-31, so Excel's fictional 29 February 1900 never comes into play. Each date result also gives Excel's serial number (1900 date system).
References
Results follow each calculator's documented rules and the sources listed. They are not financial, tax or legal advice. Check that the rules fit your case before you rely on a result. See the terms.
Use it from your code
curl https://api.curatedapi.com/v1/calc/excel/mduration \
-H "Authorization: Bearer $CURATEDAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"settlement": "2008-01-01",
"maturity": "2016-01-01",
"coupon": "0.08",
"yld": "0.09",
"frequency": 2,
"basis": 1,
"options": {"decimals": 3}
}'
The same call in Python
import os
import requests
payload = {
"settlement": "2008-01-01",
"maturity": "2016-01-01",
"coupon": "0.08",
"yld": "0.09",
"frequency": 2,
"basis": 1,
"options": {
"decimals": 3,
},
}
response = requests.post(
"https://api.curatedapi.com/v1/calc/excel/mduration",
headers={"Authorization": f"Bearer {os.environ['CURATEDAPI_KEY']}"},
json=payload,
timeout=10,
)
print(response.json()["result"])
The same call in JavaScript
const payload = {
"settlement": "2008-01-01",
"maturity": "2016-01-01",
"coupon": "0.08",
"yld": "0.09",
"frequency": 2,
"basis": 1,
"options": {
"decimals": 3,
},
};
const response = await fetch("https://api.curatedapi.com/v1/calc/excel/mduration", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.CURATEDAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify(payload),
});
console.log((await response.json()).result);
MCP tool calc_excel_mduration at https://mcp.curatedapi.com.
Inputs, outputs and errors in the API reference.
Put it on your website
<div data-curatedapi-widget="excel/mduration" data-key="capi_public_…"></div>
<script src="https://widgets.curatedapi.com/v1/widget.js" async></script>
Use a public key registered for your site. Calculations are billed like API calls. How widgets work.
Related calculators
- Excel CUMIPMT function: interest paid between two periods
- Excel CUMPRINC function: principal paid between two periods
- Excel DAYS360 function: days on a 360-day year
- Excel DB function: fixed-declining balance depreciation
- Excel DDB function: double-declining balance depreciation
- Excel DURATION function: Macaulay duration of a bond
- Excel EDATE function: same day, months later
- Excel EFFECT function: effective annual rate
- Excel EOMONTH function: end of month
- Excel FV function: future value
- Excel IPMT function: interest part of a payment
- Excel MIRR function: modified internal rate of return
- Excel NETWORKDAYS function: working days between dates
- Excel NOMINAL function: nominal annual rate
- Excel NPER function: number of periods
- Excel PMT function: loan payment
- Excel PPMT function: principal part of a payment
- Excel PRICE function: bond price per 100 face value
- Excel PV function: present value
- Excel RATE function: interest rate per period
- Excel SLN function: straight-line depreciation
- Excel SYD function: sum-of-years-digits depreciation
- Excel VDB function: variable declining balance depreciation
- Excel WORKDAY function: date after working days
- Excel XIRR function: IRR of cash flows on any dates
- Excel XNPV function: net present value of dated cash flows
- Excel YEARFRAC function: fraction of a year between dates
- Excel YIELD function: bond yield from price
Get Excel's answer in your own code
Moving a spreadsheet model into an app? The API returns what Excel returns for the same inputs, so your users see the same numbers in both.
Free for up to 1,000 calculations a month. 50,000 calculations a month cost $9.00 on the Starter plan.