Skip to main content

price_path_solution

Function price_path_solution 

Source
pub fn price_path_solution(
    prices: &[f64],
    options: PricePathOptions,
) -> FinanceResult<PricePathSolution>
Expand description

Build a PricePathSolution summarizing returns, risk, and period detail for a price path.

ยงExamples

use finance_solution::{price_path_solution, PricePathOptions, FinanceError};

match price_path_solution(&[100.0, 110.0], PricePathOptions::default()) {
    Ok(path) => assert!(path.total_return() > 0.0),
    Err(FinanceError::Unsolvable { message }) => panic!("{message}"),
    Err(e) => panic!("{e}"),
}

assert!(matches!(
    price_path_solution(&[100.0], PricePathOptions::default()),
    Err(FinanceError::Unsolvable { .. })
));