diff --git a/crates/wickra-core/src/indicators/tsi.rs b/crates/wickra-core/src/indicators/tsi.rs index 883d424c..629e222c 100644 --- a/crates/wickra-core/src/indicators/tsi.rs +++ b/crates/wickra-core/src/indicators/tsi.rs @@ -151,6 +151,21 @@ mod tests { assert!(matches!(Tsi::new(25, 0), Err(Error::PeriodZero))); } + /// Cover the const accessors `periods` / `value` (70-77) and the + /// Indicator-impl `name` body (137-139). Existing tests inspect + /// TSI output but never query the metadata. + #[test] + fn accessors_and_metadata() { + let mut tsi = Tsi::new(25, 13).unwrap(); + assert_eq!(tsi.periods(), (25, 13)); + assert_eq!(tsi.name(), "TSI"); + assert_eq!(tsi.value(), None); + for i in 1..=tsi.warmup_period() { + tsi.update(100.0 + f64::from(u32::try_from(i).unwrap())); + } + assert!(tsi.value().is_some()); + } + #[test] fn first_emission_at_warmup_period() { let mut tsi = Tsi::new(5, 3).unwrap(); diff --git a/crates/wickra-core/src/indicators/ultimate_oscillator.rs b/crates/wickra-core/src/indicators/ultimate_oscillator.rs index 30a76d3b..da530890 100644 --- a/crates/wickra-core/src/indicators/ultimate_oscillator.rs +++ b/crates/wickra-core/src/indicators/ultimate_oscillator.rs @@ -222,6 +222,28 @@ mod tests { )); } + /// Cover the const accessors `periods` / `value` (96-103) and the + /// Indicator-impl `name` body (193-195). `warmup_period` is covered + /// by `first_emission_at_warmup_period`. + #[test] + fn accessors_and_metadata() { + let mut uo = UltimateOscillator::new(7, 14, 28).unwrap(); + assert_eq!(uo.periods(), (7, 14, 28)); + assert_eq!(uo.name(), "UltimateOscillator"); + assert_eq!(uo.value(), None); + let warmup = i64::try_from(uo.warmup_period()).unwrap(); + let candles: Vec = (0..warmup) + .map(|i| { + let p = 100.0 + (i as f64 * 0.3).sin() * 5.0; + Candle::new(p, p + 1.0, p - 1.0, p, 1.0, i).unwrap() + }) + .collect(); + for c in &candles { + uo.update(*c); + } + assert!(uo.value().is_some()); + } + #[test] fn first_emission_at_warmup_period() { let mut uo = UltimateOscillator::new(2, 3, 5).unwrap(); diff --git a/crates/wickra-core/src/indicators/vortex.rs b/crates/wickra-core/src/indicators/vortex.rs index 06f158eb..08a6994b 100644 --- a/crates/wickra-core/src/indicators/vortex.rs +++ b/crates/wickra-core/src/indicators/vortex.rs @@ -174,6 +174,28 @@ mod tests { assert!(matches!(Vortex::new(0), Err(Error::PeriodZero))); } + /// Cover the const accessors `period` / `value` (84-91) and the + /// Indicator-impl `name` body (157-159). `warmup_period` is covered + /// elsewhere. + #[test] + fn accessors_and_metadata() { + let mut v = Vortex::new(14).unwrap(); + assert_eq!(v.period(), 14); + assert_eq!(v.name(), "Vortex"); + assert!(v.value().is_none()); + let warmup = i64::try_from(v.warmup_period()).unwrap(); + let candles: Vec = (0..warmup) + .map(|i| { + let p = 100.0 + (i as f64 * 0.3).sin() * 5.0; + Candle::new(p, p + 1.0, p - 1.0, p, 1.0, i).unwrap() + }) + .collect(); + for c in &candles { + v.update(*c); + } + assert!(v.value().is_some()); + } + #[test] fn reference_values() { // Vortex(2) over three explicit candles (high, low, close): diff --git a/crates/wickra-core/src/indicators/vwma.rs b/crates/wickra-core/src/indicators/vwma.rs index 39e1e824..3688f2ff 100644 --- a/crates/wickra-core/src/indicators/vwma.rs +++ b/crates/wickra-core/src/indicators/vwma.rs @@ -147,6 +147,22 @@ mod tests { assert!(matches!(Vwma::new(0), Err(Error::PeriodZero))); } + /// Cover the const accessors `period` / `value` (72-79) and the + /// Indicator-impl `name` body (129-131). Existing tests inspect + /// VWMA output but never query the metadata. + #[test] + fn accessors_and_metadata() { + let mut v = Vwma::new(5).unwrap(); + assert_eq!(v.period(), 5); + assert_eq!(v.name(), "VWMA"); + assert_eq!(v.value(), None); + for i in 1..=5i64 { + let p = 100.0 + i as f64; + v.update(Candle::new(p, p, p, p, 1.0, i).unwrap()); + } + assert!(v.value().is_some()); + } + #[test] fn reference_value() { // VWMA(2): (10·1 + 20·3) / (1 + 3) = 70 / 4 = 17.5. diff --git a/crates/wickra-core/src/indicators/zlema.rs b/crates/wickra-core/src/indicators/zlema.rs index d3bdc7ed..8f9599f0 100644 --- a/crates/wickra-core/src/indicators/zlema.rs +++ b/crates/wickra-core/src/indicators/zlema.rs @@ -124,6 +124,21 @@ mod tests { assert!(matches!(Zlema::new(0), Err(Error::PeriodZero))); } + /// Cover the const accessors `period` / `value` (62-64, 72-74) and + /// the Indicator-impl `name` body (111-113). `lag` is already covered + /// by `lag_is_half_of_period_minus_one`. + #[test] + fn accessors_and_metadata() { + let mut z = Zlema::new(5).unwrap(); + assert_eq!(z.period(), 5); + assert_eq!(z.name(), "ZLEMA"); + assert_eq!(z.value(), None); + for i in 1..=z.warmup_period() { + z.update(f64::from(u32::try_from(i).unwrap())); + } + assert!(z.value().is_some()); + } + #[test] fn lag_is_half_of_period_minus_one() { assert_eq!(Zlema::new(3).unwrap().lag(), 1);