Files
dekun e5a586f903 Restructure into modules/ with single-process CTP and config/ layout.
Move business code under modules/, env template to config/, PM2 single qihuo process, and _legacy shims for old imports.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-01 14:42:16 +08:00

122 lines
4.9 KiB
HTML

{# Copyright (c) 2025-2026 马建军. All rights reserved. 专有软件,详见 LICENSE.zh-CN.txt #}
{% extends "base.html" %}
{% block title %}手续费配置 - 国内期货 · 交易复盘系统{% endblock %}
{% block extra_css %}
<style>
.fees-status-card .card-body{display:flex;flex-wrap:wrap;gap:.75rem 1.25rem;align-items:center}
.fees-status-card .fees-meta{font-size:.85rem;color:var(--text-muted)}
.fees-table-card .card-body{padding:.75rem 1rem 1rem}
.fees-table-card .trade-table-wrap{
max-height:min(70vh,560px);
width:100%;
overflow:auto;
-webkit-overflow-scrolling:touch;
border:1px solid var(--table-border);
border-radius:10px;
background:var(--card-inner);
}
.fees-table-card .trade-table{
width:100%;
min-width:0;
table-layout:fixed;
font-size:.8rem;
}
.fees-table-card .trade-table thead th{
position:sticky;
top:0;
z-index:2;
background:var(--card-inner);
box-shadow:0 1px 0 var(--table-border);
}
.fees-table-card .trade-table th,
.fees-table-card .trade-table td{
padding:.5rem .4rem;
white-space:nowrap;
overflow:hidden;
text-overflow:ellipsis;
}
.fees-table-card .trade-table th:last-child,
.fees-table-card .trade-table td:last-child{
position:static;
box-shadow:none;
}
</style>
{% endblock %}
{% block content %}
<div class="card fees-status-card">
<h2>CTP 手续费</h2>
<div class="card-body">
<p class="fees-meta" style="margin:0;flex:1;min-width:220px">
费率由后台从 <strong>CTP 柜台</strong> 同步写入数据库,<strong>每日自动更新一次</strong>,本页只读展示。
</p>
{% if ctp_connected %}
<span class="badge profit">CTP 已连接</span>
{% else %}
<span class="badge planned">CTP 未连接</span>
{% endif %}
{% if fee_synced_today %}
<span class="badge profit">今日已同步</span>
{% else %}
<span class="badge planned">今日未同步</span>
{% endif %}
{% if fee_last_sync %}
<span class="text-muted" style="font-size:.8rem">上次:{{ fee_last_sync[:16] }}</span>
{% endif %}
{% if fee_sync_running %}
<span class="badge planned">同步中…</span>
{% endif %}
{% if fee_counts.get('ctp') %}
<span class="text-muted" style="font-size:.8rem">共 {{ fee_counts.ctp }} 个品种</span>
{% endif %}
<form action="{{ url_for('fees') }}" method="post" style="display:inline">
<input type="hidden" name="action" value="sync_ctp">
<input type="hidden" name="force" value="1">
<button type="submit" class="btn-primary" {% if not ctp_connected %}disabled title="请先连接 CTP"{% endif %}>立即同步</button>
</form>
</div>
</div>
<div class="card fees-table-card">
<h2>品种费率表</h2>
<div class="card-body">
<div class="trade-table-wrap">
<table class="trade-table">
<thead>
<tr>
<th>品种</th><th>交易所</th><th>乘数</th>
<th>开仓(元/手)</th><th>开仓(比例)</th>
<th>平昨(元/手)</th><th>平昨(比例)</th>
<th>平今(元/手)</th><th>平今(比例)</th>
<th>更新</th>
</tr>
</thead>
<tbody>
{% for r in rates %}
<tr>
<td><strong>{{ r.product }}</strong></td>
<td class="cell-readonly">{{ r.exchange or '—' }}</td>
<td class="cell-readonly">{{ r.mult }}</td>
<td class="cell-readonly">{{ r.open_fixed }}</td>
<td class="cell-readonly">{{ r.open_ratio }}</td>
<td class="cell-readonly">{{ r.close_yesterday_fixed }}</td>
<td class="cell-readonly">{{ r.close_yesterday_ratio }}</td>
<td class="cell-readonly">{{ r.close_today_fixed }}</td>
<td class="cell-readonly">{{ r.close_today_ratio }}</td>
<td class="text-muted" style="font-size:.72rem">{{ (r.updated_at or '')[:16] }}</td>
</tr>
{% else %}
<tr><td colspan="10" class="text-muted">暂无 CTP 费率,请连接 CTP 后等待自动同步或点击「立即同步」</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<p class="hint" style="margin-top:.75rem;padding:0 1rem 1rem">
公式:单边 = 固定(元/手)×手数 + 比例×价格×乘数×手数;往返 = 开仓 + 平仓(平今/平昨自动判断)。
{% if ctp_connected and not fee_counts.get('ctp') %}
<br><strong class="text-loss">数据库尚无 CTP 费率,请点击「立即同步」或等待后台每日任务。</strong>
{% endif %}
</p>
</div>
{% endblock %}