{# Common HTMX query string for swapping pages/toggle. #} {% set sym_qs %}{{ selected_symbols|join(',') }}{% endset %} {% set _sort = sort|default('market_value') %} {% set _dir = dir|default('desc') %} {% set qs %}period={{ selected_period }}&account={{ selected_account }}&group_options={{ group_options }}&symbols={{ sym_qs|urlencode }}&sort={{ _sort }}&dir={{ _dir }}{% endset %} {% set qs_full %}{{ qs }}&show={{ show }}&page_size={{ page_size }}{% endset %} {# Macro: a sortable column header. Toggles direction when re-clicked, otherwise defaults to descending. Preserves all current state via qs_full. #} {% macro sort_th(key, label, align='', tooltip='') %} {% set cur = (_sort == key) %} {% set new_dir = 'asc' if (cur and _dir == 'desc') else 'desc' %}
| Accounts | {{ sort_th('qty', 'Qty', align='r', tooltip='Sum of remaining quantity across all open lots (equity only; options excluded). Click to sort.') }} {{ sort_th('market_value', 'Mkt $', align='r', tooltip='Qty × latest fetched price. — when no price is available. Click to sort.') }} {{ sort_th('open_cost', 'Open Cost', align='r', tooltip='Sum of adjusted basis across open lots. Click to sort.') }} {{ sort_th('avg_basis', 'Avg Basis', align='r', tooltip='Open Cost ÷ Qty. Per-share book basis after wash-sale adjustments. Click to sort.') }} {{ sort_th('cash_sunk', 'Cash Sunk/sh', align='r', tooltip='(Total Buys − Total Sells, including option premium) ÷ current Qty. Click to sort.') }} {{ sort_th('unrealized', 'Unrealized', align='r', tooltip='Mkt $ − Open Cost on currently open lots. — when no price is available. Click to sort.') }} {% if extra_columns is defined %} {% if 'days_held' in extra_columns %}Days held | {% endif %} {% if 'lt_st_split' in extra_columns %}LT / ST | {% endif %} {% if 'premium_received' in extra_columns %}Prem. | {% endif %} {% if 'origin_event' in extra_columns %}Origin | {% endif %} {% if 'days_to_ltcg' in extra_columns %}→LTCG | {% endif %} {% if 'harvestable' in extra_columns %}Harv. | {% endif %} {% if 'premium_offset' in extra_columns %}Prem. off | {% endif %} {% endif %}|||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
{{ r.symbol[0] }}
{{ r.symbol }}
{% if r.open_option_contracts and r.open_option_contracts != 0 %}
{{ "%g"|format(r.open_option_contracts|float) }} opt
{% elif r.qty == 0 %}
closed
{% endif %}
|
{% if r.accounts|length <= 3 %} {{ r.accounts|join(' · ') }} {% else %} {{ r.accounts[0] }} +{{ r.accounts|length - 1 }} more {% endif %} | {{ "%.4f"|format(r.qty|float) }} | {% if r.market_value is none %}— {% else %}${{ "%.2f"|format(r.market_value|float) }}{% endif %} | ${{ "%.2f"|format(r.open_cost|float) }} | ${{ "%.2f"|format(r.avg_basis|float) }} | ${{ "%.2f"|format(r.cash_sunk_per_share|float) }} |
{% if r.unrealized_pl is none %}
—
{% else %}
{% if r.unrealized_pl < 0 %}-{% else %}+{% endif %}${{ "%.2f"|format(r.unrealized_pl|float|abs) }}
{% if r.open_cost and r.open_cost|float != 0 %}
{% set pct = (r.unrealized_pl|float / r.open_cost|float) * 100 %}
{% if pct < 0 %}-{% else %}+{% endif %}{{ "%.1f"|format(pct|abs) }}%
{% else %}
—
{% endif %}
{% endif %}
|
{% if extra_columns is defined %}
{% if 'days_held' in extra_columns %}{{ r.days_held if r.days_held is not none else '—' }}{% if r.days_held is not none %}d{% endif %} | {% endif %} {% if 'lt_st_split' in extra_columns %}{{ "%g"|format(r.lt_qty|float) }}LT / {{ "%g"|format(r.st_qty|float) }}ST | {% endif %} {% if 'premium_received' in extra_columns %}${{ "%.0f"|format(r.premium_received|float) }} | {% endif %} {% if 'origin_event' in extra_columns %}— | {% endif %} {% if 'days_to_ltcg' in extra_columns %}— | {% endif %} {% if 'harvestable' in extra_columns %}— | {% endif %} {% if 'premium_offset' in extra_columns %}— | {% endif %} {% endif %}
Click row to drill down
{% if extra_columns is defined and ('days_to_ltcg' in extra_columns or 'harvestable' in extra_columns or 'premium_offset' in extra_columns or 'origin_event' in extra_columns) %}→LTCG, Harv., Prem. off, and Origin are tax-view placeholders — not yet wired to live data, so they show — for every row. Hover any column header for what it will show.
{% endif %} {% endif %}