Updated Strategy Summary table to match other backtesting tables (#2864)

This commit is contained in:
Yazeed Al Oyoun 2020-02-06 06:58:58 +01:00 committed by GitHub
parent 9639ffb140
commit 5b00eaa42d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 12 deletions

View File

@ -237,8 +237,8 @@ There will be an additional table comparing win/losses of the different strategi
Detailed output for all strategies one after the other will be available, so make sure to scroll up to see the details per strategy. Detailed output for all strategies one after the other will be available, so make sure to scroll up to see the details per strategy.
``` ```
=========================================================== Strategy Summary =========================================================== =========================================================== STRATEGY SUMMARY ===========================================================
| Strategy | buy count | avg profit % | cum profit % | tot profit BTC | tot profit % | avg duration | profit | loss | | Strategy | Buy Count | Avg Profit % | Cum Profit % | Tot Profit BTC | Tot Profit % | Avg Duration | Wins | Losses |
|:------------|------------:|---------------:|---------------:|-----------------:|---------------:|:---------------|---------:|-------:| |:------------|------------:|---------------:|---------------:|-----------------:|---------------:|:---------------|---------:|-------:|
| Strategy1 | 429 | 0.36 | 152.41 | 0.00762792 | 76.20 | 4:12:00 | 186 | 243 | | Strategy1 | 429 | 0.36 | 152.41 | 0.00762792 | 76.20 | 4:12:00 | 186 | 243 |
| Strategy2 | 1487 | -0.13 | -197.58 | -0.00988917 | -98.79 | 4:43:00 | 662 | 825 | | Strategy2 | 1487 | -0.13 | -197.58 | -0.00988917 | -98.79 | 4:43:00 | 662 | 825 |

View File

@ -441,7 +441,7 @@ class Backtesting:
print() print()
if len(all_results) > 1: if len(all_results) > 1:
# Print Strategy summary table # Print Strategy summary table
print(' Strategy Summary '.center(133, '=')) print(' STRATEGY SUMMARY '.center(133, '='))
print(generate_text_table_strategy(self.config['stake_currency'], print(generate_text_table_strategy(self.config['stake_currency'],
self.config['max_open_trades'], self.config['max_open_trades'],
all_results=all_results)) all_results=all_results))

View File

@ -121,9 +121,9 @@ def generate_text_table_strategy(stake_currency: str, max_open_trades: str,
floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f') floatfmt = ('s', 'd', '.2f', '.2f', '.8f', '.2f', 'd', '.1f', '.1f')
tabular_data = [] tabular_data = []
headers = ['Strategy', 'buy count', 'avg profit %', 'cum profit %', headers = ['Strategy', 'Buy Count', 'Avg Profit %', 'Cum Profit %',
f'tot profit {stake_currency}', 'tot profit %', 'avg duration', f'Tot Profit {stake_currency}', 'Tot Profit %', 'Avg Duration',
'profit', 'loss'] 'Wins', 'Losses']
for strategy, results in all_results.items(): for strategy, results in all_results.items():
tabular_data.append([ tabular_data.append([
strategy, strategy,

View File

@ -91,14 +91,14 @@ def test_generate_text_table_strategy(default_conf, mocker):
) )
result_str = ( result_str = (
'| Strategy | buy count | avg profit % | cum profit % ' '| Strategy | Buy Count | Avg Profit % | Cum Profit % | Tot Profit BTC '
'| tot profit BTC | tot profit % | avg duration | profit | loss |\n' '| Tot Profit % | Avg Duration | Wins | Losses |\n'
'|:-----------|------------:|---------------:|---------------:' '|:-----------|------------:|---------------:|---------------:|-----------------:'
'|-----------------:|---------------:|:---------------|---------:|-------:|\n' '|---------------:|:---------------|-------:|---------:|\n'
'| ETH/BTC | 3 | 20.00 | 60.00 ' '| ETH/BTC | 3 | 20.00 | 60.00 '
'| 1.10000000 | 30.00 | 0:17:00 | 3 | 0 |\n' '| 1.10000000 | 30.00 | 0:17:00 | 3 | 0 |\n'
'| LTC/BTC | 3 | 30.00 | 90.00 ' '| LTC/BTC | 3 | 30.00 | 90.00 '
'| 1.30000000 | 45.00 | 0:20:00 | 3 | 0 |' '| 1.30000000 | 45.00 | 0:20:00 | 3 | 0 |'
) )
assert generate_text_table_strategy('BTC', 2, all_results=results) == result_str assert generate_text_table_strategy('BTC', 2, all_results=results) == result_str