mirror of
https://gitlab.com/simple-stock-bots/simple-stock-bot.git
synced 2025-06-16 15:17:28 +00:00
should fix #77
This commit is contained in:
parent
0577018284
commit
2a06251ac7
@ -31,14 +31,18 @@ class Router:
|
|||||||
def trending_decay(self, decay=0.5):
|
def trending_decay(self, decay=0.5):
|
||||||
"""Decays the value of each trending stock by a multiplier"""
|
"""Decays the value of each trending stock by a multiplier"""
|
||||||
t_copy = {}
|
t_copy = {}
|
||||||
|
dead_keys = []
|
||||||
if self.trending_count:
|
if self.trending_count:
|
||||||
t_copy = self.trending_count.copy()
|
t_copy = self.trending_count.copy()
|
||||||
for key in t_copy.keys():
|
for key in t_copy.keys():
|
||||||
if t_copy[key] < 0.01:
|
if t_copy[key] < 0.01:
|
||||||
# This just makes sure were not keeping around keys that havent been called in a very long time.
|
# 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:
|
else:
|
||||||
t_copy[key] = t_copy[key] * decay
|
t_copy[key] = t_copy[key] * decay
|
||||||
|
for dead in dead_keys:
|
||||||
|
t_copy.pop(dead)
|
||||||
|
|
||||||
self.trending_count = t_copy.copy()
|
self.trending_count = t_copy.copy()
|
||||||
info("Decayed trending symbols.")
|
info("Decayed trending symbols.")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user