pub fn cagr(price_start: f64, price_end: f64, years: f64) -> FinanceResult<f64>Expand description
Compound annual growth rate: (end / start)^(1/years) - 1.
ยงExamples
use finance_solution::{cagr, FinanceError};
assert!(cagr(100.0, 121.0, 2.0).is_ok());
match cagr(100.0, 121.0, 0.0) {
Err(FinanceError::Unsolvable { message }) => assert!(message.contains("years")),
other => panic!("expected Unsolvable, got {other:?}"),
}