From: Jérôme Benoit Date: Sun, 20 Jul 2025 21:58:18 +0000 (+0200) Subject: refactor: silence typing warnings X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=f41156c089cb1976905eae421cdbf1549acaa63b;p=freqai-strategies.git refactor: silence typing warnings Signed-off-by: Jérôme Benoit --- diff --git a/ReforceXY/user_data/strategies/RLAgentStrategy.py b/ReforceXY/user_data/strategies/RLAgentStrategy.py index 6903c66..95ed292 100644 --- a/ReforceXY/user_data/strategies/RLAgentStrategy.py +++ b/ReforceXY/user_data/strategies/RLAgentStrategy.py @@ -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") diff --git a/quickadapter/user_data/strategies/QuickAdapterV3.py b/quickadapter/user_data/strategies/QuickAdapterV3.py index b151e12..29e777f 100644 --- a/quickadapter/user_data/strategies/QuickAdapterV3.py +++ b/quickadapter/user_data/strategies/QuickAdapterV3.py @@ -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(