Skip to main content

bollinger_solution

Function bollinger_solution 

Source
pub fn bollinger_solution(
    closes: &[f64],
    params: BollingerParams,
) -> FinanceResult<BollingerSolution>
Expand description

Teaching solution with formulas + table.

ยงExamples

use finance_solution::stocks::ta::{bollinger_solution, BollingerParams, StdevKind};
let closes: Vec<f64> = (1..=30).map(|x| 100.0 + (x as f64) * 0.1).collect();
let sol = bollinger_solution(&closes, BollingerParams::standard()).unwrap();
assert!(sol.formula().contains("20"));
let sol_pop = bollinger_solution(
    &closes,
    BollingerParams::with_stdev(20, 2.0, StdevKind::Population),
).unwrap();
assert!(sol_pop.formula().contains("population") || sol_pop.formula().contains("Population")
    || sol_pop.symbolic_formula().contains("population"));