Fix the state profit calculation logic

This commit is contained in:
richardjozsa 2022-08-22 18:06:33 +02:00 committed by robcaulk
parent 29f0e01c4a
commit a2a4bc05db

View File

@ -142,13 +142,14 @@ class BaseReinforcementLearningModel(IFreqaiModel):
current_profit = 0 current_profit = 0
for trade in open_trades: for trade in open_trades:
if trade.pair == pair: 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 openrate = trade.open_rate
if 'long' in trade.enter_tag: if 'long' in trade.enter_tag:
market_side = 1 market_side = 1
current_profit = (current_value - openrate) / openrate
else: else:
market_side = 0 market_side = 0
current_profit = current_value / openrate - 1 current_profit = (openrate - current_value ) / openrate
total_profit = 0 total_profit = 0
closed_trades = Trade.get_trades_proxy(pair=pair, is_open=False) closed_trades = Trade.get_trades_proxy(pair=pair, is_open=False)