Update remaining tests

This commit is contained in:
Matthias 2022-03-28 19:30:14 +02:00
parent cee09493be
commit d7c6520268
2 changed files with 9 additions and 9 deletions

View File

@ -1502,10 +1502,10 @@ class Exchange:
ticker = self.fetch_ticker(pair) ticker = self.fetch_ticker(pair)
ticker_rate = ticker[price_side] ticker_rate = ticker[price_side]
if ticker['last'] and ticker_rate: 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) balance = conf_strategy.get('ask_last_balance', 0.0)
ticker_rate = ticker_rate + balance * (ticker['last'] - ticker_rate) 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) balance = conf_strategy.get('bid_last_balance', 0.0)
ticker_rate = ticker_rate - balance * (ticker_rate - ticker['last']) ticker_rate = ticker_rate - balance * (ticker_rate - ticker['last'])
rate = ticker_rate rate = ticker_rate

View File

@ -2313,14 +2313,14 @@ def test_get_entry_rate(mocker, default_conf, caplog, side, ask, bid,
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
return_value={'ask': ask, 'last': last, 'bid': bid}) 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 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) assert log_has("Using cached entry rate for ETH/BTC.", caplog)
# Running a 2nd time with Refresh on! # Running a 2nd time with Refresh on!
caplog.clear() 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) 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 # Test regular mode
exchange = get_patched_exchange(mocker, default_conf) exchange = get_patched_exchange(mocker, default_conf)
rate = exchange.get_rate(pair, refresh=True, side="sell") rate = exchange.get_rate(pair, side="exit", is_short=False, refresh=True)
assert not log_has("Using cached sell rate for ETH/BTC.", caplog) assert not log_has("Using cached exit rate for ETH/BTC.", caplog)
assert isinstance(rate, float) assert isinstance(rate, float)
assert rate == expected assert rate == expected
# Use caching # 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 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", [ @pytest.mark.parametrize("entry,is_short,side,ask,bid,last,last_ab,expected", [