{% from "_provenance_macros.html" import provenance_link %} {% set partial = kpis.missing_symbols and (kpis.open_position_value is not none) %} {% set period_label = kpis.period_label or 'Period' %} {% set _profile = profile if profile is defined else None %} {% set _slots = _profile.order("portfolio_kpi_hero") if _profile else ["ytd_realized", "ytd_unrealized", "wash_impact", "open_position"] %} {% macro slot_ytd_realized(kpis, period_label, metric_refs) %}
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 %}
{{ period_label }}
{% endmacro %} {% macro slot_ytd_unrealized(kpis, period_label, metric_refs) %}
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 %}
{{ period_label }}
{% endmacro %} {% macro slot_lifetime_growth(kpis) %}
Lifetime growth
{% if kpis.lifetime_realized < 0 %}−{% else %}+{% endif %}${{ "%.2f"|format(kpis.lifetime_realized|float|abs) }}
all time
{% endmacro %} {% macro slot_open_position(kpis) %}
Open position $
{% if kpis.open_position_value is none %} {% else %}${{ "%.2f"|format(kpis.open_position_value|float) }}{% endif %}
{% if kpis.missing_symbols %}{{ kpis.missing_symbols|length }} unpriced{% else %}all priced{% endif %}
{% endmacro %} {% macro slot_wash_impact(metric_refs) %}
Wash impact
{% if wash_impact_total is defined and wash_impact_total %} −${{ "%.2f"|format(wash_impact_total|float|abs) }} {% else %} $0.00 {% endif %}
{% if wash_violations is defined and wash_violations %}{{ wash_violations }} violation{% if wash_violations != 1 %}s{% endif %}{% else %}no violations{% endif %}
{% endmacro %} {% 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 %}
{% for slot in _slots %} {% if slot == "ytd_realized" %}{{ slot_ytd_realized(kpis, period_label, metric_refs if metric_refs is defined else {}) }} {% elif slot == "ytd_unrealized" %}{{ slot_ytd_unrealized(kpis, period_label, metric_refs if metric_refs is defined else {}) }} {% elif slot == "lifetime_growth" %}{{ slot_lifetime_growth(kpis) }} {% elif slot == "open_position" %}{{ slot_open_position(kpis) }} {% elif slot == "wash_impact" %}{{ slot_wash_impact(metric_refs if metric_refs is defined else {}) }} {% elif slot == "cash" %}{{ 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) }} {% endif %} {% endfor %}
{# Tax tiles moved to the dedicated Tax planning section at the bottom of the page (see _portfolio_body.html). Portfolio KPIs stay focused on portfolio. #} {% if cash_kpis is defined %} {% set _csp_total = (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_v = cash_kpis.cash_balance|float %} {% set _free_v = _cash_v - _csp_total %}
{# --- Cash --- #}
Cash {% if _csp_total > 0 %}(free / pledged){% endif %}
{% if _cash_v < 0 %} −${{ "%.2f"|format(_cash_v|abs) }} {% else %} ${{ "%.2f"|format(_cash_v) }} {% endif %}{% if metric_refs is defined and metric_refs.cash is defined %}{{ provenance_link(metric_refs.cash) }}{% endif %}
{% if _csp_total > 0 %} {% set _pledged_pct = (_csp_total / _cash_v * 100) if _cash_v > 0 else 0 %}
${{ "{:,.0f}".format(_free_v) }} free ${{ "{:,.0f}".format(_csp_total) }} pledged · {{ _csp_n }} CSP{% if _csp_n != 1 %}s{% endif %}
{% else %}
{{ "%.0f"|format((cash_kpis.cash_share_pct|float) * 100) }}% of account
{% endif %}
{# --- Net contributed --- #}
Net contributed
{% 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 %}
deposits − withdrawals
{# --- Growth --- #}
Growth
{% if cash_kpis.growth < 0 %}−{% else %}+{% endif %}${{ "%.2f"|format(cash_kpis.growth|float|abs) }}
{% if 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 %}
{% endif %} {% if snapshot is defined and snapshot.degraded %}
Showing stale prices (provider unavailable).
{% 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 %}