From 6bf1fac8e28b764e138928436d7e122c2185f4ea Mon Sep 17 00:00:00 2001 From: Peter Bui Date: Thu, 8 Aug 2024 10:55:47 -0400 Subject: [PATCH] stock: improve change calculation Use change attribute if available, otherwise diff previous close price and current price: https://finnhub.io/docs/api/quote Thanks @ColinMcKechney [L3gion] --- src/bobbit/modules/stock.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bobbit/modules/stock.py b/src/bobbit/modules/stock.py index 951a015..469c62a 100644 --- a/src/bobbit/modules/stock.py +++ b/src/bobbit/modules/stock.py @@ -36,7 +36,7 @@ async def stock(bot, message, symbol=None): price_open = data['o'], day_high = data['h'], day_low = data['l'], - day_change = data['c'] - data['o'], + day_change = data.get('d', data['pc'] - data['c']), ) except KeyError: response = 'No results'