]> Piment Noir Git Repositories - freqai-strategies.git/commitdiff
fix(reforcexy): correct short fee application to match Freqtrade semantics
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 12 Jan 2026 13:57:58 +0000 (14:57 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Mon, 12 Jan 2026 13:57:58 +0000 (14:57 +0100)
Short positions must use:
- Entry (sell): add_exit_fee reduces price received
- Exit (buy): add_entry_fee increases cost to close

Previous commit incorrectly inverted these in both get_most_recent_return
and get_most_recent_profit for short positions.

ReforceXY/user_data/freqaimodels/ReforceXY.py

index 000775bb99f7a7ab7725c089ee62ca86c05071bf..16d185ef5c20f2ca50d69eb8c069004f20ef92c4 100644 (file)
@@ -3528,7 +3528,7 @@ class MyRLEnv(Base5ActionRLEnv):
                 self._position_history[previous_tick] == Positions.Long
                 or self._position_history[previous_tick] == Positions.Neutral
             ):
-                previous_price = self.add_entry_fee(previous_price)
+                previous_price = self.add_exit_fee(previous_price)
 
             if (
                 previous_price <= 0.0
@@ -3580,8 +3580,8 @@ class MyRLEnv(Base5ActionRLEnv):
             return (current_price - previous_price) / previous_price
 
         elif self._position == Positions.Short:
-            current_price = self.add_exit_fee(self.current_price())
-            previous_price = self.add_entry_fee(self.previous_price())
+            current_price = self.add_entry_fee(self.current_price())
+            previous_price = self.add_exit_fee(self.previous_price())
 
             if (
                 previous_price <= 0.0