From 11ff79ce6a958f84ebc826136a8ef5693d21a87e Mon Sep 17 00:00:00 2001 From: StephanAkkerman Date: Wed, 20 Dec 2023 14:52:08 +0100 Subject: [PATCH] Fixed some bugs in events and trending coins --- src/cogs/loops/events.py | 7 +++++-- src/cogs/loops/listings.py | 6 ++++-- src/util/cg_data.py | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/cogs/loops/events.py b/src/cogs/loops/events.py index d8f5d448..69bb5e26 100644 --- a/src/cogs/loops/events.py +++ b/src/cogs/loops/events.py @@ -134,10 +134,13 @@ async def post_events(self): """ # Send this message every friday at 23:00 UTC - if datetime.datetime.today().weekday() != 4: - if datetime.datetime.utcnow().hour != 23: + if datetime.datetime.today().weekday() == 4: + if datetime.datetime.utcnow().hour == 23: df = await self.get_events() + # If time == "All Day" convert it to 00:00 + df["time"] = df["time"].str.replace("All Day", "00:00") + # Create datetime df["datetime"] = pd.to_datetime( df["date"] + " " + df["time"], diff --git a/src/cogs/loops/listings.py b/src/cogs/loops/listings.py index c12a94f4..b456fa04 100644 --- a/src/cogs/loops/listings.py +++ b/src/cogs/loops/listings.py @@ -11,7 +11,7 @@ from util.disc_util import get_channel -class Exchange_Listings: +class Exchange_Listings(commands.Cog): """ This class contains the cog for posting the new Binance listings It can be enabled / disabled in the config under ["LOOPS"]["NEW_LISTINGS"]. @@ -30,7 +30,6 @@ def __init__(self, bot: commands.Bot) -> None: ) asyncio.create_task(self.set_old_symbols()) - self.new_listings.start() async def get_symbols(self, exchange: str) -> list: """ @@ -122,6 +121,9 @@ async def set_old_symbols(self) -> None: for exchange in self.exchanges: self.old_symbols[exchange] = await self.get_symbols(exchange) + # Start after setting all the symbols + self.new_listings.start() + @loop(hours=6) async def new_listings(self) -> None: """ diff --git a/src/util/cg_data.py b/src/util/cg_data.py index 86738168..9b1f567a 100644 --- a/src/util/cg_data.py +++ b/src/util/cg_data.py @@ -253,6 +253,9 @@ async def get_trending_coins() -> pd.DataFrame: # Add website to Symbol using format: [Symbol](Website) df["Symbol"] = "[" + df["Symbol"] + "](" + df["Website"] + ")" + # Replace NaN values in '24h Volume' with values from 'Mkt Cap' + df["24h Volume"] = df["24h Volume"].fillna(df["Mkt Cap"]) + # Fix volume if it contains a % df.loc[df["24h Volume"].str.contains("%"), "24h Volume"] = df["Mkt Cap"]