{# Math explainer fragment for the Total Return KPI tile. Receives `b: TotalReturnBreakdown`. Loaded via HTMX from /portfolio/explain/total-return and swapped into a div under the tile. #}
Total Return — {{ b.period_label }}
Ending value ${{ "{:,.2f}".format(b.ending_value|float) }}
− Starting value −${{ "{:,.2f}".format(b.starting_value|float) }}{% if not b.is_lifetime %} (account value at period start){% endif %}
− Contributions −${{ "{:,.2f}".format(b.contributions|float) }} (deposits − withdrawals this period)
= Total Return {% if b.total_return < 0 %}−{% else %}+{% endif %}${{ "{:,.2f}".format(b.total_return|float|abs) }}
Decomposition:
Realized P/L (period) {% if b.realized_in_period < 0 %}−{% else %}+{% endif %}${{ "{:,.2f}".format(b.realized_in_period|float|abs) }}
Δ Unrealized (period) {% if b.delta_unrealized_residual < 0 %}−{% else %}+{% endif %}${{ "{:,.2f}".format(b.delta_unrealized_residual|float|abs) }}
{% if b.total_return < 0 %}−{% else %}+{% endif %}${{ "{:,.2f}".format(b.total_return|float|abs) }}
Δ Unrealized is computed as a residual (Total Return − Realized) — it differs from the standalone Unrealized P/L tile, which always shows current open unrealized regardless of period.
⚠ This is informational only. Consult a tax professional before filing.