parent
60b476611c
commit
8a9407bac9
@ -1038,7 +1038,7 @@ class Exchange:
|
|||||||
logger.debug(f"Using Last {conf_strategy['price_side'].capitalize()} / Last Price")
|
logger.debug(f"Using Last {conf_strategy['price_side'].capitalize()} / Last Price")
|
||||||
ticker = self.fetch_ticker(pair)
|
ticker = self.fetch_ticker(pair)
|
||||||
ticker_rate = ticker[conf_strategy['price_side']]
|
ticker_rate = ticker[conf_strategy['price_side']]
|
||||||
if ticker['last']:
|
if ticker['last'] and ticker_rate:
|
||||||
if side == 'buy' and ticker_rate > ticker['last']:
|
if side == 'buy' and ticker_rate > ticker['last']:
|
||||||
balance = conf_strategy['ask_last_balance']
|
balance = conf_strategy['ask_last_balance']
|
||||||
ticker_rate = ticker_rate + balance * (ticker['last'] - ticker_rate)
|
ticker_rate = ticker_rate + balance * (ticker['last'] - ticker_rate)
|
||||||
|
@ -1851,6 +1851,31 @@ def test_get_sell_rate(default_conf, mocker, caplog, side, bid, ask,
|
|||||||
assert log_has("Using cached sell rate for ETH/BTC.", caplog)
|
assert log_has("Using cached sell rate for ETH/BTC.", caplog)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("entry,side,ask,bid,last,last_ab,expected", [
|
||||||
|
('buy', 'ask', None, 4, 4, 0, 4), # ask not available
|
||||||
|
('buy', 'ask', None, None, 4, 0, 4), # ask not available
|
||||||
|
('buy', 'bid', 6, None, 4, 0, 5), # bid not available
|
||||||
|
('buy', 'bid', None, None, 4, 0, 5), # No rate available
|
||||||
|
('sell', 'ask', None, 4, 4, 0, 4), # ask not available
|
||||||
|
('sell', 'ask', None, None, 4, 0, 4), # ask not available
|
||||||
|
('sell', 'bid', 6, None, 4, 0, 5), # bid not available
|
||||||
|
('sell', 'bid', None, None, 4, 0, 5), # bid not available
|
||||||
|
])
|
||||||
|
def test_get_ticker_rate_error(mocker, entry, default_conf, caplog, side, ask, bid,
|
||||||
|
last, last_ab, expected) -> None:
|
||||||
|
caplog.set_level(logging.DEBUG)
|
||||||
|
default_conf['bid_strategy']['ask_last_balance'] = last_ab
|
||||||
|
default_conf['bid_strategy']['price_side'] = side
|
||||||
|
default_conf['ask_strategy']['price_side'] = side
|
||||||
|
default_conf['ask_strategy']['ask_last_balance'] = last_ab
|
||||||
|
exchange = get_patched_exchange(mocker, default_conf)
|
||||||
|
mocker.patch('freqtrade.exchange.Exchange.fetch_ticker',
|
||||||
|
return_value={'ask': ask, 'last': last, 'bid': bid})
|
||||||
|
|
||||||
|
with pytest.raises(PricingError):
|
||||||
|
exchange.get_rate('ETH/BTC', refresh=True, side=entry)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('side,expected', [
|
@pytest.mark.parametrize('side,expected', [
|
||||||
('bid', 0.043936), # Value from order_book_l2 fiture - bids side
|
('bid', 0.043936), # Value from order_book_l2 fiture - bids side
|
||||||
('ask', 0.043949), # Value from order_book_l2 fiture - asks side
|
('ask', 0.043949), # Value from order_book_l2 fiture - asks side
|
||||||
|
Loading…
Reference in New Issue
Block a user