mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-14 20:23:57 +00:00
feat: enhance data fetching logic with pagination to increase market cap rank limit
This commit is contained in:
parent
12560e983c
commit
3300d25e57
|
@ -5,6 +5,7 @@ Provides dynamic pair list based on Market Cap
|
|||
"""
|
||||
|
||||
import logging
|
||||
import math
|
||||
|
||||
from cachetools import TTLCache
|
||||
|
||||
|
@ -56,8 +57,8 @@ class MarketCapPairList(IPairList):
|
|||
f"You can choose from {category_ids}"
|
||||
)
|
||||
|
||||
if self._max_rank > 250:
|
||||
raise OperationalException("This filter only support marketcap rank up to 250.")
|
||||
if self._max_rank > 1000:
|
||||
raise OperationalException("This filter only support marketcap rank up to 1000.")
|
||||
|
||||
@property
|
||||
def needstickers(self) -> bool:
|
||||
|
@ -165,7 +166,11 @@ class MarketCapPairList(IPairList):
|
|||
data = []
|
||||
|
||||
if not self._categories:
|
||||
data = self._coingecko.get_coins_markets(**default_kwargs)
|
||||
pages_required = math.ceil(self._max_rank / 250)
|
||||
for page in range(1, pages_required + 1):
|
||||
default_kwargs["page"] = page
|
||||
page_data = self._coingecko.get_coins_markets(**default_kwargs)
|
||||
data.extend(page_data)
|
||||
else:
|
||||
for category in self._categories:
|
||||
category_data = self._coingecko.get_coins_markets(
|
||||
|
|
|
@ -2458,10 +2458,10 @@ def test_MarketCapPairList_exceptions(mocker, default_conf_usdt):
|
|||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
default_conf_usdt["pairlists"] = [
|
||||
{"method": "MarketCapPairList", "number_assets": 20, "max_rank": 260}
|
||||
{"method": "MarketCapPairList", "number_assets": 20, "max_rank": 1010}
|
||||
]
|
||||
with pytest.raises(
|
||||
OperationalException, match="This filter only support marketcap rank up to 250."
|
||||
OperationalException, match="This filter only support marketcap rank up to 1000."
|
||||
):
|
||||
PairListManager(exchange, default_conf_usdt)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user