ui: 手续费/设置布局优化,行情优先 CTP

手续费数据源与本地倍率并列双列;设置页去掉参考资金、缩小改密表单;CTP 连接时订阅柜台 tick 作为行情源。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-24 13:04:11 +08:00
parent 9d4aea60f0
commit eaca3d43ec
5 changed files with 204 additions and 105 deletions
+56 -44
View File
@@ -1,54 +1,64 @@
{% extends "base.html" %}
{% block title %}手续费配置 - 国内期货监控系统{% endblock %}
{% block extra_css %}
<style>
.fees-split{margin-bottom:1.25rem}
.fees-split .card{margin-bottom:0;min-height:auto}
</style>
{% endblock %}
{% block content %}
<div class="card">
<h2>手续费数据源</h2>
<div class="card-body">
<form action="{{ url_for('fees') }}" method="post" class="form-row" style="flex-wrap:wrap;gap:.75rem;align-items:center">
<input type="hidden" name="action" value="fee_source">
<label class="text-muted" style="font-size:.85rem">计费依据</label>
<select name="fee_source_mode" style="min-width:220px">
<option value="ctp" {% if fee_source_mode == 'ctp' %}selected{% endif %}>CTP 柜台(SimNow/实盘,推荐)</option>
<option value="local" {% if fee_source_mode == 'local' %}selected{% endif %}>本地 / AKShare 参考表</option>
</select>
<button type="submit" class="btn-primary">保存</button>
</form>
<p class="hint" style="margin-top:.75rem">
默认使用 <strong>CTP 柜台</strong> 查询到的开仓/平仓费率(连接 CTP 后自动同步,与 SimNow/期货公司一致)。
离线或未连接时可改用本地表估算。
</p>
<div class="form-row" style="margin-top:.75rem;flex-wrap:wrap;gap:.5rem">
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
<input type="hidden" name="action" value="sync_ctp">
<button type="submit" class="btn-primary" {% if not ctp_connected %}disabled title="请先连接 CTP"{% endif %}>从 CTP 同步费率</button>
<div class="split-grid fees-split">
<div class="card">
<h2>手续费数据源</h2>
<div class="card-body">
<form action="{{ url_for('fees') }}" method="post">
<input type="hidden" name="action" value="fee_source">
<div class="field" style="margin-bottom:.75rem">
<label>计费依据</label>
<select name="fee_source_mode">
<option value="ctp" {% if fee_source_mode == 'ctp' %}selected{% endif %}>CTP 柜台(SimNow/实盘,推荐)</option>
<option value="local" {% if fee_source_mode == 'local' %}selected{% endif %}>本地 / AKShare 参考表</option>
</select>
</div>
<button type="submit" class="btn-primary">保存</button>
</form>
{% if ctp_connected %}
<span class="badge profit">CTP 已连接</span>
{% else %}
<span class="badge planned">CTP 未连接 — 请先连接后再同步</span>
{% endif %}
<p class="hint" style="margin-top:.75rem">
默认使用 <strong>CTP 柜台</strong> 费率(连接后自动同步,与 SimNow/期货公司一致)。
</p>
<div class="form-row" style="margin-top:.75rem;flex-wrap:wrap;gap:.5rem">
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
<input type="hidden" name="action" value="sync_ctp">
<button type="submit" class="btn-primary" {% if not ctp_connected %}disabled title="请先连接 CTP"{% endif %}>从 CTP 同步费率</button>
</form>
{% if ctp_connected %}
<span class="badge profit">CTP 已连接</span>
{% else %}
<span class="badge planned">CTP 未连接</span>
{% endif %}
</div>
</div>
</div>
</div>
<div class="card">
<h2>本地参考倍率(仅「本地数据源」时使用)</h2>
<div class="card-body">
<form action="{{ url_for('fees') }}" method="post" class="form-row">
<input type="hidden" name="action" value="multiplier">
<label class="text-muted" style="font-size:.85rem">第三方标准费率 ×</label>
<input name="fee_multiplier" type="number" step="0.1" min="0" value="{{ multiplier }}" style="width:100px">
<button type="submit" class="btn-primary">保存倍率</button>
</form>
<div class="form-row" style="margin-top:.75rem">
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
<input type="hidden" name="action" value="sync">
<button type="submit" class="btn-secondary">从 AKShare 同步(本地)</button>
</form>
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
<input type="hidden" name="action" value="reload_json">
<button type="submit" class="btn-link" style="padding:.5rem 1rem;border:1px solid var(--card-border);border-radius:8px">重载 JSON 默认表</button>
<div class="card">
<h2>本地参考倍率</h2>
<div class="card-body">
<p class="hint" style="margin-bottom:.65rem;font-size:.78rem">仅「本地数据源」时使用</p>
<form action="{{ url_for('fees') }}" method="post" class="form-row" style="flex-wrap:wrap;gap:.5rem;align-items:center;margin-bottom:.75rem">
<input type="hidden" name="action" value="multiplier">
<label class="text-muted" style="font-size:.85rem">标准费率 ×</label>
<input name="fee_multiplier" type="number" step="0.1" min="0" value="{{ multiplier }}" style="width:88px">
<button type="submit" class="btn-primary">保存倍率</button>
</form>
<div class="form-row" style="flex-wrap:wrap;gap:.5rem">
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
<input type="hidden" name="action" value="sync">
<button type="submit" class="btn-secondary">AKShare 同步</button>
</form>
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
<input type="hidden" name="action" value="reload_json">
<button type="submit" class="btn-link" style="padding:.45rem .85rem;border:1px solid var(--card-border);border-radius:8px">重载 JSON</button>
</form>
</div>
</div>
</div>
</div>
@@ -56,6 +66,7 @@
<div class="card">
<h2>品种费率表</h2>
<div class="card-body card-scroll">
<div class="table-responsive">
<table class="trade-table">
<thead>
<tr>
@@ -91,9 +102,10 @@
{% endfor %}
</tbody>
</table>
</div>
</div>
<p class="hint" style="margin-top:.75rem">
公式:单边手续费 = 固定(元/手)×手数 + 比例×价格×乘数×手数往返 = 开仓 + 平仓(平今/平昨自动判断)。
公式:单边 = 固定(元/手)×手数 + 比例×价格×乘数×手数往返 = 开仓 + 平仓(平今/平昨自动判断)。
</p>
</div>
{% endblock %}