From 499c6772d170f30fb16a5410fd32f3c63c3dcfbd Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 7 Jun 2020 11:31:33 +0200 Subject: [PATCH] Rename tabulate methods they don't "generate" anything --- freqtrade/optimize/optimize_reports.py | 12 +++++------- tests/optimize/test_backtesting.py | 2 +- tests/optimize/test_optimize_reports.py | 14 +++++++------- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/freqtrade/optimize/optimize_reports.py b/freqtrade/optimize/optimize_reports.py index d70a80bb3..789ad7d46 100644 --- a/freqtrade/optimize/optimize_reports.py +++ b/freqtrade/optimize/optimize_reports.py @@ -245,8 +245,7 @@ def generate_text_table(pair_results: List[Dict[str, Any]], stake_currency: str) floatfmt=floatfmt, tablefmt="orgtbl", stralign="right") -def generate_text_table_sell_reason(sell_reason_stats: List[Dict[str, Any]], - stake_currency: str) -> str: +def text_table_sell_reason(sell_reason_stats: List[Dict[str, Any]], stake_currency: str) -> str: """ Generate small table outlining Backtest results :param sell_reason_stats: Sell reason metrics @@ -272,7 +271,7 @@ def generate_text_table_sell_reason(sell_reason_stats: List[Dict[str, Any]], return tabulate(output, headers=headers, tablefmt="orgtbl", stralign="right") -def generate_text_table_strategy(strategy_results, stake_currency: str) -> str: +def text_table_strategy(strategy_results, stake_currency: str) -> str: """ Generate summary table per strategy :param stake_currency: stake-currency - used to correctly name headers @@ -304,9 +303,8 @@ def show_backtest_results(config: Dict, backtest_stats: Dict): print(' BACKTESTING REPORT '.center(len(table.splitlines()[0]), '=')) print(table) - table = generate_text_table_sell_reason(sell_reason_stats=results['sell_reason_summary'], - stake_currency=stake_currency, - ) + table = text_table_sell_reason(sell_reason_stats=results['sell_reason_summary'], + stake_currency=stake_currency) if isinstance(table, str): print(' SELL REASON STATS '.center(len(table.splitlines()[0]), '=')) print(table) @@ -322,7 +320,7 @@ def show_backtest_results(config: Dict, backtest_stats: Dict): if len(backtest_stats['strategy']) > 1: # Print Strategy summary table - table = generate_text_table_strategy(backtest_stats['strategy_comparison'], stake_currency) + table = text_table_strategy(backtest_stats['strategy_comparison'], stake_currency) print(' STRATEGY SUMMARY '.center(len(table.splitlines()[0]), '=')) print(table) print('=' * len(table.splitlines()[0])) diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index 40c106975..04c8a4b0e 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -666,7 +666,7 @@ def test_backtest_start_multi_strat(default_conf, mocker, caplog, testdatadir): mocker.patch.multiple('freqtrade.optimize.optimize_reports', generate_text_table=gen_table_mock, - generate_text_table_strategy=gen_strattable_mock, + text_table_strategy=gen_strattable_mock, generate_pair_metrics=MagicMock(), generate_sell_reason_stats=sell_reason_mock, generate_strategy_metrics=gen_strat_summary, diff --git a/tests/optimize/test_optimize_reports.py b/tests/optimize/test_optimize_reports.py index 8bef6e2cc..b4105af7d 100644 --- a/tests/optimize/test_optimize_reports.py +++ b/tests/optimize/test_optimize_reports.py @@ -7,8 +7,8 @@ from arrow import Arrow from freqtrade.edge import PairInfo from freqtrade.optimize.optimize_reports import ( generate_pair_metrics, generate_edge_table, generate_sell_reason_stats, - generate_text_table, generate_text_table_sell_reason, generate_strategy_metrics, - generate_text_table_strategy, store_backtest_result) + generate_text_table, text_table_sell_reason, generate_strategy_metrics, + text_table_strategy, store_backtest_result) from freqtrade.strategy.interface import SellType from tests.conftest import patch_exchange @@ -69,7 +69,7 @@ def test_generate_pair_metrics(default_conf, mocker): pytest.approx(pair_results[-1]['profit_sum_pct']) == pair_results[-1]['profit_sum'] * 100) -def test_generate_text_table_sell_reason(default_conf): +def test_text_table_sell_reason(default_conf): results = pd.DataFrame( { @@ -97,8 +97,8 @@ def test_generate_text_table_sell_reason(default_conf): sell_reason_stats = generate_sell_reason_stats(max_open_trades=2, results=results) - assert generate_text_table_sell_reason(sell_reason_stats=sell_reason_stats, - stake_currency='BTC') == result_str + assert text_table_sell_reason(sell_reason_stats=sell_reason_stats, + stake_currency='BTC') == result_str def test_generate_sell_reason_stats(default_conf): @@ -136,7 +136,7 @@ def test_generate_sell_reason_stats(default_conf): assert stop_result['profit_mean_pct'] == round(stop_result['profit_mean'] * 100, 2) -def test_generate_text_table_strategy(default_conf, mocker): +def test_text_table_strategy(default_conf, mocker): results = {} results['TestStrategy1'] = pd.DataFrame( { @@ -178,7 +178,7 @@ def test_generate_text_table_strategy(default_conf, mocker): max_open_trades=2, all_results=results) - assert generate_text_table_strategy(strategy_results, 'BTC') == result_str + assert text_table_strategy(strategy_results, 'BTC') == result_str def test_generate_edge_table(edge_conf, mocker):