diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index eb5536dd0..1b0d556b7 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -1502,10 +1502,10 @@ class Exchange: ticker = self.fetch_ticker(pair) ticker_rate = ticker[price_side] if ticker['last'] and ticker_rate: - if side == 'buy' and ticker_rate > ticker['last']: + if side == 'entry' and ticker_rate > ticker['last']: balance = conf_strategy.get('ask_last_balance', 0.0) ticker_rate = ticker_rate + balance * (ticker['last'] - ticker_rate) - elif side == 'sell' and ticker_rate < ticker['last']: + elif side == 'exit' and ticker_rate < ticker['last']: balance = conf_strategy.get('bid_last_balance', 0.0) ticker_rate = ticker_rate - balance * (ticker_rate - ticker['last']) rate = ticker_rate diff --git a/tests/exchange/test_exchange.py b/tests/exchange/test_exchange.py index 2e09d142d..2faa27417 100644 --- a/tests/exchange/test_exchange.py +++ b/tests/exchange/test_exchange.py @@ -2313,14 +2313,14 @@ def test_get_entry_rate(mocker, default_conf, caplog, side, ask, bid, mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', return_value={'ask': ask, 'last': last, 'bid': bid}) - assert exchange.get_rate('ETH/BTC', refresh=True, side="entry") == expected + assert exchange.get_rate('ETH/BTC', side="entry", is_short=False, refresh=True) == expected assert not log_has("Using cached entry rate for ETH/BTC.", caplog) - assert exchange.get_rate('ETH/BTC', refresh=False, side="entry") == expected + assert exchange.get_rate('ETH/BTC', side="entry", is_short=False, refresh=False) == expected assert log_has("Using cached entry rate for ETH/BTC.", caplog) # Running a 2nd time with Refresh on! caplog.clear() - assert exchange.get_rate('ETH/BTC', refresh=True, side="entry") == expected + assert exchange.get_rate('ETH/BTC', side="entry", is_short=False, refresh=True) == expected assert not log_has("Using cached entry rate for ETH/BTC.", caplog) @@ -2358,14 +2358,14 @@ def test_get_exit_rate(default_conf, mocker, caplog, side, bid, ask, # Test regular mode exchange = get_patched_exchange(mocker, default_conf) - rate = exchange.get_rate(pair, refresh=True, side="sell") - assert not log_has("Using cached sell rate for ETH/BTC.", caplog) + rate = exchange.get_rate(pair, side="exit", is_short=False, refresh=True) + assert not log_has("Using cached exit rate for ETH/BTC.", caplog) assert isinstance(rate, float) assert rate == expected # Use caching - rate = exchange.get_rate(pair, refresh=False, side="sell") + rate = exchange.get_rate(pair, side="exit", is_short=False, refresh=False) assert rate == expected - assert log_has("Using cached sell rate for ETH/BTC.", caplog) + assert log_has("Using cached exit rate for ETH/BTC.", caplog) @pytest.mark.parametrize("entry,is_short,side,ask,bid,last,last_ab,expected", [