Repository: freqtrade/freqtrade

Issue:
adjust_trade_position does not exit Trade
## Describe your environment

  * Operating system: Ubuntu
  * Python Version: Python 3.9.16 (`python -V`)
  * CCXT version: ccxt==4.3.11 (`pip freeze | grep ccxt`)
  * Freqtrade Version: freqtrade 2024.5-dev-e2a9bc9c6 (`freqtrade -V` or `docker compose run --rm freqtrade -V` for Freqtrade running in docker)

## Describe the problem:

When returning -trade.stake_amount in adjust_trade_position the trade does not exit.

### Steps to reproduce:
Use any Strategy, add return -trade.stake_amount in adjust_trade_position and confirm that only one trade is being made. E.g for Strategy001: 

```python


# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
from typing import Optional, Tuple, Union
from freqtrade.data.btanalysis import Trade
from datetime import datetime
# --------------------------------

import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


class Strategy001(IStrategy):
    """
    Strategy 001
    author@: Gerald Lonlas
    github@: https://github.com/freqtrade/freqtrade-strategies

    How to use it?
    > python3 ./freqtrade/main.py -s Strategy001
    """

    INTERFACE_VERSION: int = 3
    # Minimal ROI designed for the strategy.
    # This attribute will be overridden if the config file contains "minimal_roi"
    # minimal_roi = {
    #     "60":  0.01,
    #     "30":  0.03,
    #     "20":  0.04,
    #     "0":  0.05
    # }

    # Optimal stoploss designed for the strategy
    # This attribute will be overridden if the config file contains "stoploss"
    stoploss = -0.99

    # Optimal timeframe for the strategy
    timeframe = '5m'

    # trailing stoploss
    # trailing_stop = False
    # trailing_stop_positive = 0.01
    # trailing_stop_positive_offset = 0.02

    # run "populate_indicators" only for new candle
    process_only_new_candles = True

    # Experimental settings (configuration will overide these if set)
    use_exit_signal = True
    exit_profit_only = True
    ignore_roi_if_entry_signal = False

    # Optional order type mapping
    order_types = {
        'entry': 'limit',
        'exit': 'limit',
        'stoploss': 'market',
        'stoploss_on_exchange': False
    }

    # Add entries
    position_adjustment_enable = True
    max_dca_multiplier = 5

    def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
                            proposed_stake: float, min_stake: Optional[float], max_stake: float,
                            leverage: float, entry_tag: Optional[str], side: str,
                            **kwargs) -> float:
        custom_stake = proposed_stake / self.max_dca_multiplier
        return custom_stake

    def adjust_trade_position(self, trade: Trade, current_time: datetime,
                              current_rate: float, current_profit: float,
                              min_stake: Optional[float], max_stake: float,
                              current_entry_rate: float, current_exit_rate: float,
                              current_entry_profit: float, current_exit_profit: float,
                              **kwargs
                              ) -> Union[Optional[float], Tuple[Optional[float], Optional[str]]]:
        
        dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe)
        last_candle = dataframe.iloc[-1].squeeze()

        if last_candle['ha_open'] > last_candle['ha_close']:
            return -trade.stake_amount

    def informative_pairs(self):
        """
        Define additional, informative pair/interval combinations to be cached from the exchange.
        These pair/interval combinations are non-tradeable, unless they are part
        of the whitelist as well.
        For more information, please consult the documentation
        :return: List of tuples in the format (pair, interval)
            Sample: return [("ETH/USDT", "5m"),
                            ("BTC/USDT", "15m"),
                            ]
        """
        return []

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Adds several different TA indicators to the given DataFrame

        Performance Note: For the best performance be frugal on the number of indicators
        you are using. Let uncomment only the indicator you are using in your strategies
        or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
        """

        dataframe['ema20'] = ta.EMA(dataframe, timeperiod=20)
        dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
        dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)

        heikinashi = qtpylib.heikinashi(dataframe)
        dataframe['ha_open'] = heikinashi['open']
        dataframe['ha_close'] = heikinashi['close']

        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the buy signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        dataframe.loc[
            (
                # qtpylib.crossed_above(dataframe['ema20'], dataframe['ema50']) &
                # (dataframe['ha_close'] > dataframe['ema20']) &
                (dataframe['ha_open'] < dataframe['ha_close'])  # green bar
            ),
            'enter_long'] = 1

        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the sell signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        # dataframe.loc[
        #     (
        #         (dataframe['ha_open'] > dataframe['ha_close'])  # red bar
        #     ),
        #     'exit_long'] = 1
        return dataframe
```
This is not dependent on a specific if clause surrounding the return. Thats why the example above has it very badly placed as this would sell right away IF IT WOULD SELL (it doesn't). 

### Observed Results:

Without trade adjustments it results in more than one trade, with trade adjustment its exactly one trade as it never fully exits. I also debugged it a bit to backtest.py but the remaining value is 0 (in here: https://github.com/freqtrade/freqtrade/blob/e2a9bc9c6491ee22d5d36815e03356f5e5b5cb8e/freqtrade/optimize/backtesting.py#L583C13-L583C22) so I guess it should just exit but does not
adjust_trade_position does not exit Trade
## Describe your environment

  * Operating system: Ubuntu
  * Python Version: Python 3.9.16 (`python -V`)
  * CCXT version: ccxt==4.3.11 (`pip freeze | grep ccxt`)
  * Freqtrade Version: freqtrade 2024.5-dev-e2a9bc9c6 (`freqtrade -V` or `docker compose run --rm freqtrade -V` for Freqtrade running in docker)

## Describe the problem:

When returning -trade.stake_amount in adjust_trade_position the trade does not exit.

### Steps to reproduce:
Use any Strategy, add return -trade.stake_amount in adjust_trade_position and confirm that only one trade is being made. E.g for Strategy001: 

```python


# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
from typing import Optional, Tuple, Union
from freqtrade.data.btanalysis import Trade
from datetime import datetime
# --------------------------------

import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


class Strategy001(IStrategy):
    """
    Strategy 001
    author@: Gerald Lonlas
    github@: https://github.com/freqtrade/freqtrade-strategies

    How to use it?
    > python3 ./freqtrade/main.py -s Strategy001
    """

    INTERFACE_VERSION: int = 3
    # Minimal ROI designed for the strategy.
    # This attribute will be overridden if the config file contains "minimal_roi"
    # minimal_roi = {
    #     "60":  0.01,
    #     "30":  0.03,
    #     "20":  0.04,
    #     "0":  0.05
    # }

    # Optimal stoploss designed for the strategy
    # This attribute will be overridden if the config file contains "stoploss"
    stoploss = -0.99

    # Optimal timeframe for the strategy
    timeframe = '5m'

    # trailing stoploss
    # trailing_stop = False
    # trailing_stop_positive = 0.01
    # trailing_stop_positive_offset = 0.02

    # run "populate_indicators" only for new candle
    process_only_new_candles = True

    # Experimental settings (configuration will overide these if set)
    use_exit_signal = True
    exit_profit_only = True
    ignore_roi_if_entry_signal = False

    # Optional order type mapping
    order_types = {
        'entry': 'limit',
        'exit': 'limit',
        'stoploss': 'market',
        'stoploss_on_exchange': False
    }

    # Add entries
    position_adjustment_enable = True
    max_dca_multiplier = 5

    def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
                            proposed_stake: float, min_stake: Optional[float], max_stake: float,
                            leverage: float, entry_tag: Optional[str], side: str,
                            **kwargs) -> float:
        custom_stake = proposed_stake / self.max_dca_multiplier
        return custom_stake

    def adjust_trade_position(self, trade: Trade, current_time: datetime,
                              current_rate: float, current_profit: float,
                              min_stake: Optional[float], max_stake: float,
                              current_entry_rate: float, current_exit_rate: float,
                              current_entry_profit: float, current_exit_profit: float,
                              **kwargs
                              ) -> Union[Optional[float], Tuple[Optional[float], Optional[str]]]:
        
        dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe)
        last_candle = dataframe.iloc[-1].squeeze()

        if last_candle['ha_open'] > last_candle['ha_close']:
            return -trade.stake_amount

    def informative_pairs(self):
        """
        Define additional, informative pair/interval combinations to be cached from the exchange.
        These pair/interval combinations are non-tradeable, unless they are part
        of the whitelist as well.
        For more information, please consult the documentation
        :return: List of tuples in the format (pair, interval)
            Sample: return [("ETH/USDT", "5m"),
                            ("BTC/USDT", "15m"),
                            ]
        """
        return []

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Adds several different TA indicators to the given DataFrame

        Performance Note: For the best performance be frugal on the number of indicators
        you are using. Let uncomment only the indicator you are using in your strategies
        or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
        """

        dataframe['ema20'] = ta.EMA(dataframe, timeperiod=20)
        dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
        dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)

        heikinashi = qtpylib.heikinashi(dataframe)
        dataframe['ha_open'] = heikinashi['open']
        dataframe['ha_close'] = heikinashi['close']

        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the buy signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        dataframe.loc[
            (
                # qtpylib.crossed_above(dataframe['ema20'], dataframe['ema50']) &
                # (dataframe['ha_close'] > dataframe['ema20']) &
                (dataframe['ha_open'] < dataframe['ha_close'])  # green bar
            ),
            'enter_long'] = 1

        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the sell signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        # dataframe.loc[
        #     (
        #         (dataframe['ha_open'] > dataframe['ha_close'])  # red bar
        #     ),
        #     'exit_long'] = 1
        return dataframe
```
This is not dependent on a specific if clause surrounding the return. Thats why the example above has it very badly placed as this would sell right away IF IT WOULD SELL (it doesn't). 

### Observed Results:

Without trade adjustments it results in more than one trade, with trade adjustment its exactly one trade as it never fully exits. I also debugged it a bit to backtest.py but the remaining value is 0 (in here: https://github.com/freqtrade/freqtrade/blob/e2a9bc9c6491ee22d5d36815e03356f5e5b5cb8e/freqtrade/optimize/backtesting.py#L583C13-L583C22) so I guess it should just exit but does not
adjust_trade_position does not exit Trade
## Describe your environment

  * Operating system: Ubuntu
  * Python Version: Python 3.9.16 (`python -V`)
  * CCXT version: ccxt==4.3.11 (`pip freeze | grep ccxt`)
  * Freqtrade Version: freqtrade 2024.5-dev-e2a9bc9c6 (`freqtrade -V` or `docker compose run --rm freqtrade -V` for Freqtrade running in docker)

## Describe the problem:

When returning -trade.stake_amount in adjust_trade_position the trade does not exit.

### Steps to reproduce:
Use any Strategy, add return -trade.stake_amount in adjust_trade_position and confirm that only one trade is being made. E.g for Strategy001: 

```python


# --- Do not remove these libs ---
from freqtrade.strategy import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
from typing import Optional, Tuple, Union
from freqtrade.data.btanalysis import Trade
from datetime import datetime
# --------------------------------

import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


class Strategy001(IStrategy):
    """
    Strategy 001
    author@: Gerald Lonlas
    github@: https://github.com/freqtrade/freqtrade-strategies

    How to use it?
    > python3 ./freqtrade/main.py -s Strategy001
    """

    INTERFACE_VERSION: int = 3
    # Minimal ROI designed for the strategy.
    # This attribute will be overridden if the config file contains "minimal_roi"
    # minimal_roi = {
    #     "60":  0.01,
    #     "30":  0.03,
    #     "20":  0.04,
    #     "0":  0.05
    # }

    # Optimal stoploss designed for the strategy
    # This attribute will be overridden if the config file contains "stoploss"
    stoploss = -0.99

    # Optimal timeframe for the strategy
    timeframe = '5m'

    # trailing stoploss
    # trailing_stop = False
    # trailing_stop_positive = 0.01
    # trailing_stop_positive_offset = 0.02

    # run "populate_indicators" only for new candle
    process_only_new_candles = True

    # Experimental settings (configuration will overide these if set)
    use_exit_signal = True
    exit_profit_only = True
    ignore_roi_if_entry_signal = False

    # Optional order type mapping
    order_types = {
        'entry': 'limit',
        'exit': 'limit',
        'stoploss': 'market',
        'stoploss_on_exchange': False
    }

    # Add entries
    position_adjustment_enable = True
    max_dca_multiplier = 5

    def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
                            proposed_stake: float, min_stake: Optional[float], max_stake: float,
                            leverage: float, entry_tag: Optional[str], side: str,
                            **kwargs) -> float:
        custom_stake = proposed_stake / self.max_dca_multiplier
        return custom_stake

    def adjust_trade_position(self, trade: Trade, current_time: datetime,
                              current_rate: float, current_profit: float,
                              min_stake: Optional[float], max_stake: float,
                              current_entry_rate: float, current_exit_rate: float,
                              current_entry_profit: float, current_exit_profit: float,
                              **kwargs
                              ) -> Union[Optional[float], Tuple[Optional[float], Optional[str]]]:
        
        dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe)
        last_candle = dataframe.iloc[-1].squeeze()

        if last_candle['ha_open'] > last_candle['ha_close']:
            return -trade.stake_amount

    def informative_pairs(self):
        """
        Define additional, informative pair/interval combinations to be cached from the exchange.
        These pair/interval combinations are non-tradeable, unless they are part
        of the whitelist as well.
        For more information, please consult the documentation
        :return: List of tuples in the format (pair, interval)
            Sample: return [("ETH/USDT", "5m"),
                            ("BTC/USDT", "15m"),
                            ]
        """
        return []

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Adds several different TA indicators to the given DataFrame

        Performance Note: For the best performance be frugal on the number of indicators
        you are using. Let uncomment only the indicator you are using in your strategies
        or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
        """

        dataframe['ema20'] = ta.EMA(dataframe, timeperiod=20)
        dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50)
        dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100)

        heikinashi = qtpylib.heikinashi(dataframe)
        dataframe['ha_open'] = heikinashi['open']
        dataframe['ha_close'] = heikinashi['close']

        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the buy signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        dataframe.loc[
            (
                # qtpylib.crossed_above(dataframe['ema20'], dataframe['ema50']) &
                # (dataframe['ha_close'] > dataframe['ema20']) &
                (dataframe['ha_open'] < dataframe['ha_close'])  # green bar
            ),
            'enter_long'] = 1

        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Based on TA indicators, populates the sell signal for the given dataframe
        :param dataframe: DataFrame
        :return: DataFrame with buy column
        """
        # dataframe.loc[
        #     (
        #         (dataframe['ha_open'] > dataframe['ha_close'])  # red bar
        #     ),
        #     'exit_long'] = 1
        return dataframe
```
This is not dependent on a specific if clause surrounding the return. Thats why the example above has it very badly placed as this would sell right away IF IT WOULD SELL (it doesn't). 

### Observed Results:

Without trade adjustments it results in more than one trade, with trade adjustment its exactly one trade as it never fully exits. I also debugged it a bit to backtest.py but the remaining value is 0 (in here: https://github.com/freqtrade/freqtrade/blob/e2a9bc9c6491ee22d5d36815e03356f5e5b5cb8e/freqtrade/optimize/backtesting.py#L583C13-L583C22) so I guess it should just exit but does not


Discussion:
Where is the config used, and the full backtest result?
You can use any, e.g. I used the one in the config_examples folder (just set num_trades to 1 and stake_amount to 50, which I think it should be otherwise its less than min_stake and will not trade --- this is independent of the above bug). Note that all other sells should be turned off to get the result I described above, so no trailing, stoploss set to -0.99 and no roi (I edited the above strategy) 

More specifically I used this config (directly from the config_examples folder minus the stake_amount bug): 
```
{
    "max_open_trades": 1,
    "stake_currency": "USDT",
    "stake_amount": 500,
    "tradable_balance_ratio": 0.99,
    "fiat_display_currency": "USD",
    "timeframe": "5m",
    "dry_run": true,
    "cancel_open_orders_on_exit": false,
    "unfilledtimeout": {
        "entry": 10,
        "exit": 10,
        "exit_timeout_count": 0,
        "unit": "minutes"
    },
    "entry_pricing": {
        "price_side": "same",
        "use_order_book": true,
        "order_book_top": 1,
        "price_last_balance": 0.0,
        "check_depth_of_market": {
            "enabled": false,
            "bids_to_ask_delta": 1
        }
    },
    "exit_pricing": {
        "price_side": "same",
        "use_order_book": true,
        "order_book_top": 1
    },
    "exchange": {
        "name": "binance",
        "key": "your_exchange_key",
        "secret": "your_exchange_secret",
        "ccxt_config": {},
        "ccxt_async_config": {
        },
        "pair_whitelist": [
            "ALGO/USDT",
            "ATOM/USDT",
            "BAT/USDT"
        ],
        "pair_blacklist": [
            "BNB/.*"
        ]
    },
    "pairlists": [
        {"method": "StaticPairList"}
    ],
    "telegram": {
        "enabled": false,
        "token": "your_telegram_token",
        "chat_id": "your_telegram_chat_id"
    },
    "api_server": {
        "enabled": false,
        "listen_ip_address": "127.0.0.1",
        "listen_port": 8080,
        "verbosity": "error",
        "jwt_secret_key": "somethingrandom",
        "CORS_origins": [],
        "username": "freqtrader",
        "password": "SuperSecurePassword"
    },
    "bot_name": "freqtrade",
    "initial_state": "running",
    "force_entry_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}

```

Backtest results: 
With populate_exit and no adjustment:
![image](https://github.com/freqtrade/freqtrade/assets/64589799/c14c8d16-50a4-4e6a-beb9-05f8fc3ed9f1)

With adjustment on and the same sell logic just in the adjust_trade_position function (see updated strat file above), Note that the populate exit needs to be commented out:
![image](https://github.com/freqtrade/freqtrade/assets/64589799/5362d931-f711-4e65-af44-3b80c07bdce8)


@stash86 Let me know if I can help, I tried to debug a bit but it seems unclear to me where exactly the exit should be called
Okay, confirmed the bug. Gonna try to see why it's bugged
Small update. There is no issue on dry/live. It works as intended
![image](https://github.com/freqtrade/freqtrade/assets/13656154/10d5bf19-9022-4d6f-8ab4-af93a3b3ae3f)

Now, the issue is why the backtest won't exit. Adding few prints in the relevant codes
```
      if stake_amount is not None and stake_amount < 0.0:
            logger.info(f"trade_amount is {trade.amount}")
            amount = amount_to_contract_precision(
                abs(stake_amount * trade.amount / trade.stake_amount),
                trade.amount_precision,
                self.precision_mode, trade.contract_size)
            logger.info(f"precised amount is {amount}")
            if amount == 0.0:
                logger.info(f"zero amount")
                return trade
            remaining = (trade.amount - amount) * current_rate
            if min_stake and remaining != 0 and remaining < min_stake:
                logger.info(f"low remaining amount")
                # Remaining stake is too low to be sold.
                return trade
            exit_ = ExitCheckTuple(ExitType.PARTIAL_EXIT, order_tag)
            pos_trade = self._get_exit_for_signal(trade, row, exit_, current_time, amount)
            if pos_trade is not None:
                logger.info(f"processing partial exit")
                order = pos_trade.orders[-1]
                if self._try_close_open_order(order, trade, current_time, row):
                    trade.recalc_trade_from_orders()
                self.wallets.update()
                return pos_trade

        return trade
```

gives me this log
```
2024-05-03 23:19:11,620 - freqtrade.optimize.backtesting - INFO - trade_amount is 0.002
2024-05-03 23:19:11,621 - freqtrade.optimize.backtesting - INFO - precised amount is 0.002
2024-05-03 23:19:11,621 - freqtrade.optimize.backtesting - INFO - processing partial exit
```

Gonna dig deeper
@xmatthias apparently the backtest trade isn't being closed properly

backtesting.py
```
      if stake_amount is not None and stake_amount < 0.0:
            amount = amount_to_contract_precision(
                abs(stake_amount * trade.amount / trade.stake_amount),
                trade.amount_precision,
                self.precision_mode, trade.contract_size)
            if amount == 0.0:
                return trade
            remaining = (trade.amount - amount) * current_rate
            if min_stake and remaining != 0 and remaining < min_stake:
                # Remaining stake is too low to be sold.
                return trade
            exit_ = ExitCheckTuple(ExitType.PARTIAL_EXIT, order_tag)
            pos_trade = self._get_exit_for_signal(trade, row, exit_, current_time, amount)
            logger.info(pos_trade)
            if pos_trade is not None:
                order = pos_trade.orders[-1]
                logger.info(order);
                if self._try_close_open_order(order, trade, current_time, row):
                    trade.recalc_trade_from_orders()
                self.wallets.update()
                return pos_trade
```

trade_model.py
```
def close_bt_order(self, close_date: datetime, trade: 'LocalTrade'):
        logger.info(f"close bt order at {close_date}, filled = {self.amount}")
        self.order_filled_date = close_date
        self.filled = self.amount
        self.remaining = 0
        self.status = 'closed'
        self.ft_is_open = False
        # Assign funding fees to Order.
        # Assumes backtesting will use date_last_filled_utc to calculate future funding fees.
        self.funding_fee = trade.funding_fee_running
        trade.funding_fee_running = 0.0

        logger.info(f"ft_order_side = {self.ft_order_side}, trade entry side = {trade.entry_side}, price = {self.price}")
        if (self.ft_order_side == trade.entry_side and self.price):
            trade.open_rate = self.price
            trade.recalc_trade_from_orders()
            if trade.nr_of_successful_entries == 1:
                trade.initial_stop_loss_pct = None
                trade.is_stop_loss_trailing = False
            trade.adjust_stop_loss(trade.open_rate, trade.stop_loss_pct)

        logger.info(f"Latest trade data. is_open = {trade.is_open}, close_date = {trade.close_date}")
```
```
2024-05-04 00:39:28,774 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2024-05-01 00:00:00 up to 2024-05-03 20:00:00 (2 days).
2024-05-04 00:39:28,856 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,857 - freqtrade.persistence.trade_model - INFO - ft_order_side = buy, trade entry side = buy, price = 60110.6
2024-05-04 00:39:28,858 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = None
2024-05-04 00:39:28,866 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,867 - freqtrade.optimize.backtesting - INFO - Order(id=2, trade=1, order_id=2, side=sell, filled=0, price=60110.6, status=open, date=2024-05-01 02:00:00)
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60110.6
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 02:00:00+00:00
2024-05-04 00:39:28,872 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,872 - freqtrade.optimize.backtesting - INFO - Order(id=3, trade=1, order_id=3, side=sell, filled=0, price=60214.0, status=open, date=2024-05-01 04:00:00)
2024-05-04 00:39:28,874 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,875 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60214.0
2024-05-04 00:39:28,875 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 04:00:00+00:00
2024-05-04 00:39:28,903 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,907 - freqtrade.optimize.backtesting - INFO - Order(id=4, trade=1, order_id=4, side=sell, filled=0, price=60030.1, status=open, date=2024-05-01 06:00:00)
2024-05-04 00:39:28,907 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,909 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60030.1
2024-05-04 00:39:28,909 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 06:00:00+00:00
2024-05-04 00:39:28,932 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,934 - freqtrade.optimize.backtesting - INFO - Order(id=5, trade=1, order_id=5, side=sell, filled=0, price=57482.0, status=open, date=2024-05-01 08:00:00)
2024-05-04 00:39:28,936 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,937 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57482.0
2024-05-04 00:39:28,946 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 08:00:00+00:00
2024-05-04 00:39:28,967 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,971 - freqtrade.optimize.backtesting - INFO - Order(id=6, trade=1, order_id=6, side=sell, filled=0, price=57090.0, status=open, date=2024-05-01 10:00:00)
2024-05-04 00:39:28,974 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,979 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57090.0
2024-05-04 00:39:28,982 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 10:00:00+00:00
2024-05-04 00:39:28,989 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,990 - freqtrade.optimize.backtesting - INFO - Order(id=7, trade=1, order_id=7, side=sell, filled=0, price=57862.2, status=open, date=2024-05-01 12:00:00)
2024-05-04 00:39:28,991 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,991 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57862.2
2024-05-04 00:39:28,992 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 12:00:00+00:00
2024-05-04 00:39:29,024 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,027 - freqtrade.optimize.backtesting - INFO - Order(id=8, trade=1, order_id=8, side=sell, filled=0, price=57283.5, status=open, date=2024-05-01 14:00:00)
2024-05-04 00:39:29,029 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,031 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57283.5
2024-05-04 00:39:29,032 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 14:00:00+00:00
2024-05-04 00:39:29,093 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,099 - freqtrade.optimize.backtesting - INFO - Order(id=9, trade=1, order_id=9, side=sell, filled=0, price=56865.3, status=open, date=2024-05-01 16:00:00)
2024-05-04 00:39:29,100 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,101 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 56865.3
2024-05-04 00:39:29,102 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 16:00:00+00:00
2024-05-04 00:39:29,136 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,141 - freqtrade.optimize.backtesting - INFO - Order(id=10, trade=1, order_id=10, side=sell, filled=0, price=57398.5, status=open, date=2024-05-01 18:00:00)
2024-05-04 00:39:29,147 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,148 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57398.5
2024-05-04 00:39:29,150 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 18:00:00+00:00
2024-05-04 00:39:29,195 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,200 - freqtrade.optimize.backtesting - INFO - Order(id=11, trade=1, order_id=11, side=sell, filled=0, price=56935.7, status=open, date=2024-05-01 20:00:00)
2024-05-04 00:39:29,200 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,200 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 56935.7
2024-05-04 00:39:29,201 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 20:00:00+00:00
2024-05-04 00:39:29,221 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,223 - freqtrade.optimize.backtesting - INFO - Order(id=12, trade=1, order_id=12, side=sell, filled=0, price=57888.0, status=open, date=2024-05-01 22:00:00)
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 22:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57888.0
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 22:00:00+00:00
2024-05-04 00:39:29,264 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,274 - freqtrade.optimize.backtesting - INFO - Order(id=13, trade=1, order_id=13, side=sell, filled=0, price=58307.7, status=open, date=2024-05-02 00:00:00)
2024-05-04 00:39:29,278 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 00:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,285 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58307.7
2024-05-04 00:39:29,287 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 00:00:00+00:00
2024-05-04 00:39:29,293 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,304 - freqtrade.optimize.backtesting - INFO - Order(id=14, trade=1, order_id=14, side=sell, filled=0, price=57096.5, status=open, date=2024-05-02 02:00:00)
2024-05-04 00:39:29,308 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,310 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57096.5
2024-05-04 00:39:29,313 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 02:00:00+00:00
2024-05-04 00:39:29,343 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,344 - freqtrade.optimize.backtesting - INFO - Order(id=15, trade=1, order_id=15, side=sell, filled=0, price=57407.7, status=open, date=2024-05-02 04:00:00)
2024-05-04 00:39:29,345 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,346 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57407.7
2024-05-04 00:39:29,346 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 04:00:00+00:00
2024-05-04 00:39:29,362 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,373 - freqtrade.optimize.backtesting - INFO - Order(id=16, trade=1, order_id=16, side=sell, filled=0, price=57463.1, status=open, date=2024-05-02 06:00:00)
2024-05-04 00:39:29,377 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,378 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57463.1
2024-05-04 00:39:29,379 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 06:00:00+00:00
2024-05-04 00:39:29,406 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,416 - freqtrade.optimize.backtesting - INFO - Order(id=17, trade=1, order_id=17, side=sell, filled=0, price=57645.0, status=open, date=2024-05-02 08:00:00)
2024-05-04 00:39:29,423 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,428 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57645.0
2024-05-04 00:39:29,430 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 08:00:00+00:00
2024-05-04 00:39:29,471 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,475 - freqtrade.optimize.backtesting - INFO - Order(id=18, trade=1, order_id=18, side=sell, filled=0, price=57775.8, status=open, date=2024-05-02 10:00:00)
2024-05-04 00:39:29,480 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,483 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57775.8
2024-05-04 00:39:29,486 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 10:00:00+00:00
2024-05-04 00:39:29,539 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,545 - freqtrade.optimize.backtesting - INFO - Order(id=19, trade=1, order_id=19, side=sell, filled=0, price=58538.5, status=open, date=2024-05-02 12:00:00)
2024-05-04 00:39:29,549 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,551 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58538.5
2024-05-04 00:39:29,555 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 12:00:00+00:00
2024-05-04 00:39:29,573 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,579 - freqtrade.optimize.backtesting - INFO - Order(id=20, trade=1, order_id=20, side=sell, filled=0, price=58429.6, status=open, date=2024-05-02 14:00:00)
2024-05-04 00:39:29,585 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,586 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58429.6
2024-05-04 00:39:29,592 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 14:00:00+00:00
2024-05-04 00:39:29,616 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,633 - freqtrade.optimize.backtesting - INFO - Order(id=21, trade=1, order_id=21, side=sell, filled=0, price=59230.8, status=open, date=2024-05-02 16:00:00)
2024-05-04 00:39:29,635 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,638 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59230.8
2024-05-04 00:39:29,638 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 16:00:00+00:00
2024-05-04 00:39:29,662 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,675 - freqtrade.optimize.backtesting - INFO - Order(id=22, trade=1, order_id=22, side=sell, filled=0, price=59169.9, status=open, date=2024-05-02 18:00:00)
2024-05-04 00:39:29,677 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,678 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59169.9
2024-05-04 00:39:29,680 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 18:00:00+00:00
2024-05-04 00:39:29,686 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,715 - freqtrade.optimize.backtesting - INFO - Order(id=23, trade=1, order_id=23, side=sell, filled=0, price=59324.5, status=open, date=2024-05-02 20:00:00)
2024-05-04 00:39:29,716 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,718 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59324.5
2024-05-04 00:39:29,720 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 20:00:00+00:00
2024-05-04 00:39:29,744 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,753 - freqtrade.optimize.backtesting - INFO - Order(id=24, trade=1, order_id=24, side=sell, filled=0, price=59085.1, status=open, date=2024-05-02 22:00:00)
2024-05-04 00:39:29,756 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 22:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,758 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59085.1
2024-05-04 00:39:29,762 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 22:00:00+00:00
2024-05-04 00:39:29,789 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,799 - freqtrade.optimize.backtesting - INFO - Order(id=25, trade=1, order_id=25, side=sell, filled=0, price=59036.7, status=open, date=2024-05-03 00:00:00)
2024-05-04 00:39:29,801 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 00:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,802 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59036.7
2024-05-04 00:39:29,810 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 00:00:00+00:00
2024-05-04 00:39:29,838 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,838 - freqtrade.optimize.backtesting - INFO - Order(id=26, trade=1, order_id=26, side=sell, filled=0, price=59284.9, status=open, date=2024-05-03 02:00:00)
2024-05-04 00:39:29,839 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,839 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59284.9
2024-05-04 00:39:29,841 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 02:00:00+00:00
2024-05-04 00:39:29,846 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,870 - freqtrade.optimize.backtesting - INFO - Order(id=27, trade=1, order_id=27, side=sell, filled=0, price=59687.9, status=open, date=2024-05-03 04:00:00)
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59687.9
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 04:00:00+00:00
2024-05-04 00:39:29,880 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,888 - freqtrade.optimize.backtesting - INFO - Order(id=28, trade=1, order_id=28, side=sell, filled=0, price=59495.0, status=open, date=2024-05-03 06:00:00)
2024-05-04 00:39:29,889 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,894 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59495.0
2024-05-04 00:39:29,895 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 06:00:00+00:00
2024-05-04 00:39:29,938 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,943 - freqtrade.optimize.backtesting - INFO - Order(id=29, trade=1, order_id=29, side=sell, filled=0, price=59158.1, status=open, date=2024-05-03 08:00:00)
2024-05-04 00:39:29,946 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,948 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59158.1
2024-05-04 00:39:29,949 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 08:00:00+00:00
2024-05-04 00:39:29,977 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,983 - freqtrade.optimize.backtesting - INFO - Order(id=30, trade=1, order_id=30, side=sell, filled=0, price=59445.3, status=open, date=2024-05-03 10:00:00)
2024-05-04 00:39:29,985 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,987 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59445.3
2024-05-04 00:39:29,997 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 10:00:00+00:00
2024-05-04 00:39:30,030 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,038 - freqtrade.optimize.backtesting - INFO - Order(id=31, trade=1, order_id=31, side=sell, filled=0, price=59269.4, status=open, date=2024-05-03 12:00:00)
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59269.4
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 12:00:00+00:00
2024-05-04 00:39:30,061 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,065 - freqtrade.optimize.backtesting - INFO - Order(id=32, trade=1, order_id=32, side=sell, filled=0, price=61654.0, status=open, date=2024-05-03 14:00:00)
2024-05-04 00:39:30,067 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,068 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61654.0
2024-05-04 00:39:30,068 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 14:00:00+00:00
2024-05-04 00:39:30,089 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,097 - freqtrade.optimize.backtesting - INFO - Order(id=33, trade=1, order_id=33, side=sell, filled=0, price=61662.2, status=open, date=2024-05-03 16:00:00)
2024-05-04 00:39:30,099 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,100 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61662.2
2024-05-04 00:39:30,103 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 16:00:00+00:00
2024-05-04 00:39:30,115 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,125 - freqtrade.optimize.backtesting - INFO - Order(id=34, trade=1, order_id=34, side=sell, filled=0, price=61770.8, status=open, date=2024-05-03 18:00:00)
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61770.8
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 18:00:00+00:00
2024-05-04 00:39:30,134 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,140 - freqtrade.optimize.backtesting - INFO - Order(id=35, trade=1, order_id=35, side=sell, filled=0, price=62031.9, status=open, date=2024-05-03 20:00:00)
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 62031.9
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 20:00:00+00:00
```

As you can see, the bot keeps trying to close the trade over and over
Where is the config used, and the full backtest result?
You can use any, e.g. I used the one in the config_examples folder (just set num_trades to 1 and stake_amount to 50, which I think it should be otherwise its less than min_stake and will not trade --- this is independent of the above bug). Note that all other sells should be turned off to get the result I described above, so no trailing, stoploss set to -0.99 and no roi (I edited the above strategy) 

More specifically I used this config (directly from the config_examples folder minus the stake_amount bug): 
```
{
    "max_open_trades": 1,
    "stake_currency": "USDT",
    "stake_amount": 500,
    "tradable_balance_ratio": 0.99,
    "fiat_display_currency": "USD",
    "timeframe": "5m",
    "dry_run": true,
    "cancel_open_orders_on_exit": false,
    "unfilledtimeout": {
        "entry": 10,
        "exit": 10,
        "exit_timeout_count": 0,
        "unit": "minutes"
    },
    "entry_pricing": {
        "price_side": "same",
        "use_order_book": true,
        "order_book_top": 1,
        "price_last_balance": 0.0,
        "check_depth_of_market": {
            "enabled": false,
            "bids_to_ask_delta": 1
        }
    },
    "exit_pricing": {
        "price_side": "same",
        "use_order_book": true,
        "order_book_top": 1
    },
    "exchange": {
        "name": "binance",
        "key": "your_exchange_key",
        "secret": "your_exchange_secret",
        "ccxt_config": {},
        "ccxt_async_config": {
        },
        "pair_whitelist": [
            "ALGO/USDT",
            "ATOM/USDT",
            "BAT/USDT"
        ],
        "pair_blacklist": [
            "BNB/.*"
        ]
    },
    "pairlists": [
        {"method": "StaticPairList"}
    ],
    "telegram": {
        "enabled": false,
        "token": "your_telegram_token",
        "chat_id": "your_telegram_chat_id"
    },
    "api_server": {
        "enabled": false,
        "listen_ip_address": "127.0.0.1",
        "listen_port": 8080,
        "verbosity": "error",
        "jwt_secret_key": "somethingrandom",
        "CORS_origins": [],
        "username": "freqtrader",
        "password": "SuperSecurePassword"
    },
    "bot_name": "freqtrade",
    "initial_state": "running",
    "force_entry_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}

```

Backtest results: 
With populate_exit and no adjustment:
![image](https://github.com/freqtrade/freqtrade/assets/64589799/c14c8d16-50a4-4e6a-beb9-05f8fc3ed9f1)

With adjustment on and the same sell logic just in the adjust_trade_position function (see updated strat file above), Note that the populate exit needs to be commented out:
![image](https://github.com/freqtrade/freqtrade/assets/64589799/5362d931-f711-4e65-af44-3b80c07bdce8)


@stash86 Let me know if I can help, I tried to debug a bit but it seems unclear to me where exactly the exit should be called
Okay, confirmed the bug. Gonna try to see why it's bugged
Small update. There is no issue on dry/live. It works as intended
![image](https://github.com/freqtrade/freqtrade/assets/13656154/10d5bf19-9022-4d6f-8ab4-af93a3b3ae3f)

Now, the issue is why the backtest won't exit. Adding few prints in the relevant codes
```
      if stake_amount is not None and stake_amount < 0.0:
            logger.info(f"trade_amount is {trade.amount}")
            amount = amount_to_contract_precision(
                abs(stake_amount * trade.amount / trade.stake_amount),
                trade.amount_precision,
                self.precision_mode, trade.contract_size)
            logger.info(f"precised amount is {amount}")
            if amount == 0.0:
                logger.info(f"zero amount")
                return trade
            remaining = (trade.amount - amount) * current_rate
            if min_stake and remaining != 0 and remaining < min_stake:
                logger.info(f"low remaining amount")
                # Remaining stake is too low to be sold.
                return trade
            exit_ = ExitCheckTuple(ExitType.PARTIAL_EXIT, order_tag)
            pos_trade = self._get_exit_for_signal(trade, row, exit_, current_time, amount)
            if pos_trade is not None:
                logger.info(f"processing partial exit")
                order = pos_trade.orders[-1]
                if self._try_close_open_order(order, trade, current_time, row):
                    trade.recalc_trade_from_orders()
                self.wallets.update()
                return pos_trade

        return trade
```

gives me this log
```
2024-05-03 23:19:11,620 - freqtrade.optimize.backtesting - INFO - trade_amount is 0.002
2024-05-03 23:19:11,621 - freqtrade.optimize.backtesting - INFO - precised amount is 0.002
2024-05-03 23:19:11,621 - freqtrade.optimize.backtesting - INFO - processing partial exit
```

Gonna dig deeper
@xmatthias apparently the backtest trade isn't being closed properly

backtesting.py
```
      if stake_amount is not None and stake_amount < 0.0:
            amount = amount_to_contract_precision(
                abs(stake_amount * trade.amount / trade.stake_amount),
                trade.amount_precision,
                self.precision_mode, trade.contract_size)
            if amount == 0.0:
                return trade
            remaining = (trade.amount - amount) * current_rate
            if min_stake and remaining != 0 and remaining < min_stake:
                # Remaining stake is too low to be sold.
                return trade
            exit_ = ExitCheckTuple(ExitType.PARTIAL_EXIT, order_tag)
            pos_trade = self._get_exit_for_signal(trade, row, exit_, current_time, amount)
            logger.info(pos_trade)
            if pos_trade is not None:
                order = pos_trade.orders[-1]
                logger.info(order);
                if self._try_close_open_order(order, trade, current_time, row):
                    trade.recalc_trade_from_orders()
                self.wallets.update()
                return pos_trade
```

trade_model.py
```
def close_bt_order(self, close_date: datetime, trade: 'LocalTrade'):
        logger.info(f"close bt order at {close_date}, filled = {self.amount}")
        self.order_filled_date = close_date
        self.filled = self.amount
        self.remaining = 0
        self.status = 'closed'
        self.ft_is_open = False
        # Assign funding fees to Order.
        # Assumes backtesting will use date_last_filled_utc to calculate future funding fees.
        self.funding_fee = trade.funding_fee_running
        trade.funding_fee_running = 0.0

        logger.info(f"ft_order_side = {self.ft_order_side}, trade entry side = {trade.entry_side}, price = {self.price}")
        if (self.ft_order_side == trade.entry_side and self.price):
            trade.open_rate = self.price
            trade.recalc_trade_from_orders()
            if trade.nr_of_successful_entries == 1:
                trade.initial_stop_loss_pct = None
                trade.is_stop_loss_trailing = False
            trade.adjust_stop_loss(trade.open_rate, trade.stop_loss_pct)

        logger.info(f"Latest trade data. is_open = {trade.is_open}, close_date = {trade.close_date}")
```
```
2024-05-04 00:39:28,774 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2024-05-01 00:00:00 up to 2024-05-03 20:00:00 (2 days).
2024-05-04 00:39:28,856 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,857 - freqtrade.persistence.trade_model - INFO - ft_order_side = buy, trade entry side = buy, price = 60110.6
2024-05-04 00:39:28,858 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = None
2024-05-04 00:39:28,866 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,867 - freqtrade.optimize.backtesting - INFO - Order(id=2, trade=1, order_id=2, side=sell, filled=0, price=60110.6, status=open, date=2024-05-01 02:00:00)
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60110.6
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 02:00:00+00:00
2024-05-04 00:39:28,872 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,872 - freqtrade.optimize.backtesting - INFO - Order(id=3, trade=1, order_id=3, side=sell, filled=0, price=60214.0, status=open, date=2024-05-01 04:00:00)
2024-05-04 00:39:28,874 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,875 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60214.0
2024-05-04 00:39:28,875 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 04:00:00+00:00
2024-05-04 00:39:28,903 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,907 - freqtrade.optimize.backtesting - INFO - Order(id=4, trade=1, order_id=4, side=sell, filled=0, price=60030.1, status=open, date=2024-05-01 06:00:00)
2024-05-04 00:39:28,907 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,909 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60030.1
2024-05-04 00:39:28,909 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 06:00:00+00:00
2024-05-04 00:39:28,932 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,934 - freqtrade.optimize.backtesting - INFO - Order(id=5, trade=1, order_id=5, side=sell, filled=0, price=57482.0, status=open, date=2024-05-01 08:00:00)
2024-05-04 00:39:28,936 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,937 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57482.0
2024-05-04 00:39:28,946 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 08:00:00+00:00
2024-05-04 00:39:28,967 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,971 - freqtrade.optimize.backtesting - INFO - Order(id=6, trade=1, order_id=6, side=sell, filled=0, price=57090.0, status=open, date=2024-05-01 10:00:00)
2024-05-04 00:39:28,974 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,979 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57090.0
2024-05-04 00:39:28,982 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 10:00:00+00:00
2024-05-04 00:39:28,989 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,990 - freqtrade.optimize.backtesting - INFO - Order(id=7, trade=1, order_id=7, side=sell, filled=0, price=57862.2, status=open, date=2024-05-01 12:00:00)
2024-05-04 00:39:28,991 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,991 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57862.2
2024-05-04 00:39:28,992 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 12:00:00+00:00
2024-05-04 00:39:29,024 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,027 - freqtrade.optimize.backtesting - INFO - Order(id=8, trade=1, order_id=8, side=sell, filled=0, price=57283.5, status=open, date=2024-05-01 14:00:00)
2024-05-04 00:39:29,029 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,031 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57283.5
2024-05-04 00:39:29,032 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 14:00:00+00:00
2024-05-04 00:39:29,093 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,099 - freqtrade.optimize.backtesting - INFO - Order(id=9, trade=1, order_id=9, side=sell, filled=0, price=56865.3, status=open, date=2024-05-01 16:00:00)
2024-05-04 00:39:29,100 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,101 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 56865.3
2024-05-04 00:39:29,102 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 16:00:00+00:00
2024-05-04 00:39:29,136 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,141 - freqtrade.optimize.backtesting - INFO - Order(id=10, trade=1, order_id=10, side=sell, filled=0, price=57398.5, status=open, date=2024-05-01 18:00:00)
2024-05-04 00:39:29,147 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,148 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57398.5
2024-05-04 00:39:29,150 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 18:00:00+00:00
2024-05-04 00:39:29,195 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,200 - freqtrade.optimize.backtesting - INFO - Order(id=11, trade=1, order_id=11, side=sell, filled=0, price=56935.7, status=open, date=2024-05-01 20:00:00)
2024-05-04 00:39:29,200 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,200 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 56935.7
2024-05-04 00:39:29,201 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 20:00:00+00:00
2024-05-04 00:39:29,221 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,223 - freqtrade.optimize.backtesting - INFO - Order(id=12, trade=1, order_id=12, side=sell, filled=0, price=57888.0, status=open, date=2024-05-01 22:00:00)
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 22:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57888.0
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 22:00:00+00:00
2024-05-04 00:39:29,264 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,274 - freqtrade.optimize.backtesting - INFO - Order(id=13, trade=1, order_id=13, side=sell, filled=0, price=58307.7, status=open, date=2024-05-02 00:00:00)
2024-05-04 00:39:29,278 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 00:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,285 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58307.7
2024-05-04 00:39:29,287 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 00:00:00+00:00
2024-05-04 00:39:29,293 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,304 - freqtrade.optimize.backtesting - INFO - Order(id=14, trade=1, order_id=14, side=sell, filled=0, price=57096.5, status=open, date=2024-05-02 02:00:00)
2024-05-04 00:39:29,308 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,310 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57096.5
2024-05-04 00:39:29,313 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 02:00:00+00:00
2024-05-04 00:39:29,343 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,344 - freqtrade.optimize.backtesting - INFO - Order(id=15, trade=1, order_id=15, side=sell, filled=0, price=57407.7, status=open, date=2024-05-02 04:00:00)
2024-05-04 00:39:29,345 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,346 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57407.7
2024-05-04 00:39:29,346 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 04:00:00+00:00
2024-05-04 00:39:29,362 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,373 - freqtrade.optimize.backtesting - INFO - Order(id=16, trade=1, order_id=16, side=sell, filled=0, price=57463.1, status=open, date=2024-05-02 06:00:00)
2024-05-04 00:39:29,377 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,378 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57463.1
2024-05-04 00:39:29,379 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 06:00:00+00:00
2024-05-04 00:39:29,406 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,416 - freqtrade.optimize.backtesting - INFO - Order(id=17, trade=1, order_id=17, side=sell, filled=0, price=57645.0, status=open, date=2024-05-02 08:00:00)
2024-05-04 00:39:29,423 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,428 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57645.0
2024-05-04 00:39:29,430 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 08:00:00+00:00
2024-05-04 00:39:29,471 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,475 - freqtrade.optimize.backtesting - INFO - Order(id=18, trade=1, order_id=18, side=sell, filled=0, price=57775.8, status=open, date=2024-05-02 10:00:00)
2024-05-04 00:39:29,480 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,483 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57775.8
2024-05-04 00:39:29,486 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 10:00:00+00:00
2024-05-04 00:39:29,539 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,545 - freqtrade.optimize.backtesting - INFO - Order(id=19, trade=1, order_id=19, side=sell, filled=0, price=58538.5, status=open, date=2024-05-02 12:00:00)
2024-05-04 00:39:29,549 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,551 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58538.5
2024-05-04 00:39:29,555 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 12:00:00+00:00
2024-05-04 00:39:29,573 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,579 - freqtrade.optimize.backtesting - INFO - Order(id=20, trade=1, order_id=20, side=sell, filled=0, price=58429.6, status=open, date=2024-05-02 14:00:00)
2024-05-04 00:39:29,585 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,586 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58429.6
2024-05-04 00:39:29,592 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 14:00:00+00:00
2024-05-04 00:39:29,616 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,633 - freqtrade.optimize.backtesting - INFO - Order(id=21, trade=1, order_id=21, side=sell, filled=0, price=59230.8, status=open, date=2024-05-02 16:00:00)
2024-05-04 00:39:29,635 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,638 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59230.8
2024-05-04 00:39:29,638 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 16:00:00+00:00
2024-05-04 00:39:29,662 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,675 - freqtrade.optimize.backtesting - INFO - Order(id=22, trade=1, order_id=22, side=sell, filled=0, price=59169.9, status=open, date=2024-05-02 18:00:00)
2024-05-04 00:39:29,677 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,678 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59169.9
2024-05-04 00:39:29,680 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 18:00:00+00:00
2024-05-04 00:39:29,686 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,715 - freqtrade.optimize.backtesting - INFO - Order(id=23, trade=1, order_id=23, side=sell, filled=0, price=59324.5, status=open, date=2024-05-02 20:00:00)
2024-05-04 00:39:29,716 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,718 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59324.5
2024-05-04 00:39:29,720 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 20:00:00+00:00
2024-05-04 00:39:29,744 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,753 - freqtrade.optimize.backtesting - INFO - Order(id=24, trade=1, order_id=24, side=sell, filled=0, price=59085.1, status=open, date=2024-05-02 22:00:00)
2024-05-04 00:39:29,756 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 22:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,758 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59085.1
2024-05-04 00:39:29,762 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 22:00:00+00:00
2024-05-04 00:39:29,789 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,799 - freqtrade.optimize.backtesting - INFO - Order(id=25, trade=1, order_id=25, side=sell, filled=0, price=59036.7, status=open, date=2024-05-03 00:00:00)
2024-05-04 00:39:29,801 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 00:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,802 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59036.7
2024-05-04 00:39:29,810 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 00:00:00+00:00
2024-05-04 00:39:29,838 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,838 - freqtrade.optimize.backtesting - INFO - Order(id=26, trade=1, order_id=26, side=sell, filled=0, price=59284.9, status=open, date=2024-05-03 02:00:00)
2024-05-04 00:39:29,839 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,839 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59284.9
2024-05-04 00:39:29,841 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 02:00:00+00:00
2024-05-04 00:39:29,846 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,870 - freqtrade.optimize.backtesting - INFO - Order(id=27, trade=1, order_id=27, side=sell, filled=0, price=59687.9, status=open, date=2024-05-03 04:00:00)
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59687.9
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 04:00:00+00:00
2024-05-04 00:39:29,880 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,888 - freqtrade.optimize.backtesting - INFO - Order(id=28, trade=1, order_id=28, side=sell, filled=0, price=59495.0, status=open, date=2024-05-03 06:00:00)
2024-05-04 00:39:29,889 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,894 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59495.0
2024-05-04 00:39:29,895 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 06:00:00+00:00
2024-05-04 00:39:29,938 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,943 - freqtrade.optimize.backtesting - INFO - Order(id=29, trade=1, order_id=29, side=sell, filled=0, price=59158.1, status=open, date=2024-05-03 08:00:00)
2024-05-04 00:39:29,946 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,948 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59158.1
2024-05-04 00:39:29,949 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 08:00:00+00:00
2024-05-04 00:39:29,977 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,983 - freqtrade.optimize.backtesting - INFO - Order(id=30, trade=1, order_id=30, side=sell, filled=0, price=59445.3, status=open, date=2024-05-03 10:00:00)
2024-05-04 00:39:29,985 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,987 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59445.3
2024-05-04 00:39:29,997 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 10:00:00+00:00
2024-05-04 00:39:30,030 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,038 - freqtrade.optimize.backtesting - INFO - Order(id=31, trade=1, order_id=31, side=sell, filled=0, price=59269.4, status=open, date=2024-05-03 12:00:00)
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59269.4
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 12:00:00+00:00
2024-05-04 00:39:30,061 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,065 - freqtrade.optimize.backtesting - INFO - Order(id=32, trade=1, order_id=32, side=sell, filled=0, price=61654.0, status=open, date=2024-05-03 14:00:00)
2024-05-04 00:39:30,067 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,068 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61654.0
2024-05-04 00:39:30,068 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 14:00:00+00:00
2024-05-04 00:39:30,089 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,097 - freqtrade.optimize.backtesting - INFO - Order(id=33, trade=1, order_id=33, side=sell, filled=0, price=61662.2, status=open, date=2024-05-03 16:00:00)
2024-05-04 00:39:30,099 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,100 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61662.2
2024-05-04 00:39:30,103 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 16:00:00+00:00
2024-05-04 00:39:30,115 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,125 - freqtrade.optimize.backtesting - INFO - Order(id=34, trade=1, order_id=34, side=sell, filled=0, price=61770.8, status=open, date=2024-05-03 18:00:00)
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61770.8
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 18:00:00+00:00
2024-05-04 00:39:30,134 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,140 - freqtrade.optimize.backtesting - INFO - Order(id=35, trade=1, order_id=35, side=sell, filled=0, price=62031.9, status=open, date=2024-05-03 20:00:00)
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 62031.9
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 20:00:00+00:00
```

As you can see, the bot keeps trying to close the trade over and over
Where is the config used, and the full backtest result?
You can use any, e.g. I used the one in the config_examples folder (just set num_trades to 1 and stake_amount to 50, which I think it should be otherwise its less than min_stake and will not trade --- this is independent of the above bug). Note that all other sells should be turned off to get the result I described above, so no trailing, stoploss set to -0.99 and no roi (I edited the above strategy) 

More specifically I used this config (directly from the config_examples folder minus the stake_amount bug): 
```
{
    "max_open_trades": 1,
    "stake_currency": "USDT",
    "stake_amount": 500,
    "tradable_balance_ratio": 0.99,
    "fiat_display_currency": "USD",
    "timeframe": "5m",
    "dry_run": true,
    "cancel_open_orders_on_exit": false,
    "unfilledtimeout": {
        "entry": 10,
        "exit": 10,
        "exit_timeout_count": 0,
        "unit": "minutes"
    },
    "entry_pricing": {
        "price_side": "same",
        "use_order_book": true,
        "order_book_top": 1,
        "price_last_balance": 0.0,
        "check_depth_of_market": {
            "enabled": false,
            "bids_to_ask_delta": 1
        }
    },
    "exit_pricing": {
        "price_side": "same",
        "use_order_book": true,
        "order_book_top": 1
    },
    "exchange": {
        "name": "binance",
        "key": "your_exchange_key",
        "secret": "your_exchange_secret",
        "ccxt_config": {},
        "ccxt_async_config": {
        },
        "pair_whitelist": [
            "ALGO/USDT",
            "ATOM/USDT",
            "BAT/USDT"
        ],
        "pair_blacklist": [
            "BNB/.*"
        ]
    },
    "pairlists": [
        {"method": "StaticPairList"}
    ],
    "telegram": {
        "enabled": false,
        "token": "your_telegram_token",
        "chat_id": "your_telegram_chat_id"
    },
    "api_server": {
        "enabled": false,
        "listen_ip_address": "127.0.0.1",
        "listen_port": 8080,
        "verbosity": "error",
        "jwt_secret_key": "somethingrandom",
        "CORS_origins": [],
        "username": "freqtrader",
        "password": "SuperSecurePassword"
    },
    "bot_name": "freqtrade",
    "initial_state": "running",
    "force_entry_enable": false,
    "internals": {
        "process_throttle_secs": 5
    }
}

```

Backtest results: 
With populate_exit and no adjustment:
![image](https://github.com/freqtrade/freqtrade/assets/64589799/c14c8d16-50a4-4e6a-beb9-05f8fc3ed9f1)

With adjustment on and the same sell logic just in the adjust_trade_position function (see updated strat file above), Note that the populate exit needs to be commented out:
![image](https://github.com/freqtrade/freqtrade/assets/64589799/5362d931-f711-4e65-af44-3b80c07bdce8)


@stash86 Let me know if I can help, I tried to debug a bit but it seems unclear to me where exactly the exit should be called
Okay, confirmed the bug. Gonna try to see why it's bugged
Small update. There is no issue on dry/live. It works as intended
![image](https://github.com/freqtrade/freqtrade/assets/13656154/10d5bf19-9022-4d6f-8ab4-af93a3b3ae3f)

Now, the issue is why the backtest won't exit. Adding few prints in the relevant codes
```
      if stake_amount is not None and stake_amount < 0.0:
            logger.info(f"trade_amount is {trade.amount}")
            amount = amount_to_contract_precision(
                abs(stake_amount * trade.amount / trade.stake_amount),
                trade.amount_precision,
                self.precision_mode, trade.contract_size)
            logger.info(f"precised amount is {amount}")
            if amount == 0.0:
                logger.info(f"zero amount")
                return trade
            remaining = (trade.amount - amount) * current_rate
            if min_stake and remaining != 0 and remaining < min_stake:
                logger.info(f"low remaining amount")
                # Remaining stake is too low to be sold.
                return trade
            exit_ = ExitCheckTuple(ExitType.PARTIAL_EXIT, order_tag)
            pos_trade = self._get_exit_for_signal(trade, row, exit_, current_time, amount)
            if pos_trade is not None:
                logger.info(f"processing partial exit")
                order = pos_trade.orders[-1]
                if self._try_close_open_order(order, trade, current_time, row):
                    trade.recalc_trade_from_orders()
                self.wallets.update()
                return pos_trade

        return trade
```

gives me this log
```
2024-05-03 23:19:11,620 - freqtrade.optimize.backtesting - INFO - trade_amount is 0.002
2024-05-03 23:19:11,621 - freqtrade.optimize.backtesting - INFO - precised amount is 0.002
2024-05-03 23:19:11,621 - freqtrade.optimize.backtesting - INFO - processing partial exit
```

Gonna dig deeper
@xmatthias apparently the backtest trade isn't being closed properly

backtesting.py
```
      if stake_amount is not None and stake_amount < 0.0:
            amount = amount_to_contract_precision(
                abs(stake_amount * trade.amount / trade.stake_amount),
                trade.amount_precision,
                self.precision_mode, trade.contract_size)
            if amount == 0.0:
                return trade
            remaining = (trade.amount - amount) * current_rate
            if min_stake and remaining != 0 and remaining < min_stake:
                # Remaining stake is too low to be sold.
                return trade
            exit_ = ExitCheckTuple(ExitType.PARTIAL_EXIT, order_tag)
            pos_trade = self._get_exit_for_signal(trade, row, exit_, current_time, amount)
            logger.info(pos_trade)
            if pos_trade is not None:
                order = pos_trade.orders[-1]
                logger.info(order);
                if self._try_close_open_order(order, trade, current_time, row):
                    trade.recalc_trade_from_orders()
                self.wallets.update()
                return pos_trade
```

trade_model.py
```
def close_bt_order(self, close_date: datetime, trade: 'LocalTrade'):
        logger.info(f"close bt order at {close_date}, filled = {self.amount}")
        self.order_filled_date = close_date
        self.filled = self.amount
        self.remaining = 0
        self.status = 'closed'
        self.ft_is_open = False
        # Assign funding fees to Order.
        # Assumes backtesting will use date_last_filled_utc to calculate future funding fees.
        self.funding_fee = trade.funding_fee_running
        trade.funding_fee_running = 0.0

        logger.info(f"ft_order_side = {self.ft_order_side}, trade entry side = {trade.entry_side}, price = {self.price}")
        if (self.ft_order_side == trade.entry_side and self.price):
            trade.open_rate = self.price
            trade.recalc_trade_from_orders()
            if trade.nr_of_successful_entries == 1:
                trade.initial_stop_loss_pct = None
                trade.is_stop_loss_trailing = False
            trade.adjust_stop_loss(trade.open_rate, trade.stop_loss_pct)

        logger.info(f"Latest trade data. is_open = {trade.is_open}, close_date = {trade.close_date}")
```
```
2024-05-04 00:39:28,774 - freqtrade.optimize.backtesting - INFO - Backtesting with data from 2024-05-01 00:00:00 up to 2024-05-03 20:00:00 (2 days).
2024-05-04 00:39:28,856 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,857 - freqtrade.persistence.trade_model - INFO - ft_order_side = buy, trade entry side = buy, price = 60110.6
2024-05-04 00:39:28,858 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = None
2024-05-04 00:39:28,866 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,867 - freqtrade.optimize.backtesting - INFO - Order(id=2, trade=1, order_id=2, side=sell, filled=0, price=60110.6, status=open, date=2024-05-01 02:00:00)
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60110.6
2024-05-04 00:39:28,868 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 02:00:00+00:00
2024-05-04 00:39:28,872 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,872 - freqtrade.optimize.backtesting - INFO - Order(id=3, trade=1, order_id=3, side=sell, filled=0, price=60214.0, status=open, date=2024-05-01 04:00:00)
2024-05-04 00:39:28,874 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,875 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60214.0
2024-05-04 00:39:28,875 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 04:00:00+00:00
2024-05-04 00:39:28,903 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,907 - freqtrade.optimize.backtesting - INFO - Order(id=4, trade=1, order_id=4, side=sell, filled=0, price=60030.1, status=open, date=2024-05-01 06:00:00)
2024-05-04 00:39:28,907 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,909 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 60030.1
2024-05-04 00:39:28,909 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 06:00:00+00:00
2024-05-04 00:39:28,932 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,934 - freqtrade.optimize.backtesting - INFO - Order(id=5, trade=1, order_id=5, side=sell, filled=0, price=57482.0, status=open, date=2024-05-01 08:00:00)
2024-05-04 00:39:28,936 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,937 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57482.0
2024-05-04 00:39:28,946 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 08:00:00+00:00
2024-05-04 00:39:28,967 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,971 - freqtrade.optimize.backtesting - INFO - Order(id=6, trade=1, order_id=6, side=sell, filled=0, price=57090.0, status=open, date=2024-05-01 10:00:00)
2024-05-04 00:39:28,974 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,979 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57090.0
2024-05-04 00:39:28,982 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 10:00:00+00:00
2024-05-04 00:39:28,989 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:28,990 - freqtrade.optimize.backtesting - INFO - Order(id=7, trade=1, order_id=7, side=sell, filled=0, price=57862.2, status=open, date=2024-05-01 12:00:00)
2024-05-04 00:39:28,991 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:28,991 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57862.2
2024-05-04 00:39:28,992 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 12:00:00+00:00
2024-05-04 00:39:29,024 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,027 - freqtrade.optimize.backtesting - INFO - Order(id=8, trade=1, order_id=8, side=sell, filled=0, price=57283.5, status=open, date=2024-05-01 14:00:00)
2024-05-04 00:39:29,029 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,031 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57283.5
2024-05-04 00:39:29,032 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 14:00:00+00:00
2024-05-04 00:39:29,093 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,099 - freqtrade.optimize.backtesting - INFO - Order(id=9, trade=1, order_id=9, side=sell, filled=0, price=56865.3, status=open, date=2024-05-01 16:00:00)
2024-05-04 00:39:29,100 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,101 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 56865.3
2024-05-04 00:39:29,102 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 16:00:00+00:00
2024-05-04 00:39:29,136 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,141 - freqtrade.optimize.backtesting - INFO - Order(id=10, trade=1, order_id=10, side=sell, filled=0, price=57398.5, status=open, date=2024-05-01 18:00:00)
2024-05-04 00:39:29,147 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,148 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57398.5
2024-05-04 00:39:29,150 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 18:00:00+00:00
2024-05-04 00:39:29,195 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,200 - freqtrade.optimize.backtesting - INFO - Order(id=11, trade=1, order_id=11, side=sell, filled=0, price=56935.7, status=open, date=2024-05-01 20:00:00)
2024-05-04 00:39:29,200 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,200 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 56935.7
2024-05-04 00:39:29,201 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 20:00:00+00:00
2024-05-04 00:39:29,221 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,223 - freqtrade.optimize.backtesting - INFO - Order(id=12, trade=1, order_id=12, side=sell, filled=0, price=57888.0, status=open, date=2024-05-01 22:00:00)
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-01 22:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57888.0
2024-05-04 00:39:29,224 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-01 22:00:00+00:00
2024-05-04 00:39:29,264 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,274 - freqtrade.optimize.backtesting - INFO - Order(id=13, trade=1, order_id=13, side=sell, filled=0, price=58307.7, status=open, date=2024-05-02 00:00:00)
2024-05-04 00:39:29,278 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 00:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,285 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58307.7
2024-05-04 00:39:29,287 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 00:00:00+00:00
2024-05-04 00:39:29,293 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,304 - freqtrade.optimize.backtesting - INFO - Order(id=14, trade=1, order_id=14, side=sell, filled=0, price=57096.5, status=open, date=2024-05-02 02:00:00)
2024-05-04 00:39:29,308 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,310 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57096.5
2024-05-04 00:39:29,313 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 02:00:00+00:00
2024-05-04 00:39:29,343 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,344 - freqtrade.optimize.backtesting - INFO - Order(id=15, trade=1, order_id=15, side=sell, filled=0, price=57407.7, status=open, date=2024-05-02 04:00:00)
2024-05-04 00:39:29,345 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,346 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57407.7
2024-05-04 00:39:29,346 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 04:00:00+00:00
2024-05-04 00:39:29,362 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,373 - freqtrade.optimize.backtesting - INFO - Order(id=16, trade=1, order_id=16, side=sell, filled=0, price=57463.1, status=open, date=2024-05-02 06:00:00)
2024-05-04 00:39:29,377 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,378 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57463.1
2024-05-04 00:39:29,379 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 06:00:00+00:00
2024-05-04 00:39:29,406 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,416 - freqtrade.optimize.backtesting - INFO - Order(id=17, trade=1, order_id=17, side=sell, filled=0, price=57645.0, status=open, date=2024-05-02 08:00:00)
2024-05-04 00:39:29,423 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,428 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57645.0
2024-05-04 00:39:29,430 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 08:00:00+00:00
2024-05-04 00:39:29,471 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,475 - freqtrade.optimize.backtesting - INFO - Order(id=18, trade=1, order_id=18, side=sell, filled=0, price=57775.8, status=open, date=2024-05-02 10:00:00)
2024-05-04 00:39:29,480 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,483 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 57775.8
2024-05-04 00:39:29,486 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 10:00:00+00:00
2024-05-04 00:39:29,539 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,545 - freqtrade.optimize.backtesting - INFO - Order(id=19, trade=1, order_id=19, side=sell, filled=0, price=58538.5, status=open, date=2024-05-02 12:00:00)
2024-05-04 00:39:29,549 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,551 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58538.5
2024-05-04 00:39:29,555 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 12:00:00+00:00
2024-05-04 00:39:29,573 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,579 - freqtrade.optimize.backtesting - INFO - Order(id=20, trade=1, order_id=20, side=sell, filled=0, price=58429.6, status=open, date=2024-05-02 14:00:00)
2024-05-04 00:39:29,585 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,586 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 58429.6
2024-05-04 00:39:29,592 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 14:00:00+00:00
2024-05-04 00:39:29,616 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,633 - freqtrade.optimize.backtesting - INFO - Order(id=21, trade=1, order_id=21, side=sell, filled=0, price=59230.8, status=open, date=2024-05-02 16:00:00)
2024-05-04 00:39:29,635 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,638 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59230.8
2024-05-04 00:39:29,638 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 16:00:00+00:00
2024-05-04 00:39:29,662 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,675 - freqtrade.optimize.backtesting - INFO - Order(id=22, trade=1, order_id=22, side=sell, filled=0, price=59169.9, status=open, date=2024-05-02 18:00:00)
2024-05-04 00:39:29,677 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,678 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59169.9
2024-05-04 00:39:29,680 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 18:00:00+00:00
2024-05-04 00:39:29,686 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,715 - freqtrade.optimize.backtesting - INFO - Order(id=23, trade=1, order_id=23, side=sell, filled=0, price=59324.5, status=open, date=2024-05-02 20:00:00)
2024-05-04 00:39:29,716 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,718 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59324.5
2024-05-04 00:39:29,720 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 20:00:00+00:00
2024-05-04 00:39:29,744 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,753 - freqtrade.optimize.backtesting - INFO - Order(id=24, trade=1, order_id=24, side=sell, filled=0, price=59085.1, status=open, date=2024-05-02 22:00:00)
2024-05-04 00:39:29,756 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-02 22:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,758 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59085.1
2024-05-04 00:39:29,762 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-02 22:00:00+00:00
2024-05-04 00:39:29,789 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,799 - freqtrade.optimize.backtesting - INFO - Order(id=25, trade=1, order_id=25, side=sell, filled=0, price=59036.7, status=open, date=2024-05-03 00:00:00)
2024-05-04 00:39:29,801 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 00:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,802 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59036.7
2024-05-04 00:39:29,810 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 00:00:00+00:00
2024-05-04 00:39:29,838 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,838 - freqtrade.optimize.backtesting - INFO - Order(id=26, trade=1, order_id=26, side=sell, filled=0, price=59284.9, status=open, date=2024-05-03 02:00:00)
2024-05-04 00:39:29,839 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 02:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,839 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59284.9
2024-05-04 00:39:29,841 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 02:00:00+00:00
2024-05-04 00:39:29,846 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,870 - freqtrade.optimize.backtesting - INFO - Order(id=27, trade=1, order_id=27, side=sell, filled=0, price=59687.9, status=open, date=2024-05-03 04:00:00)
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 04:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59687.9
2024-05-04 00:39:29,871 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 04:00:00+00:00
2024-05-04 00:39:29,880 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,888 - freqtrade.optimize.backtesting - INFO - Order(id=28, trade=1, order_id=28, side=sell, filled=0, price=59495.0, status=open, date=2024-05-03 06:00:00)
2024-05-04 00:39:29,889 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 06:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,894 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59495.0
2024-05-04 00:39:29,895 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 06:00:00+00:00
2024-05-04 00:39:29,938 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,943 - freqtrade.optimize.backtesting - INFO - Order(id=29, trade=1, order_id=29, side=sell, filled=0, price=59158.1, status=open, date=2024-05-03 08:00:00)
2024-05-04 00:39:29,946 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 08:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,948 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59158.1
2024-05-04 00:39:29,949 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 08:00:00+00:00
2024-05-04 00:39:29,977 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:29,983 - freqtrade.optimize.backtesting - INFO - Order(id=30, trade=1, order_id=30, side=sell, filled=0, price=59445.3, status=open, date=2024-05-03 10:00:00)
2024-05-04 00:39:29,985 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 10:00:00+00:00, filled = 0.002
2024-05-04 00:39:29,987 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59445.3
2024-05-04 00:39:29,997 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 10:00:00+00:00
2024-05-04 00:39:30,030 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,038 - freqtrade.optimize.backtesting - INFO - Order(id=31, trade=1, order_id=31, side=sell, filled=0, price=59269.4, status=open, date=2024-05-03 12:00:00)
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 12:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 59269.4
2024-05-04 00:39:30,038 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 12:00:00+00:00
2024-05-04 00:39:30,061 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,065 - freqtrade.optimize.backtesting - INFO - Order(id=32, trade=1, order_id=32, side=sell, filled=0, price=61654.0, status=open, date=2024-05-03 14:00:00)
2024-05-04 00:39:30,067 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 14:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,068 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61654.0
2024-05-04 00:39:30,068 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 14:00:00+00:00
2024-05-04 00:39:30,089 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,097 - freqtrade.optimize.backtesting - INFO - Order(id=33, trade=1, order_id=33, side=sell, filled=0, price=61662.2, status=open, date=2024-05-03 16:00:00)
2024-05-04 00:39:30,099 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 16:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,100 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61662.2
2024-05-04 00:39:30,103 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 16:00:00+00:00
2024-05-04 00:39:30,115 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,125 - freqtrade.optimize.backtesting - INFO - Order(id=34, trade=1, order_id=34, side=sell, filled=0, price=61770.8, status=open, date=2024-05-03 18:00:00)
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 18:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 61770.8
2024-05-04 00:39:30,125 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 18:00:00+00:00
2024-05-04 00:39:30,134 - freqtrade.optimize.backtesting - INFO - Trade(id=1, pair=BTC/USDT:USDT, amount=0.00200000, is_short=False, leverage=1.0, open_rate=60110.60000000, open_since=2024-05-01 02:00:00)
2024-05-04 00:39:30,140 - freqtrade.optimize.backtesting - INFO - Order(id=35, trade=1, order_id=35, side=sell, filled=0, price=62031.9, status=open, date=2024-05-03 20:00:00)
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - close bt order at 2024-05-03 20:00:00+00:00, filled = 0.002
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - ft_order_side = sell, trade entry side = buy, price = 62031.9
2024-05-04 00:39:30,140 - freqtrade.persistence.trade_model - INFO - Latest trade data. is_open = True, close_date = 2024-05-03 20:00:00+00:00
```

As you can see, the bot keeps trying to close the trade over and over

Resolving patch:
diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py
--- a/freqtrade/optimize/backtesting.py
+++ b/freqtrade/optimize/backtesting.py
@@ -42,6 +42,7 @@
 from freqtrade.strategy.interface import IStrategy
 from freqtrade.strategy.strategy_wrapper import strategy_safe_wrapper
 from freqtrade.types import BacktestResultType, get_BacktestResultType_default
+from freqtrade.util import FtPrecise
 from freqtrade.util.migrations import migrate_data
 from freqtrade.wallets import Wallets
 
@@ -575,7 +576,8 @@ def _get_adjust_trade_entry_for_candle(
 
         if stake_amount is not None and stake_amount < 0.0:
             amount = amount_to_contract_precision(
-                abs(stake_amount * trade.amount / trade.stake_amount),
+                abs(float(FtPrecise(stake_amount) * FtPrecise(trade.amount)
+                    / FtPrecise(trade.stake_amount))),
                 trade.amount_precision,
                 self.precision_mode, trade.contract_size)
             if amount == 0.0:
@@ -588,9 +590,8 @@ def _get_adjust_trade_entry_for_candle(
             pos_trade = self._get_exit_for_signal(trade, row, exit_, current_time, amount)
             if pos_trade is not None:
                 order = pos_trade.orders[-1]
-                if self._try_close_open_order(order, trade, current_time, row):
-                    trade.recalc_trade_from_orders()
-                self.wallets.update()
+                # If the order was filled and for the full trade amount, we need to close the trade.
+                self._process_exit_order(order, pos_trade, current_time, row, trade.pair)
                 return pos_trade
 
         return trade
@@ -636,6 +637,25 @@ def _try_close_open_order(
             return True
         return False
 
+    def _process_exit_order(
+            self, order: Order, trade: LocalTrade, current_time: datetime, row: Tuple, pair: str
+    ):
+        """
+        Takes an exit order and processes it, potentially closing the trade.
+        """
+        if self._try_close_open_order(order, trade, current_time, row):
+            sub_trade = order.safe_amount_after_fee != trade.amount
+            if sub_trade:
+                trade.recalc_trade_from_orders()
+            else:
+                trade.close_date = current_time
+                trade.close(order.ft_price, show_msg=False)
+
+                # logger.debug(f"{pair} - Backtesting exit {trade}")
+                LocalTrade.close_bt_trade(trade)
+            self.wallets.update()
+            self.run_protections(pair, current_time, trade.trade_direction)
+
     def _get_exit_for_signal(
             self, trade: LocalTrade, row: Tuple, exit_: ExitCheckTuple,
             current_time: datetime,
@@ -748,17 +768,18 @@ def _check_trade_exit(
         if self.strategy.position_adjustment_enable:
             trade = self._get_adjust_trade_entry_for_candle(trade, row, current_time)
 
-        enter = row[SHORT_IDX] if trade.is_short else row[LONG_IDX]
-        exit_sig = row[ESHORT_IDX] if trade.is_short else row[ELONG_IDX]
-        exits = self.strategy.should_exit(
-            trade, row[OPEN_IDX], row[DATE_IDX].to_pydatetime(),  # type: ignore
-            enter=enter, exit_=exit_sig,
-            low=row[LOW_IDX], high=row[HIGH_IDX]
-        )
-        for exit_ in exits:
-            t = self._get_exit_for_signal(trade, row, exit_, current_time)
-            if t:
-                return t
+        if trade.is_open:
+            enter = row[SHORT_IDX] if trade.is_short else row[LONG_IDX]
+            exit_sig = row[ESHORT_IDX] if trade.is_short else row[ELONG_IDX]
+            exits = self.strategy.should_exit(
+                trade, row[OPEN_IDX], row[DATE_IDX].to_pydatetime(),  # type: ignore
+                enter=enter, exit_=exit_sig,
+                low=row[LOW_IDX], high=row[HIGH_IDX]
+            )
+            for exit_ in exits:
+                t = self._get_exit_for_signal(trade, row, exit_, current_time)
+                if t:
+                    return t
         return None
 
     def _run_funding_fees(self, trade: LocalTrade, current_time: datetime, force: bool = False):
@@ -946,6 +967,7 @@ def _enter_trade(self, pair: str, row: Tuple, direction: LongShort,
                     contract_size=contract_size,
                     orders=[],
                 )
+                LocalTrade.add_bt_trade(trade)
 
             trade.adjust_stop_loss(trade.open_rate, self.strategy.stoploss, initial=True)
 
@@ -1178,8 +1200,6 @@ def backtest_loop(
                     # This emulates previous behavior - not sure if this is correct
                     # Prevents entering if the trade-slot was freed in this candle
                     open_trade_count_start += 1
-                    # logger.debug(f"{pair} - Emulate creation of new trade: {trade}.")
-                    LocalTrade.add_bt_trade(trade)
                     self.wallets.update()
             else:
                 self._collate_rejected(pair, row)
@@ -1196,18 +1216,8 @@ def backtest_loop(
 
             # 5. Process exit orders.
             order = trade.select_order(trade.exit_side, is_open=True)
-            if order and self._try_close_open_order(order, trade, current_time, row):
-                sub_trade = order.safe_amount_after_fee != trade.amount
-                if sub_trade:
-                    trade.recalc_trade_from_orders()
-                else:
-                    trade.close_date = current_time
-                    trade.close(order.ft_price, show_msg=False)
-
-                    # logger.debug(f"{pair} - Backtesting exit {trade}")
-                    LocalTrade.close_bt_trade(trade)
-                self.wallets.update()
-                self.run_protections(pair, current_time, trade.trade_direction)
+            if order:
+                self._process_exit_order(order, trade, current_time, row, pair)
         return open_trade_count_start
 
     def backtest(self, processed: Dict,


Test patch:
diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py
--- a/tests/optimize/test_backtesting.py
+++ b/tests/optimize/test_backtesting.py
@@ -501,34 +501,38 @@ def test_backtest__enter_trade(default_conf, fee, mocker) -> None:
 
     # Fake 2 trades, so there's not enough amount for the next trade left.
     LocalTrade.trades_open.append(trade)
-    LocalTrade.trades_open.append(trade)
     backtesting.wallets.update()
     trade = backtesting._enter_trade(pair, row=row, direction='long')
     assert trade is None
     LocalTrade.trades_open.pop()
     trade = backtesting._enter_trade(pair, row=row, direction='long')
     assert trade is not None
+    LocalTrade.trades_open.pop()
 
     backtesting.strategy.custom_stake_amount = lambda **kwargs: 123.5
     backtesting.wallets.update()
     trade = backtesting._enter_trade(pair, row=row, direction='long')
+    LocalTrade.trades_open.pop()
     assert trade
     assert trade.stake_amount == 123.5
 
     # In case of error - use proposed stake
     backtesting.strategy.custom_stake_amount = lambda **kwargs: 20 / 0
     trade = backtesting._enter_trade(pair, row=row, direction='long')
+    LocalTrade.trades_open.pop()
     assert trade
     assert trade.stake_amount == 495
     assert trade.is_short is False
 
     trade = backtesting._enter_trade(pair, row=row, direction='short')
+    LocalTrade.trades_open.pop()
     assert trade
     assert trade.stake_amount == 495
     assert trade.is_short is True
 
     mocker.patch(f"{EXMS}.get_max_pair_stake_amount", return_value=300.0)
     trade = backtesting._enter_trade(pair, row=row, direction='long')
+    LocalTrade.trades_open.pop()
     assert trade
     assert trade.stake_amount == 300.0
 
diff --git a/tests/optimize/test_backtesting_adjust_position.py b/tests/optimize/test_backtesting_adjust_position.py
--- a/tests/optimize/test_backtesting_adjust_position.py
+++ b/tests/optimize/test_backtesting_adjust_position.py
@@ -213,3 +213,8 @@ def test_backtest_position_adjustment_detailed(default_conf, fee, mocker, levera
     assert trade.nr_of_successful_entries == 2
     assert trade.nr_of_successful_exits == 1
     assert pytest.approx(trade.liquidation_price) == liq_price
+
+    # Adjust to close trade
+    backtesting.strategy.adjust_trade_position = MagicMock(return_value=-trade.stake_amount)
+    trade = backtesting._get_adjust_trade_entry_for_candle(trade, row_exit, current_time)
+    assert trade.is_open is False