Improve tests for pairlist-sequence behaviour
This commit is contained in:
parent
7ff61f12e9
commit
5caeca7509
@ -100,13 +100,14 @@ This is a simple provider, which however serves as a good example on how to star
|
|||||||
|
|
||||||
Next, modify the classname of the provider (ideally align this with the Filename).
|
Next, modify the classname of the provider (ideally align this with the Filename).
|
||||||
|
|
||||||
The base-class provides an instance of the exchange (`self._exchange`) the pairlist manager (`self._pairlistmanager`), as well as the main configuration (`self._config`) and the pairlist dedicated configuration (`self._pairlistconfig`).
|
The base-class provides an instance of the exchange (`self._exchange`) the pairlist manager (`self._pairlistmanager`), as well as the main configuration (`self._config`), the pairlist dedicated configuration (`self._pairlistconfig`) and the absolute position within the list of pairlists.
|
||||||
|
|
||||||
```python
|
```python
|
||||||
self._freqtrade = freqtrade
|
self._exchange = exchange
|
||||||
|
self._pairlistmanager = pairlistmanager
|
||||||
self._config = config
|
self._config = config
|
||||||
self._whitelist = self._config['exchange']['pair_whitelist']
|
self._pairlistconfig = pairlistconfig
|
||||||
self._blacklist = self._config['exchange'].get('pair_blacklist', [])
|
self._pairlist_pos = pairlist_pos
|
||||||
```
|
```
|
||||||
|
|
||||||
Now, let's step through the methods which require actions:
|
Now, let's step through the methods which require actions:
|
||||||
|
@ -135,25 +135,44 @@ def test_VolumePairList_refresh_empty(mocker, markets_empty, whitelist_conf):
|
|||||||
assert set(whitelist) == set(pairslist)
|
assert set(whitelist) == set(pairslist)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("filters,base_currency,key,whitelist_result", [
|
@pytest.mark.parametrize("pairlists,base_currency,whitelist_result", [
|
||||||
([], "BTC", "quoteVolume", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'HOT/BTC', 'FUEL/BTC']),
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "quoteVolume"}}],
|
||||||
([], "BTC", "bidVolume", ['LTC/BTC', 'TKN/BTC', 'ETH/BTC', 'HOT/BTC', 'FUEL/BTC']),
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'HOT/BTC', 'FUEL/BTC']),
|
||||||
([], "USDT", "quoteVolume", ['ETH/USDT']),
|
# Different sorting depending on quote or bid volume
|
||||||
([], "ETH", "quoteVolume", []),
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "bidVolume"}}],
|
||||||
([{"method": "PrecisionFilter"}], "BTC",
|
"BTC", ['HOT/BTC', 'FUEL/BTC', 'LTC/BTC', 'TKN/BTC', 'ETH/BTC']),
|
||||||
"quoteVolume", ["LTC/BTC", "ETH/BTC", "TKN/BTC", 'FUEL/BTC']),
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "quoteVolume"}}],
|
||||||
([{"method": "PrecisionFilter"}],
|
"USDT", ['ETH/USDT']),
|
||||||
"BTC", "bidVolume", ["LTC/BTC", "TKN/BTC", "ETH/BTC", 'FUEL/BTC']),
|
# No pair for ETH ...
|
||||||
([{"method": "LowPriceFilter", "config": {"low_price_percent": 0.03}}],
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "quoteVolume"}}],
|
||||||
"BTC", "bidVolume", ['LTC/BTC', 'TKN/BTC', 'ETH/BTC', 'FUEL/BTC']),
|
"ETH", []),
|
||||||
|
# Precisionfilter and quote volume
|
||||||
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "quoteVolume"}},
|
||||||
|
{"method": "PrecisionFilter"}], "BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'FUEL/BTC']),
|
||||||
|
# Precisionfilter bid
|
||||||
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "bidVolume"}},
|
||||||
|
{"method": "PrecisionFilter"}], "BTC", ['FUEL/BTC', 'LTC/BTC', 'TKN/BTC', 'ETH/BTC']),
|
||||||
|
# Lowpricefilter and VolumePairList
|
||||||
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "quoteVolume"}},
|
||||||
|
{"method": "LowPriceFilter", "config": {"low_price_percent": 0.03}}],
|
||||||
|
"BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC', 'FUEL/BTC']),
|
||||||
# Hot is removed by precision_filter, Fuel by low_price_filter.
|
# Hot is removed by precision_filter, Fuel by low_price_filter.
|
||||||
([{"method": "PrecisionFilter"},
|
([{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "quoteVolume"}},
|
||||||
|
{"method": "PrecisionFilter"},
|
||||||
{"method": "LowPriceFilter", "config": {"low_price_percent": 0.02}}
|
{"method": "LowPriceFilter", "config": {"low_price_percent": 0.02}}
|
||||||
], "BTC", "bidVolume", ['LTC/BTC', 'TKN/BTC', 'ETH/BTC'])])
|
], "BTC", ['ETH/BTC', 'TKN/BTC', 'LTC/BTC']),
|
||||||
|
# StaticPairlist Only
|
||||||
|
([{"method": "StaticPairList"},
|
||||||
|
], "BTC", ['ETH/BTC', 'TKN/BTC']),
|
||||||
|
# Static Pairlist before VolumePairList - sorting changes
|
||||||
|
([{"method": "StaticPairList"},
|
||||||
|
{"method": "VolumePairList", "config": {"number_assets": 5, "sort_key": "bidVolume"}},
|
||||||
|
], "BTC", ['TKN/BTC', 'ETH/BTC']),
|
||||||
|
])
|
||||||
def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, tickers,
|
def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, tickers,
|
||||||
filters, base_currency, key, whitelist_result,
|
pairlists, base_currency, whitelist_result,
|
||||||
caplog) -> None:
|
caplog) -> None:
|
||||||
whitelist_conf['pairlists'].extend(filters)
|
whitelist_conf['pairlists'] = pairlists
|
||||||
|
|
||||||
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
|
mocker.patch('freqtrade.exchange.Exchange.exchange_has', MagicMock(return_value=True))
|
||||||
freqtrade = get_patched_freqtradebot(mocker, whitelist_conf)
|
freqtrade = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
@ -167,13 +186,13 @@ def test_VolumePairList_whitelist_gen(mocker, whitelist_conf, shitcoinmarkets, t
|
|||||||
freqtrade.pairlists.refresh_pairlist()
|
freqtrade.pairlists.refresh_pairlist()
|
||||||
whitelist = freqtrade.pairlists.whitelist
|
whitelist = freqtrade.pairlists.whitelist
|
||||||
|
|
||||||
assert sorted(whitelist) == sorted(whitelist_result)
|
assert whitelist == whitelist_result
|
||||||
if 'PrecisionFilter' in filters:
|
for pairlist in pairlists:
|
||||||
assert log_has_re(r'^Removed .* from whitelist, because stop price .* '
|
if pairlist['method'] == 'PrecisionFilter':
|
||||||
r'would be <= stop limit.*', caplog)
|
assert log_has_re(r'^Removed .* from whitelist, because stop price .* '
|
||||||
|
r'would be <= stop limit.*', caplog)
|
||||||
if 'LowPriceFilter' in filters:
|
if pairlist['method'] == 'LowPriceFilter':
|
||||||
assert log_has_re(r'^Removed .* from whitelist, because 1 unit is .*%$', caplog)
|
assert log_has_re(r'^Removed .* from whitelist, because 1 unit is .*%$', caplog)
|
||||||
|
|
||||||
|
|
||||||
def test_gen_pair_whitelist_not_supported(mocker, default_conf, tickers) -> None:
|
def test_gen_pair_whitelist_not_supported(mocker, default_conf, tickers) -> None:
|
||||||
|
Loading…
Reference in New Issue
Block a user