From: Jérôme Benoit Date: Sun, 30 Mar 2025 09:26:25 +0000 (+0200) Subject: perf(qav3): use ta lib python NATR everywhere X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=8b460288a29a813ab4913e1d3f44bb98f3d895aa;p=freqai-strategies.git perf(qav3): use ta lib python NATR everywhere Signed-off-by: Jérôme Benoit --- 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"