From: Jérôme Benoit Date: Sat, 17 May 2025 16:46:58 +0000 (+0200) Subject: refactor(qav3): cleanup pivot labeling implementation X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=5dfaec222309b3895335fdfe01ec4cef077ed1b2;p=freqai-strategies.git refactor(qav3): cleanup pivot labeling implementation Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index 1641a44..06551dd 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -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, diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 61d3683..0af17a5 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -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,