pub fn sma_last(closes: &[f64], period: usize) -> FinanceResult<Option<f64>>Expand description
Last defined SMA value, if any.
Uses SmaState end-to-end (no intermediate full Vec of options beyond the push loop).
Prefer holding an SmaState across live bars instead of calling this on growing history.
ยงExamples
use finance_solution::stocks::ta::sma_last;
assert_eq!(sma_last(&[1.0, 2.0, 3.0], 3).unwrap(), Some(2.0));
assert_eq!(sma_last(&[1.0, 2.0], 3).unwrap(), None);