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

bug where some symbols return None for change

This commit is contained in:
Anson Biggs 2021-03-30 09:36:54 -07:00
parent 1e60827a66
commit 8dd3ef772f

View File

@ -171,13 +171,16 @@ class IEX_Symbol:
or (IEXData["extendedPrice"] is None)
): # Check if market is open.
message = f"The current stock price of {IEXData['companyName']} is $**{IEXData['latestPrice']}**"
change = round(IEXData["changePercent"] * 100, 2)
else:
message = (
f"{IEXData['companyName']} closed at $**{IEXData['latestPrice']}**,"
+ f" after hours _(15 minutes delayed)_ the stock price is $**{IEXData['extendedPrice']}**"
)
change = round(IEXData["extendedChangePercent"] * 100, 2)
if change := IEXData.get("extendedChangePercent", 0):
change = round(change * 100, 2)
else:
change = 0
# Determine wording of change text
if change > 0: