From c818c463e326ef1dbae20f9b5e54baae6c6c4e24 Mon Sep 17 00:00:00 2001 From: StephanAkkerman Date: Sat, 30 Mar 2024 20:34:10 +0100 Subject: [PATCH] bug fixes --- src/cogs/loops/events.py | 2 +- src/cogs/loops/losers.py | 3 ++- src/cogs/loops/nfts.py | 8 +++++++- src/util/yf_data.py | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cogs/loops/events.py b/src/cogs/loops/events.py index 69bb5e26..aca6e7c0 100644 --- a/src/cogs/loops/events.py +++ b/src/cogs/loops/events.py @@ -154,7 +154,7 @@ async def post_events(self): df["timestamp"] = df["timestamp"].apply(lambda x: f"") # Replace zone names - + # TODO: fix future warning df["zone"].replace( {"euro zone": "πŸ‡ͺπŸ‡Ί", "united states": "πŸ‡ΊπŸ‡Έ"}, inplace=True, diff --git a/src/cogs/loops/losers.py b/src/cogs/loops/losers.py index fe620978..f02fa8e9 100644 --- a/src/cogs/loops/losers.py +++ b/src/cogs/loops/losers.py @@ -1,5 +1,5 @@ # Standard libraries -import datetime +import traceback # > 3rd party dependencies import yahoo_fin.stock_info as si @@ -51,6 +51,7 @@ async def losers(self) -> None: await self.channel.send(embed=e) except Exception as e: print("Error getting or posting stock losers, error:", e) + print(traceback.format_exc()) def setup(bot: commands.Bot) -> None: diff --git a/src/cogs/loops/nfts.py b/src/cogs/loops/nfts.py index 53d4b7cd..c5400da1 100644 --- a/src/cogs/loops/nfts.py +++ b/src/cogs/loops/nfts.py @@ -409,7 +409,13 @@ async def upcoming_cmc(): df = df.head(10) # name, websiteUrl, price, dropDate - df = df[["name", "websiteUrl", "price", "dropDate"]] + # Filter out the columns that actually exist in the DataFrame + existing_columns = [ + col for col in ["name", "websiteUrl", "price", "dropDate"] if col in df.columns + ] + + # Use only the existing columns to filter the DataFrame + df = df[existing_columns] # Use same method as #events channel time # Rename to start_time diff --git a/src/util/yf_data.py b/src/util/yf_data.py index 800af797..14338369 100644 --- a/src/util/yf_data.py +++ b/src/util/yf_data.py @@ -44,7 +44,7 @@ def append_price_data(price_key, change_key): # Prepare return values url = f"https://finance.yahoo.com/quote/{ticker}" - exchange = stock_info.get("exchange", "N/A") + exchange = stock_info.get("exchange", []) return volume, url, exchange, prices, changes if changes else ["N/A"], ticker