fix: K线新浪历史补齐与手续费页布局及CTP批量同步

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-24 13:26:53 +08:00
parent 3fe4add8e1
commit de6815d481
8 changed files with 178 additions and 47 deletions
+44 -20
View File
@@ -4,6 +4,15 @@
<style>
.fees-split{margin-bottom:1.25rem}
.fees-split .card{margin-bottom:0;min-height:auto}
.fees-table-card .trade-table-wrap{
max-height:min(70vh,560px);
width:100%;
border:none;
border-radius:10px;
}
.fees-table-card .trade-table{min-width:1100px}
.fees-table-card .card-body{padding:.75rem 1rem 1rem}
.fees-source-stats{font-size:.78rem;margin-top:.35rem}
</style>
{% endblock %}
{% block content %}
@@ -36,6 +45,15 @@
<span class="badge planned">CTP 未连接</span>
{% endif %}
</div>
{% if fee_counts %}
<p class="fees-source-stats text-muted">
已缓存:
{% if fee_counts.get('ctp') %}<span class="badge profit">CTP {{ fee_counts.ctp }}</span>{% endif %}
{% if fee_counts.get('local') %}<span class="badge planned">local {{ fee_counts.local }}</span>{% endif %}
{% if fee_counts.get('json') %}<span class="badge planned">json {{ fee_counts.json }}</span>{% endif %}
{% if fee_counts.get('manual') %}<span class="badge planned">manual {{ fee_counts.manual }}</span>{% endif %}
</p>
{% endif %}
</div>
</div>
@@ -63,10 +81,10 @@
</div>
</div>
<div class="card">
<div class="card fees-table-card">
<h2>品种费率表</h2>
<div class="card-body card-scroll">
<div class="table-responsive">
<div class="card-body">
<div class="trade-table-wrap">
<table class="trade-table">
<thead>
<tr>
@@ -79,23 +97,20 @@
</thead>
<tbody>
{% for r in rates %}
{% set fid = 'fee-row-' ~ r.product %}
<tr>
<form action="{{ url_for('fees') }}" method="post" style="display:contents">
<input type="hidden" name="action" value="save_row">
<input type="hidden" name="product" value="{{ r.product }}">
<td><strong>{{ r.product }}</strong></td>
<td><span class="badge {% if r.source == 'ctp' %}profit{% else %}planned{% endif %}">{{ r.source or 'local' }}</span></td>
<td><input name="exchange" value="{{ r.exchange or '' }}" style="width:72px;padding:.3rem"></td>
<td><input name="mult" type="number" value="{{ r.mult }}" style="width:56px;padding:.3rem"></td>
<td><input name="open_fixed" type="number" step="0.0001" value="{{ r.open_fixed }}" style="width:72px;padding:.3rem"></td>
<td><input name="open_ratio" type="number" step="0.0000001" value="{{ r.open_ratio }}" style="width:88px;padding:.3rem"></td>
<td><input name="close_yesterday_fixed" type="number" step="0.0001" value="{{ r.close_yesterday_fixed }}" style="width:72px;padding:.3rem"></td>
<td><input name="close_yesterday_ratio" type="number" step="0.0000001" value="{{ r.close_yesterday_ratio }}" style="width:88px;padding:.3rem"></td>
<td><input name="close_today_fixed" type="number" step="0.0001" value="{{ r.close_today_fixed }}" style="width:72px;padding:.3rem"></td>
<td><input name="close_today_ratio" type="number" step="0.0000001" value="{{ r.close_today_ratio }}" style="width:88px;padding:.3rem"></td>
<td class="text-muted" style="font-size:.72rem">{{ (r.updated_at or '')[:16] }}</td>
<td><button type="submit" class="btn-link">保存</button></td>
</form>
<td><strong>{{ r.product }}</strong></td>
<td><span class="badge {% if r.source == 'ctp' %}profit{% else %}planned{% endif %}">{{ r.source or 'local' }}</span></td>
<td><input name="exchange" form="{{ fid }}" value="{{ r.exchange or '' }}" style="width:72px;padding:.3rem"></td>
<td><input name="mult" form="{{ fid }}" type="number" value="{{ r.mult }}" style="width:56px;padding:.3rem"></td>
<td><input name="open_fixed" form="{{ fid }}" type="number" step="0.0001" value="{{ r.open_fixed }}" style="width:72px;padding:.3rem"></td>
<td><input name="open_ratio" form="{{ fid }}" type="number" step="0.0000001" value="{{ r.open_ratio }}" style="width:88px;padding:.3rem"></td>
<td><input name="close_yesterday_fixed" form="{{ fid }}" type="number" step="0.0001" value="{{ r.close_yesterday_fixed }}" style="width:72px;padding:.3rem"></td>
<td><input name="close_yesterday_ratio" form="{{ fid }}" type="number" step="0.0000001" value="{{ r.close_yesterday_ratio }}" style="width:88px;padding:.3rem"></td>
<td><input name="close_today_fixed" form="{{ fid }}" type="number" step="0.0001" value="{{ r.close_today_fixed }}" style="width:72px;padding:.3rem"></td>
<td><input name="close_today_ratio" form="{{ fid }}" type="number" step="0.0000001" value="{{ r.close_today_ratio }}" style="width:88px;padding:.3rem"></td>
<td class="text-muted" style="font-size:.72rem">{{ (r.updated_at or '')[:16] }}</td>
<td><button type="submit" form="{{ fid }}" class="btn-link">保存</button></td>
</tr>
{% else %}
<tr><td colspan="12" class="text-muted">暂无费率,请连接 CTP 后同步</td></tr>
@@ -103,9 +118,18 @@
</tbody>
</table>
</div>
{% for r in rates %}
<form id="fee-row-{{ r.product }}" action="{{ url_for('fees') }}" method="post" hidden>
<input type="hidden" name="action" value="save_row">
<input type="hidden" name="product" value="{{ r.product }}">
</form>
{% endfor %}
</div>
<p class="hint" style="margin-top:.75rem">
<p class="hint" style="margin-top:.75rem;padding:0 1rem 1rem">
公式:单边 = 固定(元/手)×手数 + 比例×价格×乘数×手数;往返 = 开仓 + 平仓(平今/平昨自动判断)。
{% if fee_source_mode == 'ctp' and ctp_connected and not fee_counts.get('ctp') %}
<br><strong class="text-loss">当前无 CTP 费率缓存,请点击「从 CTP 同步费率」。</strong>
{% endif %}
</p>
</div>
{% endblock %}