{# Inputs: allocation: AllocationView from portfolio.allocation.build_allocation() Companion to _portfolio_allocation.html that focuses purely on the cash-vs-positions split: how much of the account is deployed in equities vs sitting in cash (and within cash, how much is pledged as CSP collateral and therefore not freely deployable). #} {% set positions_color = 'var(--color-rank-1)' %} {% set cash_color = 'rgba(142,142,147,0.6)' %} {% set cash_pledged_color = 'rgba(255,159,10,0.65)' %} {% set ns = namespace(free_cash=0.0, pledged_cash=0.0) %} {% for s in allocation.slices %} {% if s.is_pledged_cash %} {% set ns.pledged_cash = s.market_value|float %} {% elif s.is_cash %} {% set ns.free_cash = s.market_value|float %} {% endif %} {% endfor %} {% set total_val = allocation.total_market_value|float %} {% set positions_val = total_val - ns.free_cash - ns.pledged_cash %} {% if total_val <= 0 %}
No account value in scope.
{% else %} {% set positions_pct = (positions_val / total_val * 100) if total_val > 0 else 0 %} {% set free_pct = (ns.free_cash / total_val * 100) if total_val > 0 else 0 %} {% set pledged_pct = (ns.pledged_cash / total_val * 100) if total_val > 0 else 0 %} {% set cash_pct = free_pct + pledged_pct %}

Deployment

Cash vs positions
{# Hero stat: % of account deployed in positions #}
{{ "%.1f"|format(positions_pct) }}%
deployed · ${{ "%.1f"|format(positions_val / 1000) }}k of ${{ "%.1f"|format(total_val / 1000) }}k
{# Stacked horizontal bar — Positions | Cash·free | Cash·pledged #}
{% if positions_pct > 0 %}
{% endif %} {% if free_pct > 0 %}
{% endif %} {% if pledged_pct > 0 %}
{% endif %}
{# Legend rows — one per segment with $ and % #}
Positions ${{ "%.1f"|format(positions_val / 1000) }}k {{ "%.1f"|format(positions_pct) }}%
Cash · free ${{ "%.1f"|format(ns.free_cash / 1000) }}k {{ "%.1f"|format(free_pct) }}%
Cash · pledged ${{ "%.1f"|format(ns.pledged_cash / 1000) }}k {{ "%.1f"|format(pledged_pct) }}%
{# Summary: total cash share so the user can read the inverse at a glance #}
Total cash: ${{ "%.1f"|format((ns.free_cash + ns.pledged_cash) / 1000) }}k · {{ "%.1f"|format(cash_pct) }}% {% if ns.pledged_cash > 0 %} · pledged share of cash: {{ "%.0f"|format(ns.pledged_cash / (ns.free_cash + ns.pledged_cash) * 100) }}% {% endif %}
{% endif %}