{# 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 }}
{# Equation: aligned 2-col grid (label | right-aligned number). #}
Ending value
${{ "{:,.2f}".format(b.ending_value|float) }}
− Starting value
−${{ "{:,.2f}".format(b.starting_value|float) }}
− Contributions
−${{ "{:,.2f}".format(b.contributions|float) }}
= Total Return
{% if b.total_return < 0 %}−{% else %}+{% endif %}${{ "{:,.2f}".format(b.total_return|float|abs) }}
{# Footnotes for the variable definitions — kept out of the equation column. #} {% if not b.is_lifetime %}
Starting value = account value at the close of the day before the period.
Contributions = deposits − withdrawals during the period.
{% endif %}
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.