Expose relative realized profit

This commit is contained in:
Matthias 2023-03-04 18:20:31 +01:00
parent 51c15d894b
commit f0cbb4f949
4 changed files with 6 additions and 0 deletions

View File

@ -519,6 +519,8 @@ class LocalTrade():
'close_timestamp': int(self.close_date.replace(
tzinfo=timezone.utc).timestamp() * 1000) if self.close_date else None,
'realized_profit': self.realized_profit or 0.0,
# Close-profit corresponds to relative realized_profit ratio
'realized_profit_ratio': self.close_profit or None,
'close_rate': self.close_rate,
'close_rate_requested': self.close_rate_requested,
'close_profit': self.close_profit, # Deprecated

View File

@ -250,6 +250,7 @@ class TradeSchema(BaseModel):
profit_fiat: Optional[float]
realized_profit: float
realized_profit_ratio: Optional[float]
exit_reason: Optional[str]
exit_order_status: Optional[str]

View File

@ -1362,6 +1362,7 @@ def test_to_json(fee):
'trade_duration': None,
'trade_duration_s': None,
'realized_profit': 0.0,
'realized_profit_ratio': None,
'close_profit': None,
'close_profit_pct': None,
'close_profit_abs': None,
@ -1438,6 +1439,7 @@ def test_to_json(fee):
'initial_stop_loss_pct': None,
'initial_stop_loss_ratio': None,
'realized_profit': 0.0,
'realized_profit_ratio': None,
'close_profit': None,
'close_profit_pct': None,
'close_profit_abs': None,

View File

@ -76,6 +76,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
'stoploss_entry_dist_ratio': -0.10376381,
'open_order': None,
'realized_profit': 0.0,
'realized_profit_ratio': None,
'total_profit_abs': -4.09e-06,
'total_profit_fiat': ANY,
'exchange': 'binance',