{% extends "base.html" %} {% block title %}期权交易{% endblock %} {% block heading %}期权交易{% endblock %} {% block breadcrumb %}期权开平仓记录{% endblock %} {% block content %} {% set view = request.query_params.get('view', '') %}
📋 持仓 📊 已平仓
{% if view != 'closed' %}
{# ── 新建开仓 ── #}
新建开仓
{# ── 持仓列表 ── #}
持仓中 · {{ open_trades|length }} 笔
{% if open_trades %}
{% for t in open_trades %} {% endfor %}
品种合约类型买卖行权价权利金开仓日期手续费操作
{{ t.product_code }} {{ t.contract_code.replace(t.product_code, '', 1) }} {% if t.option_type == 'C' %} C {% else %} P {% endif %} {% if t.direction == 'sell' %} {% else %} {% endif %} {{ t.strike_price }} {{ t.open_price }} {{ t.open_date }} {{ weekdays[t.open_date.weekday()] }} {{ t.open_fee or 0 }}
{% else %}
暂无持仓
{% endif %} {# ── 平仓弹窗 ── #}
{% else %}
{# ═══════════════ 已平仓 ═══════════════ #} {% if closed_trades %}
已平仓 · {{ closed_trades|length }} 笔
{% for t in closed_trades %} {% endfor %}
品种合约类型买卖行权价开仓平仓持仓权利金平仓价开仓费平仓费盈亏操作
{{ t.product_code }} {{ t.contract_code.replace(t.product_code, '', 1) }} {% if t.option_type == 'C' %} C {% else %} P {% endif %} {% if t.direction == 'sell' %} {% else %} {% endif %} {{ t.strike_price }} {{ t.open_date }} {{ weekdays[t.open_date.weekday()] }} {{ t.close_date }} {{ weekdays[t.close_date.weekday()] }} {{ (t.close_date - t.open_date).days }}天 {{ t.open_price }} {{ t.close_price }} {{ t.open_fee or 0 }} {{ t.close_fee or 0 }} {% set p = t.pnl %} {% if p is not none %} {% if p > 0 %}+{% endif %}{{ p }} {% endif %}
{% set ns = namespace(total_pnl=0, total_open_fee=0, total_close_fee=0) %} {% for t in closed_trades %} {% set ns.total_pnl = ns.total_pnl + (t.pnl or 0) %} {% set ns.total_open_fee = ns.total_open_fee + (t.open_fee or 0) %} {% set ns.total_close_fee = ns.total_close_fee + (t.close_fee or 0) %} {% endfor %}
盈亏合计 {% if ns.total_pnl > 0 %}+{% endif %}{{ '%.2f'|format(ns.total_pnl) }} | 开仓手续费 {{ '%.2f'|format(ns.total_open_fee) }} | 平仓手续费 {{ '%.2f'|format(ns.total_close_fee) }} | 手续费合计 {{ '%.2f'|format(ns.total_open_fee + ns.total_close_fee) }}
{% else %}
暂无已平仓记录
{% endif %}
{% endif %} {% if view != 'closed' %} {% endif %} {% endblock %}