\shares working now and also sensing with daily update. Daily update message prettier

This commit is contained in:
Florian Kellermann
2022-05-10 16:43:17 +02:00
parent 00eeb1c924
commit 7eaddabadc
3 changed files with 32 additions and 13 deletions

View File

@@ -14,6 +14,7 @@ from bot import bot
import sys
from apscheduler.schedulers.background import BackgroundScheduler
from api_handling.api_handler import API_Handler
import shares.share_fetcher as share_fetcher
'''
@@ -137,18 +138,27 @@ def update_for_user(p_user_id, p_my_handler):
print(element["count"], element["isin"])
share_symbols.append(element["isin"])
share_amounts.append(element["count"])
share_courses.append(element["current_price"])
my_user = p_my_handler.get_user(p_user_id)
send_to_user("Hello %s this is your share update for today:"%str(my_user["username"]), pUser_id=p_user_id)
shares = p_my_handler.get_user_shares(p_user_id)
if len(share_symbols) != 0:
for i in range(len(share_symbols)):
my_update_message = f'Symbol: {share_symbols[i]}\nCurrent Price per Share: {share_courses[i]}\nAmount owned: {share_amounts[i]}\nTotal Investment: {float(share_courses[i]) * float(share_amounts[i])}'
my_price = share_fetcher.get_share_price_no_currency(share_symbols[i])
my_update_message = f'{share_fetcher.get_share_information_simple(share_symbols[i])}\nAmount owned: {share_amounts[i]}\nTotal Investment: {round(float(my_price) * float(share_amounts[i]), 2)} EUR'
send_to_user(my_update_message, pUser_id=p_user_id)
else:
send_to_user("No shares found for your account. Check https://gruppe1.testsites.info to change your settings and add shares.", pUser_id=p_user_id)
if len(shares)!=0: # Send updates on watchlist shares if existing
send_to_user("Your watchlist shares:", pUser_id=p_user_id)
for element in shares:
send_to_user(share_fetcher.get_share_information_simple(element), pUser_id=p_user_id)
keywords = p_my_handler.get_user_keywords(p_user_id) # get keywords as array
if(keywords): # if keywords exist and array is not empty