Merge pull request #12229 from freqtrade/lookahead_analysis_12168

Lookahead analysis - fix false positives
This commit is contained in:
Matthias
2025-09-10 19:46:29 +02:00
committed by GitHub
6 changed files with 43 additions and 3 deletions

View File

@@ -260,7 +260,12 @@ ARGS_LOOKAHEAD_ANALYSIS = [
a
for a in ARGS_BACKTEST
if a not in ("position_stacking", "backtest_cache", "backtest_breakdown", "backtest_notes")
] + ["minimum_trade_amount", "targeted_trade_amount", "lookahead_analysis_exportfilename"]
] + [
"minimum_trade_amount",
"targeted_trade_amount",
"lookahead_analysis_exportfilename",
"lookahead_allow_limit_orders",
]
ARGS_RECURSIVE_ANALYSIS = ["timeframe", "timerange", "dataformat_ohlcv", "pairs", "startup_candle"]

View File

@@ -806,6 +806,14 @@ AVAILABLE_CLI_OPTIONS = {
help="Specify startup candles to be checked (`199`, `499`, `999`, `1999`).",
nargs="+",
),
"lookahead_allow_limit_orders": Arg(
"--allow-limit-orders",
help=(
"Allow limit orders in lookahead analysis (could cause false positives "
"in lookahead analysis results)."
),
action="store_true",
),
"show_sensitive": Arg(
"--show-sensitive",
help="Show secrets in the output.",

View File

@@ -147,6 +147,17 @@ class LookaheadAnalysisSubFunctions:
"Protections were enabled. "
"Disabling protections now since they can produce false positives."
)
if not config.get("lookahead_allow_limit_orders", False):
logger.info("Forced order_types to market orders.")
config["order_types"] = {
"entry": "market",
"exit": "market",
"stoploss": "market",
"stoploss_on_exchange": False,
}
else:
logger.info("Using configured order_types, skipping order_types override.")
if config["targeted_trade_amount"] < config["minimum_trade_amount"]:
# this combo doesn't make any sense.
raise OperationalException(