From: Jérôme Benoit Date: Sun, 18 May 2025 19:11:40 +0000 (+0200) Subject: refactor(qav3): code cleanups X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=1f932aec0e89343f61fb10e773a8036a16485385;p=freqai-strategies.git refactor(qav3): code cleanups Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index f273230..4991301 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -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, diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 8c9e61e..b01947f 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -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,