NPV, IRR, XIRR, MIRR & Payback Calculator Online
NPV, IRR (all roots), MIRR, XNPV / XIRR, payback, B/C ratio and sensitivity for a cash-flow series, plus bond price ↔ yield and duration, matching Excel.
Result
Press “Run” to see the result.
Send cashflows (the investment as a negative number first, e.g. [-10000, 3000, 4200, 6800], or objects { "date", "amount" } for dated flows) and a discount rate (10, "10%" or 0.1; or one rate per period). The answer gives NPV (first flow at t = 0) and excel_npv (Excel's NPV over all flows), IRR (every root when the flows change sign several times, with a warning), MIRR with finance_rate / reinvest_rate, simple and discounted payback, present values of inflows and outflows, benefit / cost ratio, profitability index and a sensitivity table of NPV when inflows and outflows move by ±x%. Dated flows give XNPV / XIRR (actual days / 365 like Excel) and the payback date. Optional break-even from fixed costs, unit price and unit variable cost.
type=bond prices a bond from its yield or solves the yield from a clean price (Excel PRICE / YIELD conventions, day-count basis 0–4, annual / semi-annual / quarterly coupons) and returns accrued interest, dirty price, coupon dates and Macaulay / modified duration. Results reproduce the examples in the Excel documentation (NPV 1,188.44; IRR 8.66%; XIRR 37.34%; MIRR 12.61%; PRICE 94.6344).
format=xlsx returns a workbook with live Excel formulas (NPV, IRR, MIRR, XIRR, XNPV) so you can check the numbers. Up to 10,000 flows.
Use this in your code
curl -X POST "https://apibox.io.vn/v1/cashflow-calc" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"cashflows":[-10000,3000,4200,6800],"rate":10,"finance_rate":10,"reinvest_rate":12}'const res = await fetch('https://apibox.io.vn/v1/cashflow-calc', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"cashflows": [
-10000,
3000,
4200,
6800
],
"rate": 10,
"finance_rate": 10,
"reinvest_rate": 12
}),
});
const data = await res.json();
console.log(data);import requests
res = requests.post(
"https://apibox.io.vn/v1/cashflow-calc",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={"cashflows": [-10000, 3000, 4200, 6800], "rate": 10, "finance_rate": 10, "reinvest_rate": 12},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/cashflow-calc');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => '{"cashflows":[-10000,3000,4200,6800],"rate":10,"finance_rate":10,"reinvest_rate":12}',
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
FAQ
Why does NPV differ from Excel's NPV()?
Excel's NPV discounts the first value by one period. This API treats the first flow as t = 0 (the usual textbook NPV) and also returns excel_npv for comparison.
What if there are several IRRs?
When the flows change sign more than once, all roots are returned in irr_all with a warning; use NPV or MIRR to decide.
Which day count does the bond calculation use?
Excel's basis codes: 0 US 30/360 (default), 1 actual/actual, 2 actual/360, 3 actual/365, 4 European 30/360.