From 78acee20915c945e9c7badba56fe97746439d125 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Thu, 8 May 2025 19:02:44 +0200 Subject: [PATCH] fix(qav3): revert too strict pivot timing checks MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../freqaimodels/QuickAdapterRegressorV3.py | 29 +------------------ quickadapter/user_data/strategies/Utils.py | 29 +------------------ 2 files changed, 2 insertions(+), 56 deletions(-) diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index d24b7ce..af4e10b 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -850,7 +850,7 @@ def zigzag( df: pd.DataFrame, natr_period: int = 14, natr_ratio: float = 1.0, - confirmation_window: int = 2, + confirmation_window: int = 3, depth: int = 12, ) -> tuple[list[int], list[float], list[int]]: n = len(df) @@ -932,37 +932,12 @@ def zigzag( elif direction == TrendDirection.UP: previous_slope_ok = previous_slope < 0 - previous_timing_ok = True - if direction == TrendDirection.DOWN: - if len(previous_highs) >= 1: - previous_timing_ok = ( - highs[previous_slice].argmax() >= (len(previous_highs) - 1) // 2 - ) - elif direction == TrendDirection.UP: - if len(previous_lows) >= 1: - previous_timing_ok = ( - lows[previous_slice].argmin() <= (len(previous_lows) - 1) // 2 - ) - - next_timing_ok = True - if direction == TrendDirection.DOWN: - if len(next_lows) >= 1: - next_timing_ok = lows[next_slice].argmin() >= (len(next_lows) - 1) // 2 - - elif direction == TrendDirection.UP: - if len(next_highs) >= 1: - next_timing_ok = ( - highs[next_slice].argmax() >= (len(next_highs) - 1) // 2 - ) - if direction == TrendDirection.DOWN: return ( np.all(next_closes < highs[pos]) and np.all(previous_closes < highs[pos]) and np.max(next_highs) <= highs[pos] and np.max(previous_highs) <= highs[pos] - and next_timing_ok - and previous_timing_ok and next_slope_ok and previous_slope_ok ) @@ -972,8 +947,6 @@ def zigzag( and np.all(previous_closes > lows[pos]) and np.min(next_lows) >= lows[pos] and np.min(previous_lows) >= lows[pos] - and next_timing_ok - and previous_timing_ok and next_slope_ok and previous_slope_ok ) diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 719ecad..856f7fc 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -344,7 +344,7 @@ def zigzag( df: pd.DataFrame, natr_period: int = 14, natr_ratio: float = 1.0, - confirmation_window: int = 2, + confirmation_window: int = 3, depth: int = 12, ) -> tuple[list[int], list[float], list[int]]: n = len(df) @@ -426,37 +426,12 @@ def zigzag( elif direction == TrendDirection.UP: previous_slope_ok = previous_slope < 0 - previous_timing_ok = True - if direction == TrendDirection.DOWN: - if len(previous_highs) >= 1: - previous_timing_ok = ( - highs[previous_slice].argmax() >= (len(previous_highs) - 1) // 2 - ) - elif direction == TrendDirection.UP: - if len(previous_lows) >= 1: - previous_timing_ok = ( - lows[previous_slice].argmin() <= (len(previous_lows) - 1) // 2 - ) - - next_timing_ok = True - if direction == TrendDirection.DOWN: - if len(next_lows) >= 1: - next_timing_ok = lows[next_slice].argmin() >= (len(next_lows) - 1) // 2 - - elif direction == TrendDirection.UP: - if len(next_highs) >= 1: - next_timing_ok = ( - highs[next_slice].argmax() >= (len(next_highs) - 1) // 2 - ) - if direction == TrendDirection.DOWN: return ( np.all(next_closes < highs[pos]) and np.all(previous_closes < highs[pos]) and np.max(next_highs) <= highs[pos] and np.max(previous_highs) <= highs[pos] - and next_timing_ok - and previous_timing_ok and next_slope_ok and previous_slope_ok ) @@ -466,8 +441,6 @@ def zigzag( and np.all(previous_closes > lows[pos]) and np.min(next_lows) >= lows[pos] and np.min(previous_lows) >= lows[pos] - and next_timing_ok - and previous_timing_ok and next_slope_ok and previous_slope_ok ) -- 2.43.0