01 — Parse & coerce
FastAPI Query models coerce types; lists (cashflows) arrive as comma-separated strings and decode to float[].
Engine room · /tools
After sign-in, one route hosts 14 modes of desk math — each backed by
callables in app/engines/tools/service.py, the same module the
homepage signal calls via the public demo API.
Replace the sample with your own query string after the gate. Marketing demo:
POST /api/public/marketing-desk-demo (allowlisted).
Routers validate query params and call thin wrappers; numerics stay in one service module so tests and marketing demos cannot drift from production.
FastAPI Query models coerce types; lists (cashflows) arrive as comma-separated strings and decode to float[].
npv, irr, npv_schedule_rows, rule_of_40_from_pct, wacc_cost_of_capital…
No ORM, no tenant — deterministic outputs for a given input vector.
Templates re-render the same page with result dicts — no client-required JS for the signed-in tool index.
Leading lines of the real tools module — not marketing lorem.
"""Operator pocket tools — small pure functions used by /tools.
Each function returns a dict with the inputs echoed back, the result, and a
short interpretation sentence (in casual exec tone).
"""
from __future__ import annotations
from dataclasses import dataclass
import math
from typing import Iterable
# -------- IRR / NPV ---------------------------------------------------------
def npv(rate: float, cashflows: list[float]) -> float:
return sum(cf / ((1 + rate) ** t) for t, cf in enumerate(cashflows))
def npv_rate_sensitivity(rate: float, cashflows: list[float], bump: float = 0.01) -> dict:
"""±bump hurdle NPV and approximate $ / 1% change in NPV (last period scale)."""
base = npv(rate, cashflows)
up = npv(rate + bump, cashflows)
npv, irr & schedules · compound · multiples · breakeven · kelly · margin of safety · cash conversion cycle · coverage · payback · wacc · SaaS unit economics · Rule of 40 · DuPont ROE · ROIC vs WACC
| Slug | Role | Typical params |
|---|---|---|
npv | Hurdle PV + IRR + schedule slice | rate, cf |
compound | FV / rule of 72 | principal, growth, years |
kelly | Edge → size | win_prob, win_amt, loss_amt |
mos | Price vs intrinsic | mos_price, iv |
ccc | Cash conversion | dso, dio, dpo |
r40 | Rule of 40 | r40_g, r40_m |
wacc | CAPM blend | rf, beta, mrp, pretax_rd, tax, de |
dupont | ROE decomposition | dup_nm, dup_at, dup_em |
spread | ROIC − WACC | spr_n, spr_ic, spr_w |
…plus breakeven, multiples, coverage, payback, SaaS unit economics, and more inside /tools. | ||