From 20ec52fc227df58fd967446f3d6ec44fd0b6bb38 Mon Sep 17 00:00:00 2001 From: Anson Date: Tue, 5 Oct 2021 15:37:39 -0700 Subject: [PATCH] hopeful fix for #77 --- symbol_router.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/symbol_router.py b/symbol_router.py index 9940c48..e34b53d 100644 --- a/symbol_router.py +++ b/symbol_router.py @@ -31,14 +31,16 @@ class Router: def trending_decay(self, decay=0.5): """Decays the value of each trending stock by a multiplier""" - info("Decaying trending symbols.") if self.trending_count: - for key in self.trending_count.keys(): - if self.trending_count[key] < 0.01: + t_copy = self.trending_count.copy() + for key in t_copy.keys(): + if t_copy[key] < 0.01: # This just makes sure were not keeping around keys that havent been called in a very long time. - self.trending_count.pop(key, None) + t_copy.pop(key, None) else: - self.trending_count[key] = self.trending_count[key] * decay + t_copy[key] = t_copy[key] * decay + self.trending_count = t_copy.copy() + info("Decayed trending symbols.") def find_symbols(self, text: str) -> list[Symbol]: """Finds stock tickers starting with a dollar sign, and cryptocurrencies with two dollar signs