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