Add trade_duration to to_json
This commit is contained in:
parent
9a3c425cf4
commit
3b51545d23
@ -302,6 +302,9 @@ class Trade(_DECL_BASE):
|
|||||||
'close_profit_pct': round(self.close_profit * 100, 2) if self.close_profit else None,
|
'close_profit_pct': round(self.close_profit * 100, 2) if self.close_profit else None,
|
||||||
'close_profit_abs': self.close_profit_abs, # Deprecated
|
'close_profit_abs': self.close_profit_abs, # Deprecated
|
||||||
|
|
||||||
|
# TODO: should this be in minutes or seconds??
|
||||||
|
'trade_duration': (int((self.close_date - self.open_date).total_seconds() // 60)
|
||||||
|
if self.close_date else None),
|
||||||
'profit_ratio': self.close_profit,
|
'profit_ratio': self.close_profit,
|
||||||
'profit_pct': round(self.close_profit * 100, 2) if self.close_profit else None,
|
'profit_pct': round(self.close_profit * 100, 2) if self.close_profit else None,
|
||||||
'profit_abs': self.close_profit_abs,
|
'profit_abs': self.close_profit_abs,
|
||||||
|
@ -80,6 +80,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'amount': 91.07468123,
|
'amount': 91.07468123,
|
||||||
'amount_requested': 91.07468123,
|
'amount_requested': 91.07468123,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
|
'trade_duration': None,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'close_profit_pct': None,
|
'close_profit_pct': None,
|
||||||
'close_profit_abs': None,
|
'close_profit_abs': None,
|
||||||
@ -144,6 +145,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'current_rate': ANY,
|
'current_rate': ANY,
|
||||||
'amount': 91.07468123,
|
'amount': 91.07468123,
|
||||||
'amount_requested': 91.07468123,
|
'amount_requested': 91.07468123,
|
||||||
|
'trade_duration': ANY,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'close_profit_pct': None,
|
'close_profit_pct': None,
|
||||||
|
@ -815,6 +815,7 @@ def test_to_json(default_conf, fee):
|
|||||||
'amount': 123.0,
|
'amount': 123.0,
|
||||||
'amount_requested': 123.0,
|
'amount_requested': 123.0,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
|
'trade_duration': None,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'close_profit_pct': None,
|
'close_profit_pct': None,
|
||||||
'close_profit_abs': None,
|
'close_profit_abs': None,
|
||||||
@ -869,6 +870,7 @@ def test_to_json(default_conf, fee):
|
|||||||
'amount': 100.0,
|
'amount': 100.0,
|
||||||
'amount_requested': 101.0,
|
'amount_requested': 101.0,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
|
'trade_duration': 60,
|
||||||
'stop_loss_abs': None,
|
'stop_loss_abs': None,
|
||||||
'stop_loss_pct': None,
|
'stop_loss_pct': None,
|
||||||
'stop_loss_ratio': None,
|
'stop_loss_ratio': None,
|
||||||
|
Loading…
Reference in New Issue
Block a user