Skip to main content

Module returns

Module returns 

Source
Expand description

Simple and logarithmic returns from prices.

§Error handling (v0.1+)

All public functions return FinanceResult. Empty series, zero start prices, and non-positive prices for log/CAGR paths are structured errors.

Functions§

cagr
Compound annual growth rate: (end / start)^(1/years) - 1.
log_return
Logarithmic return: ln(p1 / p0). Requires strictly positive prices.
log_returns
Log returns for consecutive prices: length prices.len() - 1.
mean_return
Arithmetic mean of a return series.
simple_return
Simple return between two prices: (p1 - p0) / p0.
simple_returns
Simple returns for consecutive prices: length prices.len() - 1.
total_return
Total simple return from first to last price: (end - start) / start.