mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-14 11:51:19 +00:00
Add --enable-dynamic-pairlist option in backtesting
This commit is contained in:
@@ -49,6 +49,7 @@ ARGS_BACKTEST = [
|
||||
*ARGS_COMMON_OPTIMIZE,
|
||||
"position_stacking",
|
||||
"enable_protections",
|
||||
"enable_dynamic_pairlist",
|
||||
"dry_run_wallet",
|
||||
"timeframe_detail",
|
||||
"strategy_list",
|
||||
|
||||
@@ -184,12 +184,20 @@ AVAILABLE_CLI_OPTIONS = {
|
||||
"enable_protections": Arg(
|
||||
"--enable-protections",
|
||||
"--enableprotections",
|
||||
help="Enable protections for backtesting."
|
||||
help="Enable protections for backtesting. "
|
||||
"Will slow backtesting down by a considerable amount, but will include "
|
||||
"configured protections",
|
||||
action="store_true",
|
||||
default=False,
|
||||
),
|
||||
"enable_dynamic_pairlist": Arg(
|
||||
"--enable-dynamic-pairlist",
|
||||
help="Enables dynamic pairlisting in backtesting. "
|
||||
"The pairlist will be generated for each new candle if you're using a "
|
||||
"pairlist handler that supports this feature, for example, ShuffleFilter.",
|
||||
action="store_true",
|
||||
default=False,
|
||||
),
|
||||
"strategy_list": Arg(
|
||||
"--strategy-list",
|
||||
help="Provide a space-separated list of strategies to backtest. "
|
||||
|
||||
@@ -256,7 +256,13 @@ class Configuration:
|
||||
self._args_to_config(
|
||||
config,
|
||||
argname="enable_protections",
|
||||
logstring="Parameter --enable-protections detected, enabling Protections. ...",
|
||||
logstring="Parameter --enable-protections detected, enabling Protections ...",
|
||||
)
|
||||
|
||||
self._args_to_config(
|
||||
config,
|
||||
argname="enable_dynamic_pairlist",
|
||||
logstring="Parameter --enable-dynamic-pairlist detected, enabling dynamic pairlist ...",
|
||||
)
|
||||
|
||||
if self.args.get("max_open_trades"):
|
||||
|
||||
@@ -173,7 +173,6 @@ class Backtesting:
|
||||
self.disable_database_use()
|
||||
self.init_backtest_detail()
|
||||
self.pairlists = PairListManager(self.exchange, self.config, self.dataprovider)
|
||||
self.dynamic_pairlist = False
|
||||
self._validate_pairlists_for_backtesting()
|
||||
|
||||
self.dataprovider.add_pairlisthandler(self.pairlists)
|
||||
@@ -212,6 +211,7 @@ class Backtesting:
|
||||
self._can_short = self.trading_mode != TradingMode.SPOT
|
||||
self._position_stacking: bool = self.config.get("position_stacking", False)
|
||||
self.enable_protections: bool = self.config.get("enable_protections", False)
|
||||
self.dynamic_pairlist: bool = self.config.get("enable_dynamic_pairlist", False)
|
||||
migrate_data(config, self.exchange)
|
||||
|
||||
self.init_backtest()
|
||||
@@ -227,9 +227,6 @@ class Backtesting:
|
||||
"PrecisionFilter not allowed for backtesting multiple strategies."
|
||||
)
|
||||
|
||||
if "ShuffleFilter" in self.pairlists.name_list:
|
||||
self.dynamic_pairlist = True
|
||||
|
||||
def log_once(self, msg: str) -> None:
|
||||
"""
|
||||
Partial reimplementation of log_once from the Login mixin.
|
||||
|
||||
Reference in New Issue
Block a user