From a2a4bc05dbcd56b94bf87393e78864dde2d5d916 Mon Sep 17 00:00:00 2001 From: richardjozsa Date: Mon, 22 Aug 2022 18:06:33 +0200 Subject: [PATCH] Fix the state profit calculation logic --- freqtrade/freqai/RL/BaseReinforcementLearningModel.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/freqtrade/freqai/RL/BaseReinforcementLearningModel.py b/freqtrade/freqai/RL/BaseReinforcementLearningModel.py index 0618a91ed..a9f406c9d 100644 --- a/freqtrade/freqai/RL/BaseReinforcementLearningModel.py +++ b/freqtrade/freqai/RL/BaseReinforcementLearningModel.py @@ -142,13 +142,14 @@ class BaseReinforcementLearningModel(IFreqaiModel): current_profit = 0 for trade in open_trades: if trade.pair == pair: - current_value = trade.open_trade_value + current_value = self.strategy.dp._exchange.get_rate(pair, refresh=False) openrate = trade.open_rate if 'long' in trade.enter_tag: market_side = 1 + current_profit = (current_value - openrate) / openrate else: market_side = 0 - current_profit = current_value / openrate - 1 + current_profit = (openrate - current_value ) / openrate total_profit = 0 closed_trades = Trade.get_trades_proxy(pair=pair, is_open=False)