From 71fed7fd18c5ab7eade55c67e07c84e8eab51edb Mon Sep 17 00:00:00 2001 From: Linus E <75929322+Rripped@users.noreply.github.com> Date: Tue, 19 Apr 2022 21:08:47 +0200 Subject: [PATCH] added formatting and adapted to isin --- telegram_bot/bot.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/telegram_bot/bot.py b/telegram_bot/bot.py index c3ab17e..0f32fe6 100644 --- a/telegram_bot/bot.py +++ b/telegram_bot/bot.py @@ -417,9 +417,12 @@ def send_portfolio(message): bot.send_message(chat_id=user_id, text='You do not have any stocks in your portfolio.') return else: - # tbd: format portfolio - - bot.send_message(chat_id=user_id, text=f'Your portfolio is: _{str(portfolio)}_', parse_mode="MARKDOWN") + for stock in portfolio: + comment = str(stock["comment"]) + count = "{:.2f}".format(float(stock["count"])) + isin = str(stock["isin"]) + worth = "{:.2f}".format(float(stock["current_price"]) * float(stock["count"])) + bot.send_message(chat_id=user_id, text=f'*{comment}*\n_{isin}_\namount: {count}\nworth: ${worth}', parse_mode="MARKDOWN") @bot.message_handler(commands=['newtransaction']) #tbd not working rn @@ -458,7 +461,7 @@ def set_new_transaction_step(message): bot.send_message(chat_id=user_id, text=f'Failed adding transaction. (statuscode {status})') -@bot.message_handler(commands=['interval']) #tbd +@bot.message_handler(commands=['interval']) def send_interval(message): """ send interval for user :type message: message object bot