]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): revert too strict pivot timing checks
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 8 May 2025 17:02:44 +0000 (19:02 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 8 May 2025 17:02:44 +0000 (19:02 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py
quickadapter/user_data/strategies/Utils.py

index d24b7ce39137f1361ca60f37613d930011a3c1be..af4e10b9d554c0a11cef5f1bbfa0b6ac05d9e480 100644 (file)
@@ -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
             )
index 719ecad2353bf0dbbbe18678508b45bc419038bf..856f7fc55449fee97dd041c11c3fb263c71be7ec 100644 (file)
@@ -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
             )