mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
Compare commits
3 Commits
0b7cb2a1a8
...
50f07e7b11
Author | SHA1 | Date | |
---|---|---|---|
|
50f07e7b11 | ||
|
660623181a | ||
|
03ee3aaf40 |
|
@ -34,11 +34,9 @@ class MarketCapPairList(IPairList):
|
||||||
self._stake_currency = self._config["stake_currency"]
|
self._stake_currency = self._config["stake_currency"]
|
||||||
self._number_assets = self._pairlistconfig["number_assets"]
|
self._number_assets = self._pairlistconfig["number_assets"]
|
||||||
self._max_rank = self._pairlistconfig.get("max_rank", 30)
|
self._max_rank = self._pairlistconfig.get("max_rank", 30)
|
||||||
self._refresh_period = self._pairlistconfig.get(
|
self._refresh_period = self._pairlistconfig.get("refresh_period", 86400)
|
||||||
"refresh_period", 86400)
|
|
||||||
self._category = self._pairlistconfig.get("category", None)
|
self._category = self._pairlistconfig.get("category", None)
|
||||||
self._marketcap_cache: TTLCache = TTLCache(
|
self._marketcap_cache: TTLCache = TTLCache(maxsize=1, ttl=self._refresh_period)
|
||||||
maxsize=1, ttl=self._refresh_period)
|
|
||||||
self._def_candletype = self._config["candle_type_def"]
|
self._def_candletype = self._config["candle_type_def"]
|
||||||
|
|
||||||
_coingecko_config = self._config.get("coingecko", {})
|
_coingecko_config = self._config.get("coingecko", {})
|
||||||
|
@ -48,9 +46,17 @@ class MarketCapPairList(IPairList):
|
||||||
is_demo=_coingecko_config.get("is_demo", True),
|
is_demo=_coingecko_config.get("is_demo", True),
|
||||||
)
|
)
|
||||||
|
|
||||||
if self._max_rank > 250:
|
if self._category:
|
||||||
|
categories = self._coingecko.get_coins_categories_list()
|
||||||
|
category_ids = [cat["category_id"] for cat in categories]
|
||||||
|
|
||||||
|
if self._category not in category_ids:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
"This filter only support marketcap rank up to 250.")
|
f"category not in coingecko category list you can choose from {category_ids}"
|
||||||
|
)
|
||||||
|
|
||||||
|
if self._max_rank > 250:
|
||||||
|
raise OperationalException("This filter only support marketcap rank up to 250.")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def needstickers(self) -> bool:
|
def needstickers(self) -> bool:
|
||||||
|
@ -143,7 +149,6 @@ class MarketCapPairList(IPairList):
|
||||||
marketcap_list = self._marketcap_cache.get("marketcap")
|
marketcap_list = self._marketcap_cache.get("marketcap")
|
||||||
|
|
||||||
if marketcap_list is None:
|
if marketcap_list is None:
|
||||||
|
|
||||||
data = self._coingecko.get_coins_markets(
|
data = self._coingecko.get_coins_markets(
|
||||||
vs_currency="usd",
|
vs_currency="usd",
|
||||||
order="market_cap_desc",
|
order="market_cap_desc",
|
||||||
|
@ -151,7 +156,7 @@ class MarketCapPairList(IPairList):
|
||||||
page="1",
|
page="1",
|
||||||
sparkline="false",
|
sparkline="false",
|
||||||
locale="en",
|
locale="en",
|
||||||
**({"category": self._category} if self._category else {})
|
**({"category": self._category} if self._category else {}),
|
||||||
)
|
)
|
||||||
if data:
|
if data:
|
||||||
marketcap_list = [row["symbol"] for row in data]
|
marketcap_list = [row["symbol"] for row in data]
|
||||||
|
@ -165,11 +170,11 @@ class MarketCapPairList(IPairList):
|
||||||
if market == "futures":
|
if market == "futures":
|
||||||
pair_format += f":{self._stake_currency.upper()}"
|
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:
|
for mc_pair in top_marketcap:
|
||||||
test_pair = f"{mc_pair.upper()}/{pair_format}"
|
test_pair = f"{mc_pair.upper()}/{pair_format}"
|
||||||
if test_pair in pairlist and test_pair not in filtered_pairlist:
|
if test_pair in pairlist:
|
||||||
filtered_pairlist.append(test_pair)
|
filtered_pairlist.append(test_pair)
|
||||||
if len(filtered_pairlist) == self._number_assets:
|
if len(filtered_pairlist) == self._number_assets:
|
||||||
break
|
break
|
||||||
|
|
Loading…
Reference in New Issue
Block a user