Add trade_duration to to_json

This commit is contained in:
Matthias
2021-01-23 12:43:27 +01:00
parent 9a3c425cf4
commit 3b51545d23
3 changed files with 7 additions and 0 deletions

View File

@@ -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_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_pct': round(self.close_profit * 100, 2) if self.close_profit else None,
'profit_abs': self.close_profit_abs,