Skip to main content

boki

boki

Financial models as code. Banker-grade Excel as output.
Write the business in Python. Compile 3-statement, LBO, and DCF workbooks where every cell is a live, verified formula — built for engineers and AI agents.

Website · Docs · 日本語

boki IB-grade Excel output: LBO Returns with live 2D sensitivity and DCF Valuation Summary

Spreadsheet models cannot be diffed, tested, or reviewed, and their hardest parts — circular references, macro-pasted values, broken links — are the least visible. boki keeps the model in Python and compiles Excel as the output, not the source.


Quickstart

uv add "boki[excel]"   # or: pip install "boki[excel]"

Core boki has zero required dependencies; the [excel] extra installs openpyxl for .xlsx export.

import boki as b
from boki.lib import compound
from boki.units import USD, year

m = b.Model("Widget Co", start="2027-01", periods=5, step=year)
co = m.entity("Widget Co", standard=b.USGAAP, currency=USD)
co.bs.opening(cash=20e6 * USD)

growth = m.input("Revenue growth", 0.25)
sales = co.pl.revenue("Product sales", compound(40e6 * USD, growth))
co.pl.cogs("Cost of sales", 0.45 * sales)
co.pl.sga("Operating expenses", 6e6 * USD + 0.15 * sales)
co.bs.receivable("Accounts receivable", target=0.12 * sales)
co.bs.fixed_asset("Plant", 30e6 * USD, at=0, life=10 * year)
co.bs.loan("Term loan", draw={0: 25e6 * USD}, rate=0.07, repay=5e6 * USD)
co.pl.income_tax("Income taxes", rate=0.21, base=co.pl.pretax_income)

m.render().to_excel("widget.xlsx", money="$mm")

You never wrote a journal entry, a depreciation schedule, or a cash-flow statement — they are all live formulas in widget.xlsx (Inputs, IS, BS, CF, Schedules, Checks, Model).


Investment-banking grade models

boki builds presentation-ready IB workbooks with historical actuals (actual_until + actuals=, FY2024A | FY2025E divider), proof-carrying Excel formula rewrites (b.row(..., formula=...), b.block), live =INDEX scenario switchers (Inputs!$C$3), 2D summary panels (b.panel), live 2D sensitivity matrices (b.sensitivity), and optional omission of the Model sheet (omit_unused_model=True).

Three complete benchmark workbooks ship in examples/ and are recalculated and verified automatically in pytest with zero formula mismatches:

Model Example Highlights
3-Statement examples/ib_3statement 3Y historical actuals (2022A–2024A) + 5Y forecast (2025E–2029E), US GAAP, indirect CF, Valuation & Credit Bridge, zero Model sheet
LBO examples/ib_lbo Live Sources & Uses, Goodwill, Pro Forma Opening BS, 2-tranche Debt Waterfall + 100% Excess Cash Sweep, Exit Bridge, Sponsor IRR/MoIC, live Entry × Exit sensitivity
DCF examples/ib_dcf CAPM WACC, mid-year discounted UFCF, Perpetuity Growth & Exit Multiple cross-check, live WACC × g and WACC × Exit Multiple sensitivity
uv run python examples/ib_lbo/plan.py out/         # generates out/apex_lbo.xlsx
uv run python examples/ib_dcf/plan.py out/         # generates out/veridian_dcf.xlsx
uv run python examples/ib_3statement/plan.py out/  # generates out/acme_ib_3statement.xlsx

Every number is a live formula

Live Excel formula trace from Inputs to Income Statement to Checks

Every assumption lives once on Inputs in blue, flows cleanly through statement formulas in black, and ties out automatically on Checks. An analyst can change a growth rate, scenario selector, or sensitivity axis header right inside Excel and watch the entire workbook recalculate.


Built for AI agents — mistakes cannot get through

Four compile-time guardrails that verify AI-generated financial models before exporting Excel

Editing spreadsheets by cell coordinates is fragile for humans and worse for LLMs. With boki, an engineer or AI agent writes typed Python and boki enforces four hard guardrails before a single cell hits Excel:

  1. Units are types. Adding USD and kW raises UnitError immediately.
  2. Double-entry ledger. Every line posts double entries; the balance sheet balances and CF = ΔCash in every period of every scenario.
  3. Explicit circularity. Debt sculpting, interest during construction, and goal seeks are solved explicitly with m.solve; any unintended loop stops with CycleError:
    debt = m.unknown("Debt", unit=USD.dims)
    idc = m.series("Interest during construction", 0.08 * debt)
    m.solve(debt, debt == 1_000 * USD + idc)   # 1,086.96
    
  4. Proof-carrying Excel rewrites. Override verbose ledger expansions with clean banker =SUM(...) blocks — boki verifies equivalence across Base, all scenarios, and random perturbations before writing (EquivalenceError on mismatch):
    b.block(
        co.cf.operating,
        [co.pl.net_income, depreciation, change_in_nwc],
        label="Cash flow from operations",
        verify="perturb",
    )
    

And because it is just Python, you can diff assumptions in Git, run scenarios in a loop, and pin board-approved numbers in pytest:

b.expect(m.render(), {co.pl.net_income: [7.9e6, 7.3e6, 11.5e6, 16.7e6, 23.2e6]}, rel=0.01)

Proof

Metric Result
Public financial models rewritten in boki 228
Models reproducing their source workbooks 211
Silent inconsistencies uncovered in published originals 102 (across 50 models)
Formula mismatches across all exported Excel workbooks 0

The 117 matching models published by public bodies and universities are catalogued in docs/public-models.md alongside every source inconsistency found. Every formula cell boki exports is recalculated by an independent engine and compared against Python.


Features & multi-standard support

Switch between US GAAP, IFRS, and J-GAAP — or between banker, sec (10-K), japanese, and plain Excel styles — without rewriting your business logic.

  • Time & actuals: monthly, quarterly, annual, or mixed-frequency timelines; fiscal years (including year-end changes); historical actuals (actual_until + actuals=) with automatic opening-balance handoff into forecast.
  • Accounting: double-entry ledger, payment terms (settle=), deferred revenue/prepaids (recognize=), VAT, opening BS, arbitrary journal entries, indirect & direct cash flow.
  • Assets & debt: straight-line, declining-balance, MACRS tax depreciation, construction in progress with capitalized interest, multi-tranche loans, revolvers, cash sweeps.
  • Consolidation: non-controlling interests, goodwill, equity & cost methods, intercompany eliminations, foreign subsidiary translation.
  • Tax & finance: income tax with loss carryforwards and brackets; npv, irr, xirr, pmt, wacc, capm, gordon, levelized, black_scholes, banded lookup.
  • Excel & Beancount: custom sheet layouts (b.sheet, b.section, b.row, b.link), verified blocks (b.block), 2D panels (b.panel), live 2D sensitivities (b.sensitivity), live scenario switches (scenarios=), Beancount ledger export.

Documentation & status

Status: v0.1 (pre-1.0 — the API may evolve). Not there yet: a cover sheet, accounting-policy differences between standards (goodwill amortization, leases).

License

MIT.

Metadata

Release files for boki 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 boki 0.1.0
File Size Uploaded Provenance Actions
boki-0.1.0.tar.gz 1.8 MB With provenance Details for boki-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 2.1 MB

Release files / boki-0.1.0.tar.gz

Download URL boki-0.1.0.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
86ab9f9f1a4f942ad7e22083b69690d10c756310e39d26dfa81961dc5406138a
BLAKE2b-256 checksum
How to use checksums
f1843cae6314925123fd5c6e6efd43fb374dac717d45508e4fee6a07cc54bd8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 25, 2026.

Transparency log

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

Download URL boki-0.1.0-py3-none-any.whl
Size 270.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9ea75f32a290cbb997d7c9f463b8b238c1e77df2b153c7c936406a63feb1b78
BLAKE2b-256 checksum
How to use checksums
13b141eaabdee991f0bc5ac4f2543acb0830c3deb7a769a25442c7b1e76b2d67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 25, 2026.

Transparency log

Security for boki 0.1.0

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for boki-0.1.0.tar.gz

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 Nov 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

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