Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Internal Rate of Return

finance.irr

ProductionBounded custom (Class B)Deterministicstrictfastv1.0.0
No network

Overview

You send cashflows numbered by period; we search for the rate whose net present value is zero, using halving over the fixed range -0.999999 to 10 so the same series always gives the same rate. When a series has more than one sign change it may have several real answers, and we say so instead of picking one: you get converged false and a reason rather than a number nobody can defend. Discounting is shared with finance.npv, so both skills agree on what a rate means.

Spreadsheet rate functions start from a guess, so two people with the same cashflows can get two different rates and neither can prove which is right. We fix the range, halve it in exact decimals, and tell you when your series simply does not have one answer.

Reliability

Same series, same rate, every time: the range is fixed at -0.999999 to 10, the step count is capped, and your guess is deliberately ignored. A refusal is reported as converged false with a reason, so you can tell "no single answer" apart from "something went wrong". The three refusals are answers, not errors: they come back as a successful call with converged false, and irr and residualNpv are both absent, so nothing can be misread as a rate of zero. What the fixed range costs you is explicit: a series whose true rate exceeds 1000 percent per period, or sits at or below -99.9999 percent, is reported NO_ROOT_IN_BRACKET — we do not widen the range to find it, because a reproducible range matters more than reaching a rate no lender would write. A tolerance so loose that the range closes before the value does still converges, and residualNpv is how you see it: that is the number to check, not converged alone. IRR_CASHFLOWS_INVALID — trigger: fewer than two cashflows, two entries claiming the same period, an amount we cannot read or one beyond the 1E18 cap, or an entry with a property we do not define; retryable: no, the same payload always fails; next: check the position we name in the details, one entry per period, amounts as plain decimal strings. IRR_SIGNS_UNIFORM — trigger: every amount points the same way, so no rate can bring the series to zero; retryable: no; next: include the outlay as a negative amount and the receipts as positive ones. IRR_TOLERANCE_INVALID — trigger: a tolerance we cannot read, or one outside 0.000000000000001 to 0.000001; retryable: no; next: send a plain decimal in that range, or leave it out for 0.000000000001. NPV_CASHFLOW_LIMIT_EXCEEDED — trigger: more than 1,200 cashflows in one call, whether you overshoot by one entry or by a thousand; retryable: no; next: aggregate the series into fewer periods, since a rate over thousands of periods is dominated by the first few anyway.

Context footprint

Returns one rate and a short account of how it was reached, with no per-period rows. A successful call costs 1 execution credit.

When to use it

When your series goes out once and comes back over later periods, and you want a rate you can reproduce.

When the series changes direction more than once, or when you already know the rate and want a value instead.

Scope

Note
The per-period rate at which a cashflow series has zero net present value, found by halving a fixed range.

Non-goals

  • Does not pick one answer when a series has several real ones
  • Does not use your starting guess, so it cannot drift to a different root
  • Does not convert dates to periods or handle several currencies
  • Does not compare the result against a hurdle rate for you

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

math

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input512 KB

How we handle your data

Sensitive input, safe output
What this means

This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.

Squillify guarantees
  • Runs inside Squillify
  • This skill runs inside Squillify.
  • Payloads are not sent to an external service by this skill.
  • Squillify does not permanently store submitted payloads.
  • Telemetry records metadata only, not submitted content.
  • Submitted payloads are not used for training.
  • Submitted payloads are not reviewed by humans.
  • This skill does not target sensitive data.
  • The response does not contain submitted content.
Your responsibility

Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
cashflowsarrayYesFrom 2 through 1,200 closed cashflows with unique periods and at least one negative and one positive amount.
guessobjectNoOptional starting rate greater than -1, read then ignored because the search range is fixed; omit it for the same search.
toleranceobjectNoOptional rate precision from 1e-15 through 1e-6; omit it for 0.000000000001.
maxIterationsintegerNoOptional cap on halving steps from 1 through 500; omit it for 200.

Output schema

FieldTypeRequiredDescription
irrstringNoPer-period rate as a decimal such as 0.25 for 25 percent; omitted when converged is false so a refusal cannot read as zero.
convergedbooleanYesTrue when a single rate was found inside the range at the requested precision; false is a successful refusal.
reasonCodestringYesWhy the search ended.
iterationsintegerYesHow many halving steps were taken, or 0 when the series was refused before searching.
residualNpvstringNoNet present value left at the reported rate to 12 places; present exactly when irr is present.
bracketobjectYesFixed search range as low and high decimal strings, published because rates outside it are never sought.
tolerancestringYesRate precision the search actually ran to, filled in with the default when you left it out.
signChangesintegerYesHow many times the series changes direction when ordered by period.

API contract

POST /v1/execute
curl
curl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"finance.irr","input":{"cashflows":[{"period":0,"amount":"-1000.00"},{"period":1,"amount":"500.00"},{"period":2,"amount":"500.00"},{"period":3,"amount":"500.00"}]}}'
Integrations
TypeScript SDK
import { Squillify } from "@squillify/sdk";

const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });

const { output } = await sq.execute("finance.irr", {"cashflows":[{"period":0,"amount":"-1000.00"},{"period":1,"amount":"500.00"},{"period":2,"amount":"500.00"},{"period":3,"amount":"500.00"}]});

Errors

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.
IRR_CASHFLOWS_INVALID400NoThe request payload failed this skill's input validation.
IRR_SIGNS_UNIFORM400NoThe request payload failed this skill's input validation.
IRR_TOLERANCE_INVALID400NoThe request payload failed this skill's input validation.
NPV_CASHFLOW_LIMIT_EXCEEDED429NoA size, quota, rate, or time limit was exceeded.

Other limits

LimitValue
Recommended inline bytes32 KiB

Limitations

  • Does not pick one answer when a series has several real ones
  • Does not use your starting guess, so it cannot drift to a different root
  • Does not convert dates to periods or handle several currencies
  • Does not compare the result against a hurdle rate for you
  • Series that swing between paying out and paying in repeatedly
  • Cashflows still expressed as calendar dates
  • Comparing projects of different sizes, where the rate flatters the smaller one

How to call

POST /v1/execute (requires authentication)

Request bodyjson
{
  "skillKey": "finance.irr",
  "input": {
    "cashflows": [
      {
        "period": 0,
        "amount": "-1000.00"
      },
      {
        "period": 1,
        "amount": "500.00"
      },
      {
        "period": 2,
        "amount": "500.00"
      },
      {
        "period": 3,
        "amount": "500.00"
      }
    ]
  }
}

Examples

One outlay and three equal receipts

Inputjson
{
  "cashflows": [
    {
      "period": 0,
      "amount": "-1000.00"
    },
    {
      "period": 1,
      "amount": "500.00"
    },
    {
      "period": 2,
      "amount": "500.00"
    },
    {
      "period": 3,
      "amount": "500.00"
    }
  ]
}
Expected outputjson
{
  "bracket": {
    "low": "-0.999999",
    "high": "10"
  },
  "irr": "0.233751928528",
  "tolerance": "0.000000000001",
  "residualNpv": "0.00000000089",
  "reasonCode": "CONVERGED",
  "converged": true,
  "iterations": 44,
  "signChanges": 1
}

Two sign changes are refused rather than guessed

Inputjson
{
  "cashflows": [
    {
      "period": 0,
      "amount": "-100.00"
    },
    {
      "period": 1,
      "amount": "300.00"
    },
    {
      "period": 2,
      "amount": "-250.00"
    }
  ]
}
Expected outputjson
{
  "signChanges": 2,
  "converged": false,
  "tolerance": "0.000000000001",
  "bracket": {
    "low": "-0.999999",
    "high": "10"
  },
  "reasonCode": "MULTIPLE_SIGN_CHANGES",
  "iterations": 0
}
  • Report the return on an investment with one outlay and later receipts
  • Check whether a payment plan clears an agreed hurdle rate
  • Reproduce a spreadsheet rate with an answer you can audit

Avoid for

  • Series that swing between paying out and paying in repeatedly
  • Cashflows still expressed as calendar dates
  • Comparing projects of different sizes, where the rate flatters the smaller one

Composable with

Safety & privacy

  • Runs without calling any external service.
  • Your payloads are never stored permanently.
  • Telemetry captures metadata only — never your payload contents.
  • We never train models on your payloads.
  • No human reviews your payloads.

Tags

mathanalysiscurrencyfinanceirr