Changed table formatting

This commit is contained in:
socks 2021-02-13 06:03:42 +00:00
parent b3af02125c
commit a3f2892aba

View file

@ -22,9 +22,9 @@ def generate_table(stonks):
for ticker in stonks.keys():
price = get_current_price(ticker)
shares_count = stonks[ticker]
table_data.append([ticker, shares_count, Decimal(price) * Decimal(stonks[ticker])])
table_data.append([ticker, shares_count, round(Decimal(price) * Decimal(stonks[ticker]), 2)])
total += (Decimal(price) * Decimal(stonks[ticker]))
table_data.append(['Total', '', total])
table_data.append(['Total', '', round(total, 2)])
return str( tabulate(table_data, ['Ticker', 'Shares', 'Value ($)'], tablefmt="fancy_grid") )
return str( tabulate(table_data, ['Ticker', 'Shares', 'Value ($)'], tablefmt="pretty") )