Skip to content

Commit a2c3729

Browse files
committed
feat: Override order types for lookahead analysis
this avoids false positives - but could cause false-negatives if the problem is in a pricing callback. `--allow-limit-orders` can re-allow limit orders to test for this scenario. part of freqtrade#12168
1 parent 14c9f78 commit a2c3729

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

freqtrade/commands/arguments.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,12 @@
260260
a
261261
for a in ARGS_BACKTEST
262262
if a not in ("position_stacking", "backtest_cache", "backtest_breakdown", "backtest_notes")
263-
] + ["minimum_trade_amount", "targeted_trade_amount", "lookahead_analysis_exportfilename"]
263+
] + [
264+
"minimum_trade_amount",
265+
"targeted_trade_amount",
266+
"lookahead_analysis_exportfilename",
267+
"lookahead_allow_limit_orders",
268+
]
264269

265270
ARGS_RECURSIVE_ANALYSIS = ["timeframe", "timerange", "dataformat_ohlcv", "pairs", "startup_candle"]
266271

freqtrade/commands/cli_options.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,14 @@ def __init__(self, *args, **kwargs):
806806
help="Specify startup candles to be checked (`199`, `499`, `999`, `1999`).",
807807
nargs="+",
808808
),
809+
"lookahead_allow_limit_orders": Arg(
810+
"--allow-limit-orders",
811+
help=(
812+
"Allow limit orders in lookahead analysis (could cause false positives "
813+
"in lookahead analysis results)."
814+
),
815+
action="store_true",
816+
),
809817
"show_sensitive": Arg(
810818
"--show-sensitive",
811819
help="Show secrets in the output.",

freqtrade/optimize/analysis/lookahead_helpers.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,17 @@ def calculate_config_overrides(config: Config):
147147
"Protections were enabled. "
148148
"Disabling protections now since they can produce false positives."
149149
)
150+
if not config.get("lookahead_allow_limit_orders", False):
151+
logger.info("Forced order_types to market orders.")
152+
config["order_types"] = {
153+
"entry": "market",
154+
"exit": "market",
155+
"stoploss": "market",
156+
"stoploss_on_exchange": False,
157+
}
158+
else:
159+
logger.info("Using configured order_types, skipping order_types override.")
160+
150161
if config["targeted_trade_amount"] < config["minimum_trade_amount"]:
151162
# this combo doesn't make any sense.
152163
raise OperationalException(

0 commit comments

Comments
 (0)