Expand description
Ordered price-path analytics (equities or any positive price series).
§Layers
| Layer | API | Purpose |
|---|---|---|
| Scalars | simple_return, volatility, beta, … | One-off metrics |
| Solution | price_path_solution | Summary stats + formulas for a full path |
| Series | PricePathSolution::series | Period detail (return, wealth, drawdown) |
| Tables | PricePathSeries::print_table | Terminal / copy-paste output |
§Error handling (v0.1+)
Public scalars and price_path_solution return crate::FinanceResult.
Empty series, non-positive prices, length mismatches, and zero volatility cases are
structured crate::FinanceError values — not panics.
Prefer composing with ? when prices come from users or external data.
Modules§
- path
- Price-path analysis: solution struct, period series, and pretty tables.
- returns
- Simple and logarithmic returns from prices.
- risk
- Risk metrics: volatility, Sharpe, Sortino, max drawdown, beta, rolling drawdown.
Structs§
- Price
Path Options - Options for
price_path_solution. - Price
Path Period - One step between consecutive prices.
- Price
Path Series - Period series for a price path. Derefs to
[PricePathPeriod]. - Price
Path Solution - Full analysis of an ordered price path.
Enums§
- Return
Kind - Kind of return used for mean / vol / Sharpe on the path.
Functions§
- beta
- OLS beta of asset returns vs market returns (same length series).
- cagr
- Compound annual growth rate:
(end / start)^(1/years) - 1. - drawdown_
series - Running drawdown series (one value per price, starting at 0).
- log_
return - Logarithmic return:
ln(p1 / p0). Requires strictly positive prices. - log_
returns - Log returns for consecutive prices: length
prices.len() - 1. - max_
drawdown - Maximum peak-to-trough drawdown over a positive price series (most negative fraction).
- mean_
return - Arithmetic mean of a return series.
- price_
path_ solution - Build a
PricePathSolutionsummarizing returns, risk, and period detail for a price path. - price_
volatility - Volatility of simple returns computed from consecutive prices.
- rolling_
max_ drawdown - Running maximum drawdown magnitude observed up to each price index.
- sharpe_
ratio - Sharpe ratio:
(mean - risk_free) / volatilityover the return series. - simple_
return - Simple return between two prices:
(p1 - p0) / p0. - simple_
returns - Simple returns for consecutive prices: length
prices.len() - 1. - sortino_
ratio - Sortino ratio:
(mean - target) / downside_deviation, using returns belowtargetonly. - total_
return - Total simple return from first to last price:
(end - start) / start. - volatility
- Sample standard deviation of a return series (population divisor
n - 1). - volatility_
annualized - Annualized volatility:
volatility(returns) * sqrt(periods_per_year).