add valuation netWorth

This commit is contained in:
Emil Lerch 2026-04-21 13:07:24 -07:00
parent 7f8e430b59
commit b717c9fa3d
Signed by: lobo
GPG key ID: A7B62D657EF764F8

View file

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