diff --git a/ta_lib/indicators/momentum/src/sso.rs b/ta_lib/indicators/momentum/src/sso.rs index 5f338ed5..8d98c634 100644 --- a/ta_lib/indicators/momentum/src/sso.rs +++ b/ta_lib/indicators/momentum/src/sso.rs @@ -2,18 +2,18 @@ use crate::stoch; use core::prelude::*; pub fn sso( + source: &Series, high: &Series, low: &Series, - close: &Series, smooth_type: Smooth, k_period: usize, d_period: usize, ) -> (Series, Series) { let high_smooth = high.smooth(smooth_type, k_period); let low_smooth = low.smooth(smooth_type, k_period); - let close_smooth = close.smooth(smooth_type, k_period); + let source = source.smooth(smooth_type, k_period); - let k = stoch(&close_smooth, &high_smooth, &low_smooth, k_period); + let k = stoch(&source, &high_smooth, &low_smooth, k_period); let d = k.smooth(smooth_type, d_period); (k, d) @@ -34,7 +34,7 @@ mod tests { let expected_k = vec![0.0, 0.0, 58.333336, 41.666668, 41.666668]; let expected_d = vec![0.0, 0.0, 0.0, 0.0, 44.444447]; - let (k, d) = sso(&high, &low, &close, Smooth::WMA, k_period, d_period); + let (k, d) = sso(&close, &high, &low, Smooth::WMA, k_period, d_period); let result_k: Vec = k.into(); let result_d: Vec = d.into(); diff --git a/ta_lib/strategies/base/src/price.rs b/ta_lib/strategies/base/src/price.rs index 6198759e..7c1df9db 100644 --- a/ta_lib/strategies/base/src/price.rs +++ b/ta_lib/strategies/base/src/price.rs @@ -13,26 +13,32 @@ pub trait Price { } impl Price for OHLCVSeries { + #[inline] fn hl2(&self) -> Series { median_price(&self.high, &self.low) } + #[inline] fn hlc3(&self) -> Series { typical_price(&self.high, &self.low, &self.close) } + #[inline] fn hlcc4(&self) -> Series { wcl(&self.high, &self.low, &self.close) } + #[inline] fn ohlc4(&self) -> Series { average_price(&self.open, &self.high, &self.low, &self.close) } + #[inline] fn atr(&self, period: usize, smooth_type: Smooth) -> Series { atr(&self.high, &self.low, &self.close, smooth_type, period) } + #[inline] fn tr(&self) -> Series { tr(&self.high, &self.low, &self.close) }