diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 53477f0ca..a73a2e98f 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -798,8 +798,11 @@ class FreqtradeBot(object): if sell_reason in (SellType.STOP_LOSS, SellType.TRAILING_STOP_LOSS): sell_type = 'stoploss' - if self.config.get('dry_run', False) and sell_type == 'stoploss' and self.strategy.order_types['stoploss_on_exchange']: - limit = trade.stop_loss + # if stoploss is on exchange and we are on dry_run mode, + # we consider the sell price stop price + if self.config.get('dry_run', False) and sell_type == 'stoploss' \ + and self.strategy.order_types['stoploss_on_exchange']: + limit = trade.stop_loss # First cancelling stoploss on exchange ... if self.strategy.order_types.get('stoploss_on_exchange') and trade.stoploss_order_id: diff --git a/freqtrade/tests/test_freqtradebot.py b/freqtrade/tests/test_freqtradebot.py index fb42dd518..912adacaf 100644 --- a/freqtrade/tests/test_freqtradebot.py +++ b/freqtrade/tests/test_freqtradebot.py @@ -1516,8 +1516,9 @@ def test_execute_sell_up(default_conf, ticker, fee, ticker_sell_up, markets, moc } == last_msg -def test_execute_sell_down_live(default_conf, ticker, fee, - ticker_sell_down, markets, mocker) -> None: +def test_execute_sell_down(default_conf, ticker, fee, + ticker_sell_down, markets, mocker) -> None: + rpc_mock = patch_RPCManager(mocker) mocker.patch.multiple( 'freqtrade.exchange.Exchange', @@ -1540,7 +1541,7 @@ def test_execute_sell_down_live(default_conf, ticker, fee, 'freqtrade.exchange.Exchange', get_ticker=ticker_sell_down ) - default_conf['dry_run'] = False + freqtrade.execute_sell(trade=trade, limit=ticker_sell_down()['bid'], sell_reason=SellType.STOP_LOSS)