Skip to content

Investment · Calculation

Dated investment cash-flow returns

Enter initial capital in dollars and dated signed receipts or expenses. Computes XIRR and all detected roots, XNPV, MIRR, NPV profile, break-even and the dated cash ledger. Returned IRR and MIRR are fractional annual rates.

Example result · state: available See output

Cost per success
20 calculation credits
Production plans
Standard, Business, Scale, Enterprise
Plan allowances
Free sandbox
Not available

Integration example

Make a request

Use a production key scoped to investor-irr.

Keep the key on your server. A successful call uses 20 calculation credits.

Production request

Set HT_PRODUCTION_KEY on your server. Save as example.mjs and run node example.mjs with Node.js 18 or later.

import { randomUUID } from "node:crypto";

const key = process.env.HT_PRODUCTION_KEY;
if (!key) throw new Error("Set HT_PRODUCTION_KEY on your server.");
const endpoint = "https://calc.hasstechapi.com/v2/calc/investor-irr";
const input = {
  "initialInvestment": 100000,
  "startDate": "2025-01-01",
  "cashFlows": [
    {
      "date": "2026-01-01",
      "amount": 110000
    }
  ],
  "discountRatePct": 5,
  "financeRatePct": 8,
  "reinvestRatePct": 5,
  "dayCount": "ACT/365F"
};
const requestId = process.env.HT_REQUEST_ID || Date.now() + "." + randomUUID();
// Keep this ID to look up usage if the connection is interrupted.
console.error("Usage lookup ID:", requestId);

const response = await fetch(endpoint, {
  method: "POST",
  redirect: "error",
  headers: {
    "Authorization": "Bearer " + key,
    "Content-Type": "application/json",
    "Idempotency-Key": requestId
  },
  body: JSON.stringify(input)
});
if (!response.ok) {
  const problem = await response.json().catch(() => null);
  const code = problem?.error?.code || response.statusText;
  const delay = response.headers.get("retry-after");
  if (delay) console.error("Retry-After (seconds):", delay);
  console.error("HTTP " + response.status + " " + code + ". Usage lookup ID: " + requestId);
  if (Array.isArray(problem?.error?.details)) {
    for (const issue of problem.error.details) console.error("Input issue:", JSON.stringify(issue));
  }
  process.exitCode = 1;
} else {
  console.log(JSON.stringify(await response.json(), null, 2));
}
cURL (shell)

Set HT_PRODUCTION_KEY on your server. Run in a POSIX shell with cURL 7.76+ and Python 3.7+ to create a request ID.

(
  set -eu
  : "${HT_PRODUCTION_KEY:?Set HT_PRODUCTION_KEY on your server}"
  request_id="${HT_REQUEST_ID:-}"
  if [ -z "$request_id" ]; then
    request_id=$(python3 -c 'import time, uuid; print(str(time.time_ns() // 1000000) + "." + str(uuid.uuid4()))')
  fi
  printf 'Usage lookup ID: %s\n' "$request_id" >&2
  # On INVALID_INPUT, read error.details in the JSON response body.
  curl --disable --silent --show-error --fail-with-body --include \
    --request POST 'https://calc.hasstechapi.com/v2/calc/investor-irr' \
    --header "Authorization: Bearer $HT_PRODUCTION_KEY" \
    --header 'Content-Type: application/json' \
    --header "Idempotency-Key: $request_id" \
    --data-binary @- <<'HT_INPUT'
{
  "initialInvestment": 100000,
  "startDate": "2025-01-01",
  "cashFlows": [
    {
      "date": "2026-01-01",
      "amount": 110000
    }
  ],
  "discountRatePct": 5,
  "financeRatePct": 8,
  "reinvestRatePct": 5,
  "dayCount": "ACT/365F"
}
HT_INPUT
)
If your request fails
400 INVALID_INPUT

Read error.details when present. Node prints each issue. cURL returns the JSON body. Each path points into your request. An empty path refers to the whole body.

Check the accepted inputs for required fields, units and ranges. Send the corrected JSON as a new request.

401 or 403
Check that the server has the bearer key for the endpoint’s environment and that the key includes investor-irr.
429
Read the service error code, check your allowance, and wait for the Retry-After interval when supplied before trying again.
Lost response, 409 or 503
Open Request lookup, select the same environment and enter the printed usage lookup ID. A settled ID has already consumed credits. To retry the same calculation, set HT_REQUEST_ID to the original ID and reuse the same inputs. A settled request does not return its result again. Unset the variable for a new request, which can consume credits.

The usage lookup ID is the Idempotency-Key your server sends. The response’s x-request-id identifies the HTTP exchange for support.

Output

Example result

These values come from running this operation on the example inputs.

state
available
formulaVersion
irr-2.1.0
value.irr
0.1 fractional annual return
How to interpret this result
  • Enter initial capital in dollars and dated signed receipts or expenses. Computes XIRR and all detected roots, XNPV, MIRR, NPV profile, break-even and the dated cash ledger. Returned IRR and MIRR are fractional annual rates.
Full example response (JSON)
{
  "status": "available",
  "result": {
    "state": "available",
    "fieldErrors": {},
    "warnings": [],
    "assumptions": [
      {
        "key": "dayCount",
        "value": "ACT/365F",
        "source": "user"
      },
      {
        "key": "discountRatePct",
        "value": "5",
        "unit": "%",
        "source": "user"
      },
      {
        "key": "financeRatePct",
        "value": "8",
        "unit": "%",
        "source": "user"
      },
      {
        "key": "reinvestRatePct",
        "value": "5",
        "unit": "%",
        "source": "user"
      }
    ],
    "provenance": [],
    "formulaVersion": "irr-2.1.0",
    "ruleVersions": [],
    "auditTrail": [
      "Parsed 2 dated cash flows from 2025-01-01 to 2026-01-01.",
      "Netted the ledger to 2 effective calendar-date cash flows before root isolation.",
      "Day count ACT/365F; rate solved in log(1 + rate) space by derivative-root isolation and bracketed bisection, residual tolerance 0.01.",
      "Chronological sign changes after same-day netting: 1. Roots found: 1."
    ],
    "value": {
      "irr": 0.1,
      "irrState": "available",
      "roots": [
        0.1
      ],
      "residualXnpv": "0",
      "converged": true,
      "iterations": 5,
      "tolerance": 0.01,
      "dayCount": "ACT/365F",
      "npv": "4761.9",
      "discountRatePct": "5",
      "mirr": 0.10000000000000009,
      "mirrState": "available",
      "financeRatePct": "8",
      "reinvestRatePct": "5",
      "totalInflows": "110000",
      "totalOutflows": "100000",
      "netProfit": "10000",
      "equityMultiple": "1.1",
      "holdingPeriodYears": 1,
      "timeline": [
        {
          "date": "2025-01-01",
          "amount": "-100000",
          "cumulative": "-100000",
          "discountedCumulative": "-100000",
          "label": "Initial investment"
        },
        {
          "date": "2026-01-01",
          "amount": "110000",
          "cumulative": "10000",
          "discountedCumulative": "4761.9"
        }
      ],
      "breakEvenDate": "2026-01-01",
      "npvProfile": [
        {
          "rate": -0.5,
          "npv": "120000"
        },
        {
          "rate": -0.4741666666666667,
          "npv": "109191.7591125197833037389397756217681472"
        },
        {
          "rate": -0.44833333333333336,
          "npv": "99395.7703927492688091565429304252337349"
        },
        {
          "rate": -0.4225,
          "npv": "90476.1904761904761904761904761904761905"
        },
        {
          "rate": -0.39666666666666667,
          "npv": "82320.4419889502863160465187265351555827"
        },
        {
          "rate": -0.37083333333333335,
          "npv": "74834.4370860927059690364457699228625676"
        },
        {
          "rate": -0.345,
          "npv": "67938.9312977099236641221374045801526718"
        },
        {
          "rate": -0.3191666666666667,
          "npv": "61566.7074663402771880884928440772185111"
        },
        {
          "rate": -0.29333333333333333,
          "npv": "55660.377358490558695265218939124589846"
        },
        {
          "rate": -0.26749999999999996,
          "npv": "50170.6484641638225255972696245733788396"
        },
        {
          "rate": -0.24166666666666664,
          "npv": "45054.9450549450613210964859316510470812"
        },
        {
          "rate": -0.21583333333333332,
          "npv": "40276.3018065887294250243652884705876717"
        },
        {
          "rate": -0.19,
          "npv": "35802.4691358024691358024691358024691358"
        },
        {
          "rate": -0.16416666666666663,
          "npv": "31605.1844466600094432554778336981500893"
        },
        {
          "rate": -0.13833333333333336,
          "npv": "27659.5744680851162599283921149026119867"
        },
        {
          "rate": -0.11249999999999999,
          "npv": "23943.6619718309859154929577464788732394"
        },
        {
          "rate": -0.08666666666666667,
          "npv": "20437.9562043795664393414673131228627497"
        },
        {
          "rate": -0.060833333333333295,
          "npv": "17125.110913930785550129160108933964503"
        },
        {
          "rate": -0.034999999999999976,
          "npv": "13989.637305699470052887325834251807991"
        },
        {
          "rate": -0.009166666666666656,
          "npv": "11017.6619007569423386934197058685395692"
        },
        {
          "rate": 0.01666666666666672,
          "npv": "8196.7213114754169309325450147814380939"
        },
        {
          "rate": 0.04250000000000009,
          "npv": "5515.5875299760191846522781774580335731"
        },
        {
          "rate": 0.06833333333333336,
          "npv": "2964.1185647425832783701363655174241267"
        },
        {
          "rate": 0.09000000000000001,
          "npv": "917.4311926605504587155963302752293578"
        },
        {
          "rate": 0.09416666666666662,
          "npv": "533.1302361005300675360171789632881177"
        },
        {
          "rate": 0.1,
          "npv": "0"
        },
        {
          "rate": 0.11,
          "npv": "-900.9009009009009009009009009009009009"
        },
        {
          "rate": 0.12,
          "npv": "-1785.71428571428571428571428571428571429"
        },
        {
          "rate": 0.14583333333333337,
          "npv": "-4000.00000000001396363636363636160528926"
        },
        {
          "rate": 0.17166666666666675,
          "npv": "-6116.64295874824060266000821514411895818"
        },
        {
          "rate": 0.1975,
          "npv": "-8141.96242171189979123173277661795407098"
        },
        {
          "rate": 0.22333333333333327,
          "npv": "-10081.74386920979946395028547245770724254"
        },
        {
          "rate": 0.24916666666666676,
          "npv": "-11941.29419613076323508534264114601893685"
        },
        {
          "rate": 0.275,
          "npv": "-13725.4901960784313725490196078431372549"
        },
        {
          "rate": 0.3008333333333334,
          "npv": "-15438.82126841767880688843737136909178446"
        },
        {
          "rate": 0.32666666666666666,
          "npv": "-17085.42713567839404307972020908557680704"
        },
        {
          "rate": 0.3524999999999999,
          "npv": "-18669.13123844731977818853974121996303142"
        },
        {
          "rate": 0.3783333333333334,
          "npv": "-20193.47037484885512969913543657290787429"
        },
        {
          "rate": 0.4041666666666667,
          "npv": "-21661.72106824926559888702022558902325108"
        },
        {
          "rate": 0.43000000000000005,
          "npv": "-23076.92307692308768154922001075696761549"
        },
        {
          "rate": 0.4558333333333333,
          "npv": "-24441.90040068689008453120551086182219877"
        },
        {
          "rate": 0.4816666666666667,
          "npv": "-25759.28008998875307628166276740712989243"
        },
        {
          "rate": 0.5075000000000001,
          "npv": "-27031.50912106135986733001658374792703151"
        },
        {
          "rate": 0.5333333333333334,
          "npv": "-28260.86956521739442344045368620024245911"
        },
        {
          "rate": 0.5591666666666668,
          "npv": "-29449.49225013362441907067876997332600144"
        },
        {
          "rate": 0.5850000000000002,
          "npv": "-30599.36908517351033446446874782203981521"
        },
        {
          "rate": 0.6108333333333333,
          "npv": "-31712.36420072426139084043871131425537176"
        },
        {
          "rate": 0.6366666666666667,
          "npv": "-32790.22403258655941364105839945907507859"
        },
        {
          "rate": 0.6625000000000001,
          "npv": "-33834.58646616541353383458646616541353383"
        },
        {
          "rate": 0.6883333333333332,
          "npv": "-34846.98914116485171545817501795472580124"
        },
        {
          "rate": 0.7141666666666668,
          "npv": "-35828.87700534759857432167192240361113687"
        },
        {
          "rate": 0.74,
          "npv": "-36781.60919540229885057471264367816091954"
        },
        {
          "rate": 0.7658333333333334,
          "npv": "-37706.4653138272793692698324180357010186"
        },
        {
          "rate": 0.7916666666666667,
          "npv": "-38604.65116279069881665765278528932434125"
        },
        {
          "rate": 0.8174999999999999,
          "npv": "-39477.30398899587345254470426409903713893"
        },
        {
          "rate": 0.8433333333333335,
          "npv": "-40325.49728752260937382483837951090652578"
        },
        {
          "rate": 0.8691666666666669,
          "npv": "-41150.24520731164354789627371945599937095"
        },
        {
          "rate": 0.895,
          "npv": "-41952.50659630606860158311345646437994723"
        },
        {
          "rate": 0.9208333333333334,
          "npv": "-42733.18872017353777932533726078827663947"
        },
        {
          "rate": 0.9466666666666665,
          "npv": "-43493.15068493150201139988740851900782533"
        },
        {
          "rate": 0.9725000000000001,
          "npv": "-44233.20659062104211745467221186098263855"
        },
        {
          "rate": 0.9983333333333335,
          "npv": "-44954.12844036697706804600163744978581768"
        },
        {
          "rate": 1.0241666666666667,
          "npv": "-45656.64882667765407053950981018459110095"
        },
        {
          "rate": 1.05,
          "npv": "-46341.46341463414634146341463414634146341"
        }
      ],
      "diagnostic": ""
    }
  },
  "formulaVersion": "irr-2.1.0",
  "units": {
    "cashFlows": "signed USD on each date",
    "initialInvestment": "positive USD outlay",
    "discountRatePct": "annual percent",
    "financeRatePct": "annual percent",
    "reinvestRatePct": "annual percent",
    "irr": "fractional annual return",
    "roots": "fractional annual returns",
    "mirr": "fractional annual return",
    "npv": "USD",
    "npvProfile": "fractional annual rate; USD NPV",
    "equityMultiple": "times",
    "tolerance": "USD maximum solver residual"
  },
  "assumptions": [
    "Enter initial capital in dollars and dated signed receipts or expenses. Computes XIRR and all detected roots, XNPV, MIRR, NPV profile, break-even and the dated cash ledger. Returned IRR and MIRR are fractional annual rates."
  ],
  "warnings": [],
  "creditCost": 20
}

Request contract

Accepted inputs

Fields for this example. Expand the schema for all supported combinations and limits.

FieldType, units and limits

initialInvestmentRequired
number

Initial invested capital, in USD. Supply a positive outlay. The engine enters it as negative cash.

Min 0 · Max 1000000000
startDateRequired
string

Gregorian calendar date, YYYY-MM-DD.

Format: date · Min length 10 · Max length 10
cashFlowsRequired
arrayMin items 1 · Max items 63
cashFlows[].dateRequired
string

Gregorian calendar date, YYYY-MM-DD.

Format: date · Min length 10 · Max length 10
cashFlows[].amountRequired
number

Signed USD on the associated date. A receipt is positive and a contribution or expense is negative.

Min -1000000000 · Max 1000000000
discountRatePctRequired
number

Annual discount rate for net present value, in percent (8 means 8%).

Min -50 · Max 100
financeRatePctOptional
number

Annual financing rate applied to negative flows for MIRR, in percent. Default 8%.

Min -50 · Max 100
reinvestRatePctOptional
number

Annual reinvestment rate applied to positive flows for MIRR, in percent. Default 5%.

Min -50 · Max 100
dayCountOptional
stringAllowed: "ACT/365F", "ACT/360", "30/360US", "ACT/ACT-ISDA"
Example request body (JSON)
{
  "initialInvestment": 100000,
  "startDate": "2025-01-01",
  "cashFlows": [
    {
      "date": "2026-01-01",
      "amount": 110000
    }
  ],
  "discountRatePct": 5,
  "financeRatePct": 8,
  "reinvestRatePct": 5,
  "dayCount": "ACT/365F"
}
Full JSON schema
{
  "type": "object",
  "properties": {
    "initialInvestment": {
      "type": "number",
      "minimum": 0,
      "maximum": 1000000000,
      "description": "Initial invested capital, in USD. Supply a positive outlay. The engine enters it as negative cash."
    },
    "startDate": {
      "type": "string",
      "format": "date",
      "minLength": 10,
      "maxLength": 10,
      "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
      "description": "Gregorian calendar date, YYYY-MM-DD."
    },
    "cashFlows": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "minLength": 10,
            "maxLength": 10,
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "description": "Gregorian calendar date, YYYY-MM-DD."
          },
          "amount": {
            "type": "number",
            "minimum": -1000000000,
            "maximum": 1000000000,
            "description": "Signed USD on the associated date. A receipt is positive and a contribution or expense is negative."
          }
        },
        "required": [
          "date",
          "amount"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 63
    },
    "discountRatePct": {
      "type": "number",
      "minimum": -50,
      "maximum": 100,
      "description": "Annual discount rate for net present value, in percent (8 means 8%)."
    },
    "financeRatePct": {
      "type": "number",
      "minimum": -50,
      "maximum": 100,
      "description": "Annual financing rate applied to negative flows for MIRR, in percent. Default 8%."
    },
    "reinvestRatePct": {
      "type": "number",
      "minimum": -50,
      "maximum": 100,
      "description": "Annual reinvestment rate applied to positive flows for MIRR, in percent. Default 5%."
    },
    "dayCount": {
      "enum": [
        "ACT/365F",
        "ACT/360",
        "30/360US",
        "ACT/ACT-ISDA"
      ]
    }
  },
  "required": [
    "initialInvestment",
    "startDate",
    "cashFlows",
    "discountRatePct"
  ],
  "additionalProperties": false,
  "description": "Enter initial capital in dollars and dated signed receipts or expenses. Computes XIRR and all detected roots, XNPV, MIRR, NPV profile, break-even and the dated cash ledger. Returned IRR and MIRR are fractional annual rates."
}

Production endpoint: POST https://calc.hasstechapi.com/v2/calc/investor-irr
Formula: irr-2.1.0

Related PDF reports