mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 12:13:57 +00:00
chore: add warning when max_rank exceeds 250 in MarketCapPairList
This commit is contained in:
parent
00318be59f
commit
7b471d59c5
|
@ -6,6 +6,7 @@ Provides dynamic pair list based on Market Cap
|
|||
|
||||
import logging
|
||||
import math
|
||||
import warnings
|
||||
|
||||
from cachetools import TTLCache
|
||||
|
||||
|
@ -57,8 +58,11 @@ class MarketCapPairList(IPairList):
|
|||
f"You can choose from {category_ids}"
|
||||
)
|
||||
|
||||
if self._max_rank > 1000:
|
||||
raise OperationalException("This filter only support marketcap rank up to 1000.")
|
||||
if self._max_rank > 250:
|
||||
self.logger.warning(
|
||||
f"The max rank you have set ({self._max_rank}) is quite high. "
|
||||
"Please ensure this value is appropriate for your use case.",
|
||||
)
|
||||
|
||||
@property
|
||||
def needstickers(self) -> bool:
|
||||
|
|
|
@ -2450,7 +2450,7 @@ def test_MarketCapPairList_filter_special_no_pair_from_coingecko(
|
|||
assert pm.whitelist == []
|
||||
|
||||
|
||||
def test_MarketCapPairList_exceptions(mocker, default_conf_usdt):
|
||||
def test_MarketCapPairList_exceptions(mocker, default_conf_usdt, caplog):
|
||||
exchange = get_patched_exchange(mocker, default_conf_usdt)
|
||||
default_conf_usdt["pairlists"] = [{"method": "MarketCapPairList"}]
|
||||
with pytest.raises(OperationalException, match=r"`number_assets` not specified.*"):
|
||||
|
@ -2458,13 +2458,11 @@ def test_MarketCapPairList_exceptions(mocker, default_conf_usdt):
|
|||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
default_conf_usdt["pairlists"] = [
|
||||
{"method": "MarketCapPairList", "number_assets": 20, "max_rank": 1010}
|
||||
{"method": "MarketCapPairList", "number_assets": 20, "max_rank": 500}
|
||||
]
|
||||
with pytest.raises(
|
||||
OperationalException, match="This filter only support marketcap rank up to 1000."
|
||||
):
|
||||
with caplog.at_level(logging.WARNING):
|
||||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
assert log_has_re("The max rank you have set \\(500\\) is quite high", caplog)
|
||||
# Test invalid coinmarkets list
|
||||
mocker.patch(
|
||||
"freqtrade.plugins.pairlist.MarketCapPairList.FtCoinGeckoApi.get_coins_categories_list",
|
||||
|
|
Loading…
Reference in New Issue
Block a user