]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): cleanup pivot labeling implementation
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 17 May 2025 16:46:58 +0000 (18:46 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sat, 17 May 2025 16:46:58 +0000 (18:46 +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 1641a44d318de30e6e2a3ac9de16b0fe474090c5..06551ddefa8c5cdf74f9c0d4000b014ece5c87d8 100644 (file)
@@ -912,7 +912,7 @@ def zigzag(
         return np.clip(depth_factor, min_factor, max_factor)
 
     def calculate_depth(
-        pivots_indices: list[int],
+        pos: int,
         min_depth: int = 5,
         max_depth: int = 30,
     ) -> int:
@@ -923,7 +923,7 @@ def zigzag(
         weights = np.linspace(0.5, 1.5, len(previous_periods))
         average_period = np.average(previous_periods, weights=weights)
 
-        depth_factor = calculate_depth_factor(last_pivot_pos)
+        depth_factor = calculate_depth_factor(pos)
         depth = int(average_period * depth_factor)
 
         return np.clip(depth, min_depth, max_depth)
@@ -970,7 +970,7 @@ def zigzag(
         pivots_values.append(value)
         pivots_directions.append(direction)
         last_pivot_pos = pos
-        depth = calculate_depth(pivots_indices)
+        depth = calculate_depth(pos)
 
     def is_reversal_confirmed(
         candidate_pivot_pos: int,
index 61d368301a40016aacdec8bed405fc44c3d591ef..0af17a504cb071d5193bb1ec2db49d1be622df2a 100644 (file)
@@ -408,7 +408,7 @@ def zigzag(
         return np.clip(depth_factor, min_factor, max_factor)
 
     def calculate_depth(
-        pivots_indices: list[int],
+        pos: int,
         min_depth: int = 5,
         max_depth: int = 30,
     ) -> int:
@@ -419,7 +419,7 @@ def zigzag(
         weights = np.linspace(0.5, 1.5, len(previous_periods))
         average_period = np.average(previous_periods, weights=weights)
 
-        depth_factor = calculate_depth_factor(last_pivot_pos)
+        depth_factor = calculate_depth_factor(pos)
         depth = int(average_period * depth_factor)
 
         return np.clip(depth, min_depth, max_depth)
@@ -466,7 +466,7 @@ def zigzag(
         pivots_values.append(value)
         pivots_directions.append(direction)
         last_pivot_pos = pos
-        depth = calculate_depth(pivots_indices)
+        depth = calculate_depth(pos)
 
     def is_reversal_confirmed(
         candidate_pivot_pos: int,