]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
refactor: silence typing warnings
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 20 Jul 2025 21:58:18 +0000 (23:58 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 20 Jul 2025 21:58:18 +0000 (23:58 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ReforceXY/user_data/strategies/RLAgentStrategy.py
quickadapter/user_data/strategies/QuickAdapterV3.py

index 6903c6613a54662a0ac1b332c6ddb609b85551b6..95ed29275988c0c41c771b9bd32c13298dad020f 100644 (file)
@@ -106,32 +106,48 @@ class RLAgentStrategy(IStrategy):
         return dataframe
 
     def populate_entry_trend(
-        self, df: DataFrame, metadata: dict[str, Any]
+        self, dataframe: DataFrame, metadata: dict[str, Any]
     ) -> DataFrame:
-        enter_long_conditions = [df.get("do_predict") == 1, df.get(ACTION_COLUMN) == 1]
+        enter_long_conditions = [
+            dataframe.get("do_predict") == 1,
+            dataframe.get(ACTION_COLUMN) == 1,
+        ]
 
-        df.loc[
+        dataframe.loc[
             reduce(lambda x, y: x & y, enter_long_conditions),
             ["enter_long", "enter_tag"],
         ] = (1, "long")
 
-        enter_short_conditions = [df.get("do_predict") == 1, df.get(ACTION_COLUMN) == 3]
+        enter_short_conditions = [
+            dataframe.get("do_predict") == 1,
+            dataframe.get(ACTION_COLUMN) == 3,
+        ]
 
-        df.loc[
+        dataframe.loc[
             reduce(lambda x, y: x & y, enter_short_conditions),
             ["enter_short", "enter_tag"],
         ] = (1, "short")
 
-        return df
-
-    def populate_exit_trend(self, df: DataFrame, metadata: dict[str, Any]) -> DataFrame:
-        exit_long_conditions = [df.get("do_predict") == 1, df.get(ACTION_COLUMN) == 2]
-        df.loc[reduce(lambda x, y: x & y, exit_long_conditions), "exit_long"] = 1
+        return dataframe
 
-        exit_short_conditions = [df.get("do_predict") == 1, df.get(ACTION_COLUMN) == 4]
-        df.loc[reduce(lambda x, y: x & y, exit_short_conditions), "exit_short"] = 1
+    def populate_exit_trend(
+        self, dataframe: DataFrame, metadata: dict[str, Any]
+    ) -> DataFrame:
+        exit_long_conditions = [
+            dataframe.get("do_predict") == 1,
+            dataframe.get(ACTION_COLUMN) == 2,
+        ]
+        dataframe.loc[reduce(lambda x, y: x & y, exit_long_conditions), "exit_long"] = 1
+
+        exit_short_conditions = [
+            dataframe.get("do_predict") == 1,
+            dataframe.get(ACTION_COLUMN) == 4,
+        ]
+        dataframe.loc[
+            reduce(lambda x, y: x & y, exit_short_conditions), "exit_short"
+        ] = 1
 
-        return df
+        return dataframe
 
     def is_short_allowed(self) -> bool:
         trading_mode = self.config.get("trading_mode")
index b151e12c533d4279b0b4b1a252074a50c40dd27a..29e777f84772e9edab302870d45205b59c1628a0 100644 (file)
@@ -372,7 +372,9 @@ class QuickAdapterV3(IStrategy):
         dataframe["%-raw_high"] = highs
         return dataframe
 
-    def feature_engineering_standard(self, dataframe: DataFrame, **kwargs) -> DataFrame:
+    def feature_engineering_standard(
+        self, dataframe: DataFrame, metadata: dict[str, Any], **kwargs
+    ) -> DataFrame:
         dates = dataframe.get("date")
 
         dataframe["%-day_of_week"] = (dates.dt.dayofweek + 1) / 7
@@ -499,34 +501,36 @@ class QuickAdapterV3(IStrategy):
         return dataframe
 
     def populate_entry_trend(
-        self, df: DataFrame, metadata: dict[str, Any]
+        self, dataframe: DataFrame, metadata: dict[str, Any]
     ) -> DataFrame:
         enter_long_conditions = [
-            df.get("do_predict") == 1,
-            df.get("DI_catch") == 1,
-            df.get(EXTREMA_COLUMN) < df.get("minima_threshold"),
+            dataframe.get("do_predict") == 1,
+            dataframe.get("DI_catch") == 1,
+            dataframe.get(EXTREMA_COLUMN) < dataframe.get("minima_threshold"),
         ]
 
-        df.loc[
+        dataframe.loc[
             reduce(lambda x, y: x & y, enter_long_conditions),
             ["enter_long", "enter_tag"],
         ] = (1, "long")
 
         enter_short_conditions = [
-            df.get("do_predict") == 1,
-            df.get("DI_catch") == 1,
-            df.get(EXTREMA_COLUMN) > df.get("maxima_threshold"),
+            dataframe.get("do_predict") == 1,
+            dataframe.get("DI_catch") == 1,
+            dataframe.get(EXTREMA_COLUMN) > dataframe.get("maxima_threshold"),
         ]
 
-        df.loc[
+        dataframe.loc[
             reduce(lambda x, y: x & y, enter_short_conditions),
             ["enter_short", "enter_tag"],
         ] = (1, "short")
 
-        return df
+        return dataframe
 
-    def populate_exit_trend(self, df: DataFrame, metadata: dict[str, Any]) -> DataFrame:
-        return df
+    def populate_exit_trend(
+        self, dataframe: DataFrame, metadata: dict[str, Any]
+    ) -> DataFrame:
+        return dataframe
 
     def get_trade_entry_date(self, trade: Trade) -> datetime.datetime:
         return timeframe_to_prev_date(self.config.get("timeframe"), trade.open_date_utc)
@@ -759,6 +763,7 @@ class QuickAdapterV3(IStrategy):
         current_time: datetime.datetime,
         current_rate: float,
         current_profit: float,
+        after_fill: bool,
         **kwargs,
     ) -> Optional[float]:
         df, _ = self.dp.get_analyzed_dataframe(