Add best / worst trade

This commit is contained in:
Matthias 2020-11-28 17:45:56 +01:00
parent a00f852cf9
commit 5d3f59df90
2 changed files with 17 additions and 6 deletions

View File

@ -165,10 +165,13 @@ A backtesting result will look like that:
| Max open trades | 3 |
| | |
| Total trades | 429 |
| Best Pair | LSK/BTC - 26.26% |
| Worst Pair | ZEC/BTC - -10.18% |
| Total Profit % | 152.41% |
| Trades per day | 3.575 |
| | |
| Best Pair | LSK/BTC - 26.26% |
| Worst Pair | ZEC/BTC - -10.18% |
| Best Trade | LSK/BTC - 4.25% |
| Worst Trade | ZEC/BTC - -10.25% |
| Best day | 25.27% |
| Worst day | -30.67% |
| Avg. Duration Winners | 4:23:00 |
@ -238,10 +241,13 @@ It contains some useful key metrics about performance of your strategy on backte
| Max open trades | 3 |
| | |
| Total trades | 429 |
| Best Pair | LSK/BTC - 26.26% |
| Worst Pair | ZEC/BTC - -10.18% |
| Total Profit % | 152.41% |
| Trades per day | 3.575 |
| | |
| Best Pair | LSK/BTC - 26.26% |
| Worst Pair | ZEC/BTC - -10.18% |
| Best Trade | LSK/BTC - 4.25% |
| Worst Trade | ZEC/BTC - -10.25% |
| Best day | 25.27% |
| Worst day | -30.67% |
| Avg. Duration Winners | 4:23:00 |
@ -258,10 +264,10 @@ 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).
- `Max open trades`: Setting of `max_open_trades` (or `--max-open-trades`) - to clearly see settings for this.
- `Total trades`: Identical to the total trades of the backtest output table.
- `Best Pair`: Which pair performed best, and it's corresponding `Cum Profit %`.
- `Worst pair`: Which pair performed worst and it's corresponding `Cum Profit %`.
- `Total Profit %`: Total profit per stake amount. Aligned to the TOTAL column of 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).
- `Best Pair` / `Worst Pair`: Best and worst performing pair, and it's corresponding `Cum Profit %`.
- `Best Trade` / `Worst Trade`: Biggest winning trade and biggest losing trade
- `Best day` / `Worst day`: Best and worst day based on daily profit.
- `Avg. Duration Winners` / `Avg. Duration Loser`: Average durations for winning and losing trades.
- `Max Drawdown`: Maximum drawdown experienced. For example, the value of 50% means that from highest to subsequent lowest point, a 50% drop was experienced).

View File

@ -400,6 +400,8 @@ def text_table_strategy(strategy_results, stake_currency: str) -> str:
def text_table_add_metrics(strat_results: Dict) -> str:
if len(strat_results['trades']) > 0:
best_trade = max(strat_results['trades'], key=lambda x: x['profit_percent'])
worst_trade = min(strat_results['trades'], key=lambda x: x['profit_percent'])
metrics = [
('Backtesting from', strat_results['backtest_start'].strftime(DATETIME_PRINT_FORMAT)),
('Backtesting to', strat_results['backtest_end'].strftime(DATETIME_PRINT_FORMAT)),
@ -413,6 +415,9 @@ def text_table_add_metrics(strat_results: Dict) -> str:
f"{round(strat_results['best_pair']['profit_sum_pct'], 2)}%"),
('Worst Pair', f"{strat_results['worst_pair']['key']} - "
f"{round(strat_results['worst_pair']['profit_sum_pct'], 2)}%"),
('Best trade', f"{best_trade['pair']} {round(best_trade['profit_percent'] * 100, 2)}%"),
('Worst trade', f"{worst_trade['pair']} {round(worst_trade['profit_percent'] * 100, 2)}%"),
('Best day', f"{round(strat_results['backtest_best_day'] * 100, 2)}%"),
('Worst day', f"{round(strat_results['backtest_worst_day'] * 100, 2)}%"),
('Days win/draw/lose', f"{strat_results['winning_days']} / "