]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
perf(qav3): slighly improve time complexity at pivots labeling
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 28 Sep 2025 22:01:04 +0000 (00:01 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 28 Sep 2025 22:01:04 +0000 (00:01 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/Utils.py

index 692f5244880ac483a54d307acb3e69108681f70c..ccefb838002163b872467e40bc4a7721f28704f4 100644 (file)
@@ -506,6 +506,7 @@ def zigzag(
     indices: list[int] = df.index.tolist()
     thresholds: NDArray[np.floating] = natr_values * natr_ratio
     closes = df.get("close").to_numpy()
+    log_closes = np.log(closes)
     highs = df.get("high").to_numpy()
     lows = df.get("low").to_numpy()
 
@@ -590,8 +591,8 @@ def zigzag(
             slope_ok_cache[cache_key] = False
             return slope_ok_cache[cache_key]
 
-        log_candidate_pivot_close = np.log(closes[candidate_pivot_pos])
-        log_current_close = np.log(closes[pos])
+        log_candidate_pivot_close = log_closes[candidate_pivot_pos]
+        log_current_close = log_closes[pos]
 
         log_slope_close = (log_current_close - log_candidate_pivot_close) / (
             pos - candidate_pivot_pos