From b9d51aec90453901418be3de15cf554f8347d28a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Wed, 26 Feb 2025 20:21:18 +0100 Subject: [PATCH] refactor(qav3): cleanup confirm_trade_entry() 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 | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index 30d506d..c0a9253 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -365,6 +365,7 @@ class QuickAdapterV3(IStrategy): ) -> bool: open_trades = Trade.get_trades(trade_filter=Trade.is_open.is_(True)) + max_per_side_open_trades = self.freqai_info.get("max_per_side_open_trades", 5) num_shorts, num_longs = 0, 0 for trade in open_trades: if "short" in trade.enter_tag: @@ -372,21 +373,18 @@ class QuickAdapterV3(IStrategy): elif "long" in trade.enter_tag: num_longs += 1 - if side == "long" and num_longs >= 5: - return False - - if side == "short" and num_shorts >= 5: + if (side == "long" and num_longs >= max_per_side_open_trades) or ( + side == "short" and num_shorts >= max_per_side_open_trades + ): return False df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) last_candle = df.iloc[-1].squeeze() - if side == "long": - if rate > (last_candle["close"] * (1 + 0.0025)): - return False - else: - if rate < (last_candle["close"] * (1 - 0.0025)): - return False + if (side == "long" and rate > last_candle["close"] * (1 + 0.0025)) or ( + side == "short" and rate < last_candle["close"] * (1 - 0.0025) + ): + return False return True -- 2.43.0