{# 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' %} {{ label }}{% if cur %} {{ '↓' if _dir == 'desc' else '↑' }}{% endif %} {% endmacro %}
Show:
{{ total_rows }} {% if show == 'all' %}total{% else %}open{% endif %} {% if selected_symbols %}· {{ selected_symbols|length }} symbol{% if selected_symbols|length != 1 %}s{% endif %} filtered{% endif %} · account: {% if selected_account %}{{ selected_account }}{% else %}all{% endif %}
{% if total_pages > 1 %} {% set prev_disabled = (page <= 1) %} {% set next_disabled = (page >= total_pages) %}
page {{ page }} / {{ total_pages }}
{% endif %}
{% if extra_columns is defined and extra_columns %} {% endif %} {% if not rows %}
{% if selected_symbols %}No symbols match the selected filter. {% elif show == 'all' %}No positions in scope. {% else %}No open positions. {% endif %}
{% else %}
{{ sort_th('symbol', 'Symbol', tooltip='Underlying ticker. Click to sort. Options are merged into their underlying for quantity/market value (cash flows still tracked).') }} {{ 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 invested / sh', align='r', tooltip="Net cash you've put in for this position, divided by current shares. Includes wash adjustments.") }} {{ 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 %}{% endif %} {% if 'lt_st_split' in extra_columns %}{% endif %} {% if 'premium_received' in extra_columns %}{% 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 %} {% if 'target' in extra_columns %}{% endif %} {% endif %} {% for r in rows %} {% if extra_columns is defined %} {% if 'days_held' in extra_columns %}{% endif %} {% if 'lt_st_split' in extra_columns %}{% endif %} {% if 'premium_received' in extra_columns %}{% 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 %} {% if 'target' in extra_columns %} {% endif %} {% endif %} {% endfor %}
AccountsDays heldLT / STPrem.Origin→LTCGHarv.Prem. offTarget
{{ 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 %}
{% set _displays = r.account_displays if r.account_displays else r.accounts %} {% if _displays|length <= 1 %} {{ r.account_chip or (_displays[0] if _displays else '—') }} {% else %} {{ r.account_chip or (_displays|join('+')) }} {% endif %} {{ fmt_quantity(r.qty) }} {% if r.market_value is none %} {% else %}${{ "%.2f"|format(r.market_value|float) }}{% endif %} {% if (r.open_cost is none or r.open_cost == 0) and not r.basis_known and r.qty and r.qty != 0 %} {% include "_basis_missing_chip.html" %} {% else %} {{ fmt_currency(r.open_cost) }} {% endif %} {% if (r.avg_basis is none or r.avg_basis == 0) and not r.basis_known and r.qty and r.qty != 0 %} {% include "_basis_missing_chip.html" %} {% else %} {{ fmt_currency(r.avg_basis) }} {% endif %} {{ fmt_currency(r.cash_sunk_per_share) }} {% 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 %}
{{ r.days_held if r.days_held is not none else '—' }}{% if r.days_held is not none %}d{% endif %}{{ fmt_quantity(r.lt_qty) }}LT / {{ fmt_quantity(r.st_qty) }}ST${{ "%.0f"|format(r.premium_received|float) }} {% set _t = targets_by_symbol.get(r.symbol) if targets_by_symbol is defined else None %} {% if _t %} {% set _native = ('$%.0f' % _t.target_amount|float) if _t.target_unit.value == 'usd' else ('%.2f sh' % _t.target_amount|float) %} {% set _curr = ('$%.0f' % r.market_value|float) if (_t.target_unit.value == 'usd' and r.market_value is not none) else ('%.2f sh' % r.qty|float) %} {% if _t.target_unit.value == 'usd' and r.market_value is not none and _t.target_amount > 0 %} {% set _pct = (r.market_value|float / _t.target_amount|float * 100) %} {% elif _t.target_unit.value == 'shares' and _t.target_amount > 0 %} {% set _pct = (r.qty|float / _t.target_amount|float * 100) %} {% else %} {% set _pct = 0 %} {% endif %} {% set _color = 'var(--color-info)' if _pct == 0 else ('var(--color-warn)' if _pct < 95 else ('var(--color-pos)' if _pct <= 105 else 'var(--color-neg)')) %}
{{ _curr }} / {{ _native }}
{% if _pct > 100 %}
{% else %}
{% endif %}
{{ "%.0f"|format(_pct) }}%
{% else %} — no target {% endif %}
{% with sym=r.symbol, qty=r.qty, account=r.accounts[0] if r.accounts else '', account_id=none %} {% include "_row_actions.html" %} {% endwith %}
{% 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 %}