Leading lines of the real module (marketing excerpt).
"""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)