pub fn simple_return(price_start: f64, price_end: f64) -> FinanceResult<f64>Expand description
Simple return between two prices: (p1 - p0) / p0.
ยงExamples
use finance_solution::{simple_return, FinanceError};
assert!(simple_return(100.0, 110.0).is_ok());
match simple_return(0.0, 110.0) {
Err(FinanceError::ZeroValue { field }) => assert_eq!(field, "price_start"),
other => panic!("expected ZeroValue, got {other:?}"),
}