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.
28 lines
739 B
Python
28 lines
739 B
Python
"""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
|