Excel XIRR function: IRR of cash flows on any dates API
The annual rate of return of cash flows on any dates, as Excel's XIRR, proven correct to the last digit.
POST https://api.curatedapi.com/v1/calc/excel/xirr
- Version 1
- MCP tool
calc_excel_xirr - Try it in the browser
XIRR(values, dates, [guess]): the rate at which XNPV is zero. Excel iterates to within 0.000001% and gives up after 100 tries; here every rate above −100% is found and pinned down exactly.
Formula
Σ Pᵢ / (1 + xirr)^((dᵢ − d₁)/365) = 0
- Excel finds this value by iterating from a guess until it stops changing. Here the root of the same equation is pinned between two proven bounds, so the result is correctly rounded. When the equation has several roots, the one closest to guess is returned (Excel's iteration usually ends there) and all are listed.
- Excel stops iterating once the rate changes by less than 0.000001%, so its digits past about the 8th can be off: for Microsoft's own example Excel shows 0.373362535, while the exact root is 0.37336253351883…
- 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).
Inputs
Send numbers as strings to keep every digit. options sets precision and rounding (see numbers and rounding).
| Input | Type | Description |
|---|---|---|
values required |
list of decimal (string) | The cash flows. Money paid out is negative, money received positive. 2 to 1000 items. Each item: >= -1000000000000000 and <= 1000000000000000. |
dates required |
list of date (YYYY-MM-DD) | The date of each cash flow, in the same order. The first date is the start: no date may be before it. 2 to 1000 items. |
guess |
decimal (string) default 0.1 |
Your guess (Excel's default 0.1); chooses between several solutions. A ratio of two decimals such as "0.08/12" is accepted. Allowed: > -1 and <= 1000. |
options.rounding |
half_even | half_up | half_down | up | down | ceiling | floor | Rounding mode applied once to each result. Default half_even. |
options.decimals |
integer | Round results to this many digits after the decimal point. |
options.significant_digits |
integer | Round results to this many significant digits. |
Result
Under result in the answer, next to exactness, precision, inputs, formula, references and warnings.
| Result | Type | Description |
|---|---|---|
xirr | decimal (string) | Annual rate as a decimal (0.3734 is 37.34%). |
all_rates | list of string | Every rate found, lowest first. |
Examples
Microsoft's example: five dated cash flows
curl https://api.curatedapi.com/v1/calc/excel/xirr \
-H "Authorization: Bearer $CURATEDAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"values": ["-10000", "2750", "4250", "3250", "2750"],
"dates": ["2008-01-01", "2008-03-01", "2008-10-30", "2009-02-15", "2009-04-01"],
"options": {"significant_digits": 7}
}'
{
"calculator": "excel/xirr@1",
"result": {
"xirr": "0.3733625",
"all_rates": [
"0.3733625"
]
},
"exactness": {
"xirr": "rounded"
},
"precision": {
"rounding": "half_even",
"significant_digits": 7
},
"inputs": {
"values": [
"-10000",
"2750",
"4250",
"3250",
"2750"
],
"dates": [
"2008-01-01",
"2008-03-01",
"2008-10-30",
"2009-02-15",
"2009-04-01"
],
"guess": "0.1"
},
"formula": "Σ Pᵢ / (1 + xirr)^((dᵢ − d₁)/365) = 0",
"references": [
{
"title": "Microsoft Excel XIRR function",
"url": "https://support.microsoft.com/en-us/excel/functions/xirr-function"
}
],
"warnings": []
}
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.
Errors share one format; see errors. Billing, retries and batches work the same for every endpoint.