mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
use number_assets instead of limit
This commit is contained in:
@@ -237,17 +237,17 @@ The optional `bearer_token` will be included in the requests Authorization Heade
|
|||||||
{
|
{
|
||||||
"method": "MarketCapPairList",
|
"method": "MarketCapPairList",
|
||||||
"mode": "top_rank",
|
"mode": "top_rank",
|
||||||
"limit": 20,
|
"number_assets": 20,
|
||||||
"refresh_period": 86400
|
"refresh_period": 86400
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
##### `top_rank` mode
|
##### `top_rank` mode
|
||||||
In this mode, it will return pairlist consist of active and not-blaclisted pairs that are placed at the top `limit` rank of the marketcap.
|
In this mode, it will return pairlist consist of active and not-blaclisted pairs that are placed at the top `number_assets` rank of the marketcap.
|
||||||
|
|
||||||
##### `total_assets` mode
|
##### `total_assets` mode
|
||||||
In this mode, it will return pairlist consist of `limit` number of active and not-blaclisted pairs sorted by their marketcap rank.
|
In this mode, it will return pairlist consist of `number_assets` number of active and not-blaclisted pairs sorted by their marketcap rank.
|
||||||
|
|
||||||
The refresh_period setting allows to define the period (in seconds), at which the marketcap rank data will be refreshed. Defaults to 86,400s (1 day). The pairlist cache (refresh_period) is applicable on both generating pairlists (first position in the list) and filtering instances (not the first position in the list).
|
The refresh_period setting allows to define the period (in seconds), at which the marketcap rank data will be refreshed. Defaults to 86,400s (1 day). The pairlist cache (refresh_period) is applicable on both generating pairlists (first position in the list) and filtering instances (not the first position in the list).
|
||||||
|
|
||||||
|
|||||||
@@ -32,22 +32,22 @@ class MarketCapPairList(IPairList):
|
|||||||
pairlist_pos: int) -> None:
|
pairlist_pos: int) -> None:
|
||||||
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
|
super().__init__(exchange, pairlistmanager, config, pairlistconfig, pairlist_pos)
|
||||||
|
|
||||||
if 'limit' not in self._pairlistconfig:
|
if 'number_assets' not in self._pairlistconfig:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
'`limit` not specified. Please check your configuration '
|
'`number_assets` not specified. Please check your configuration '
|
||||||
'for "pairlist.config.limit"')
|
'for "pairlist.config.number_assets"')
|
||||||
|
|
||||||
self._stake_currency = config['stake_currency']
|
self._stake_currency = config['stake_currency']
|
||||||
self._mode = self._pairlistconfig.get('mode', 'top_rank')
|
self._mode = self._pairlistconfig.get('mode', 'top_rank')
|
||||||
self._limit = self._pairlistconfig['limit']
|
self._number_assets = self._pairlistconfig['number_assets']
|
||||||
self._refresh_period = self._pairlistconfig.get('refresh_period', 86400)
|
self._refresh_period = self._pairlistconfig.get('refresh_period', 86400)
|
||||||
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']
|
self._def_candletype = self._config['candle_type_def']
|
||||||
self._coingekko: CoinGeckoAPI = CoinGeckoAPI()
|
self._coingekko: CoinGeckoAPI = CoinGeckoAPI()
|
||||||
|
|
||||||
if self._limit > 250:
|
if self._number_assets > 250:
|
||||||
raise OperationalException(
|
raise OperationalException(
|
||||||
"This filter only support limit value up to 250."
|
"This filter only support number_assets value up to 250."
|
||||||
)
|
)
|
||||||
|
|
||||||
if not self._validate_keys(self._mode):
|
if not self._validate_keys(self._mode):
|
||||||
@@ -71,16 +71,20 @@ class MarketCapPairList(IPairList):
|
|||||||
"""
|
"""
|
||||||
Short whitelist method description - used for startup-messages
|
Short whitelist method description - used for startup-messages
|
||||||
"""
|
"""
|
||||||
return f"{self.name} - Only use top {self._pairlistconfig['limit']} market cap pairs."
|
num = self._pairlistconfig['number_assets']
|
||||||
|
msg = f"{self.name} - Only include pairs ranked within top {num} market cap."
|
||||||
|
if self._mode == "total_assets":
|
||||||
|
msg = f"{self.name} - top {num} pairs sorted by market cap."
|
||||||
|
return msg
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def description() -> str:
|
def description() -> str:
|
||||||
return "Filter pair list based on market cap."
|
return "Provides pair list based on CoinGecko's market cap rank."
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def available_parameters() -> Dict[str, PairlistParameter]:
|
def available_parameters() -> Dict[str, PairlistParameter]:
|
||||||
return {
|
return {
|
||||||
"limit": {
|
"number_assets": {
|
||||||
"type": "number",
|
"type": "number",
|
||||||
"default": 30,
|
"default": 30,
|
||||||
"description": "Max market cap rank",
|
"description": "Max market cap rank",
|
||||||
@@ -157,7 +161,7 @@ class MarketCapPairList(IPairList):
|
|||||||
|
|
||||||
|
|
||||||
if self._mode == 'top_rank':
|
if self._mode == 'top_rank':
|
||||||
top_marketcap = marketcap_list[:self._limit:]
|
top_marketcap = marketcap_list[:self._number_assets:]
|
||||||
|
|
||||||
for pair in pairlist:
|
for pair in pairlist:
|
||||||
base = pair.split('/')[0]
|
base = pair.split('/')[0]
|
||||||
@@ -165,7 +169,7 @@ class MarketCapPairList(IPairList):
|
|||||||
filtered_pairlist.append(pair)
|
filtered_pairlist.append(pair)
|
||||||
else:
|
else:
|
||||||
logger.info(f"Remove {pair} from whitelist because it's not ranked "
|
logger.info(f"Remove {pair} from whitelist because it's not ranked "
|
||||||
f"within top {self._limit} market cap")
|
f"within top {self._number_assets} market cap")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
market = self._config['trading_mode']
|
market = self._config['trading_mode']
|
||||||
@@ -176,7 +180,7 @@ class MarketCapPairList(IPairList):
|
|||||||
test_pair = f"{mc_pair.upper()}/{pair_format}"
|
test_pair = f"{mc_pair.upper()}/{pair_format}"
|
||||||
if test_pair in pairlist:
|
if test_pair in pairlist:
|
||||||
filtered_pairlist.append(test_pair)
|
filtered_pairlist.append(test_pair)
|
||||||
if len(filtered_pairlist) == self._limit:
|
if len(filtered_pairlist) == self._number_assets:
|
||||||
break
|
break
|
||||||
|
|
||||||
if len(filtered_pairlist) > 0:
|
if len(filtered_pairlist) > 0:
|
||||||
|
|||||||
Reference in New Issue
Block a user