{% 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 %}
{% set _acct_qs %}{% for _a in selected_accounts | default([]) %}&account={{ _a|urlencode }}{% endfor %}{% endset %} {# ── 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 %}
{# Two compact bar visualizations fill the previously empty hero body: 1. Composition — holdings (indigo) vs cash (violet). Brand-gradient categorical pair so it doesn't collide with the green used for gains elsewhere on the page. 2. Lifetime — contributed (muted) baseline vs growth (pos/neg). For gains, the bar's full width = current account value; for losses, it = lifetime contributed and the loss is the red tail. #} {% if total_account_value is defined and total_account_value is not none and cash_kpis is defined and cash_kpis %} {% set _holdings = (kpis.open_position_value|float) if kpis and kpis.open_position_value is not none else 0 %} {% set _cash = cash_kpis.cash_balance|float %} {% set _tav = total_account_value|float %} {% set _holdings_pct = (_holdings / _tav * 100) if _tav > 0 else 0 %} {% set _cash_pct = 100 - _holdings_pct if _tav > 0 else 0 %}
Composition ${{ "{:,.0f}".format(_tav) }} total
Holdings ${{ "{:,.0f}".format(_holdings) }} {{ _holdings_pct|round(0,'floor')|int }}% {{ _cash_pct|round(0,'ceil')|int }}% ${{ "{:,.0f}".format(_cash) }} Cash
{% if vs_contributed_delta is defined and vs_contributed_delta is not none and cash_kpis.net_contributions and cash_kpis.net_contributions|float > 0 %} {% set _delta = vs_contributed_delta|float %} {% set _contrib = cash_kpis.net_contributions|float %} {% if _delta >= 0 %} {# Gain: bar width = total account value. Left segment = contributed baseline (what you put in), right tail = pure growth. #} {% set _bar_total = _tav if _tav > 0 else _contrib %} {% set _baseline_pct = (_contrib / _bar_total * 100) if _bar_total > 0 else 0 %} {% set _gain_pct = 100 - _baseline_pct %} {% set _baseline_pct_int = _baseline_pct|round(0,'floor')|int %} {% set _gain_pct_int = (100 - _baseline_pct_int) %} {% set _delta_pct = (_delta / _contrib) * 100 %} {% else %} {# Loss: bar width = contributed. Left segment = remaining value (what you still have), right tail = the loss in red. #} {% set _bar_total = _contrib %} {% set _baseline_pct = (_tav / _bar_total * 100) if _bar_total > 0 else 0 %} {% set _gain_pct = 100 - _baseline_pct %} {% set _baseline_pct_int = _baseline_pct|round(0,'floor')|int %} {% set _gain_pct_int = (100 - _baseline_pct_int) %} {% set _delta_pct = (_delta|abs / _contrib) * 100 %} {% endif %}
Lifetime {% if _delta < 0 %}−{% else %}+{% endif %}${{ "{:,.0f}".format(_delta|abs) }} ({% if _delta < 0 %}−{% else %}+{% endif %}{{ "{:,.1f}".format(_delta_pct) }}%)
Contributed ${{ "{:,.0f}".format(_contrib) }} {% if _delta < 0 %}Lost{% else %}Earned{% endif %} {% if _delta < 0 %}−{% else %}+{% endif %}${{ "{:,.0f}".format(_delta|abs) }}
{% endif %} {% if snapshot is defined and snapshot.fetched_at %}
As of {{ snapshot.fetched_at.strftime('%b %-d · %-I:%M %p') }}
{% endif %} {% 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 %}
{% if lifetime_kpis is defined and lifetime_kpis is not none and total_account_value is not none and cash_kpis is defined and cash_kpis %} {% set _lifetime_delta = total_account_value - cash_kpis.net_contributions %}
Lifetime {% if _lifetime_delta < 0 %} −${{ "{:,.2f}".format(_lifetime_delta|float|abs) }} {% else %} +${{ "{:,.2f}".format(_lifetime_delta|float) }} {% endif %} {% if cash_kpis.net_contributions and cash_kpis.net_contributions|float > 0 %} ({% if _lifetime_delta < 0 %}−{% else %}+{% endif %}{{ "{:,.1f}".format((_lifetime_delta|float|abs / cash_kpis.net_contributions|float) * 100) }}%) {% endif %}
{% endif %}
{% 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) }}
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 %} · cash-netted {% if kpis.period_realized_economic < 0 %}−{% else %}+{% endif %}${{ "{:,.2f}".format(kpis.period_realized_economic|float|abs) }} (?) {% endif %}
Economic · GL-canonical · all accounts
{% if lifetime_kpis is defined and lifetime_kpis is not none %} {# Use the same tax-recognized number that the Lifetime view shows as its main figure (`period_realized`), so toggling Period to Lifetime doesn't reveal a different "Lifetime" total. The economic / cash-netted variant is documented in the panel's title attribute. #}
Lifetime {% if lifetime_kpis.period_realized < 0 %} −${{ "{:,.2f}".format(lifetime_kpis.period_realized|float|abs) }} {% else %} +${{ "{:,.2f}".format(lifetime_kpis.period_realized|float) }} {% endif %}
{% 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 }}
{% 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 %}