|
16 | 16 |
|
17 | 17 | import ccxt |
18 | 18 | import ccxt.pro as ccxt_pro |
19 | | -from cachetools import TTLCache |
20 | 19 | from ccxt import TICK_SIZE |
21 | 20 | from dateutil import parser |
22 | 21 | from pandas import DataFrame, concat |
|
107 | 106 | file_load_json, |
108 | 107 | safe_value_fallback2, |
109 | 108 | ) |
110 | | -from freqtrade.util import dt_from_ts, dt_now |
| 109 | +from freqtrade.util import FtTTLCache, PeriodicCache, dt_from_ts, dt_now |
111 | 110 | from freqtrade.util.datetime_helpers import dt_humanize_delta, dt_ts, format_ms_time |
112 | | -from freqtrade.util.periodic_cache import PeriodicCache |
113 | 111 |
|
114 | 112 |
|
115 | 113 | logger = logging.getLogger(__name__) |
@@ -230,13 +228,13 @@ def __init__( |
230 | 228 |
|
231 | 229 | self._cache_lock = Lock() |
232 | 230 | # Cache for 10 minutes ... |
233 | | - self._fetch_tickers_cache: TTLCache = TTLCache(maxsize=4, ttl=60 * 10) |
| 231 | + self._fetch_tickers_cache: FtTTLCache = FtTTLCache(maxsize=4, ttl=60 * 10) |
234 | 232 | # Cache values for 300 to avoid frequent polling of the exchange for prices |
235 | 233 | # Caching only applies to RPC methods, so prices for open trades are still |
236 | 234 | # refreshed once every iteration. |
237 | 235 | # Shouldn't be too high either, as it'll freeze UI updates in case of open orders. |
238 | | - self._exit_rate_cache: TTLCache = TTLCache(maxsize=100, ttl=300) |
239 | | - self._entry_rate_cache: TTLCache = TTLCache(maxsize=100, ttl=300) |
| 236 | + self._exit_rate_cache: FtTTLCache = FtTTLCache(maxsize=100, ttl=300) |
| 237 | + self._entry_rate_cache: FtTTLCache = FtTTLCache(maxsize=100, ttl=300) |
240 | 238 |
|
241 | 239 | # Holds candles |
242 | 240 | self._klines: dict[PairWithTimeframe, DataFrame] = {} |
@@ -2164,7 +2162,9 @@ def get_rate( |
2164 | 2162 | name = side.capitalize() |
2165 | 2163 | strat_name = "entry_pricing" if side == "entry" else "exit_pricing" |
2166 | 2164 |
|
2167 | | - cache_rate: TTLCache = self._entry_rate_cache if side == "entry" else self._exit_rate_cache |
| 2165 | + cache_rate: FtTTLCache = ( |
| 2166 | + self._entry_rate_cache if side == "entry" else self._exit_rate_cache |
| 2167 | + ) |
2168 | 2168 | if not refresh: |
2169 | 2169 | with self._cache_lock: |
2170 | 2170 | rate = cache_rate.get(pair) |
|
0 commit comments