mirror of
https://gitlab.com/simple-stock-bots/simple-telegram-stock-bot.git
synced 2025-08-02 19:41:26 +00:00
small code clean up and add linting to repo
This commit is contained in:
@@ -69,11 +69,7 @@ class Router:
|
||||
|
||||
coins = set(re.findall(self.CRYPTO_REGEX, text))
|
||||
for coin in coins:
|
||||
sym = self.crypto.symbol_list[
|
||||
self.crypto.symbol_list["symbol"].str.fullmatch(
|
||||
coin.lower(), case=False
|
||||
)
|
||||
]
|
||||
sym = self.crypto.symbol_list[self.crypto.symbol_list["symbol"].str.fullmatch(coin.lower(), case=False)]
|
||||
if ~sym.empty:
|
||||
symbols.append(Coin(sym))
|
||||
else:
|
||||
@@ -81,9 +77,7 @@ class Router:
|
||||
if symbols:
|
||||
info(symbols)
|
||||
for symbol in symbols:
|
||||
self.trending_count[symbol.tag] = (
|
||||
self.trending_count.get(symbol.tag, 0) + trending_weight
|
||||
)
|
||||
self.trending_count[symbol.tag] = self.trending_count.get(symbol.tag, 0) + trending_weight
|
||||
|
||||
return symbols
|
||||
|
||||
@@ -128,9 +122,9 @@ class Router:
|
||||
|
||||
df = pd.concat([self.stock.symbol_list, self.crypto.symbol_list])
|
||||
|
||||
df = df[
|
||||
df["description"].str.contains(search, regex=False, case=False)
|
||||
].sort_values(by="type_id", key=lambda x: x.str.len())
|
||||
df = df[df["description"].str.contains(search, regex=False, case=False)].sort_values(
|
||||
by="type_id", key=lambda x: x.str.len()
|
||||
)
|
||||
|
||||
symbols = df.head(matches)
|
||||
symbols["price_reply"] = symbols["type_id"].apply(
|
||||
@@ -335,10 +329,7 @@ class Router:
|
||||
reply += "🔥Trending on the Stock Bot:\n`"
|
||||
reply += "━" * len("Trending on the Stock Bot:") + "`\n"
|
||||
|
||||
sorted_trending = [
|
||||
s[0]
|
||||
for s in sorted(self.trending_count.items(), key=lambda item: item[1])
|
||||
][::-1][0:5]
|
||||
sorted_trending = [s[0] for s in sorted(self.trending_count.items(), key=lambda item: item[1])][::-1][0:5]
|
||||
|
||||
for t in sorted_trending:
|
||||
reply += self.spark_reply(self.find_symbols(t))[0] + "\n"
|
||||
@@ -365,13 +356,8 @@ class Router:
|
||||
return "Trending data is not currently available."
|
||||
|
||||
def random_pick(self) -> str:
|
||||
choice = random.choice(
|
||||
list(self.stock.symbol_list["description"])
|
||||
+ list(self.crypto.symbol_list["description"])
|
||||
)
|
||||
hold = (
|
||||
datetime.date.today() + datetime.timedelta(random.randint(1, 365))
|
||||
).strftime("%b %d, %Y")
|
||||
choice = random.choice(list(self.stock.symbol_list["description"]) + list(self.crypto.symbol_list["description"]))
|
||||
hold = (datetime.date.today() + datetime.timedelta(random.randint(1, 365))).strftime("%b %d, %Y")
|
||||
|
||||
return f"{choice}\nBuy and hold until: {hold}"
|
||||
|
||||
|
Reference in New Issue
Block a user