Files
palladium/core/calculations/roi.py
Robert Helewka a2420ed692 refactor: restructure repo into core/app modules with per-study folders
Reorganize Palladium codebase into a modular architecture with `core/`
shared logic and `app/` Streamlit UI, separating per-study assets into
`studies/YYYYMM_<Vendor>/` folders containing notebooks, seed data, and
configuration. Update README to reflect new structure, add `.gitignore`
entries for `.env` and study exports, and refresh component documentation.
2026-05-20 22:28:12 -04:00

28 lines
739 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""Return on Investment."""
from __future__ import annotations
def roi(benefits_pv: float, costs_pv: float) -> float:
"""
Return on Investment as a fraction.
``ROI = (Benefits Costs) / Costs``
Costs here are expressed as a positive present-value amount (the absolute
cost). Returns ``0.0`` when costs are zero (rather than dividing by zero).
Example::
>>> round(roi(101_696_791, 22_983_076), 2) # Amazon Connect: 342%
3.42
"""
if costs_pv <= 0:
return 0.0
return (benefits_pv - costs_pv) / costs_pv
def roi_percentage(benefits_pv: float, costs_pv: float) -> float:
"""ROI as a percentage (e.g. 342.0 for 342%)."""
return roi(benefits_pv, costs_pv) * 100.0