]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(reforcexy): fix tensorboard take_profit plotting
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 10 Aug 2025 13:56:00 +0000 (15:56 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 10 Aug 2025 13:56:00 +0000 (15:56 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ReforceXY/user_data/freqaimodels/ReforceXY.py
ReforceXY/user_data/strategies/RLAgentStrategy.py

index ab89adbc4b812b1e6f6d45369f0ee5db65895868..f024094f499180f8720aa7a742b4449b3982960b 100644 (file)
@@ -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"]
 
index a4b0cf3b3ed5e90a2298f4e4a7eb2689970ee0a4..28f08c677154ee32cad9b25957405dcc357f2c81 100644 (file)
@@ -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"