]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(qav3): flag strategy as supporting short
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 28 Feb 2025 17:54:17 +0000 (18:54 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Fri, 28 Feb 2025 17:54:17 +0000 (18:54 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
quickadapter/user_data/strategies/QuickAdapterV3.py

index ad97a20bfe4ac53f841bea1c00de24b03b2ffcc2..52e59c63f49475635c7a792f6f43573126c17252 100644 (file)
@@ -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:
     """