]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): find_fractals must return the dataframe indices
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 4 Jun 2025 10:20:37 +0000 (12:20 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 4 Jun 2025 10:20:37 +0000 (12:20 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/Utils.py

index 0c2cd95aeb1ee92658116ae8574ff92afbdd58ce..943adf0d8c7891ec8b09162eab98e18daf858df5 100644 (file)
@@ -333,6 +333,8 @@ def find_fractals(df: pd.DataFrame, period: int = 2) -> tuple[list[int], list[in
     highs = df.get("high").to_numpy()
     lows = df.get("low").to_numpy()
 
+    indices = df.index.tolist()
+
     fractal_highs = []
     fractal_lows = []
 
@@ -347,9 +349,9 @@ def find_fractals(df: pd.DataFrame, period: int = 2) -> tuple[list[int], list[in
         )
 
         if is_high_fractal:
-            fractal_highs.append(i)
+            fractal_highs.append(indices[i])
         if is_low_fractal:
-            fractal_lows.append(i)
+            fractal_lows.append(indices[i])
 
     return fractal_highs, fractal_lows