Skip to content

Free and open source · Apache-2.0

Economics and finance models you can read, run and cite.

50 free models with their formulas, sources and tested values, and 171 data series, for students, analysts and developers. Run them here, or from Python, the command line, a REST API or your AI assistant.

Install the Python package: pip install --pre pyeconomics

This is a preview of version 1.0 (1.0.0rc2). Get an email when 1.0 ships.

Time value of money

PV=FV(1+r)n+PMT 1−(1+g1+r)nr−g (1+r)dPV = \frac{FV}{(1+r)^n} + PMT\,\frac{1 - \left(\frac{1+g}{1+r}\right)^n}{r - g}\,(1+r)^{d}
One of 50 formulas, each typeset from its model and linked to its sources. See the model

Try it: Time value of money

Present and future values of sums, annuities and perpetuities, the five-key solve, NPV, IRR, XNPV, XIRR and amortization schedules.

The calculator starts from the model's example. Change any value and press Run: the result comes from the same API, with the same bytes, as Python and the command line give.

The model's page: every formula, its variables, citations and tests.

Loading the calculator…

Where to start

The same model from code

Install the package, then run any model by its id. Every result carries its inputs, units, warnings and a manifest: the model's version, the hashes of its inputs and result, and where each value came from.

Python
pip install --pre pyeconomics

import pyeconomics

inputs = {
    "calculation": "present_value",
    "due": False,
    "future_value": 0,
    "growth": 0,
    "payment": 500,
    "periods": 240,
    "rate": 0.006666666666666667,
}
result = pyeconomics.run("foundations.time_value", inputs)
print(result.to_json())
Command line
pyeconomics models run foundations.time_value --inputs - <<'JSON'
{
  "calculation": "present_value",
  "due": false,
  "future_value": 0,
  "growth": 0,
  "payment": 500,
  "periods": 240,
  "rate": 0.006666666666666667
}
JSON
REST API
Every model is an endpoint: POST /v1/models/foundations.time_value/run with its inputs as JSON.
MCP server
Give your AI assistant every model as a tool: uvx --prerelease allow --from "pyeconomics[mcp]" pyeconomics mcp. The tool run_model runs any model by its id, and 16 models have a tool of their own, such as foundations_time_value. Connect your assistant
Reproducibility
Download any result with its manifest, or as a bundle that runs it again. What a result holds

How every model is checked

Domains

Every model, with filters · Search · What the catalog covers