From 090554f19784b4387837e1b6103acd2aebfff182 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 30 Jan 2022 15:41:05 +0100 Subject: [PATCH] Try fill backtest order imediately for adjusted order --- freqtrade/optimize/backtesting.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index 31cb20ee7..ff139c674 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -566,8 +566,6 @@ class Backtesting: exchange='backtesting', orders=[] ) - else: - trade.open_order_id = self.order_id_counter trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True) @@ -592,6 +590,12 @@ class Backtesting: remaining=amount, cost=stake_amount + trade.fee_open, ) + if pos_adjust and self._get_order_filled(order.price, row): + order.filled = order.amount + order.status = 'closed' + order.ft_is_open = False + else: + trade.open_order_id = self.order_id_counter trade.orders.append(order) trade.recalc_trade_from_orders()