diff --git a/tests/optimize/test_optimize_reports.py b/tests/optimize/test_optimize_reports.py index 4ff8a981d..2ea6a33a4 100644 --- a/tests/optimize/test_optimize_reports.py +++ b/tests/optimize/test_optimize_reports.py @@ -24,7 +24,7 @@ from freqtrade.optimize.optimize_reports import (generate_backtest_stats, genera store_backtest_stats, text_table_bt_results, text_table_exit_reason, text_table_strategy) from freqtrade.optimize.optimize_reports.optimize_reports import (_get_resample_from_period, - calc_consecutive) + calc_streak) from freqtrade.resolvers.strategy_resolver import StrategyResolver from freqtrade.util import dt_ts from freqtrade.util.datetime_helpers import dt_from_ts, dt_utc @@ -349,27 +349,30 @@ def test_generate_trading_stats(testdatadir): assert res['losses'] == 0 -def test_calculate_consecutive(testdatadir): +def test_calc_streak(testdatadir): df = pd.DataFrame({ 'profit_ratio': [0.05, -0.02, -0.03, -0.05, 0.01, 0.02, 0.03, 0.04, -0.02, -0.03], }) # 4 consecutive wins, 3 consecutive losses - assert calc_consecutive(df) == (4, 3) + res = calc_streak(df) + assert res == (4, 3) + assert isinstance(res[0], int) + assert isinstance(res[1], int) # invert situation df1 = df.copy() df1['profit_ratio'] = df1['profit_ratio'] * -1 - assert calc_consecutive(df1) == (3, 4) + assert calc_streak(df1) == (3, 4) df_empty = pd.DataFrame({ 'profit_ratio': [], }) assert df_empty.empty - assert calc_consecutive(df_empty) == (0, 0) + assert calc_streak(df_empty) == (0, 0) filename = testdatadir / "backtest_results/backtest-result.json" bt_data = load_backtest_data(filename) - assert calc_consecutive(bt_data) == (7, 18) + assert calc_streak(bt_data) == (7, 18) def test_text_table_exit_reason():