]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(reforcexy): revert Actions usage in strategy
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 10 Aug 2025 15:06:14 +0000 (17:06 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 10 Aug 2025 15:06:14 +0000 (17:06 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ReforceXY/user_data/strategies/RLAgentStrategy.py

index 28f08c677154ee32cad9b25957405dcc357f2c81..a4b0cf3b3ed5e90a2298f4e4a7eb2689970ee0a4 100644 (file)
@@ -3,7 +3,6 @@ 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
 
@@ -107,7 +106,7 @@ class RLAgentStrategy(IStrategy):
     def set_freqai_targets(
         self, dataframe: DataFrame, metadata: dict[str, Any], **kwargs
     ) -> DataFrame:
-        dataframe[ACTION_COLUMN] = Actions.Neutral
+        dataframe[ACTION_COLUMN] = 0
 
         return dataframe
 
@@ -123,7 +122,7 @@ class RLAgentStrategy(IStrategy):
     ) -> DataFrame:
         enter_long_conditions = [
             dataframe.get("do_predict") == 1,
-            dataframe.get(ACTION_COLUMN) == Actions.Long_enter,
+            dataframe.get(ACTION_COLUMN) == 1,
         ]
         dataframe.loc[
             reduce(lambda x, y: x & y, enter_long_conditions),
@@ -132,7 +131,7 @@ class RLAgentStrategy(IStrategy):
 
         enter_short_conditions = [
             dataframe.get("do_predict") == 1,
-            dataframe.get(ACTION_COLUMN) == Actions.Short_enter,
+            dataframe.get(ACTION_COLUMN) == 3,
         ]
         dataframe.loc[
             reduce(lambda x, y: x & y, enter_short_conditions),
@@ -146,13 +145,13 @@ class RLAgentStrategy(IStrategy):
     ) -> DataFrame:
         exit_long_conditions = [
             dataframe.get("do_predict") == 1,
-            dataframe.get(ACTION_COLUMN) == Actions.Long_exit,
+            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) == Actions.Short_exit,
+            dataframe.get(ACTION_COLUMN) == 4,
         ]
         dataframe.loc[
             reduce(lambda x, y: x & y, exit_short_conditions), "exit_short"