From: Jérôme Benoit Date: Sun, 15 Jun 2025 19:56:08 +0000 (+0200) Subject: refactor(qav3): align cache variable namespace X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=103eccd89ed87af0aeff1c74ae1560520a5c9bfa;p=freqai-strategies.git refactor(qav3): align cache variable namespace Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py index d9bbac3..b29d39e 100644 --- a/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py +++ b/quickadapter/user_data/freqaimodels/QuickAdapterRegressorV3.py @@ -1366,7 +1366,7 @@ def zigzag( last_pivot_pos = pos reset_candidate_pivot() - slopes_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} + slope_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} def get_slope_ok( pos: int, @@ -1383,16 +1383,16 @@ def zigzag( min_slope, ) - if cache_key in slopes_ok_cache: - return slopes_ok_cache[cache_key] + if cache_key in slope_ok_cache: + return slope_ok_cache[cache_key] next_start = pos next_end = min(next_start + slope_confirmation_window, n) next_closes = closes[next_start:next_end] if len(next_closes) < 2: - slopes_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + slope_ok_cache[cache_key] = False + return slope_ok_cache[cache_key] log_next_closes = np.log(next_closes) log_next_closes_length = len(log_next_closes) @@ -1408,13 +1408,13 @@ def zigzag( )[0] if direction == TrendDirection.DOWN: - slopes_ok_cache[cache_key] = log_next_slope < -min_slope + slope_ok_cache[cache_key] = log_next_slope < -min_slope elif direction == TrendDirection.UP: - slopes_ok_cache[cache_key] = log_next_slope > min_slope + slope_ok_cache[cache_key] = log_next_slope > min_slope else: - slopes_ok_cache[cache_key] = False + slope_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + return slope_ok_cache[cache_key] def is_pivot_confirmed( pos: int, diff --git a/quickadapter/user_data/strategies/Utils.py b/quickadapter/user_data/strategies/Utils.py index 4f1c1db..ad88660 100644 --- a/quickadapter/user_data/strategies/Utils.py +++ b/quickadapter/user_data/strategies/Utils.py @@ -490,7 +490,7 @@ def zigzag( last_pivot_pos = pos reset_candidate_pivot() - slopes_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} + slope_ok_cache: dict[tuple[int, int, bool, int, float], bool] = {} def get_slope_ok( pos: int, @@ -507,16 +507,16 @@ def zigzag( min_slope, ) - if cache_key in slopes_ok_cache: - return slopes_ok_cache[cache_key] + if cache_key in slope_ok_cache: + return slope_ok_cache[cache_key] next_start = pos next_end = min(next_start + slope_confirmation_window, n) next_closes = closes[next_start:next_end] if len(next_closes) < 2: - slopes_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + slope_ok_cache[cache_key] = False + return slope_ok_cache[cache_key] log_next_closes = np.log(next_closes) log_next_closes_length = len(log_next_closes) @@ -532,13 +532,13 @@ def zigzag( )[0] if direction == TrendDirection.DOWN: - slopes_ok_cache[cache_key] = log_next_slope < -min_slope + slope_ok_cache[cache_key] = log_next_slope < -min_slope elif direction == TrendDirection.UP: - slopes_ok_cache[cache_key] = log_next_slope > min_slope + slope_ok_cache[cache_key] = log_next_slope > min_slope else: - slopes_ok_cache[cache_key] = False + slope_ok_cache[cache_key] = False - return slopes_ok_cache[cache_key] + return slope_ok_cache[cache_key] def is_pivot_confirmed( pos: int,