]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
feat(reforcexy): log invalid actions with enum names for non-masking models
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 1 Mar 2026 18:54:50 +0000 (19:54 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Sun, 1 Mar 2026 18:54:50 +0000 (19:54 +0100)
ReforceXY/user_data/freqaimodels/ReforceXY.py

index d003a3a6c680d441493a9fac79d5fbe8377fb08f..eebdb2ceffe64b42590d4a06ab2c1ae3325266e9 100644 (file)
@@ -1216,7 +1216,12 @@ class ReforceXY(BaseReinforcementLearningModel):
                 )
                 episode_start[:] = False
                 action = int(action.item())
-                logger.debug("Predict [%s]: predicted action=%d", dk.pair, action)
+                logger.debug(
+                    "Predict [%s]: predicted action=%s (%d)",
+                    dk.pair,
+                    Actions(action).name,
+                    action,
+                )
             else:
                 logger.debug(
                     "Predict [%s]: model.predict (observations.shape=%s)",
@@ -1227,7 +1232,12 @@ class ReforceXY(BaseReinforcementLearningModel):
                     observations, deterministic=True, **action_masks_param
                 )
                 action = int(action.item())
-                logger.debug("Predict [%s]: predicted action=%d", dk.pair, action)
+                logger.debug(
+                    "Predict [%s]: predicted action=%s (%d)",
+                    dk.pair,
+                    Actions(action).name,
+                    action,
+                )
 
             return action
 
@@ -3375,6 +3385,15 @@ class MyRLEnv(Base5ActionRLEnv):
         trade_type = self.execute_trade(action)
         if trade_type is not None:
             self.append_trade_history(trade_type, self.current_price(), pre_pnl)
+        elif action != Actions.Neutral.value:
+            logger.warning(
+                "Env [%s]: invalid action=%s (%d) in position=%s at tick=%d",
+                self.id,
+                Actions(action).name,
+                action,
+                self._position.name,
+                self._current_tick,
+            )
         self._position_history.append(self._position)
         terminated = self.is_terminated()
         if terminated: