From 8b460288a29a813ab4913e1d3f44bb98f3d895aa Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 30 Mar 2025 11:26:25 +0200 Subject: [PATCH] perf(qav3): use ta lib python NATR everywhere MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../user_data/strategies/QuickAdapterV3.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 3d2daaa..af143d8 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -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" -- 2.43.0