From b717c9fa3d5095db1e6fb9366663b174e608ee95 Mon Sep 17 00:00:00 2001 From: Emil Lerch Date: Tue, 21 Apr 2026 13:07:24 -0700 Subject: [PATCH] add valuation netWorth --- src/analytics/valuation.zig | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/analytics/valuation.zig b/src/analytics/valuation.zig index 67df66d..4eb1472 100644 --- a/src/analytics/valuation.zig +++ b/src/analytics/valuation.zig @@ -142,6 +142,18 @@ pub const Allocation = struct { price_ratio: f64 = 1.0, }; +/// Net worth = liquid (stocks + cash + CDs + options) + illiquid assets. +/// +/// Lives here rather than on `Portfolio` because the liquid side needs a +/// fully-computed `PortfolioSummary` (current prices, covered-call +/// adjustments, non-stock totals). The illiquid side is a simple sum the +/// model already exposes. Every display site — CLI `portfolio` command, +/// TUI portfolio tab, planned snapshot writer — should call this instead +/// of re-summing inline. +pub fn netWorth(portfolio: portfolio_mod.Portfolio, summary: PortfolioSummary) f64 { + return summary.total_value + portfolio.totalIlliquid(); +} + /// Compute portfolio summary given positions and current prices. /// `prices` maps symbol -> current price. /// `manual_prices` optionally marks symbols whose price came from manual override (not live API).