]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
perf(qav3): use ta lib python NATR everywhere
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 30 Mar 2025 09:26:25 +0000 (11:26 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 30 Mar 2025 09:26:25 +0000 (11:26 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/QuickAdapterV3.py

index 3d2daaad9202ff2cca0b161b51fd3931846a70ea..af143d8454d975eee70f84d198ecc6652880b79d 100644 (file)
@@ -59,7 +59,7 @@ class QuickAdapterV3(IStrategy):
     INTERFACE_VERSION = 3
 
     def version(self) -> str:
-        return "3.2.3"
+        return "3.2.4"
 
     timeframe = "5m"
 
@@ -383,15 +383,10 @@ class QuickAdapterV3(IStrategy):
             "label_period_candles"
         ].iloc[-1]
 
-        label_window = self.get_label_period_candles(pair) * 2
+        labeling_window = self.get_label_period_candles(pair) * 2
 
-        dataframe["natr_ratio_labeling_window"] = pta.natr(
-            dataframe["high"],
-            dataframe["low"],
-            dataframe["close"],
-            length=label_window,
-            scalar=1,
-            mamode="ema",
+        dataframe["natr_labeling_window"] = ta.NATR(
+            dataframe, timeperiod=labeling_window
         )
 
         dataframe["minima_threshold"] = dataframe[MINIMA_THRESHOLD_COLUMN]
@@ -439,7 +434,7 @@ class QuickAdapterV3(IStrategy):
         if entry_candle is None:
             return None
         entry_candle = entry_candle.squeeze()
-        return entry_candle["natr_ratio_labeling_window"]
+        return entry_candle["natr_labeling_window"]
 
     def get_trade_duration_candles(self, df: DataFrame, trade: Trade) -> int | None:
         """
@@ -475,7 +470,7 @@ class QuickAdapterV3(IStrategy):
         trade_duration_candles = self.get_trade_duration_candles(df, trade)
         if QuickAdapterV3.is_trade_duration_valid(trade_duration_candles) is False:
             return None
-        current_natr = df["natr_ratio_labeling_window"].iloc[-1]
+        current_natr = df["natr_labeling_window"].iloc[-1]
         if isna(current_natr):
             return None
         return (
@@ -492,7 +487,7 @@ class QuickAdapterV3(IStrategy):
         entry_natr = self.get_trade_entry_natr(df, trade)
         if isna(entry_natr):
             return None
-        current_natr = df["natr_ratio_labeling_window"].iloc[-1]
+        current_natr = df["natr_labeling_window"].iloc[-1]
         if isna(current_natr):
             return None
         return (
@@ -621,7 +616,7 @@ class QuickAdapterV3(IStrategy):
             return False
         last_candle = df.iloc[-1].squeeze()
         entry_price_fluctuation_threshold = (
-            last_candle["natr_ratio_labeling_window"] * self.entry_natr_ratio
+            last_candle["natr_labeling_window"] * self.entry_natr_ratio
         )
         if (
             side == "long"