From: Jérôme Benoit Date: Sat, 12 Apr 2025 17:26:38 +0000 (+0200) Subject: refactor(qav3): cleanup trade entry confirmation X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=54f3eb376e546ab50dcff3e0192e4e55592548e8;p=freqai-strategies.git refactor(qav3): cleanup trade entry confirmation Signed-off-by: Jérôme Benoit --- diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 2719a51..46ac921 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -649,15 +649,17 @@ class QuickAdapterV3(IStrategy): if df.empty: return False last_candle = df.iloc[-1] - entry_price_fluctuation_threshold = ( - last_candle["natr_label_period_candles"] * self.entry_natr_ratio - ) + last_candle_close = last_candle["close"] + last_candle_natr = last_candle["natr_label_period_candles"] + if isna(last_candle_natr): + return False + entry_price_fluctuation_threshold = last_candle_natr * self.entry_natr_ratio if ( side == "long" - and rate > last_candle["close"] * (1 + entry_price_fluctuation_threshold) + and rate > last_candle_close * (1 + entry_price_fluctuation_threshold) ) or ( side == "short" - and rate < last_candle["close"] * (1 - entry_price_fluctuation_threshold) + and rate < last_candle_close * (1 - entry_price_fluctuation_threshold) ): return False