From 2a06251ac7f1f0473e6f21fdbdae838c320ccb51 Mon Sep 17 00:00:00 2001 From: Anson Biggs Date: Wed, 6 Oct 2021 14:11:57 +0000 Subject: [PATCH] should fix #77 --- symbol_router.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/symbol_router.py b/symbol_router.py index 083ec04..7a11f5b 100644 --- a/symbol_router.py +++ b/symbol_router.py @@ -31,14 +31,18 @@ class Router: def trending_decay(self, decay=0.5): """Decays the value of each trending stock by a multiplier""" t_copy = {} + dead_keys = [] if self.trending_count: 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. - t_copy.pop(key, None) + dead_keys.append(key) else: t_copy[key] = t_copy[key] * decay + for dead in dead_keys: + t_copy.pop(dead) + self.trending_count = t_copy.copy() info("Decayed trending symbols.")