{% from "_provenance_macros.html" import provenance_link %} {% set _profile = profile if profile is defined else None %} {# ── Cash subtitle helper (free / pledged share + net contributed) ──────── #} {% macro cash_breakdown_subtitle(cash_kpis, csp_total, csp_n) %} {% set _csp = (csp_total|float) if csp_total is defined and csp_total else 0 %} {% set _cash = (cash_kpis.cash_balance|float) if cash_kpis else 0 %} {% set _free = _cash - _csp %} {% 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 %}{{ "%.0f"|format((cash_kpis.cash_share_pct|float) * 100) }}% of account{% endif %}
{% endif %} {# Net Contributed subtitle row — folded in from the old standalone tile. #} {% if cash_kpis is defined and cash_kpis %}
{% if cash_kpis.period_net_contributions < 0 %} −${{ "%.2f"|format(cash_kpis.period_net_contributions|float|abs) }} {% else %} ${{ "%.2f"|format(cash_kpis.period_net_contributions|float) }} {% endif %} contributed{% if metric_refs is defined and metric_refs.net_contributed_period is defined %}{{ provenance_link(metric_refs.net_contributed_period) }}{% endif %}
{% endif %} {% endmacro %}
{# ── Command-center header: hero on the left (4 cols × 2 rows on lg+), four small KPIs auto-flow into the 2×2 area to the right. ───────── #}
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 %}−{% else %}+{% endif %}${{ "%.2f"|format(vs_contributed_delta|float|abs) }} vs contributed {% endif %} {% if snapshot is defined and snapshot.fetched_at %} · as of {{ snapshot.fetched_at.strftime("%b %-d") }} quotes {% endif %}
Total Return
{% 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 starting + contributed {% else %} no contributions {% endif %}
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 }} {% if kpis.period_realized_economic != kpis.period_realized %} · economic {% if kpis.period_realized_economic < 0 %}−{% else %}+{% endif %}${{ "%.2f"|format(kpis.period_realized_economic|float|abs) }} {% endif %}
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 }}
{% set _csp_n = csp_count if csp_count is defined and csp_count else 0 %} {% set _cash_val = (cash_kpis.cash_balance|float) if cash_kpis else 0 %}
Cash {% if cash_secured_total is defined and cash_secured_total > 0 %}(free / pledged){% endif %}
{% if cash_kpis is defined and cash_kpis %} {% if _cash_val < 0 %}−${{ "%.2f"|format(_cash_val|abs) }} {% else %}${{ "%.2f"|format(_cash_val) }}{% endif %} {% else %}{% endif %}
{{ cash_breakdown_subtitle(cash_kpis if cash_kpis is defined else None, cash_secured_total if cash_secured_total is defined else 0, _csp_n) }}
{% 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 %}