From 5654b1693ea9d9827cdfb45b3aaef4424ecc75c3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 28 Feb 2025 18:54:17 +0100 Subject: [PATCH] fix(qav3): flag strategy as supporting short 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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index ad97a20..52e59c6 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -65,7 +65,7 @@ class QuickAdapterV3(IStrategy): process_only_new_candles = True - can_short = False + can_short = True @property def plot_config(self): @@ -393,11 +393,20 @@ class QuickAdapterV3(IStrategy): elif max_open_trades == 0 or max_open_trades == 1: return max_open_trades elif max_open_trades >= 2: - if self.can_short: + if self.is_short_allowed(): return max_open_trades // 2 else: return max_open_trades + def is_short_allowed(self) -> bool: + trading_mode = self.config.get("trading_mode") + if trading_mode == "futures": + return True + elif trading_mode == "spot": + return False + else: + raise ValueError(f"Invalid trading_mode: {trading_mode}") + def top_percent_change(dataframe: DataFrame, length: int) -> float: """ -- 2.43.0