remove can_filter, and use log_once

This commit is contained in:
Stefano Ariestasia
2024-01-21 13:28:50 +09:00
parent de91261f73
commit bbec51685d

View File

@@ -137,20 +137,16 @@ class MarketCapPairList(IPairList):
:return: new whitelist :return: new whitelist
""" """
marketcap_list = self._marketcap_cache.get('marketcap') marketcap_list = self._marketcap_cache.get('marketcap')
can_filter = False
if marketcap_list: if marketcap_list is None:
can_filter = True
else:
data = self._coingekko.get_coins_markets(vs_currency='usd', order='market_cap_desc', data = self._coingekko.get_coins_markets(vs_currency='usd', order='market_cap_desc',
per_page='250', page='1', sparkline='false', per_page='250', page='1', sparkline='false',
locale='en') locale='en')
if data: if data:
marketcap_list = [row['symbol'] for row in data] marketcap_list = [row['symbol'] for row in data]
self._marketcap_cache['marketcap'] = marketcap_list self._marketcap_cache['marketcap'] = marketcap_list
can_filter = True
if can_filter: if marketcap_list:
filtered_pairlist = [] filtered_pairlist = []
if self._mode == 'top_rank': if self._mode == 'top_rank':
@@ -161,8 +157,8 @@ class MarketCapPairList(IPairList):
if base.lower() in top_marketcap: if base.lower() in top_marketcap:
filtered_pairlist.append(pair) filtered_pairlist.append(pair)
else: else:
logger.info(f"Remove {pair} from whitelist because it's not ranked " self.log_once(f"Remove {pair} from whitelist because it's not ranked "
f"within top {self._number_assets} market cap") f"within top {self._number_assets} market cap")
else: else:
market = self._config['trading_mode'] market = self._config['trading_mode']