diff --git a/invest/services.py b/invest/services.py index 78de648..df4f7a4 100644 --- a/invest/services.py +++ b/invest/services.py @@ -96,9 +96,11 @@ def get_portfolio_value(portfolio: Portfolio) -> dict: price_change = None price_change_pct = None + value_change = None if price and last_week_price and last_week_price > 0: price_change = round(price - last_week_price, 4) price_change_pct = round((price_change / last_week_price) * 100, 2) + value_change = round(price_change * float(stock.quantity), 2) holdings.append({ 'stock_code': stock.stock_code, @@ -108,6 +110,7 @@ def get_portfolio_value(portfolio: Portfolio) -> dict: 'last_week_price': last_week_price, 'price_change': price_change, 'price_change_pct': price_change_pct, + 'value_change': value_change, }) total_value += value diff --git a/invest/templates/invest/dashboard.html b/invest/templates/invest/dashboard.html index 22002dc..a8f78a0 100644 --- a/invest/templates/invest/dashboard.html +++ b/invest/templates/invest/dashboard.html @@ -126,7 +126,7 @@ Ticker Qty Price - Week + Week Change Mkt Value @@ -143,9 +143,9 @@ {% if stock.current_price %}${{ stock.current_price|floatformat:2 }}{% else %}{% endif %} - {% if stock.price_change is not None %} - - {% if stock.price_change >= 0 %}+{% endif %}{{ stock.price_change_pct|floatformat:1 }}% + {% if stock.value_change is not None %} + + {% if stock.value_change >= 0 %}+{% endif %}${{ stock.value_change|floatformat:0 }} ({% if stock.price_change_pct >= 0 %}+{% endif %}{{ stock.price_change_pct|floatformat:1 }}%) {% else %}