]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor(qav3): code cleanups
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 18 May 2025 19:11:40 +0000 (21:11 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 18 May 2025 19:11:40 +0000 (21:11 +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 f2732306c3245db68f898a5da9bdccaa44c13468..499130173b5705ea7a8e7a3735278c73555cc33e 100644 (file)
@@ -919,16 +919,15 @@ def zigzag(
         max_depth: int = 30,
     ) -> int:
         if len(pivots_indices) < 2:
-            return initial_depth
+            return depth
 
         previous_periods = np.diff(pivots_indices[-3:])
         weights = np.linspace(0.5, 1.5, len(previous_periods))
         average_period = np.average(previous_periods, weights=weights)
 
         depth_factor = calculate_depth_factor(pos)
-        depth = int(average_period * depth_factor)
 
-        return np.clip(depth, min_depth, max_depth)
+        return np.clip(int(average_period * depth_factor), min_depth, max_depth)
 
     def calculate_min_slope_strength(
         pos: int,
index 8c9e61e66fcacf6aa56c0268068dafff5e57cd69..b01947ff764a857c6100861c6d67ec8ba1aa22ec 100644 (file)
@@ -416,16 +416,15 @@ def zigzag(
         max_depth: int = 30,
     ) -> int:
         if len(pivots_indices) < 2:
-            return initial_depth
+            return depth
 
         previous_periods = np.diff(pivots_indices[-3:])
         weights = np.linspace(0.5, 1.5, len(previous_periods))
         average_period = np.average(previous_periods, weights=weights)
 
         depth_factor = calculate_depth_factor(pos)
-        depth = int(average_period * depth_factor)
 
-        return np.clip(depth, min_depth, max_depth)
+        return np.clip(int(average_period * depth_factor), min_depth, max_depth)
 
     def calculate_min_slope_strength(
         pos: int,