-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
23 lines (18 loc) · 970 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from src.services.bot_catalog_service import BOTCatalogService
from tabulate import tabulate
# Esempio di utilizzo della classe BOTCatalog
if __name__ == "__main__":
catalog = BOTCatalogService()
# Ottenere la lista di tutti i BOT
bot_list = catalog.get_bot_list()
# Creare una lista di tuple con i dati dei BOT
table_data = []
# Aggiungere la colonna del Rendimento Emissione
for bot in bot_list:
duration = (bot.maturity_date - bot.issuance_date).days
gain = 100 - bot.issuance_price
yield_percent = (gain * 100) / bot.issuance_price * (365 / duration) if duration != 0 else 0
table_data.append((bot.name, bot.isin, bot.issuance_date, bot.issuance_price, bot.maturity_date, "{:.2f}%".format(yield_percent)))
# Stampa la tabella formattata
headers = ["Nome BOT", "ISIN", "Data E.", "Prezzo E.", "Scadenza", "Rendimento E. Lordo"]
print(tabulate(table_data, headers=headers, tablefmt="grid"))