Add tests for PriceFilter
This commit is contained in:
parent
c78199d3d9
commit
5c2481082e
@ -590,34 +590,58 @@ def test_agefilter_caching(mocker, markets, whitelist_conf_3, tickers, ohlcv_his
|
|||||||
assert freqtrade.exchange.get_historic_ohlcv.call_count == previous_call_count
|
assert freqtrade.exchange.get_historic_ohlcv.call_count == previous_call_count
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("pairlistconfig,expected", [
|
@pytest.mark.parametrize("pairlistconfig,desc_expected,exception_expected", [
|
||||||
({"method": "PriceFilter", "low_price_ratio": 0.001, "min_price": 0.00000010,
|
({"method": "PriceFilter", "low_price_ratio": 0.001, "min_price": 0.00000010,
|
||||||
"max_price": 1.0}, "[{'PriceFilter': 'PriceFilter - Filtering pairs priced below "
|
"max_price": 1.0},
|
||||||
"0.1% or below 0.00000010 or above 1.00000000.'}]"
|
"[{'PriceFilter': 'PriceFilter - Filtering pairs priced below "
|
||||||
),
|
"0.1% or below 0.00000010 or above 1.00000000.'}]",
|
||||||
|
None
|
||||||
|
),
|
||||||
({"method": "PriceFilter", "low_price_ratio": 0.001, "min_price": 0.00000010},
|
({"method": "PriceFilter", "low_price_ratio": 0.001, "min_price": 0.00000010},
|
||||||
"[{'PriceFilter': 'PriceFilter - Filtering pairs priced below 0.1% or below 0.00000010.'}]"
|
"[{'PriceFilter': 'PriceFilter - Filtering pairs priced below 0.1% or below 0.00000010.'}]",
|
||||||
),
|
None
|
||||||
|
),
|
||||||
({"method": "PriceFilter", "low_price_ratio": 0.001, "max_price": 1.00010000},
|
({"method": "PriceFilter", "low_price_ratio": 0.001, "max_price": 1.00010000},
|
||||||
"[{'PriceFilter': 'PriceFilter - Filtering pairs priced below 0.1% or above 1.00010000.'}]"
|
"[{'PriceFilter': 'PriceFilter - Filtering pairs priced below 0.1% or above 1.00010000.'}]",
|
||||||
),
|
None
|
||||||
|
),
|
||||||
({"method": "PriceFilter", "min_price": 0.00002000},
|
({"method": "PriceFilter", "min_price": 0.00002000},
|
||||||
"[{'PriceFilter': 'PriceFilter - Filtering pairs priced below 0.00002000.'}]"
|
"[{'PriceFilter': 'PriceFilter - Filtering pairs priced below 0.00002000.'}]",
|
||||||
),
|
None
|
||||||
|
),
|
||||||
({"method": "PriceFilter"},
|
({"method": "PriceFilter"},
|
||||||
"[{'PriceFilter': 'PriceFilter - No price filters configured.'}]"
|
"[{'PriceFilter': 'PriceFilter - No price filters configured.'}]",
|
||||||
),
|
None
|
||||||
|
),
|
||||||
|
({"method": "PriceFilter", "low_price_ratio": -0.001},
|
||||||
|
None,
|
||||||
|
"PriceFilter requires low_price_ratio be >= 0"
|
||||||
|
), # OperationalException expected
|
||||||
|
({"method": "PriceFilter", "min_price": -0.00000010},
|
||||||
|
None,
|
||||||
|
"PriceFilter requires min_price be >= 0"
|
||||||
|
), # OperationalException expected
|
||||||
|
({"method": "PriceFilter", "max_price": -1.00010000},
|
||||||
|
None,
|
||||||
|
"PriceFilter requires max_price be >= 0"
|
||||||
|
), # OperationalException expected
|
||||||
])
|
])
|
||||||
def test_pricefilter_desc(mocker, whitelist_conf, markets, pairlistconfig, expected):
|
def test_pricefilter_desc(mocker, whitelist_conf, markets, pairlistconfig,
|
||||||
|
desc_expected, exception_expected):
|
||||||
mocker.patch.multiple('freqtrade.exchange.Exchange',
|
mocker.patch.multiple('freqtrade.exchange.Exchange',
|
||||||
markets=PropertyMock(return_value=markets),
|
markets=PropertyMock(return_value=markets),
|
||||||
exchange_has=MagicMock(return_value=True)
|
exchange_has=MagicMock(return_value=True)
|
||||||
)
|
)
|
||||||
whitelist_conf['pairlists'] = [pairlistconfig]
|
whitelist_conf['pairlists'] = [pairlistconfig]
|
||||||
|
|
||||||
freqtrade = get_patched_freqtradebot(mocker, whitelist_conf)
|
if desc_expected is not None:
|
||||||
short_desc = str(freqtrade.pairlists.short_desc())
|
freqtrade = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
assert short_desc == expected
|
short_desc = str(freqtrade.pairlists.short_desc())
|
||||||
|
assert short_desc == desc_expected
|
||||||
|
else: # # OperationalException expected
|
||||||
|
with pytest.raises(OperationalException,
|
||||||
|
match=exception_expected):
|
||||||
|
freqtrade = get_patched_freqtradebot(mocker, whitelist_conf)
|
||||||
|
|
||||||
|
|
||||||
def test_pairlistmanager_no_pairlist(mocker, markets, whitelist_conf, caplog):
|
def test_pairlistmanager_no_pairlist(mocker, markets, whitelist_conf, caplog):
|
||||||
|
Loading…
Reference in New Issue
Block a user