From b38f9ed5e7967e116a36ff088f1ade46e61a1abd Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 3 May 2020 20:44:18 +0200 Subject: [PATCH 1/2] Increase cache for rate limit to avoid delays Helps when calling /status or /status table frequently on slowish exchanges --- freqtrade/freqtradebot.py | 7 +++++-- tests/conftest.py | 3 ++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 7ae87e807..32fbde562 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -54,8 +54,11 @@ class FreqtradeBot: # Init objects self.config = config - self._sell_rate_cache = TTLCache(maxsize=100, ttl=5) - self._buy_rate_cache = TTLCache(maxsize=100, ttl=5) + _process_throttle_secs = self.config['internals'].get('process_throttle_secs', + constants.PROCESS_THROTTLE_SECS) + # Use 3x process_throttle_secs for caching to avoid delays in RPC methods. + self._sell_rate_cache = TTLCache(maxsize=100, ttl=_process_throttle_secs * 3) + self._buy_rate_cache = TTLCache(maxsize=100, ttl=_process_throttle_secs * 3) self.strategy: IStrategy = StrategyResolver.load_strategy(self.config) diff --git a/tests/conftest.py b/tests/conftest.py index d95475b8c..5c2e3e8e9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -304,7 +304,8 @@ def default_conf(testdatadir): "user_data_dir": Path("user_data"), "verbosity": 3, "strategy_path": str(Path(__file__).parent / "strategy" / "strats"), - "strategy": "DefaultStrategy" + "strategy": "DefaultStrategy", + "internals": {}, } return configuration From 648723fb8325fe3e3c4fb1a371ed360b1b0d6e32 Mon Sep 17 00:00:00 2001 From: Matthias Date: Tue, 5 May 2020 06:32:03 +0200 Subject: [PATCH 2/2] Use 30min rate cache --- freqtrade/freqtradebot.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/freqtrade/freqtradebot.py b/freqtrade/freqtradebot.py index 32fbde562..86c8e03b7 100644 --- a/freqtrade/freqtradebot.py +++ b/freqtrade/freqtradebot.py @@ -54,11 +54,11 @@ class FreqtradeBot: # Init objects self.config = config - _process_throttle_secs = self.config['internals'].get('process_throttle_secs', - constants.PROCESS_THROTTLE_SECS) - # Use 3x process_throttle_secs for caching to avoid delays in RPC methods. - self._sell_rate_cache = TTLCache(maxsize=100, ttl=_process_throttle_secs * 3) - self._buy_rate_cache = TTLCache(maxsize=100, ttl=_process_throttle_secs * 3) + # Cache values for 1800 to avoid frequent polling of the exchange for prices + # Caching only applies to RPC methods, so prices for open trades are still + # refreshed once every iteration. + self._sell_rate_cache = TTLCache(maxsize=100, ttl=1800) + self._buy_rate_cache = TTLCache(maxsize=100, ttl=1800) self.strategy: IStrategy = StrategyResolver.load_strategy(self.config)