pub fn simple_returns(prices: &[f64]) -> FinanceResult<Vec<f64>>Expand description
Simple returns for consecutive prices: length prices.len() - 1.
ยงExamples
use finance_solution::{simple_returns, FinanceError};
assert_eq!(simple_returns(&[100.0, 110.0]).unwrap().len(), 1);
match simple_returns(&[100.0]) {
Err(FinanceError::Unsolvable { message }) => assert!(message.contains("two")),
other => panic!("expected Unsolvable, got {other:?}"),
}