From d05e9c65358b7e7cbf476c37762e6d901d078a39 Mon Sep 17 00:00:00 2001 From: m5l14i11 Date: Sun, 2 Jul 2023 11:09:01 +0300 Subject: [PATCH] refactor --- ta_lib/momentum/src/aosc.rs | 6 +++--- ta_lib/utils/src/tr.rs | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ta_lib/momentum/src/aosc.rs b/ta_lib/momentum/src/aosc.rs index 072806bd..2c5ce8dc 100644 --- a/ta_lib/momentum/src/aosc.rs +++ b/ta_lib/momentum/src/aosc.rs @@ -21,9 +21,9 @@ mod tests { #[test] fn test_aosc() { - let high = &[3.0, 4.0, 5.0, 6.0, 7.0]; - let low = &[1.0, 2.0, 3.0, 4.0, 5.0]; - let hl2 = median_price(high, low); + let high = vec![3.0, 4.0, 5.0, 6.0, 7.0]; + let low = vec![1.0, 2.0, 3.0, 4.0, 5.0]; + let hl2 = median_price(&high, &low); let short_period = 2; let long_period = 4; let expected_result = vec![None, None, None, Some(1.0), Some(1.0)]; diff --git a/ta_lib/utils/src/tr.rs b/ta_lib/utils/src/tr.rs index 7c30c58b..47b338f4 100644 --- a/ta_lib/utils/src/tr.rs +++ b/ta_lib/utils/src/tr.rs @@ -12,11 +12,11 @@ pub fn true_range(high: &[f64], low: &[f64], close: &[f64]) -> Vec { high[i] - low[i] } else { f64::max( - high[i] - low[i], f64::max( - f64::abs(high[i] - close[i - 1]), - f64::abs(low[i] - close[i - 1]), + high[i] - low[i], + f64::abs(high[i] - close[i - 1]) ), + f64::abs(low[i] - close[i - 1]), ) };