{# Inputs: open_options: list[OpenOptionRow] — both long and short, sorted by expiry cash_secured_total: Decimal premium_received_total: Decimal long_cost_total: Decimal today: date show: "open" | "all" — All includes expired-but-not-yet-broker-closed contracts. #} {% set _show = show|default('open') %} {% set _expanded = open_options|length > 0 or (option_counts is defined and (option_counts.long > 0 or option_counts.short > 0)) %} {# Use option_counts from the route (computed pre-slice) for accurate totals when paginated. Fall back to counting from open_options (the page slice) when option_counts is absent. #} {% set _long_count = option_counts.long|default(open_options | selectattr('side', 'equalto', 'long') | list | length) %} {% set _short_count = option_counts.short|default(open_options | selectattr('side', 'equalto', 'short') | list | length) %} {% set _acct_qs_root %}{% for _a in selected_accounts | default([]) %}&account={{ _a|urlencode }}{% endfor %}{% endset %}

Open options

{% if _long_count %}{{ _long_count }} long{% endif %} {% if _long_count and _short_count %} · {% endif %} {% if _short_count %}{{ _short_count }} short{% endif %} {% if cash_secured_total %} · ${{ "{:,.0f}".format(cash_secured_total) }} secured{% endif %} {% if premium_received_total %} · short premium +${{ "{:,.2f}".format(premium_received_total) }}{% endif %} {% if long_cost_total %} · long cost ${{ "{:,.2f}".format(long_cost_total) }}{% endif %} {% if expired_count is defined and expired_count > 0 %} · {{ expired_count }} expired (awaiting broker close){% endif %}
Show:
{% if not open_options %}
{% if _show == 'all' %}No option positions in scope.{% else %}No open option positions.{% endif %}
{% else %} {% if options_summary is defined and options_summary %}
Open contracts
{{ fmt_quantity(options_summary.open_contracts) }}
Net premium
{{ fmt_currency(options_summary.net_premium) }}
Avg DTE
{{ options_summary.avg_dte|round(0)|int }}d
{% endif %}
{# Bar = days-to-expiry on a fixed 0–365d scale. Same expiry → same bar. The fill is a single left→right gradient (urgent red → neutral amber → safe green) anchored to the full 365d track and clipped to the visible portion, so a longer bar naturally reveals more green. The DTE pill on the right still gets a bucket-keyed text color for at-a-glance urgency. #} {% set MAX_DTE = 365 %} {% for s in open_options %} {% set dte = (s.expiry - today).days %} {% if dte <= 7 %}{% set dte_class = 'text-warn' %} {% elif dte <= 21 %}{% set dte_class = 'text-label-1' %} {% else %}{% set dte_class = 'text-label-2' %}{% endif %} {% set _capped = dte if dte > 0 else 0 %} {% if _capped > MAX_DTE %}{% set _capped = MAX_DTE %}{% endif %} {% set fill_pct = (_capped / MAX_DTE * 100)|round(0, 'common') %} {% set is_long = s.side == 'long' %}
{{ 'LONG' if is_long else 'SHORT' }}
{% if s.call_put == 'C' %}CALL{% else %}PUT{% endif %} ${{ "%g"|format(s.strike) }}
{{ s.expiry.strftime('%m/%d/%y') }}
{% if s.opened_at %}opened {{ (today - s.opened_at).days }}d ago{% else %}— {% endif %}
{# Gradient is sized to the full 365d track via background-size so the fill, clipped to fill_pct, always shows the correct slice of red→amber→green. fill_pct guarded against 0 to avoid div/0. #} {% set _bg_size = (10000 / fill_pct)|round(0, 'common') if fill_pct > 0 else 100 %}
{% if is_long %}-${{ "{:,.2f}".format(s.cash_basis) }}{% else %}+${{ "{:,.2f}".format(s.cash_basis) }}{% endif %}
{% if is_long %}cost paid{% elif s.call_put == 'P' %}${{ "{:,.0f}".format(s.cash_secured) }} secured{% else %}premium{% endif %}
{{ dte }}d
{% endfor %}
{% set page_base_url = '/holdings/options' %} {% set page_extra_qs %}&show={{ _show }}{{ _acct_qs_root }}{% endset %} {% set page_target = '#holdings-options' %} {% set page_swap = 'innerHTML' %} {% include "_pagination_footer.html" %} {% endif %}