Some minor cleanup and improved test coverage

This commit is contained in:
Matthias 2021-08-02 07:15:09 +02:00
parent 059c32b067
commit b63eda3a2b
2 changed files with 16 additions and 3 deletions

View File

@ -51,9 +51,12 @@ class RangeStabilityFilter(IPairList):
""" """
Short whitelist method description - used for startup-messages Short whitelist method description - used for startup-messages
""" """
max_rate_desc = ""
if self._max_rate_of_change:
max_rate_desc = (f" and above {self._max_rate_of_change}")
return (f"{self.name} - Filtering pairs with rate of change below " return (f"{self.name} - Filtering pairs with rate of change below "
f"{self._min_rate_of_change} and above " f"{self._min_rate_of_change}{max_rate_desc} over the "
f"{self._max_rate_of_change} over the last {plural(self._days, 'day')}.") f"last {plural(self._days, 'day')}.")
def filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]: def filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]:
""" """

View File

@ -425,8 +425,12 @@ def test_VolumePairList_refresh_empty(mocker, markets_empty, whitelist_conf):
"USDT", ['NANO/USDT']), "USDT", ['NANO/USDT']),
([{"method": "StaticPairList"}, ([{"method": "StaticPairList"},
{"method": "RangeStabilityFilter", "lookback_days": 10, {"method": "RangeStabilityFilter", "lookback_days": 10,
"min_rate_of_change": 0.01, "max_rate_of_change": 0.99, "refresh_period": 1440}], "min_rate_of_change": 0.01, "refresh_period": 1440}],
"BTC", ['ETH/BTC', 'TKN/BTC', 'HOT/BTC']), "BTC", ['ETH/BTC', 'TKN/BTC', 'HOT/BTC']),
([{"method": "StaticPairList"},
{"method": "RangeStabilityFilter", "lookback_days": 10,
"max_rate_of_change": 0.01, "refresh_period": 1440}],
"BTC", []), # All removed because of max_rate_of_change being 0.017
([{"method": "StaticPairList"}, ([{"method": "StaticPairList"},
{"method": "VolatilityFilter", "lookback_days": 3, {"method": "VolatilityFilter", "lookback_days": 3,
"min_volatility": 0.002, "max_volatility": 0.004, "refresh_period": 1440}], "min_volatility": 0.002, "max_volatility": 0.004, "refresh_period": 1440}],
@ -985,6 +989,12 @@ def test_spreadfilter_invalid_data(mocker, default_conf, markets, tickers, caplo
None, None,
"PriceFilter requires max_value to be >= 0" "PriceFilter requires max_value to be >= 0"
), # OperationalException expected ), # OperationalException expected
({"method": "RangeStabilityFilter", "lookback_days": 10,
"min_rate_of_change": 0.01},
"[{'RangeStabilityFilter': 'RangeStabilityFilter - Filtering pairs with rate of change below "
"0.01 over the last days.'}]",
None
),
({"method": "RangeStabilityFilter", "lookback_days": 10, ({"method": "RangeStabilityFilter", "lookback_days": 10,
"min_rate_of_change": 0.01, "max_rate_of_change": 0.99}, "min_rate_of_change": 0.01, "max_rate_of_change": 0.99},
"[{'RangeStabilityFilter': 'RangeStabilityFilter - Filtering pairs with rate of change below " "[{'RangeStabilityFilter': 'RangeStabilityFilter - Filtering pairs with rate of change below "