validate_whitelist should return the list again
This commit is contained in:
parent
1738633efc
commit
8fd713f3ae
@ -28,13 +28,13 @@ class StaticList(object):
|
|||||||
def blacklist(self) -> List[str]:
|
def blacklist(self) -> List[str]:
|
||||||
return self._blacklist
|
return self._blacklist
|
||||||
|
|
||||||
def refresh_whitelist(self) -> bool:
|
def refresh_whitelist(self) -> None:
|
||||||
"""
|
"""
|
||||||
Refreshes whitelist.
|
Refreshes whitelist.
|
||||||
"""
|
"""
|
||||||
return self.validate_whitelist(self._config['exchange']['pair_whitelist'])
|
self._whitelist = self.validate_whitelist(self._config['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
def validate_whitelist(self, whitelist: List[str]) -> bool:
|
def validate_whitelist(self, whitelist: List[str]) -> List[str]:
|
||||||
"""
|
"""
|
||||||
Check available markets and remove pair from whitelist if necessary
|
Check available markets and remove pair from whitelist if necessary
|
||||||
:param whitelist: the sorted list (based on BaseVolume) of pairs the user might want to
|
:param whitelist: the sorted list (based on BaseVolume) of pairs the user might want to
|
||||||
@ -65,6 +65,4 @@ class StaticList(object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
# We need to remove pairs that are unknown
|
# We need to remove pairs that are unknown
|
||||||
self._whitelist = [x for x in sanitized_whitelist if x in known_pairs]
|
return [x for x in sanitized_whitelist if x in known_pairs]
|
||||||
|
|
||||||
return True
|
|
||||||
|
@ -31,22 +31,21 @@ def test_refresh_market_pair_not_in_whitelist(mocker, markets, whitelist_conf):
|
|||||||
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
||||||
freqtradebot.pairlists.validate_whitelist(
|
freqtradebot.pairlists.refresh_whitelist()
|
||||||
whitelist_conf['exchange']['pair_whitelist'] + ['XXX/BTC']
|
|
||||||
)
|
|
||||||
# List ordered by BaseVolume
|
# List ordered by BaseVolume
|
||||||
whitelist = ['ETH/BTC', 'TKN/BTC']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
# Ensure all except those in whitelist are removed
|
# Ensure all except those in whitelist are removed
|
||||||
assert whitelist == freqtradebot.pairlists.whitelist
|
assert whitelist == freqtradebot.pairlists.whitelist
|
||||||
|
# Ensure config dict hasn't been changed
|
||||||
|
assert (whitelist_conf['exchange']['pair_whitelist'] ==
|
||||||
|
freqtradebot.config['exchange']['pair_whitelist'])
|
||||||
|
|
||||||
|
|
||||||
def test_refresh_whitelist(mocker, markets, whitelist_conf):
|
def test_refresh_whitelist(mocker, markets, whitelist_conf):
|
||||||
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
freqtradebot = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
mocker.patch('freqtrade.exchange.Exchange.get_markets', markets)
|
||||||
freqtradebot.pairlists.validate_whitelist(
|
freqtradebot.pairlists.refresh_whitelist()
|
||||||
whitelist_conf['exchange']['pair_whitelist'])
|
|
||||||
|
|
||||||
# List ordered by BaseVolume
|
# List ordered by BaseVolume
|
||||||
whitelist = ['ETH/BTC', 'TKN/BTC']
|
whitelist = ['ETH/BTC', 'TKN/BTC']
|
||||||
# Ensure all except those in whitelist are removed
|
# Ensure all except those in whitelist are removed
|
||||||
|
Loading…
Reference in New Issue
Block a user