From a3f2892aba3dbfc26c85c1180d71cfbcf273301d Mon Sep 17 00:00:00 2001 From: socks Date: Sat, 13 Feb 2021 06:03:42 +0000 Subject: [PATCH] Changed table formatting --- table.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/table.py b/table.py index 2c37d6e..5d667b8 100644 --- a/table.py +++ b/table.py @@ -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") )