aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmarket.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/market.py b/market.py
index d5f3c76..3eefd5b 100755
--- a/market.py
+++ b/market.py
@@ -130,9 +130,9 @@ def update_exchanges(state: State) -> State:
130 return State(state.stocks, exchanges) 130 return State(state.stocks, exchanges)
131 131
132 132
133def format_delta(stock: Stock, percent: bool = False) -> str: 133def format_delta(delta: float, percent: bool = False) -> str:
134 sign = "+" if stock.change_point >= 0 else "-" 134 sign = "+" if delta >= 0 else "-"
135 change = f"{sign}{abs(stock.change_point)}{'%' if percent else ''}" 135 change = f"{sign}{abs(delta)}{'%' if percent else ''}"
136 return change 136 return change
137 137
138 138
@@ -257,8 +257,9 @@ class MarketApp(App):
257 table.clear(columns=True) 257 table.clear(columns=True)
258 table.add_columns("Stock", "Price($)", "Change($)", "%") 258 table.add_columns("Stock", "Price($)", "Change($)", "%")
259 for stock in self.state.stocks: 259 for stock in self.state.stocks:
260 table.add_row(stock.sticker, stock.price, format_delta(stock), 260 table.add_row(stock.sticker, stock.price,
261 format_delta(stock, percent=True)) 261 format_delta(stock.change_point),
262 format_delta(stock.change_percent, percent=True))
262 for exchange in self.state.exchanges: 263 for exchange in self.state.exchanges:
263 table.add_row(format_exchange_name(exchange), exchange.rate, "", "") 264 table.add_row(format_exchange_name(exchange), exchange.rate, "", "")
264 265