From 51d21b413da418444d54a906f492a6a0999fef7f Mon Sep 17 00:00:00 2001 From: stm <37817561+initrv@users.noreply.github.com> Date: Sat, 26 Nov 2022 23:35:20 +0300 Subject: [PATCH] Fix 4ac update_total_profit _update_total_profit() must be executed before "self._position = Positions.Neutral" because _update_total_profit() calls get_unrealized_profit(), which returns 0 if position is neutral and total_profit is not updated --- freqtrade/freqai/RL/Base4ActionRLEnv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/freqtrade/freqai/RL/Base4ActionRLEnv.py b/freqtrade/freqai/RL/Base4ActionRLEnv.py index 1a235801c..df4e79bea 100644 --- a/freqtrade/freqai/RL/Base4ActionRLEnv.py +++ b/freqtrade/freqai/RL/Base4ActionRLEnv.py @@ -73,8 +73,8 @@ class Base4ActionRLEnv(BaseEnvironment): trade_type = "short" self._last_trade_tick = self._current_tick elif action == Actions.Exit.value: - self._position = Positions.Neutral self._update_total_profit() + self._position = Positions.Neutral trade_type = "neutral" self._last_trade_tick = None else: