curatedapi
Browse the docs

Guides

Finance

Excel functions

Late payments

E-invoices

Accounting

Number checks

VAT and GST

Billing and pricing

Money and currencies

Dates and time

Math

Unit conversion

Everyday

Health

Excel XNPV function: net present value of dated cash flows API

Net present value of cash flows on any dates, the same as Excel's XNPV.

POST https://api.curatedapi.com/v1/calc/excel/xnpv

XNPV(rate, values, dates) = Σ valueᵢ / (1 + rate)^((dateᵢ − date₁)/365). Each flow is discounted by its days from the first date over a 365-day year, as in Excel.

Formula

Σ Pᵢ / (1 + rate)^((dᵢ − d₁)/365)
  • 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).

InputTypeDescription
rate required decimal (string) Annual discount rate as a decimal. A ratio of two decimals such as "0.08/12" is accepted. Allowed: > -1 and <= 1000.
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.
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.

ResultTypeDescription
xnpvdecimal (string)Net present value at the first date.

Examples

Microsoft's example: five dated cash flows at 9%

Requestcurl
curl https://api.curatedapi.com/v1/calc/excel/xnpv \
  -H "Authorization: Bearer $CURATEDAPI_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "rate": "0.09",
    "values": ["-10000", "2750", "4250", "3250", "2750"],
    "dates": ["2008-01-01", "2008-03-01", "2008-10-30", "2009-02-15", "2009-04-01"],
    "options": {"decimals": 2}
  }'
200 OKResponse
{
  "calculator": "excel/xnpv@1",
  "result": {
    "xnpv": "2086.65"
  },
  "exactness": {
    "xnpv": "rounded"
  },
  "precision": {
    "rounding": "half_even",
    "decimals": 2
  },
  "inputs": {
    "rate": "0.09",
    "values": [
      "-10000",
      "2750",
      "4250",
      "3250",
      "2750"
    ],
    "dates": [
      "2008-01-01",
      "2008-03-01",
      "2008-10-30",
      "2009-02-15",
      "2009-04-01"
    ]
  },
  "formula": "Σ Pᵢ / (1 + rate)^((dᵢ − d₁)/365)",
  "references": [
    {
      "title": "Microsoft Excel XNPV function",
      "url": "https://support.microsoft.com/en-us/excel/functions/xnpv-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.