mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
Add --enable-dynamic-pairlist option in backtesting
This commit is contained in:
@@ -10,6 +10,7 @@ usage: freqtrade backtesting [-h] [-v] [--no-color] [--logfile FILE] [-V]
|
|||||||
[--stake-amount STAKE_AMOUNT] [--fee FLOAT]
|
[--stake-amount STAKE_AMOUNT] [--fee FLOAT]
|
||||||
[-p PAIRS [PAIRS ...]] [--eps]
|
[-p PAIRS [PAIRS ...]] [--eps]
|
||||||
[--enable-protections]
|
[--enable-protections]
|
||||||
|
[--enable-dynamic-pairlist]
|
||||||
[--dry-run-wallet DRY_RUN_WALLET]
|
[--dry-run-wallet DRY_RUN_WALLET]
|
||||||
[--timeframe-detail TIMEFRAME_DETAIL]
|
[--timeframe-detail TIMEFRAME_DETAIL]
|
||||||
[--strategy-list STRATEGY_LIST [STRATEGY_LIST ...]]
|
[--strategy-list STRATEGY_LIST [STRATEGY_LIST ...]]
|
||||||
@@ -44,9 +45,14 @@ options:
|
|||||||
Allow buying the same pair multiple times (position
|
Allow buying the same pair multiple times (position
|
||||||
stacking).
|
stacking).
|
||||||
--enable-protections, --enableprotections
|
--enable-protections, --enableprotections
|
||||||
Enable protections for backtesting.Will slow
|
Enable protections for backtesting. Will slow
|
||||||
backtesting down by a considerable amount, but will
|
backtesting down by a considerable amount, but will
|
||||||
include configured protections
|
include configured protections
|
||||||
|
--enable-dynamic-pairlist
|
||||||
|
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.
|
||||||
--dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET
|
--dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET
|
||||||
Starting balance, used for backtesting / hyperopt and
|
Starting balance, used for backtesting / hyperopt and
|
||||||
dry-runs.
|
dry-runs.
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ options:
|
|||||||
Allow buying the same pair multiple times (position
|
Allow buying the same pair multiple times (position
|
||||||
stacking).
|
stacking).
|
||||||
--enable-protections, --enableprotections
|
--enable-protections, --enableprotections
|
||||||
Enable protections for backtesting.Will slow
|
Enable protections for backtesting. Will slow
|
||||||
backtesting down by a considerable amount, but will
|
backtesting down by a considerable amount, but will
|
||||||
include configured protections
|
include configured protections
|
||||||
--dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET
|
--dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ usage: freqtrade lookahead-analysis [-h] [-v] [--no-color] [--logfile FILE]
|
|||||||
[--stake-amount STAKE_AMOUNT]
|
[--stake-amount STAKE_AMOUNT]
|
||||||
[--fee FLOAT] [-p PAIRS [PAIRS ...]]
|
[--fee FLOAT] [-p PAIRS [PAIRS ...]]
|
||||||
[--enable-protections]
|
[--enable-protections]
|
||||||
|
[--enable-dynamic-pairlist]
|
||||||
[--dry-run-wallet DRY_RUN_WALLET]
|
[--dry-run-wallet DRY_RUN_WALLET]
|
||||||
[--timeframe-detail TIMEFRAME_DETAIL]
|
[--timeframe-detail TIMEFRAME_DETAIL]
|
||||||
[--strategy-list STRATEGY_LIST [STRATEGY_LIST ...]]
|
[--strategy-list STRATEGY_LIST [STRATEGY_LIST ...]]
|
||||||
@@ -43,9 +44,14 @@ options:
|
|||||||
Limit command to these pairs. Pairs are space-
|
Limit command to these pairs. Pairs are space-
|
||||||
separated.
|
separated.
|
||||||
--enable-protections, --enableprotections
|
--enable-protections, --enableprotections
|
||||||
Enable protections for backtesting.Will slow
|
Enable protections for backtesting. Will slow
|
||||||
backtesting down by a considerable amount, but will
|
backtesting down by a considerable amount, but will
|
||||||
include configured protections
|
include configured protections
|
||||||
|
--enable-dynamic-pairlist
|
||||||
|
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.
|
||||||
--dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET
|
--dry-run-wallet DRY_RUN_WALLET, --starting-balance DRY_RUN_WALLET
|
||||||
Starting balance, used for backtesting / hyperopt and
|
Starting balance, used for backtesting / hyperopt and
|
||||||
dry-runs.
|
dry-runs.
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ ARGS_BACKTEST = [
|
|||||||
*ARGS_COMMON_OPTIMIZE,
|
*ARGS_COMMON_OPTIMIZE,
|
||||||
"position_stacking",
|
"position_stacking",
|
||||||
"enable_protections",
|
"enable_protections",
|
||||||
|
"enable_dynamic_pairlist",
|
||||||
"dry_run_wallet",
|
"dry_run_wallet",
|
||||||
"timeframe_detail",
|
"timeframe_detail",
|
||||||
"strategy_list",
|
"strategy_list",
|
||||||
|
|||||||
@@ -184,12 +184,20 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
"enable_protections": Arg(
|
"enable_protections": Arg(
|
||||||
"--enable-protections",
|
"--enable-protections",
|
||||||
"--enableprotections",
|
"--enableprotections",
|
||||||
help="Enable protections for backtesting."
|
help="Enable protections for backtesting. "
|
||||||
"Will slow backtesting down by a considerable amount, but will include "
|
"Will slow backtesting down by a considerable amount, but will include "
|
||||||
"configured protections",
|
"configured protections",
|
||||||
action="store_true",
|
action="store_true",
|
||||||
default=False,
|
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": Arg(
|
||||||
"--strategy-list",
|
"--strategy-list",
|
||||||
help="Provide a space-separated list of strategies to backtest. "
|
help="Provide a space-separated list of strategies to backtest. "
|
||||||
|
|||||||
@@ -256,7 +256,13 @@ class Configuration:
|
|||||||
self._args_to_config(
|
self._args_to_config(
|
||||||
config,
|
config,
|
||||||
argname="enable_protections",
|
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"):
|
if self.args.get("max_open_trades"):
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ class Backtesting:
|
|||||||
self.disable_database_use()
|
self.disable_database_use()
|
||||||
self.init_backtest_detail()
|
self.init_backtest_detail()
|
||||||
self.pairlists = PairListManager(self.exchange, self.config, self.dataprovider)
|
self.pairlists = PairListManager(self.exchange, self.config, self.dataprovider)
|
||||||
self.dynamic_pairlist = False
|
|
||||||
self._validate_pairlists_for_backtesting()
|
self._validate_pairlists_for_backtesting()
|
||||||
|
|
||||||
self.dataprovider.add_pairlisthandler(self.pairlists)
|
self.dataprovider.add_pairlisthandler(self.pairlists)
|
||||||
@@ -212,6 +211,7 @@ class Backtesting:
|
|||||||
self._can_short = self.trading_mode != TradingMode.SPOT
|
self._can_short = self.trading_mode != TradingMode.SPOT
|
||||||
self._position_stacking: bool = self.config.get("position_stacking", False)
|
self._position_stacking: bool = self.config.get("position_stacking", False)
|
||||||
self.enable_protections: bool = self.config.get("enable_protections", 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)
|
migrate_data(config, self.exchange)
|
||||||
|
|
||||||
self.init_backtest()
|
self.init_backtest()
|
||||||
@@ -227,9 +227,6 @@ class Backtesting:
|
|||||||
"PrecisionFilter not allowed for backtesting multiple strategies."
|
"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:
|
def log_once(self, msg: str) -> None:
|
||||||
"""
|
"""
|
||||||
Partial reimplementation of log_once from the Login mixin.
|
Partial reimplementation of log_once from the Login mixin.
|
||||||
|
|||||||
Reference in New Issue
Block a user