From: Jérôme Benoit Date: Fri, 28 Feb 2025 17:54:17 +0000 (+0100) Subject: fix(qav3): flag strategy as supporting short X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=5654b1693ea9d9827cdfb45b3aaef4424ecc75c3;p=freqai-strategies.git fix(qav3): flag strategy as supporting short Signed-off-by: Jérôme Benoit --- 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: """