From c504de1465c75be3553438a5c7c182b1bf9206bd Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 10 Aug 2025 15:56:00 +0200 Subject: [PATCH] fix(reforcexy): fix tensorboard take_profit plotting MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- ReforceXY/user_data/freqaimodels/ReforceXY.py | 6 +++--- ReforceXY/user_data/strategies/RLAgentStrategy.py | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ReforceXY/user_data/freqaimodels/ReforceXY.py b/ReforceXY/user_data/freqaimodels/ReforceXY.py index ab89adb..f024094 100644 --- a/ReforceXY/user_data/freqaimodels/ReforceXY.py +++ b/ReforceXY/user_data/freqaimodels/ReforceXY.py @@ -182,7 +182,7 @@ class ReforceXY(BaseReinforcementLearningModel): [ make_env( self.MyRLEnv, - "train_env", + f"train_env{i}", i, seed, train_df, @@ -196,7 +196,7 @@ class ReforceXY(BaseReinforcementLearningModel): [ make_env( self.MyRLEnv, - "eval_env", + f"eval_env{i}", i, seed, test_df, @@ -1273,7 +1273,7 @@ class ReforceXY(BaseReinforcementLearningModel): enter_short_prices = history.loc[history_type == "short_enter", "price"] exit_long_prices = history.loc[history_type == "long_exit", "price"] exit_short_prices = history.loc[history_type == "short_exit", "price"] - take_profit_prices = history.loc[history_type == "take_profit"] + take_profit_prices = history.loc[history_type == "take_profit", "price"] stop_loss_prices = history.loc[history_type == "stop_loss", "price"] timeout_prices = history.loc[history_type == "timeout", "price"] diff --git a/ReforceXY/user_data/strategies/RLAgentStrategy.py b/ReforceXY/user_data/strategies/RLAgentStrategy.py index a4b0cf3..28f08c6 100644 --- a/ReforceXY/user_data/strategies/RLAgentStrategy.py +++ b/ReforceXY/user_data/strategies/RLAgentStrategy.py @@ -3,6 +3,7 @@ from functools import cached_property, reduce from typing import Any # import talib.abstract as ta +from freqtrade.freqai.RL.Base5ActionRLEnv import Actions from freqtrade.strategy import IStrategy from pandas import DataFrame @@ -106,7 +107,7 @@ class RLAgentStrategy(IStrategy): def set_freqai_targets( self, dataframe: DataFrame, metadata: dict[str, Any], **kwargs ) -> DataFrame: - dataframe[ACTION_COLUMN] = 0 + dataframe[ACTION_COLUMN] = Actions.Neutral return dataframe @@ -122,7 +123,7 @@ class RLAgentStrategy(IStrategy): ) -> DataFrame: enter_long_conditions = [ dataframe.get("do_predict") == 1, - dataframe.get(ACTION_COLUMN) == 1, + dataframe.get(ACTION_COLUMN) == Actions.Long_enter, ] dataframe.loc[ reduce(lambda x, y: x & y, enter_long_conditions), @@ -131,7 +132,7 @@ class RLAgentStrategy(IStrategy): enter_short_conditions = [ dataframe.get("do_predict") == 1, - dataframe.get(ACTION_COLUMN) == 3, + dataframe.get(ACTION_COLUMN) == Actions.Short_enter, ] dataframe.loc[ reduce(lambda x, y: x & y, enter_short_conditions), @@ -145,13 +146,13 @@ class RLAgentStrategy(IStrategy): ) -> DataFrame: exit_long_conditions = [ dataframe.get("do_predict") == 1, - dataframe.get(ACTION_COLUMN) == 2, + dataframe.get(ACTION_COLUMN) == Actions.Long_exit, ] 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.get(ACTION_COLUMN) == Actions.Short_exit, ] dataframe.loc[ reduce(lambda x, y: x & y, exit_short_conditions), "exit_short" -- 2.43.0