Add option to show sorted pairlist
Allows easy copy/pasting of the pairlist to a configuration
This commit is contained in:
@@ -41,7 +41,7 @@ ARGS_LIST_STRATEGIES = ["strategy_path", "print_one_column", "print_colorized"]
|
||||
|
||||
ARGS_LIST_HYPEROPTS = ["hyperopt_path", "print_one_column", "print_colorized"]
|
||||
|
||||
ARGS_BACKTEST_FILTER = []
|
||||
ARGS_BACKTEST_FILTER = ["exportfilename", "backtest_show_pair_list"]
|
||||
|
||||
ARGS_LIST_EXCHANGES = ["print_one_column", "list_exchanges_all"]
|
||||
|
||||
@@ -175,16 +175,15 @@ class Arguments:
|
||||
self.parser = argparse.ArgumentParser(description='Free, open source crypto trading bot')
|
||||
self._build_args(optionlist=['version'], parser=self.parser)
|
||||
|
||||
from freqtrade.commands import (
|
||||
start_backtesting, start_backtest_filter, start_convert_data, start_convert_trades,
|
||||
start_create_userdir, start_download_data, start_edge,
|
||||
start_hyperopt, start_hyperopt_list, start_hyperopt_show,
|
||||
start_install_ui, start_list_data, start_list_exchanges,
|
||||
start_list_markets, start_list_strategies,
|
||||
start_list_timeframes, start_new_config, start_new_strategy,
|
||||
start_plot_dataframe, start_plot_profit, start_show_trades,
|
||||
start_test_pairlist, start_trading, start_webserver
|
||||
)
|
||||
from freqtrade.commands import (start_backtest_filter, start_backtesting,
|
||||
start_convert_data, start_convert_trades,
|
||||
start_create_userdir, start_download_data, start_edge,
|
||||
start_hyperopt, start_hyperopt_list, start_hyperopt_show,
|
||||
start_install_ui, start_list_data, start_list_exchanges,
|
||||
start_list_markets, start_list_strategies,
|
||||
start_list_timeframes, start_new_config, start_new_strategy,
|
||||
start_plot_dataframe, start_plot_profit, start_show_trades,
|
||||
start_test_pairlist, start_trading, start_webserver)
|
||||
|
||||
subparsers = self.parser.add_subparsers(dest='command',
|
||||
# Use custom message when no subhandler is added
|
||||
|
@@ -152,6 +152,12 @@ AVAILABLE_CLI_OPTIONS = {
|
||||
action='store_false',
|
||||
default=True,
|
||||
),
|
||||
"backtest_show_pair_list": Arg(
|
||||
'--show-pair-list',
|
||||
help='Show backtesting pairlist sorted by profit.',
|
||||
action='store_true',
|
||||
default=False,
|
||||
),
|
||||
"enable_protections": Arg(
|
||||
'--enable-protections', '--enableprotections',
|
||||
help='Enable protections for backtesting.'
|
||||
|
@@ -1,15 +1,13 @@
|
||||
from freqtrade.data.btanalysis import get_latest_backtest_filename
|
||||
import pandas
|
||||
from pandas.io import json
|
||||
from freqtrade.optimize import backtesting
|
||||
import logging
|
||||
from typing import Any, Dict
|
||||
|
||||
from freqtrade import constants
|
||||
from freqtrade.configuration import setup_utils_configuration
|
||||
from freqtrade.data.btanalysis import load_backtest_stats
|
||||
from freqtrade.enums import RunMode
|
||||
from freqtrade.exceptions import OperationalException
|
||||
from freqtrade.misc import round_coin_value
|
||||
from freqtrade.optimize.optimize_reports import show_backtest_results, show_filtered_pairlist
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -57,27 +55,19 @@ def start_backtesting(args: Dict[str, Any]) -> None:
|
||||
backtesting = Backtesting(config)
|
||||
backtesting.start()
|
||||
|
||||
|
||||
def start_backtest_filter(args: Dict[str, Any]) -> None:
|
||||
"""
|
||||
List backtest pairs previously filtered
|
||||
Show previous backtest result
|
||||
"""
|
||||
|
||||
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
|
||||
|
||||
no_header = config.get('backtest_show_pair_list', False)
|
||||
results_file = get_latest_backtest_filename(
|
||||
config['user_data_dir'] / 'backtest_results/')
|
||||
|
||||
logger.info("Using Backtesting result {results_file}")
|
||||
|
||||
# load data using Python JSON module
|
||||
with open(config['user_data_dir'] / 'backtest_results/' / results_file,'r') as f:
|
||||
data = json.loads(f.read())
|
||||
strategy = list(data["strategy"])[0]
|
||||
trades = data["strategy"][strategy]
|
||||
|
||||
print(trades)
|
||||
results = load_backtest_stats(config['exportfilename'])
|
||||
|
||||
# print(results)
|
||||
show_backtest_results(config, results)
|
||||
show_filtered_pairlist(config, results)
|
||||
|
||||
logger.info("Backtest filtering complete. ")
|
||||
|
||||
|
Reference in New Issue
Block a user