Add test for backtest_show logic
This commit is contained in:
parent
650d6c276a
commit
72ecb45d86
@ -740,7 +740,7 @@ def show_backtest_results(config: Dict, backtest_stats: Dict):
|
|||||||
def show_filtered_pairlist(config: Dict, backtest_stats: Dict):
|
def show_filtered_pairlist(config: Dict, backtest_stats: Dict):
|
||||||
if config.get('backtest_show_pair_list', False):
|
if config.get('backtest_show_pair_list', False):
|
||||||
for strategy, results in backtest_stats['strategy'].items():
|
for strategy, results in backtest_stats['strategy'].items():
|
||||||
print("Pairs for Strategy: \n[")
|
print(f"Pairs for Strategy {strategy}: \n[")
|
||||||
for result in results['results_per_pair']:
|
for result in results['results_per_pair']:
|
||||||
if result["key"] != 'TOTAL':
|
if result["key"] != 'TOTAL':
|
||||||
print(f'"{result["key"]}", // {round(result["profit_mean_pct"], 2)}%')
|
print(f'"{result["key"]}", // {round(result["profit_mean_pct"], 2)}%')
|
||||||
|
@ -10,7 +10,7 @@ from arrow import Arrow
|
|||||||
from freqtrade.configuration import TimeRange
|
from freqtrade.configuration import TimeRange
|
||||||
from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN
|
from freqtrade.constants import DATETIME_PRINT_FORMAT, LAST_BT_RESULT_FN
|
||||||
from freqtrade.data import history
|
from freqtrade.data import history
|
||||||
from freqtrade.data.btanalysis import get_latest_backtest_filename, load_backtest_data
|
from freqtrade.data.btanalysis import get_latest_backtest_filename, load_backtest_data, load_backtest_stats
|
||||||
from freqtrade.edge import PairInfo
|
from freqtrade.edge import PairInfo
|
||||||
from freqtrade.enums import SellType
|
from freqtrade.enums import SellType
|
||||||
from freqtrade.optimize.optimize_reports import (_get_resample_from_period, generate_backtest_stats,
|
from freqtrade.optimize.optimize_reports import (_get_resample_from_period, generate_backtest_stats,
|
||||||
@ -19,7 +19,7 @@ from freqtrade.optimize.optimize_reports import (_get_resample_from_period, gene
|
|||||||
generate_periodic_breakdown_stats,
|
generate_periodic_breakdown_stats,
|
||||||
generate_sell_reason_stats,
|
generate_sell_reason_stats,
|
||||||
generate_strategy_comparison,
|
generate_strategy_comparison,
|
||||||
generate_trading_stats, store_backtest_stats,
|
generate_trading_stats, show_filtered_pairlist, store_backtest_stats,
|
||||||
text_table_bt_results, text_table_sell_reason,
|
text_table_bt_results, text_table_sell_reason,
|
||||||
text_table_strategy)
|
text_table_strategy)
|
||||||
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
from freqtrade.resolvers.strategy_resolver import StrategyResolver
|
||||||
@ -407,3 +407,16 @@ def test__get_resample_from_period():
|
|||||||
assert _get_resample_from_period('month') == '1M'
|
assert _get_resample_from_period('month') == '1M'
|
||||||
with pytest.raises(ValueError, match=r"Period noooo is not supported."):
|
with pytest.raises(ValueError, match=r"Period noooo is not supported."):
|
||||||
_get_resample_from_period('noooo')
|
_get_resample_from_period('noooo')
|
||||||
|
|
||||||
|
|
||||||
|
def test_show_filtered_pairlist(testdatadir, default_conf, capsys):
|
||||||
|
filename = testdatadir / "backtest-result_new.json"
|
||||||
|
bt_data = load_backtest_stats(filename)
|
||||||
|
default_conf['backtest_show_pair_list'] = True
|
||||||
|
|
||||||
|
show_filtered_pairlist(default_conf, bt_data)
|
||||||
|
|
||||||
|
out, err = capsys.readouterr()
|
||||||
|
assert 'Pairs for Strategy StrategyTestV2: \n[' in out
|
||||||
|
assert 'TOTAL' not in out
|
||||||
|
assert '"ETH/BTC", // ' in out
|
||||||
|
Loading…
Reference in New Issue
Block a user