diff --git a/freqtrade/optimize/backtesting.py b/freqtrade/optimize/backtesting.py index cf499d4e2..267827a2c 100644 --- a/freqtrade/optimize/backtesting.py +++ b/freqtrade/optimize/backtesting.py @@ -429,7 +429,7 @@ class Backtesting: # - (Expected abs profit - open_rate - open_fee) / (fee_close -1) roi_rate = trade.open_rate * roi / leverage open_fee_rate = side_1 * trade.open_rate * (1 + side_1 * trade.fee_open) - close_rate = -side_1 * (roi_rate + open_fee_rate) / (trade.fee_close - side_1 * 1) + close_rate = -(roi_rate + open_fee_rate) / (trade.fee_close - side_1 * 1) if is_short: is_new_roi = sell_row[OPEN_IDX] < close_rate else: diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 975e9d41f..179db1313 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -869,7 +869,7 @@ class IStrategy(ABC, HyperStrategyMixin): force_stoploss=force_stoploss, low=low, high=high) # Set current rate to high for backtesting sell - current_rate = high or rate + current_rate = (low if trade.is_short else high) or rate current_profit = trade.calc_profit_ratio(current_rate) # if enter signal and ignore_roi is set, we don't need to evaluate min_roi.