From 1e60528a08dae18be1e716667836c5ccc89fc2d9 Mon Sep 17 00:00:00 2001 From: Anson Biggs Date: Fri, 5 Feb 2021 15:55:23 -0700 Subject: [PATCH] fixed bug where data wasn't available afterhours. --- functions.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/functions.py b/functions.py index b332318..4ee4d7f 100644 --- a/functions.py +++ b/functions.py @@ -192,7 +192,11 @@ _Donations can only be made in a chat directly with @simplestockbot_ if response.status_code == 200: IEXData = response.json() - if IEXData["isUSMarketOpen"]: # Check if market is open. + if ( + IEXData["isUSMarketOpen"] + or (IEXData["extendedChangePercent"] == None) + or (IEXData["extendedPrice"] == 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: