From 07ec8047155ff787fbbb7ac05099a4f767cd5279 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 16 Mar 2025 22:15:12 +0100 Subject: [PATCH] refactor(reforcexy): cleanups MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- .../user_data/strategies/RLAgentStrategy.py | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/ReforceXY/user_data/strategies/RLAgentStrategy.py b/ReforceXY/user_data/strategies/RLAgentStrategy.py index 99a4b9c..322edf6 100644 --- a/ReforceXY/user_data/strategies/RLAgentStrategy.py +++ b/ReforceXY/user_data/strategies/RLAgentStrategy.py @@ -24,8 +24,8 @@ class RLAgentStrategy(IStrategy): stoploss = -0.02 # Trailing stop: trailing_stop = True - trailing_stop_positive = 0.0099 - trailing_stop_positive_offset = 0.01 + trailing_stop_positive = 0.01 + trailing_stop_positive_offset = 0.011 trailing_only_offset_is_reached = True use_exit_signal = True @@ -100,30 +100,26 @@ class RLAgentStrategy(IStrategy): def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame: enter_long_conditions = [df["do_predict"] == 1, df[ACTION_COLUMN] == 1] - if enter_long_conditions: - df.loc[ - reduce(lambda x, y: x & y, enter_long_conditions), - ["enter_long", "enter_tag"], - ] = (1, "long") + df.loc[ + reduce(lambda x, y: x & y, enter_long_conditions), + ["enter_long", "enter_tag"], + ] = (1, "long") enter_short_conditions = [df["do_predict"] == 1, df[ACTION_COLUMN] == 3] - if enter_short_conditions: - df.loc[ - reduce(lambda x, y: x & y, enter_short_conditions), - ["enter_short", "enter_tag"], - ] = (1, "short") + df.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) -> DataFrame: exit_long_conditions = [df["do_predict"] == 1, df[ACTION_COLUMN] == 2] - if exit_long_conditions: - df.loc[reduce(lambda x, y: x & y, exit_long_conditions), "exit_long"] = 1 + df.loc[reduce(lambda x, y: x & y, exit_long_conditions), "exit_long"] = 1 exit_short_conditions = [df["do_predict"] == 1, df[ACTION_COLUMN] == 4] - if exit_short_conditions: - df.loc[reduce(lambda x, y: x & y, exit_short_conditions), "exit_short"] = 1 + df.loc[reduce(lambda x, y: x & y, exit_short_conditions), "exit_short"] = 1 return df -- 2.43.0