Also print trade_duration in seconds to json
This commit is contained in:
parent
62e43539c9
commit
c659150d9f
@ -262,7 +262,7 @@ It contains some useful key metrics about performance of your strategy on backte
|
|||||||
```
|
```
|
||||||
|
|
||||||
- `Backtesting from` / `Backtesting to`: Backtesting range (usually defined with the `--timerange` option).
|
- `Backtesting from` / `Backtesting to`: Backtesting range (usually defined with the `--timerange` option).
|
||||||
- `Max open trades`: Setting of `max_open_trades` (or `--max-open-trades`) - to clearly see settings for this.
|
- `Max open trades`: Setting of `max_open_trades` (or `--max-open-trades`) - or number of pairs in the pairlist (whatever is lower).
|
||||||
- `Total trades`: Identical to the total trades of the backtest output table.
|
- `Total trades`: Identical to the total trades of the backtest output table.
|
||||||
- `Total Profit %`: Total profit. Aligned to the `TOTAL` row's `Tot Profit %` from the first table.
|
- `Total Profit %`: Total profit. Aligned to the `TOTAL` row's `Tot Profit %` from the first table.
|
||||||
- `Trades per day`: Total trades divided by the backtesting duration in days (this will give you information about how many trades to expect from the strategy).
|
- `Trades per day`: Total trades divided by the backtesting duration in days (this will give you information about how many trades to expect from the strategy).
|
||||||
|
@ -585,9 +585,9 @@ class Hyperopt:
|
|||||||
'winsdrawslosses': f"{wins:>4} {draws:>4} {losses:>4}",
|
'winsdrawslosses': f"{wins:>4} {draws:>4} {losses:>4}",
|
||||||
'avg_profit': backtesting_results['profit_ratio'].mean() * 100.0,
|
'avg_profit': backtesting_results['profit_ratio'].mean() * 100.0,
|
||||||
'median_profit': backtesting_results['profit_ratio'].median() * 100.0,
|
'median_profit': backtesting_results['profit_ratio'].median() * 100.0,
|
||||||
'total_profit': backtesting_results.profit_abs.sum(),
|
'total_profit': backtesting_results['profit_abs'].sum(),
|
||||||
'profit': backtesting_results['profit_ratio'].sum() * 100.0,
|
'profit': backtesting_results['profit_ratio'].sum() * 100.0,
|
||||||
'duration': backtesting_results.trade_duration.mean(),
|
'duration': backtesting_results['trade_duration'].mean(),
|
||||||
}
|
}
|
||||||
|
|
||||||
def _format_results_explanation_string(self, results_metrics: Dict) -> str:
|
def _format_results_explanation_string(self, results_metrics: Dict) -> str:
|
||||||
|
@ -302,9 +302,11 @@ 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_s': (int((self.close_date - self.open_date).total_seconds())
|
||||||
|
if self.close_date else None),
|
||||||
'trade_duration': (int((self.close_date - self.open_date).total_seconds() // 60)
|
'trade_duration': (int((self.close_date - self.open_date).total_seconds() // 60)
|
||||||
if self.close_date else None),
|
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,
|
||||||
|
@ -81,6 +81,7 @@ def test_rpc_trade_status(default_conf, ticker, fee, mocker) -> None:
|
|||||||
'amount_requested': 91.07468123,
|
'amount_requested': 91.07468123,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
'trade_duration': None,
|
'trade_duration': None,
|
||||||
|
'trade_duration_s': None,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'close_profit_pct': None,
|
'close_profit_pct': None,
|
||||||
'close_profit_abs': None,
|
'close_profit_abs': None,
|
||||||
@ -146,6 +147,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,
|
||||||
'trade_duration': ANY,
|
'trade_duration': ANY,
|
||||||
|
'trade_duration_s': ANY,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'close_profit_pct': None,
|
'close_profit_pct': None,
|
||||||
|
@ -816,6 +816,7 @@ def test_to_json(default_conf, fee):
|
|||||||
'amount_requested': 123.0,
|
'amount_requested': 123.0,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
'trade_duration': None,
|
'trade_duration': None,
|
||||||
|
'trade_duration_s': None,
|
||||||
'close_profit': None,
|
'close_profit': None,
|
||||||
'close_profit_pct': None,
|
'close_profit_pct': None,
|
||||||
'close_profit_abs': None,
|
'close_profit_abs': None,
|
||||||
@ -871,6 +872,7 @@ def test_to_json(default_conf, fee):
|
|||||||
'amount_requested': 101.0,
|
'amount_requested': 101.0,
|
||||||
'stake_amount': 0.001,
|
'stake_amount': 0.001,
|
||||||
'trade_duration': 60,
|
'trade_duration': 60,
|
||||||
|
'trade_duration_s': 3600,
|
||||||
'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