mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Verify sell-rate got a value - otherwise downstream code does not work.
Using PricingException here will cease operation for this pair for this iteration - postponing handling to the next iteration - where hopefully a price is again present.
This commit is contained in:
parent
84c50bf16c
commit
c35f9f8d39
|
@ -676,6 +676,8 @@ class FreqtradeBot:
|
||||||
raise PricingError from e
|
raise PricingError from e
|
||||||
else:
|
else:
|
||||||
rate = self.exchange.fetch_ticker(pair)[ask_strategy['price_side']]
|
rate = self.exchange.fetch_ticker(pair)[ask_strategy['price_side']]
|
||||||
|
if rate is None:
|
||||||
|
raise PricingError(f"Sell-Rate for {pair} was empty.")
|
||||||
self._sell_rate_cache[pair] = rate
|
self._sell_rate_cache[pair] = rate
|
||||||
return rate
|
return rate
|
||||||
|
|
||||||
|
|
|
@ -3931,6 +3931,26 @@ def test_get_sell_rate_orderbook_exception(default_conf, mocker, caplog):
|
||||||
assert log_has("Sell Price at location from orderbook could not be determined.", caplog)
|
assert log_has("Sell Price at location from orderbook could not be determined.", caplog)
|
||||||
|
|
||||||
|
|
||||||
|
def test_get_sell_rate_exception(default_conf, mocker, caplog):
|
||||||
|
# Ticker on one side can be empty in certain circumstances.
|
||||||
|
default_conf['ask_strategy']['price_side'] = 'ask'
|
||||||
|
pair = "ETH/BTC"
|
||||||
|
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', return_value={'ask': None, 'bid': 0.12})
|
||||||
|
ft = get_patched_freqtradebot(mocker, default_conf)
|
||||||
|
with pytest.raises(PricingError, match=r"Sell-Rate for ETH/BTC was empty."):
|
||||||
|
ft.get_sell_rate(pair, True)
|
||||||
|
|
||||||
|
ft.config['ask_strategy']['price_side'] = 'bid'
|
||||||
|
assert ft.get_sell_rate(pair, True) == 0.12
|
||||||
|
# Reverse sides
|
||||||
|
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker', return_value={'ask': 0.13, 'bid': None})
|
||||||
|
with pytest.raises(PricingError, match=r"Sell-Rate for ETH/BTC was empty."):
|
||||||
|
ft.get_sell_rate(pair, True)
|
||||||
|
|
||||||
|
ft.config['ask_strategy']['price_side'] = 'ask'
|
||||||
|
assert ft.get_sell_rate(pair, True) == 0.13
|
||||||
|
|
||||||
|
|
||||||
def test_startup_state(default_conf, mocker):
|
def test_startup_state(default_conf, mocker):
|
||||||
default_conf['pairlist'] = {'method': 'VolumePairList',
|
default_conf['pairlist'] = {'method': 'VolumePairList',
|
||||||
'config': {'number_assets': 20}
|
'config': {'number_assets': 20}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user