From dc26d0d7ba421cf95e00968a6cf786d5c8224474 Mon Sep 17 00:00:00 2001 From: "Jakub Werner (jakubikan)" Date: Mon, 16 Sep 2024 22:50:08 +0200 Subject: [PATCH 1/3] adding category for MarketCapPairList.py --- freqtrade/plugins/pairlist/MarketCapPairList.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/freqtrade/plugins/pairlist/MarketCapPairList.py b/freqtrade/plugins/pairlist/MarketCapPairList.py index 95f0e2805..e865a2ea5 100644 --- a/freqtrade/plugins/pairlist/MarketCapPairList.py +++ b/freqtrade/plugins/pairlist/MarketCapPairList.py @@ -35,6 +35,7 @@ class MarketCapPairList(IPairList): self._number_assets = self._pairlistconfig["number_assets"] self._max_rank = self._pairlistconfig.get("max_rank", 30) self._refresh_period = self._pairlistconfig.get("refresh_period", 86400) + self._category = self._pairlistconfig.get("category", None) self._marketcap_cache: TTLCache = TTLCache(maxsize=1, ttl=self._refresh_period) self._def_candletype = self._config["candle_type_def"] @@ -85,6 +86,12 @@ class MarketCapPairList(IPairList): "description": "Max rank of assets", "help": "Maximum rank of assets to use from the pairlist", }, + "category": { + "type": "string", + "default": None, + "description": "The Category", + "help": "Th Category of the coin e.g layer-1 default None", + }, "refresh_period": { "type": "number", "default": 86400, @@ -133,6 +140,9 @@ class MarketCapPairList(IPairList): marketcap_list = self._marketcap_cache.get("marketcap") if marketcap_list is None: + # categories = self._coingecko.get_coins_categories() + # print([cat['id'] for cat in categories]) + data = self._coingecko.get_coins_markets( vs_currency="usd", order="market_cap_desc", @@ -140,6 +150,7 @@ class MarketCapPairList(IPairList): page="1", sparkline="false", locale="en", + **({"category": self._category} if self._category else {}) ) if data: marketcap_list = [row["symbol"] for row in data] @@ -153,11 +164,11 @@ class MarketCapPairList(IPairList): if market == "futures": pair_format += f":{self._stake_currency.upper()}" - top_marketcap = marketcap_list[: self._max_rank :] + top_marketcap = marketcap_list[: self._max_rank:] for mc_pair in top_marketcap: test_pair = f"{mc_pair.upper()}/{pair_format}" - if test_pair in pairlist: + if test_pair in pairlist and test_pair not in filtered_pairlist: filtered_pairlist.append(test_pair) if len(filtered_pairlist) == self._number_assets: break From 92af01b0cba577a7877d236025786cc039c894b5 Mon Sep 17 00:00:00 2001 From: "Jakub Werner (jakubikan)" Date: Mon, 16 Sep 2024 22:51:42 +0200 Subject: [PATCH 2/3] adding category for MarketCapPairList.py --- freqtrade/plugins/pairlist/MarketCapPairList.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/freqtrade/plugins/pairlist/MarketCapPairList.py b/freqtrade/plugins/pairlist/MarketCapPairList.py index e865a2ea5..25e0c21b7 100644 --- a/freqtrade/plugins/pairlist/MarketCapPairList.py +++ b/freqtrade/plugins/pairlist/MarketCapPairList.py @@ -34,9 +34,11 @@ class MarketCapPairList(IPairList): self._stake_currency = self._config["stake_currency"] self._number_assets = self._pairlistconfig["number_assets"] self._max_rank = self._pairlistconfig.get("max_rank", 30) - self._refresh_period = self._pairlistconfig.get("refresh_period", 86400) + self._refresh_period = self._pairlistconfig.get( + "refresh_period", 86400) self._category = self._pairlistconfig.get("category", None) - self._marketcap_cache: TTLCache = TTLCache(maxsize=1, ttl=self._refresh_period) + self._marketcap_cache: TTLCache = TTLCache( + maxsize=1, ttl=self._refresh_period) self._def_candletype = self._config["candle_type_def"] _coingecko_config = self._config.get("coingecko", {}) @@ -47,7 +49,8 @@ class MarketCapPairList(IPairList): ) if self._max_rank > 250: - raise OperationalException("This filter only support marketcap rank up to 250.") + raise OperationalException( + "This filter only support marketcap rank up to 250.") @property def needstickers(self) -> bool: From 0b7cb2a1a81c575885e4352b91a40d17d8f1c944 Mon Sep 17 00:00:00 2001 From: "Jakub Werner (jakubikan)" Date: Mon, 16 Sep 2024 22:52:26 +0200 Subject: [PATCH 3/3] cleanup --- freqtrade/plugins/pairlist/MarketCapPairList.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/freqtrade/plugins/pairlist/MarketCapPairList.py b/freqtrade/plugins/pairlist/MarketCapPairList.py index 25e0c21b7..05f2e6a0a 100644 --- a/freqtrade/plugins/pairlist/MarketCapPairList.py +++ b/freqtrade/plugins/pairlist/MarketCapPairList.py @@ -143,8 +143,6 @@ class MarketCapPairList(IPairList): marketcap_list = self._marketcap_cache.get("marketcap") if marketcap_list is None: - # categories = self._coingecko.get_coins_categories() - # print([cat['id'] for cat in categories]) data = self._coingecko.get_coins_markets( vs_currency="usd",