mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 00:23:07 +00:00
Add cache for expanded_blacklist() in PairListManager in backtest mode
This commit is contained in:
@@ -5,7 +5,7 @@ PairList manager class
|
||||
import logging
|
||||
from functools import partial
|
||||
|
||||
from cachetools import TTLCache, cached
|
||||
from cachetools import LRUCache, TTLCache, cached
|
||||
|
||||
from freqtrade.constants import Config, ListPairsWithTimeframes
|
||||
from freqtrade.data.dataprovider import DataProvider
|
||||
@@ -56,6 +56,7 @@ class PairListManager(LoggingMixin):
|
||||
)
|
||||
|
||||
self._check_backtest()
|
||||
self._not_expiring_cache: LRUCache = LRUCache(maxsize=1)
|
||||
|
||||
refresh_period = config.get("pairlist_refresh_period", 3600)
|
||||
LoggingMixin.__init__(self, logger, refresh_period)
|
||||
@@ -109,7 +110,15 @@ class PairListManager(LoggingMixin):
|
||||
@property
|
||||
def expanded_blacklist(self) -> list[str]:
|
||||
"""The expanded blacklist (including wildcard expansion)"""
|
||||
return expand_pairlist(self._blacklist, self._exchange.get_markets().keys())
|
||||
eblacklist = self._not_expiring_cache.get("eblacklist")
|
||||
|
||||
if not eblacklist:
|
||||
eblacklist = expand_pairlist(self._blacklist, self._exchange.get_markets().keys())
|
||||
|
||||
if self._config["runmode"] in (RunMode.BACKTEST, RunMode.HYPEROPT):
|
||||
self._not_expiring_cache["eblacklist"] = eblacklist.copy()
|
||||
|
||||
return eblacklist
|
||||
|
||||
@property
|
||||
def name_list(self) -> list[str]:
|
||||
|
||||
Reference in New Issue
Block a user