1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-06-16 07:16:40 +00:00

trending only returns if data was retrieved. #75

This commit is contained in:
Anson Biggs 2021-08-30 13:46:12 -07:00
parent 0649789bf8
commit 0877949a89
3 changed files with 467 additions and 459 deletions

View File

@ -25,7 +25,7 @@ class IEX_Symbol:
searched_symbols = {}
otc_list = []
charts = {}
trending_cache = ["Trending Stocks Currently Unavailable."]
trending_cache = None
def __init__(self) -> None:
"""Creates a Symbol Object

View File

@ -22,7 +22,7 @@ class cg_Crypto:
vs_currency = "usd" # simple/supported_vs_currencies for list of options
searched_symbols = {}
trending_cache = ["Trending Coins Currently Unavailable."]
trending_cache = None
def __init__(self) -> None:
"""Creates a Symbol Object

View File

@ -388,27 +388,35 @@ class Router:
reply = ""
reply += "Trending on the Stock Bot:\n"
reply += "-" * len("Trending on the Stock Bot:") + "\n"
if self.trending_count:
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.price_reply(self.find_symbols(t))[0] + "\n"
for t in sorted_trending:
reply += self.price_reply(self.find_symbols(t))[0] + "\n"
reply += "\n\nTrending Stocks:\n"
reply += "-" * len("Trending Stocks:") + "\n"
for stock in stocks:
reply += stock + "\n"
if stocks:
reply += "\n\n💵Trending Stocks:\n`"
reply += "" * len("Trending Stocks:") + "`\n"
for stock in stocks:
reply += stock + "\n"
reply += "\n\nTrending Crypto:\n"
reply += "-" * len("Trending Crypto:") + "\n"
for coin in coins:
reply += coin + "\n"
if coins:
reply += "\n\n🦎Trending Crypto:\n`"
reply += "" * len("Trending Crypto:") + "`\n"
for coin in coins:
reply += coin + "\n"
return reply
if reply:
return reply
else:
warning("Failed to collect trending data.")
return "Trending data is not currently available."
def random_pick(self) -> str: