From c0b1530b7f92eb201866e16501efe8cb1f287f55 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Wed, 20 Aug 2025 23:55:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8D=B0=E7=BC=93=E5=AD=98=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freqtrade/templates/freqaiprimer.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/freqtrade/templates/freqaiprimer.py b/freqtrade/templates/freqaiprimer.py index 4b6682d3..b5341da7 100644 --- a/freqtrade/templates/freqaiprimer.py +++ b/freqtrade/templates/freqaiprimer.py @@ -1728,11 +1728,12 @@ class FreqaiPrimer(IStrategy): self.cleanup_local_cache() # 打印缓存统计 - stats = self.get_cache_stats() - if stats['total_requests'] > 0: - logger.info(f"📊 缓存性能统计: 本地命中率 {stats['local_hit_rate']:.1f}%, " - f"Redis命中率 {stats['redis_hit_rate']:.1f}%, " - f"总命中率 {stats['overall_hit_rate']:.1f}%") + stats = self._local_cache_stats + total_requests = stats['hits'] + stats['misses'] + if total_requests > 0: + local_hit_rate = (stats['hits'] / total_requests) * 100 + logger.info(f"📊 缓存性能统计: 本地命中率 {local_hit_rate:.1f}%, " + f"计算次数: {stats['computes']}") def bot_start(self, **kwargs) -> None: """ @@ -1764,13 +1765,14 @@ class FreqaiPrimer(IStrategy): self.cleanup_local_cache() # 打印最终统计 - stats = self.get_cache_stats() - if stats['total_requests'] > 0: - logger.info(f"📊 最终缓存统计 - 总请求: {stats['total_requests']}, " - f"本地命中: {stats['local_hits']}, " - f"Redis命中: {stats['redis_hits']}, " + stats = self._local_cache_stats + total_requests = stats['hits'] + stats['misses'] + if total_requests > 0: + hit_rate = (stats['hits'] / total_requests) * 100 + logger.info(f"📊 最终缓存统计 - 总请求: {total_requests}, " + f"本地命中: {stats['hits']}, " f"计算次数: {stats['computes']}, " - f"总命中率: {stats['overall_hit_rate']:.1f}%") + f"总命中率: {hit_rate:.1f}%") # 注意:由于使用延迟初始化,无需关闭持久化的Redis连接