From 54f3eb376e546ab50dcff3e0192e4e55592548e8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sat, 12 Apr 2025 19:26:38 +0200 Subject: [PATCH] refactor(qav3): cleanup trade entry confirmation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- quickadapter/user_data/strategies/QuickAdapterV3.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 -- 2.43.0