合并期货下单与持仓监控为统一界面,移除手工录入。
策略与 CTP 自动同步持仓,新增 /api/trading/live 聚合展示与平仓接口。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+1
-2
@@ -483,12 +483,11 @@
|
||||
<h1 class="site-title">国内期货 · 交易监控 + 复盘<span class="site-title-sub">FUTURES MONITOR SYSTEM</span></h1>
|
||||
<button type="button" class="nav-backdrop" id="nav-backdrop" aria-label="关闭菜单" hidden></button>
|
||||
<nav class="site-nav" id="site-nav">
|
||||
<a href="{{ url_for('trade_page') }}" class="{% if request.endpoint == 'trade_page' %}active{% endif %}">期货下单</a>
|
||||
<a href="{{ url_for('positions') }}" class="{% if request.endpoint in ('positions', 'trade_page') %}active{% endif %}">持仓监控</a>
|
||||
<a href="{{ url_for('recommend_page') }}" class="{% if request.endpoint == 'recommend_page' %}active{% endif %}">品种推荐</a>
|
||||
<a href="{{ url_for('strategy_page') }}" class="{% if request.endpoint in ('strategy_page', 'strategy_records_page') %}active{% endif %}">策略交易</a>
|
||||
<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('positions') }}" class="{% if request.endpoint == 'positions' %}active{% endif %}">持仓监控</a>
|
||||
<a href="{{ url_for('market_page') }}" class="{% if request.endpoint == 'market_page' %}active{% endif %}">行情K线</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>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
</form>
|
||||
<p class="hint" style="margin-top:.75rem">
|
||||
<strong>模拟盘</strong>连接上期 SimNow 仿真柜台(非本地假资金)。在 <code>.env</code> 配置
|
||||
<code>SIMNOW_USER</code>、<code>SIMNOW_PASSWORD</code> 等,在「期货下单」页点击连接 CTP。<br>
|
||||
<code>SIMNOW_USER</code>、<code>SIMNOW_PASSWORD</code> 等,在「持仓监控」页点击连接 CTP。<br>
|
||||
<strong>实盘</strong>后期配置 <code>CTP_LIVE_*</code> 对接你的期货公司。
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<button type="button" class="btn-primary" id="btn-roll-exec" hidden>执行滚仓</button>
|
||||
</form>
|
||||
{% else %}
|
||||
<p class="empty-hint">请先在「期货下单」开仓并建立监控。</p>
|
||||
<p class="empty-hint">请先在「策略交易」开仓,持仓将自动出现在「持仓监控」。</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+16
-71
@@ -1,5 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}期货下单 - 国内期货监控系统{% endblock %}
|
||||
{% block title %}持仓监控 - 国内期货监控系统{% endblock %}
|
||||
{% block extra_css %}
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/trade.css') }}">
|
||||
{% endblock %}
|
||||
@@ -12,85 +12,30 @@
|
||||
</span>
|
||||
<span class="badge {% if risk_status.can_trade %}profit{% else %}loss{% endif %}" id="risk-badge">{{ risk_status.status_label }}</span>
|
||||
<span class="text-muted">权益 <strong id="cap-display">{{ '%.2f'|format(capital) }}</strong> 元</span>
|
||||
{% if ctp_account.available is defined and ctp_status.connected %}
|
||||
<span class="text-muted">可用 <strong>{{ '%.2f'|format(ctp_account.available) }}</strong> 元</span>
|
||||
{% endif %}
|
||||
<button type="button" class="btn-primary" id="btn-ctp-connect" style="padding:.4rem .9rem;font-size:.8rem">连接 CTP</button>
|
||||
</div>
|
||||
|
||||
<div class="card trade-order-card">
|
||||
<div class="trade-tabs">
|
||||
<span class="active">期货下单</span>
|
||||
<a href="{{ url_for('recommend_page') }}">品种推荐</a>
|
||||
<a href="{{ url_for('strategy_page') }}">策略交易</a>
|
||||
</div>
|
||||
|
||||
<div class="trade-input-row">
|
||||
<div class="symbol-wrap trade-field">
|
||||
<label class="text-label">品种</label>
|
||||
<input type="text" id="trade-symbol" class="symbol-input" placeholder="主力合约 rb2610" autocomplete="off" value="">
|
||||
<div class="symbol-dropdown"></div>
|
||||
<div class="symbol-selected" id="sym-selected"></div>
|
||||
</div>
|
||||
<div class="trade-field">
|
||||
<label class="text-label">手数</label>
|
||||
<input type="number" id="trade-lots" min="1" step="1" value="1">
|
||||
</div>
|
||||
<div class="trade-field">
|
||||
<label class="text-label">价格</label>
|
||||
<input type="number" id="trade-price" step="any" placeholder="限价">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="risk-fields" class="trade-risk-row" {% if sizing_mode != 'risk' %}hidden{% endif %}>
|
||||
<div class="trade-field"><label class="text-label">止损</label><input type="number" id="trade-sl" step="any"></div>
|
||||
<div class="trade-field"><label class="text-label">止盈</label><input type="number" id="trade-tp" step="any"></div>
|
||||
</div>
|
||||
|
||||
<div class="trade-btn-row">
|
||||
<button type="button" class="trade-btn long" id="btn-open-long">
|
||||
<span class="btn-price" id="px-long">—</span>
|
||||
<span class="btn-label">加多</span>
|
||||
<span class="btn-sub" id="max-long">≤—</span>
|
||||
</button>
|
||||
<button type="button" class="trade-btn lock" id="btn-open-short">
|
||||
<span class="btn-price" id="px-short">—</span>
|
||||
<span class="btn-label">加空</span>
|
||||
<span class="btn-sub" id="max-short">≤—</span>
|
||||
</button>
|
||||
<button type="button" class="trade-btn close" id="btn-close-long">
|
||||
<span class="btn-sub">平多</span>
|
||||
<span class="btn-label">平多</span>
|
||||
<span class="btn-sub" id="pos-long">≤0</span>
|
||||
</button>
|
||||
<button type="button" class="trade-btn close" id="btn-close-short">
|
||||
<span class="btn-sub">平空</span>
|
||||
<span class="btn-label">平空</span>
|
||||
<span class="btn-sub" id="pos-short">≤0</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="trade-footer" id="trade-footer">
|
||||
<p class="hint">SimNow 模拟盘:请先连接 CTP。输入品种与手数后显示跳动价值与价格精度。</p>
|
||||
{% if ctp_status.last_error %}<p class="text-loss" style="font-size:.78rem">{{ ctp_status.last_error }}</p>{% endif %}
|
||||
</div>
|
||||
<div class="trade-subnav">
|
||||
<span class="active">持仓监控</span>
|
||||
<a href="{{ url_for('recommend_page') }}">品种推荐</a>
|
||||
<a href="{{ url_for('strategy_page') }}">策略交易</a>
|
||||
</div>
|
||||
|
||||
{% if ctp_positions %}
|
||||
<div class="card">
|
||||
<h2>CTP 持仓(SimNow / 柜台)</h2>
|
||||
<ul class="list">
|
||||
{% for p in ctp_positions %}
|
||||
<li class="list-item">
|
||||
<span>{{ p.symbol }} {{ '多' if p.direction=='long' else '空' }} {{ p.lots }}手 @ {{ p.avg_price }}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h2>实时持仓</h2>
|
||||
<div class="card-body" id="position-live-list">
|
||||
<div class="empty-hint">加载中…</div>
|
||||
</div>
|
||||
<div class="trade-footer" id="trade-footer">
|
||||
<p class="hint">开仓请使用「策略交易」;连接 CTP 后自动同步 SimNow / 柜台持仓与程序监控。</p>
|
||||
{% if ctp_status.last_error %}<p class="text-loss" style="font-size:.78rem;margin-top:.5rem">{{ ctp_status.last_error }}</p>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block extra_js %}
|
||||
<script>
|
||||
window.TRADE_SIZING_MODE = {{ sizing_mode|tojson }};
|
||||
window.TRADE_RISK_PERCENT = {{ risk_percent }};
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/trade.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user