Standardize trade api outputs
there should be no difference between current_profit and close_profit it's always profit, and the information if it's a closed trade is available elsewhere
This commit is contained in:
@@ -295,8 +295,13 @@ class Trade(_DECL_BASE):
|
||||
tzinfo=timezone.utc).timestamp() * 1000) if self.close_date else None,
|
||||
'close_rate': self.close_rate,
|
||||
'close_rate_requested': self.close_rate_requested,
|
||||
'close_profit': self.close_profit,
|
||||
'close_profit_abs': self.close_profit_abs,
|
||||
'close_profit': self.close_profit, # Deprecated
|
||||
'close_profit_pct': round(self.close_profit * 100, 2) if self.close_profit else None,
|
||||
'close_profit_abs': self.close_profit_abs, # Deprecated
|
||||
|
||||
'profit_ratio': self.close_profit,
|
||||
'profit_pct': round(self.close_profit * 100, 2) if self.close_profit else None,
|
||||
'profit_abs': self.close_profit_abs,
|
||||
|
||||
'sell_reason': self.sell_reason,
|
||||
'sell_order_status': self.sell_order_status,
|
||||
|
@@ -152,17 +152,18 @@ class RPC:
|
||||
stoploss_current_dist = trade.stop_loss - current_rate
|
||||
stoploss_current_dist_ratio = stoploss_current_dist / current_rate
|
||||
|
||||
fmt_close_profit = (f'{round(trade.close_profit * 100, 2):.2f}%'
|
||||
if trade.close_profit is not None else None)
|
||||
trade_dict = trade.to_json()
|
||||
trade_dict.update(dict(
|
||||
base_currency=self._freqtrade.config['stake_currency'],
|
||||
close_profit=trade.close_profit if trade.close_profit is not None else None,
|
||||
close_profit_pct=fmt_close_profit,
|
||||
current_rate=current_rate,
|
||||
current_profit=current_profit,
|
||||
current_profit_pct=round(current_profit * 100, 2),
|
||||
current_profit_abs=current_profit_abs,
|
||||
current_profit=current_profit, # Deprectated
|
||||
current_profit_pct=round(current_profit * 100, 2), # Deprectated
|
||||
current_profit_abs=current_profit_abs, # Deprectated
|
||||
profit_ratio=current_profit,
|
||||
profit_pct=round(current_profit * 100, 2),
|
||||
profit_abs=current_profit_abs,
|
||||
|
||||
stoploss_current_dist=stoploss_current_dist,
|
||||
stoploss_current_dist_ratio=round(stoploss_current_dist_ratio, 8),
|
||||
stoploss_current_dist_pct=round(stoploss_current_dist_ratio * 100, 2),
|
||||
|
Reference in New Issue
Block a user