81trust / 100

Npv

by Net present value (NPV) in Markets & finance

x402 APIPassing, checked 13 min ago

Compute the net present value of a stream of cashflows at a given discount rate. Index 0 is treated as t=0 (today, not discounted); indices 1..n are discounted by (1+rate)^t. Matches Excel's NPV but with the conventional t=0 treatment most finance textbooks use (Excel itself starts discounting at t=1 - see notes). Use for capital-budgeting decisions: positive NPV = creates value at the discount rate; negative = destroys value.

POST https://agent402.tools/api/npv

Last 30 days

All checks passedSome failedAll failedNot checked
Uptime
100%
Response time
196 ms typical, 196 ms slowest 5%
Last check
13 min ago
Next check
in 19 min

How to call it

# See the payment challenge (nothing is charged)
curl -i -X POST "https://agent402.tools/api/npv" \
  -H "content-type: application/json" \
  -d '{"cashflows":[-1000,300,400,500,600],"discountRate":0.1}'
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client().register(
  "eip155:8453",
  new ExactEvmScheme(privateKeyToAccount(process.env.AGENT_KEY)),
);
const pay = wrapFetchWithPayment(fetch, client);

// Not sure it's safe to pay? Preflight it first for $0.005:
// GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fagent402.tools%2Fapi%2Fnpv
const res = await pay("https://agent402.tools/api/npv", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"cashflows":[-1000,300,400,500,600],"discountRate":0.1}),
});
console.log(await res.json());

Example input

{
  "cashflows": [
    -1000,
    300,
    400,
    500,
    600
  ],
  "discountRate": 0.1
}

Example output

{
  "discountRate": 0.1,
  "npv": 388.77,
  "presentValues": [
    -1000,
    272.73,
    330.58,
    375.66,
    409.81
  ],
  "undiscountedSum": 800
}

Security scan

  • No findings. We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.

Recent checks

WhenResultHTTPTimePrice
13 min agoPassed402290 ms$0.001
5 h agoPassed402196 ms$0.001