持仓监控独立导航页,交易记录与复盘合并为同一页

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-15 15:06:18 +08:00
parent 5aa9f11733
commit 9ba9733523
8 changed files with 273 additions and 244 deletions
+9 -3
View File
@@ -350,7 +350,13 @@
.pos-footer span{color:var(--text-primary)}
.pos-del{font-size:.75rem;padding:.35rem .65rem}
.trade-toolbar{display:flex;align-items:center;gap:1rem;margin-bottom:1rem;flex-wrap:wrap}
.trade-toolbar label{display:flex;align-items:center;gap:.4rem;font-size:.85rem;cursor:pointer;color:var(--text-muted)}
.trade-switch-label{
display:flex;align-items:center;gap:.35rem;
font-size:.68rem;color:var(--text-muted);
white-space:nowrap;margin-bottom:.65rem;cursor:pointer;
}
.trade-switch-label span{line-height:1}
.trade-switch-label input{flex-shrink:0}
.trade-table-wrap{overflow-x:auto}
.trade-table{font-size:.8rem}
.trade-table th{font-size:.75rem;padding:.55rem .45rem}
@@ -396,8 +402,8 @@
<nav class="site-nav">
<a href="{{ url_for('plans') }}" class="{% if request.endpoint == 'plans' %}active{% endif %}">开单计划</a>
<a href="{{ url_for('keys') }}" class="{% if request.endpoint == 'keys' %}active{% endif %}">关键位监控</a>
<a href="{{ url_for('trades') }}" class="{% if request.endpoint == 'trades' %}active{% endif %}">交易记录</a>
<a href="{{ url_for('records') }}" class="{% if request.endpoint == 'records' %}active{% endif %}">复盘</a>
<a href="{{ url_for('positions') }}" class="{% if request.endpoint == 'positions' %}active{% endif %}">持仓监控</a>
<a href="{{ url_for('records') }}" class="{% if request.endpoint in ('records', 'trades') %}active{% endif %}">交易记录与复盘</a>
<a href="{{ url_for('stats') }}" class="{% if request.endpoint == 'stats' %}active{% endif %}">统计分析</a>
<a href="{{ url_for('settings') }}" class="{% if request.endpoint == 'settings' %}active{% endif %}">系统设置</a>
</nav>
-41
View File
@@ -79,47 +79,6 @@
</div>
</div>
</div>
<div class="split-grid" style="margin-top:1.5rem">
<div class="card">
<h2>持仓录入</h2>
<div class="card-body">
<form action="{{ url_for('add_position') }}" method="post" class="form-compact">
<div class="form-line line-3">
<div class="symbol-wrap">
<input type="text" class="symbol-input" placeholder="主力合约" autocomplete="off" required>
<input type="hidden" name="symbol" required>
<input type="hidden" name="symbol_name">
<input type="hidden" name="market_code" required>
<input type="hidden" name="sina_code">
<div class="symbol-dropdown"></div>
<div class="symbol-selected"></div>
</div>
<div class="mini-field"><span>开仓时间</span><input type="datetime-local" name="open_time" required></div>
<input name="lots" type="number" step="1" min="1" value="1" placeholder="张数" required>
</div>
<div class="form-line line-3">
<input name="entry_price" type="number" step="0.0001" placeholder="成交价格" required>
<input name="stop_loss" type="number" step="0.0001" placeholder="止损" required>
<input name="take_profit" type="number" step="0.0001" placeholder="止盈" required>
</div>
<div class="form-line line-btn">
<button type="submit" class="btn-primary">添加持仓</button>
</div>
</form>
<p class="hint" style="margin-top:.5rem">方向根据止损与成交价自动判断;风险比例依赖系统设置中的实盘资金。</p>
</div>
</div>
<div class="card">
<h2>实时持仓</h2>
<div class="card-body card-scroll" id="position-live-list">
{% if not positions %}
<div class="empty-hint">暂无持仓,左侧录入后显示</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block extra_js %}
<script src="{{ url_for('static', filename='js/keys.js') }}"></script>
+47
View File
@@ -0,0 +1,47 @@
{% extends "base.html" %}
{% block title %}持仓监控 - 国内期货监控系统{% endblock %}
{% block content %}
<div class="split-grid">
<div class="card">
<h2>持仓录入</h2>
<div class="card-body">
<form action="{{ url_for('add_position') }}" method="post" class="form-compact">
<div class="form-line line-3">
<div class="symbol-wrap">
<input type="text" class="symbol-input" placeholder="主力合约" autocomplete="off" required>
<input type="hidden" name="symbol" required>
<input type="hidden" name="symbol_name">
<input type="hidden" name="market_code" required>
<input type="hidden" name="sina_code">
<div class="symbol-dropdown"></div>
<div class="symbol-selected"></div>
</div>
<input type="datetime-local" name="open_time" required title="开仓时间">
<input name="lots" type="number" step="1" min="1" value="1" placeholder="张数" required>
</div>
<div class="form-line line-3">
<input name="entry_price" type="number" step="0.0001" placeholder="成交价格" required>
<input name="stop_loss" type="number" step="0.0001" placeholder="止损" required>
<input name="take_profit" type="number" step="0.0001" placeholder="止盈" required>
</div>
<div class="form-line line-btn">
<button type="submit" class="btn-primary">添加持仓</button>
</div>
</form>
<p class="hint" style="margin-top:.5rem">方向根据止损与成交价自动判断;风险比例依赖系统设置中的实盘资金。</p>
</div>
</div>
<div class="card">
<h2>实时持仓</h2>
<div class="card-body card-scroll" id="position-live-list">
{% if not positions %}
<div class="empty-hint">暂无持仓,左侧录入后显示</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}
{% block extra_js %}
<script src="{{ url_for('static', filename='js/positions.js') }}"></script>
{% endblock %}
+119 -2
View File
@@ -1,8 +1,114 @@
{% extends "base.html" %}
{% block title %}复盘 - 国内期货监控系统{% endblock %}
{% block title %}交易记录与复盘 - 国内期货监控系统{% endblock %}
{% block content %}
<div class="card" style="margin-bottom:1.25rem">
<h2>交易记录</h2>
<div class="card-body">
<label class="trade-switch-label">
<input type="checkbox" id="trade-edit-switch">
<span>修改/核对开关(开启后可编辑关键字段)</span>
</label>
<div class="trade-table-wrap card-scroll">
<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><th>平仓时间</th>
<th>盈亏(元)</th><th>结果</th><th>操作</th>
</tr>
</thead>
<tbody>
{% for t in trades %}
<tr data-trade-id="{{ t.id }}">
<td><span class="cell-readonly">{{ t.symbol_name or t.symbol }}</span></td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.monitor_type }}</span>
<input class="cell-edit-show" type="hidden" name="monitor_type" value="{{ t.monitor_type }}">
</td>
<td>
<span class="cell-readonly cell-edit-hide">
<span class="badge dir">{{ '做多' if t.direction == 'long' else '做空' }}</span>
</span>
<select class="cell-edit-show" name="direction" style="display:none">
<option value="long" {% if t.direction=='long' %}selected{% endif %}>做多</option>
<option value="short" {% if t.direction=='short' %}selected{% endif %}>做空</option>
</select>
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.entry_price }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="entry_price" value="{{ t.entry_price }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.stop_loss }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="stop_loss" value="{{ t.stop_loss }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.take_profit }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="take_profit" value="{{ t.take_profit }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.lots }}手 / {{ t.margin or '-' }}</span>
<input class="cell-edit-show" type="number" step="0.01" name="margin" value="{{ t.margin or '' }}" placeholder="保证金" style="display:none">
<input type="hidden" name="lots" value="{{ t.lots }}">
</td>
<td><span class="cell-readonly"></span></td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.holding_minutes or 0 }}</span>
<input class="cell-edit-show" type="number" name="holding_minutes" value="{{ t.holding_minutes or 0 }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ (t.open_time or '')[:16].replace('T',' ') }}</span>
<input class="cell-edit-show" type="text" name="open_time" value="{{ t.open_time or '' }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ (t.close_time or '')[:16].replace('T',' ') }}</span>
<input class="cell-edit-show" type="text" name="close_time" value="{{ t.close_time or '' }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide {% if t.pnl and t.pnl > 0 %}text-profit{% elif t.pnl and t.pnl < 0 %}text-loss{% endif %}">
{{ t.pnl if t.pnl is not none else '-' }}
</span>
<input class="cell-edit-show" type="number" step="0.01" name="pnl" value="{{ t.pnl or '' }}" style="display:none">
<input type="hidden" name="close_price" value="{{ t.close_price or '' }}">
<input type="hidden" name="symbol_name" value="{{ t.symbol_name or t.symbol }}">
</td>
<td>
<span class="cell-readonly cell-edit-hide">
{% if t.result == '止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '止损' %}<span class="badge loss">{{ t.result }}</span>
{% elif t.result == '手动平仓' %}<span class="badge result-manual">{{ t.result }}</span>
{% else %}<span class="badge result-external">{{ t.result }}</span>{% endif %}
{% if t.verified %}<span class="badge active" style="margin-left:.25rem">已核对</span>{% endif %}
</span>
<select class="cell-edit-show" name="result" style="display:none">
<option value="手动平仓" {% if t.result=='手动平仓' %}selected{% endif %}>手动平仓</option>
<option value="止盈" {% if t.result=='止盈' %}selected{% endif %}>止盈</option>
<option value="止损" {% if t.result=='止损' %}selected{% endif %}>止损</option>
<option value="外部平仓" {% if t.result=='外部平仓' %}selected{% endif %}>外部平仓</option>
<option value="时间平仓" {% if t.result=='时间平仓' %}selected{% endif %}>时间平仓</option>
</select>
</td>
<td>
<div class="trade-actions">
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-fill">填入复盘</a>
<button type="button" class="btn-verify trade-save-btn" disabled>核对修改</button>
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-del" onclick="return confirm('删除?')">删除</a>
</div>
</td>
</tr>
{% else %}
<tr><td colspan="14" class="text-muted">暂无交易记录</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="split-grid records-split">
<div class="card">
<div class="card" id="review-panel">
<h2>复盘上传</h2>
<div class="card-body">
<form id="review-form" action="{{ url_for('add_review') }}" method="post" enctype="multipart/form-data" class="form-compact form-compact-review line-tight">
@@ -178,10 +284,12 @@
{% endblock %}
{% block extra_js %}
<script src="{{ url_for('static', filename='js/review.js') }}"></script>
<script src="{{ url_for('static', filename='js/trades.js') }}"></script>
{% if prefill %}
<script>
document.addEventListener('DOMContentLoaded', function () {
var form = document.getElementById('review-form');
var panel = document.getElementById('review-panel');
if (!form) return;
var map = {{ prefill | tojson }};
Object.keys(map).forEach(function (k) {
@@ -191,7 +299,16 @@ document.addEventListener('DOMContentLoaded', function () {
var symInput = form.querySelector('.symbol-input');
if (symInput && map.symbol_name) symInput.value = map.symbol_name;
if (typeof recalc === 'function') recalc();
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
});
</script>
{% endif %}
<script>
document.addEventListener('DOMContentLoaded', function () {
if (window.location.hash === '#review-panel') {
var panel = document.getElementById('review-panel');
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
}
});
</script>
{% endblock %}
-111
View File
@@ -1,111 +0,0 @@
{% extends "base.html" %}
{% block title %}交易记录 - 国内期货监控系统{% endblock %}
{% block content %}
<div class="card">
<h2>交易记录</h2>
<div class="card-body">
<div class="trade-toolbar">
<label><input type="checkbox" id="trade-edit-switch"> 修改/核对开关(开启后可编辑关键字段)</label>
</div>
<div class="trade-table-wrap card-scroll">
<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><th>平仓时间</th>
<th>盈亏(元)</th><th>结果</th><th>操作</th>
</tr>
</thead>
<tbody>
{% for t in trades %}
<tr data-trade-id="{{ t.id }}">
<td><span class="cell-readonly">{{ t.symbol_name or t.symbol }}</span></td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.monitor_type }}</span>
<input class="cell-edit-show" type="hidden" name="monitor_type" value="{{ t.monitor_type }}">
</td>
<td>
<span class="cell-readonly cell-edit-hide">
<span class="badge dir">{{ '做多' if t.direction == 'long' else '做空' }}</span>
</span>
<select class="cell-edit-show" name="direction" style="display:none">
<option value="long" {% if t.direction=='long' %}selected{% endif %}>做多</option>
<option value="short" {% if t.direction=='short' %}selected{% endif %}>做空</option>
</select>
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.entry_price }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="entry_price" value="{{ t.entry_price }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.stop_loss }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="stop_loss" value="{{ t.stop_loss }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.take_profit }}</span>
<input class="cell-edit-show" type="number" step="0.0001" name="take_profit" value="{{ t.take_profit }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.lots }}手 / {{ t.margin or '-' }}</span>
<input class="cell-edit-show" type="number" step="0.01" name="margin" value="{{ t.margin or '' }}" placeholder="保证金" style="display:none">
<input type="hidden" name="lots" value="{{ t.lots }}">
</td>
<td><span class="cell-readonly"></span></td>
<td>
<span class="cell-readonly cell-edit-hide">{{ t.holding_minutes or 0 }}</span>
<input class="cell-edit-show" type="number" name="holding_minutes" value="{{ t.holding_minutes or 0 }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ (t.open_time or '')[:16].replace('T',' ') }}</span>
<input class="cell-edit-show" type="text" name="open_time" value="{{ t.open_time or '' }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide">{{ (t.close_time or '')[:16].replace('T',' ') }}</span>
<input class="cell-edit-show" type="text" name="close_time" value="{{ t.close_time or '' }}" style="display:none">
</td>
<td>
<span class="cell-readonly cell-edit-hide {% if t.pnl and t.pnl > 0 %}text-profit{% elif t.pnl and t.pnl < 0 %}text-loss{% endif %}">
{{ t.pnl if t.pnl is not none else '-' }}
</span>
<input class="cell-edit-show" type="number" step="0.01" name="pnl" value="{{ t.pnl or '' }}" style="display:none">
<input type="hidden" name="close_price" value="{{ t.close_price or '' }}">
<input type="hidden" name="symbol_name" value="{{ t.symbol_name or t.symbol }}">
</td>
<td>
<span class="cell-readonly cell-edit-hide">
{% if t.result == '止盈' %}<span class="badge profit">{{ t.result }}</span>
{% elif t.result == '止损' %}<span class="badge loss">{{ t.result }}</span>
{% elif t.result == '手动平仓' %}<span class="badge result-manual">{{ t.result }}</span>
{% else %}<span class="badge result-external">{{ t.result }}</span>{% endif %}
{% if t.verified %}<span class="badge active" style="margin-left:.25rem">已核对</span>{% endif %}
</span>
<select class="cell-edit-show" name="result" style="display:none">
<option value="手动平仓" {% if t.result=='手动平仓' %}selected{% endif %}>手动平仓</option>
<option value="止盈" {% if t.result=='止盈' %}selected{% endif %}>止盈</option>
<option value="止损" {% if t.result=='止损' %}selected{% endif %}>止损</option>
<option value="外部平仓" {% if t.result=='外部平仓' %}selected{% endif %}>外部平仓</option>
<option value="时间平仓" {% if t.result=='时间平仓' %}selected{% endif %}>时间平仓</option>
</select>
</td>
<td>
<div class="trade-actions">
<a href="{{ url_for('fill_review_from_trade', tid=t.id) }}" class="btn-fill">填入复盘</a>
<button type="button" class="btn-verify trade-save-btn" disabled>核对修改</button>
<a href="{{ url_for('del_trade', tid=t.id) }}" class="btn-del" onclick="return confirm('删除?')">删除</a>
</div>
</td>
</tr>
{% else %}
<tr><td colspan="14" class="text-muted">暂无交易记录</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}
{% block extra_js %}
<script src="{{ url_for('static', filename='js/trades.js') }}"></script>
{% endblock %}