Skip to content

Commit

Permalink
stock: normalize pricing format to 0.2f
Browse files Browse the repository at this point in the history
Also change should fall back to c - pc (not vice versa)
  • Loading branch information
pbui committed Aug 8, 2024
1 parent 6bf1fac commit d2faa7b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/bobbit/modules/stock.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ async def stock(bot, message, symbol=None):
data = await response.json()
response = bot.client.format_text(
"{bold}Symbol{bold}: {symbol}, "
"{color}{magenta}Price{color}: {price}, "
"{color}{blue}Open{color}: {price_open}, "
"{color}{green}High{color}: {day_high}, "
"{color}{red}Low{color}: {day_low}, "
"{color}{magenta}Price{color}: {price:0.2f}, "
"{color}{blue}Open{color}: {price_open:0.2f}, "
"{color}{green}High{color}: {day_high:0.2f}, "
"{color}{red}Low{color}: {day_low:0.2f}, "
"{color}{cyan}Change{color}: {day_change:0.2f}",
symbol = symbol.upper(),
price = data['c'],
price_open = data['o'],
day_high = data['h'],
day_low = data['l'],
day_change = data.get('d', data['pc'] - data['c']),
day_change = data.get('d', data['c'] - data['pc']),
)
except KeyError:
response = 'No results'
Expand Down

0 comments on commit d2faa7b

Please sign in to comment.