Changed table formatting
This commit is contained in:
parent
b3af02125c
commit
a3f2892aba
1 changed files with 3 additions and 3 deletions
6
table.py
6
table.py
|
@ -22,9 +22,9 @@ def generate_table(stonks):
|
||||||
for ticker in stonks.keys():
|
for ticker in stonks.keys():
|
||||||
price = get_current_price(ticker)
|
price = get_current_price(ticker)
|
||||||
shares_count = stonks[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]))
|
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") )
|
||||||
|
|
Loading…
Add table
Reference in a new issue