Move generate_wins_draw_losses to bt_output (it's an output function, not a calculation)

This commit is contained in:
Matthias
2023-07-23 19:57:47 +02:00
parent a00fcd68f8
commit 6ddbc8c00d
3 changed files with 13 additions and 14 deletions

View File

@@ -5,8 +5,7 @@ from tabulate import tabulate
from freqtrade.constants import UNLIMITED_STAKE_AMOUNT, Config
from freqtrade.misc import decimals_per_coin, round_coin_value
from freqtrade.optimize.optimize_reports.optimize_reports import (generate_periodic_breakdown_stats,
generate_wins_draws_losses)
from freqtrade.optimize.optimize_reports.optimize_reports import generate_periodic_breakdown_stats
logger = logging.getLogger(__name__)
@@ -30,6 +29,16 @@ def _get_line_header(first_column: str, stake_currency: str,
'Win Draw Loss Win%']
def generate_wins_draws_losses(wins, draws, losses):
if wins > 0 and losses == 0:
wl_ratio = '100'
elif wins == 0:
wl_ratio = '0'
else:
wl_ratio = f'{100.0 / (wins + draws + losses) * wins:.1f}' if losses > 0 else '100'
return f'{wins:>4} {draws:>4} {losses:>4} {wl_ratio:>4}'
def text_table_bt_results(pair_results: List[Dict[str, Any]], stake_currency: str) -> str:
"""
Generates and returns a text table for the given backtest data and the results dataframe