Added ability to keep invalid pairs while expanding expand_pairlist
This commit is contained in:
@@ -505,38 +505,37 @@ def test_validate_pairs(default_conf, mocker): # test exchange.validate_pairs d
|
||||
Exchange(default_conf)
|
||||
|
||||
|
||||
# This cannot happen anymore as expand_pairlist implicitly filters out unavaliablie pairs
|
||||
# def test_validate_pairs_not_available(default_conf, mocker):
|
||||
# api_mock = MagicMock()
|
||||
# type(api_mock).markets = PropertyMock(return_value={
|
||||
# 'XRP/BTC': {'inactive': True, 'base': 'XRP', 'quote': 'BTC'}
|
||||
# })
|
||||
# mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
|
||||
# mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
|
||||
# mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
|
||||
# mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
|
||||
#
|
||||
# with pytest.raises(OperationalException, match=r'not available'):
|
||||
# Exchange(default_conf)
|
||||
#
|
||||
#
|
||||
# def test_validate_pairs_exception(default_conf, mocker, caplog):
|
||||
# caplog.set_level(logging.INFO)
|
||||
# api_mock = MagicMock()
|
||||
# mocker.patch('freqtrade.exchange.Exchange.name', PropertyMock(return_value='Binance'))
|
||||
#
|
||||
# type(api_mock).markets = PropertyMock(return_value={})
|
||||
# mocker.patch('freqtrade.exchange.Exchange._init_ccxt', api_mock)
|
||||
# mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
|
||||
# mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
|
||||
# mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
|
||||
#
|
||||
# with pytest.raises(OperationalException, match=r'Pair ETH/BTC is not available on Binance'):
|
||||
# Exchange(default_conf)
|
||||
#
|
||||
# mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value={}))
|
||||
# Exchange(default_conf)
|
||||
# assert log_has('Unable to validate pairs (assuming they are correct).', caplog)
|
||||
def test_validate_pairs_not_available(default_conf, mocker):
|
||||
api_mock = MagicMock()
|
||||
type(api_mock).markets = PropertyMock(return_value={
|
||||
'XRP/BTC': {'inactive': True, 'base': 'XRP', 'quote': 'BTC'}
|
||||
})
|
||||
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', MagicMock(return_value=api_mock))
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
|
||||
mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
|
||||
|
||||
with pytest.raises(OperationalException, match=r'not available'):
|
||||
Exchange(default_conf)
|
||||
|
||||
|
||||
def test_validate_pairs_exception(default_conf, mocker, caplog):
|
||||
caplog.set_level(logging.INFO)
|
||||
api_mock = MagicMock()
|
||||
mocker.patch('freqtrade.exchange.Exchange.name', PropertyMock(return_value='Binance'))
|
||||
|
||||
type(api_mock).markets = PropertyMock(return_value={})
|
||||
mocker.patch('freqtrade.exchange.Exchange._init_ccxt', api_mock)
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_timeframes')
|
||||
mocker.patch('freqtrade.exchange.Exchange.validate_stakecurrency')
|
||||
mocker.patch('freqtrade.exchange.Exchange._load_async_markets')
|
||||
|
||||
with pytest.raises(OperationalException, match=r'Pair ETH/BTC is not available on Binance'):
|
||||
Exchange(default_conf)
|
||||
|
||||
mocker.patch('freqtrade.exchange.Exchange.markets', PropertyMock(return_value={}))
|
||||
Exchange(default_conf)
|
||||
assert log_has('Unable to validate pairs (assuming they are correct).', caplog)
|
||||
|
||||
|
||||
def test_validate_pairs_restricted(default_conf, mocker, caplog):
|
||||
|
@@ -853,3 +853,35 @@ def test_expand_pairlist(wildcardlist, pairs, expected):
|
||||
expand_pairlist(wildcardlist, pairs)
|
||||
else:
|
||||
assert sorted(expand_pairlist(wildcardlist, pairs)) == sorted(expected)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('wildcardlist,pairs,expected', [
|
||||
(['BTC/USDT'],
|
||||
['BTC/USDT'],
|
||||
['BTC/USDT']),
|
||||
(['BTC/USDT', 'ETH/USDT'],
|
||||
['BTC/USDT', 'ETH/USDT'],
|
||||
['BTC/USDT', 'ETH/USDT']),
|
||||
(['BTC/USDT', 'ETH/USDT'],
|
||||
['BTC/USDT'], ['BTC/USDT', 'ETH/USDT']), # Test one too many
|
||||
(['.*/USDT'],
|
||||
['BTC/USDT', 'ETH/USDT'], ['BTC/USDT', 'ETH/USDT']), # Wildcard simple
|
||||
(['.*C/USDT'],
|
||||
['BTC/USDT', 'ETC/USDT', 'ETH/USDT'], ['BTC/USDT', 'ETC/USDT']), # Wildcard exclude one
|
||||
(['.*UP/USDT', 'BTC/USDT', 'ETH/USDT'],
|
||||
['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'],
|
||||
['BTC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT']), # Wildcard exclude one
|
||||
(['BTC/.*', 'ETH/.*'],
|
||||
['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTC/USD', 'ETH/EUR', 'BTC/GBP'],
|
||||
['BTC/USDT', 'ETH/USDT', 'BTC/USD', 'ETH/EUR', 'BTC/GBP']), # Wildcard exclude one
|
||||
(['*UP/USDT', 'BTC/USDT', 'ETH/USDT'],
|
||||
['BTC/USDT', 'ETC/USDT', 'ETH/USDT', 'BTCUP/USDT', 'XRPUP/USDT', 'XRPDOWN/USDT'],
|
||||
None),
|
||||
(['HELLO/WORLD'], [], ['HELLO/WORLD']) # Invalid pair kept
|
||||
])
|
||||
def test_expand_pairlist_keep_invalid(wildcardlist, pairs, expected):
|
||||
if expected is None:
|
||||
with pytest.raises(ValueError, match=r'Wildcard error in \*UP/USDT,'):
|
||||
expand_pairlist(wildcardlist, pairs, keep_invalid=True)
|
||||
else:
|
||||
assert sorted(expand_pairlist(wildcardlist, pairs, keep_invalid=True)) == sorted(expected)
|
||||
|
Reference in New Issue
Block a user