Skip to main content

calcfinc

ci

Auditable financial metrics from the statements of any entity. Give it periodic figures (a CSV, a pandas frame, an SEC filing, an Indian exchange filing) and ask for ratios, growth, CAGR, valuation, DuPont, trailing twelve months. Every answer carries the formula that produced it, the exact figures it used, and a plain-language note whenever something was substituted or could not be computed.

roe = eng.get_ratio("Acme Inc", "roe")
roe.value        # Decimal('25')
roe.formula      # '100 * net_profit / total_equity'
roe.inputs       # the facts used: metric, value, period, currency, source, date reported
roe.limitations  # () - or why the value is None, or what was substituted
  • Exact. Every number is a Decimal; floats are refused at every entrance. A result is the same on any machine and any Python version.
  • Honest. A missing input gives None and the reason, never zero and never an estimate.
  • Open. More than a hundred ratios, each one a readable formula string (list). Add your own with register_ratio.
  • Any entity. Any currency, any fiscal calendar (March, 52/53-week...), months, quarters and years, consolidated and standalone, banks and insurers.
  • Zero runtime dependencies. Python 3.11 or later; pandas is optional.

Status: 0.1, beta. Tested on 19 US and 20 Indian companies' real filings (see what has and has not been verified). The API may still change in 0.x; changes are listed in CHANGELOG.md.

Install

pip install calcfinc

Quick start

A CSV with one row per metric and one column per fiscal year:

metric,FY2025,FY2026
revenue,1000,1200
net_profit,100,150
total_equity,500,600
total_assets,2000,2400
from calcfinc import FinancialEngine

eng = FinancialEngine.from_csv("acme.csv", entity="Acme Inc", currency="USD")

roe = eng.get_ratio("Acme Inc", "roe")
roe.value                                        # -> 25
roe.formula                                      # -> 100 * net_profit / total_equity

# growth in percent, FY2025 to FY2026, and compound annual growth
eng.get_growth("Acme Inc", "revenue").value      # -> 20
eng.get_cagr("Acme Inc", "revenue").value        # -> 20

A figure that cannot be computed says why instead of guessing. This file has no cash flow statement:

fcf = eng.get_ratio("Acme Inc", "free_cash_flow")
fcf.value                                        # -> None
print(fcf.limitations[0])

What you can ask

get_ratio, get_metric margins, returns, leverage, liquidity, efficiency, per-share, trailing twelve months
get_valuation P/E, P/B, EV/EBITDA, yields, market cap (you supply prices)
get_growth, get_cagr year on year, quarter on quarter, month on month, compound
compare_periods, compare_companies two periods side by side; rank entities (never across currencies)
decompose_metric DuPont (three and five factor), net-margin bridge
check, check_periods accounting identities; do the quarters add up to the year
get_segment_data, segment_growth segment revenue, contribution, growth
calculate any formula over numbers you give it

Where data comes from

CSV (long or wide), dicts, pandas, or your own storage; a SQLite file if you want it to persist. Two adapters read real filings:

  • SEC companyfacts (US-GAAP): exact periods, restatements kept as versions, the fourth quarter derived, bank lines for banks.
  • Indian exchange XBRL (Ind-AS): April-March year, india.* ratios in the Schedule III and ICAI forms, placeholder zeros not loaded.

Both tie every fact to its filing. See docs/adapters.md. No market or vendor data is bundled, and there is no network access except one explicit SEC download helper.

Things it deliberately will not do

  • Convert currencies. Amounts in different currencies are listed, never ranked.
  • Annualise a quarterly ratio. It says "not annualised" and offers the trailing-twelve-month form.
  • Hide a substitution. A fallback definition, a derived quarter or a mixed restatement vintage is always in limitations.
  • Apply operating-company ratios to a bank or an insurer. Interest cover, debt and the working-capital ratios return None with the reason for financial companies.

Documentation

Development

python -m venv .venv
.venv/bin/python -m pip install -e ".[dev]"     # Windows: .venv\Scripts\python
.venv/bin/python -m pytest && .venv/bin/ruff check . && .venv/bin/mypy

See CONTRIBUTING.md. To report a vulnerability, see SECURITY.md.

Licence

MIT. Results are calculations, not investment advice.

Metadata

Release files for calcfinc 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for calcfinc 0.1.0
File Size Uploaded
calcfinc-0.1.0.tar.gz 155.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for calcfinc 0.1.0
File Interpreter ABI Platform
calcfinc-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 247.0 kB

Release files / calcfinc-0.1.0.tar.gz

Download URL calcfinc-0.1.0.tar.gz
Size 155.3 kB
Tags Source
SHA-256 checksum
How to use checksums
4471dcb8b415f5c07298fce09f765702849f618dd62f62e6057c2c856f1ee8d3
BLAKE2b-256 checksum
How to use checksums
487d45f78a293a8734856ad3c7a217edb1a5893d36445f3312b3317834080931
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release files / calcfinc-0.1.0-py3-none-any.whl

Download URL calcfinc-0.1.0-py3-none-any.whl
Size 91.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a482d44e235bdaf7ba62898e5b172aefde51e1d3001f09ae81b2228229afea7
BLAKE2b-256 checksum
How to use checksums
20bbe79b54f83462ee5be64555f26319d70e2145e946dab7c5f53866a93f541e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page