Skip to content

Commit

Permalink
stock: improve change calculation
Browse files Browse the repository at this point in the history
Use change attribute if available, otherwise diff previous close price
and current price:

    https://finnhub.io/docs/api/quote

Thanks @ColinMcKechney [L3gion]
  • Loading branch information
pbui committed Aug 8, 2024
1 parent 766db6c commit 6bf1fac
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/bobbit/modules/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 6bf1fac

Please sign in to comment.