1
0
mirror of https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git synced 2025-07-25 07:31:48 +00:00

add weights to trending based on command #84

This commit is contained in:
2021-11-07 11:43:42 -07:00
parent d26a3cfc78
commit 6d269c7466
2 changed files with 6 additions and 6 deletions

View File

@@ -44,7 +44,7 @@ class Router:
self.trending_count = t_copy.copy()
info("Decayed trending symbols.")
def find_symbols(self, text: str) -> list[Symbol]:
def find_symbols(self, text: str, *, trending_weight: int = 1) -> list[Symbol]:
"""Finds stock tickers starting with a dollar sign, and cryptocurrencies with two dollar signs
in a blob of text and returns them in a list.
@@ -79,7 +79,7 @@ class Router:
info(symbols)
for symbol in symbols:
self.trending_count[symbol.tag] = (
self.trending_count.get(symbol.tag, 0) + 1
self.trending_count.get(symbol.tag, 0) + trending_weight
)
return symbols
@@ -131,7 +131,7 @@ class Router:
symbols = df.head(matches)
symbols["price_reply"] = symbols["type_id"].apply(
lambda sym: self.price_reply(self.find_symbols(sym))[0]
lambda sym: self.price_reply(self.find_symbols(sym, trending_weight=0))[0]
)
return symbols