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 @@