{% from "_provenance_macros.html" import provenance_link %} {% set _profile = profile if profile is defined else None %} {# ── slot_cash macro ──────────────────────────────────────────────────────── #} {% macro slot_cash(cash_kpis, cash_secured_total, csp_count) %} {% set _csp = (cash_secured_total|float) if cash_secured_total is defined and cash_secured_total else 0 %} {% set _csp_n = csp_count if csp_count is defined and csp_count else 0 %} {% set _cash = (cash_kpis.cash_balance|float) if cash_kpis else 0 %} {% set _free = _cash - _csp %}
Cash {% if _csp > 0 %}(free / pledged){% endif %}
{% if cash_kpis is defined and cash_kpis %} {% if _cash < 0 %}−${{ "%.2f"|format(_cash|abs) }} {% else %}${{ "%.2f"|format(_cash) }}{% endif %} {% else %}{% endif %}
{% if _csp > 0 and cash_kpis %} {% set _pledged_pct = (_csp / _cash * 100) if _cash > 0 else 0 %}
${{ "{:,.0f}".format(_free) }} free ${{ "{:,.0f}".format(_csp) }} pledged · {{ _csp_n }} CSP{% if _csp_n != 1 %}s{% endif %}
{% else %}
{% if cash_kpis is defined and cash_kpis %}{{ "%.0f"|format((cash_kpis.cash_share_pct|float) * 100) }}% of account{% endif %}
{% endif %}
{% endmacro %} {# ── KPI grid — Phase 3 restructure (§4.1, §5.6) ────────────────────────── #} {# Top row: hero + today + cash (large, col-span-4 each in a 12-col grid). #} {# Bottom row: 4 small numerics (col-span-3 each). #}
{# ── Hero: Total Account Value ─────────────────────────────────────────── #}
TOTAL ACCOUNT VALUE
{% if total_account_value is defined and total_account_value is not none %} ${{ "%.2f"|format(total_account_value|float) }} {% else %} {% endif %}
{% if vs_contributed_delta is defined and vs_contributed_delta is not none %} {% if vs_contributed_delta > 0 %}+{% endif %}{{ fmt_currency(vs_contributed_delta) }} vs contributed {% endif %}
{# ── Today tile (NEW) ───────────────────────────────────────────────────── #} {% include "_portfolio_today_tile.html" %} {# ── Cash — single canonical emit ──────────────────────────────────────── #} {{ slot_cash(cash_kpis if cash_kpis is defined else None, cash_secured_total if cash_secured_total is defined else 0, csp_count if csp_count is defined else 0) }}
{# ── Bottom row: 4 small KPIs ─────────────────────────────────────────────── #}
{# Realized P/L #}
Realized P/L
{% if kpis.period_realized < 0 %}−{% else %}+{% endif %}${{ "%.2f"|format(kpis.period_realized|float|abs) }}{% if metric_refs is defined and metric_refs.realized_period is defined %}{{ provenance_link(metric_refs.realized_period) }}{% endif %}
{{ kpis.period_label }}
{# Unrealized P/L #}
Unrealized P/L
{% if kpis.period_unrealized is none %} {% elif kpis.period_unrealized < 0 %}−${{ "%.2f"|format(kpis.period_unrealized|float|abs) }} {% else %}+${{ "%.2f"|format(kpis.period_unrealized|float) }} {% endif %}
{{ kpis.period_label }}
{# Net Contributed #}
Net contributed
{% if cash_kpis is defined and cash_kpis %} {% if cash_kpis.net_contributions < 0 %} −${{ "%.2f"|format(cash_kpis.net_contributions|float|abs) }} {% else %} ${{ "%.2f"|format(cash_kpis.net_contributions|float) }} {% endif %}{% if metric_refs is defined and metric_refs.net_contributed_period is defined %}{{ provenance_link(metric_refs.net_contributed_period) }}{% endif %} {% else %} {% endif %}
deposits − withdrawals
{# Growth #}
Growth
{% if cash_kpis is defined and cash_kpis %} {% if cash_kpis.growth < 0 %}−{% else %}+{% endif %}${{ "%.2f"|format(cash_kpis.growth|float|abs) }} {% else %} {% endif %}
{% if cash_kpis is defined and cash_kpis and cash_kpis.growth_pct is not none %} {% if cash_kpis.growth_pct < 0 %}−{% else %}+{% endif %}{{ "%.1f"|format((cash_kpis.growth_pct|float|abs) * 100) }}% vs contributed {% else %} no contributions {% endif %}
{# Global price freshness is shown in the toolbar freshness chip (§5.11 / P5). Only tile-specific data-quality warnings (e.g. partial sum) remain here. #} {% if snapshot is defined and snapshot.degraded %}
Quote provider unavailable — some prices may be missing.
{% endif %} {% if kpis.missing_symbols %}
{% if kpis.open_position_value is none %} No quotes available. {% else %} Partial sum — {{ kpis.missing_symbols|length }} symbol{% if kpis.missing_symbols|length != 1 %}s{% endif %} unpriced: {{ kpis.missing_symbols|join(', ') }} {% endif %}
{% endif %}