1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2025-06-16 15:17:28 +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 = {} searched_symbols = {}
otc_list = [] otc_list = []
charts = {} charts = {}
trending_cache = ["Trending Stocks Currently Unavailable."] trending_cache = None
def __init__(self) -> None: def __init__(self) -> None:
"""Creates a Symbol Object """Creates a Symbol Object

View File

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

View File

@ -388,27 +388,35 @@ class Router:
reply = "" reply = ""
reply += "Trending on the Stock Bot:\n" if self.trending_count:
reply += "-" * len("Trending on the Stock Bot:") + "\n" reply += "🔥Trending on the Stock Bot:\n`"
reply += "" * len("Trending on the Stock Bot:") + "`\n"
sorted_trending = [ sorted_trending = [
s[0] for s in sorted(self.trending_count.items(), key=lambda item: item[1]) s[0]
][::-1][0:5] for s in sorted(self.trending_count.items(), key=lambda item: item[1])
][::-1][0:5]
for t in sorted_trending: for t in sorted_trending:
reply += self.price_reply(self.find_symbols(t))[0] + "\n" reply += self.price_reply(self.find_symbols(t))[0] + "\n"
reply += "\n\nTrending Stocks:\n" if stocks:
reply += "-" * len("Trending Stocks:") + "\n" reply += "\n\n💵Trending Stocks:\n`"
for stock in stocks: reply += "" * len("Trending Stocks:") + "`\n"
reply += stock + "\n" for stock in stocks:
reply += stock + "\n"
reply += "\n\nTrending Crypto:\n" if coins:
reply += "-" * len("Trending Crypto:") + "\n" reply += "\n\n🦎Trending Crypto:\n`"
for coin in coins: reply += "" * len("Trending Crypto:") + "`\n"
reply += coin + "\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: def random_pick(self) -> str: